.Rhistory 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512
  1. paste0(getwd(), "/R/db_all_schemas.R")
  2. source(paste0(getwd(), "/R/db_all_schemas.R"))
  3. db_is_shema_exist(schema = "x_matsalu")
  4. db_is_shema_exist(schema = "x_matsalu")
  5. db_is_shema_exist(schema = "zx_matsalu")
  6. styler:::style_active_file()
  7. styler:::style_active_file()
  8. db_create_new_schema <- function(conf) {
  9. source(paste0(getwd(), "/R/db_is_shema_exist.R"))
  10. if(db_is_shema_exist(schema)) {
  11. conn <- db_connect()
  12. DBI::dbExecute(conn, sprintf(
  13. "-- DROP SCHEMA x_matsalu;
  14. CREATE SCHEMA %s AUTHORIZATION %s;", conf$schema, conf$user
  15. ))
  16. }
  17. }
  18. conf <- ruut::get_config()
  19. conf$schema <- "x_valga"
  20. db_create_new_schema(conf)
  21. conf <- ruut::get_config()
  22. conf$schema <- "x_valga1"
  23. db_create_new_schema(conf)
  24. conf <- ruut::get_config()
  25. conf
  26. conf$schema <- "x_valga1"
  27. conf
  28. db_create_new_schema(conf)
  29. conf$schema
  30. db_create_new_schema <- function(conf) {
  31. source(paste0(getwd(), "/R/db_is_shema_exist.R"))
  32. if(!db_is_shema_exist(conf$schema)) {
  33. conn <- db_connect()
  34. DBI::dbExecute(conn, sprintf(
  35. "-- DROP SCHEMA x_matsalu;
  36. CREATE SCHEMA %s AUTHORIZATION %s;", conf$schema, conf$user
  37. ))
  38. }
  39. }
  40. conf <- ruut::get_config()
  41. conf$schema <- "x_valga1"
  42. db_create_new_schema(conf)
  43. conf <- ruut::get_config()
  44. conf$schema <- "x_valga1"
  45. db_create_new_schema(conf)
  46. library(ruut)
  47. conf <- ruut::get_config()
  48. conf
  49. conf$schema <- "x_valga1"
  50. db_create_new_schema(conf)
  51. db_create_new_schema <- function(conf) {
  52. source(paste0(getwd(), "/R/db_is_shema_exist.R"))
  53. if(!db_is_shema_exist(conf$schema)) {
  54. conn <- db_connect()
  55. DBI::dbExecute(conn, sprintf(
  56. "-- DROP SCHEMA x_matsalu;
  57. CREATE SCHEMA %s AUTHORIZATION %s;", conf$schema, conf$user
  58. ))
  59. }
  60. }
  61. db_create_new_schema(conf)
  62. DBI::dbDisconnect(conn)
  63. conf <- ruut::get_config()
  64. conf$schema <- "x_valga1"
  65. db_create_new_schema(conf)
  66. conf <- ruut::get_config()
  67. conf$schema <- "x_valga1"
  68. db_create_new_schema(conf)
  69. conf <- ruut::get_config()
  70. conf$schema <- "x_valga"
  71. db_create_new_schema(conf)
  72. conf <- ruut::get_config()
  73. conf$schema <- "x_valga"
  74. db_create_new_schema(conf)
  75. conf <- ruut::get_config()
  76. conf$schema <- "x_valga"
  77. db_create_new_schema(conf)
  78. conf <- ruut::get_config()
  79. conf$schema <- "x_valga"
  80. db_create_new_schema(conf)
  81. styler:::style_active_file()
  82. library(ruut)
  83. styler:::style_active_file()
  84. library(ruut)
  85. styler:::style_active_file()
  86. library(ruut)
  87. library(ruut)
  88. library(ruut)
  89. library(ruut)
  90. library(ruut)
  91. ogr2ogr --long-usage
  92. system("ogr2ogr --long-usage")
  93. library(ruut)
  94. library(ruut)
  95. library(ruut)
  96. styler:::style_active_file()
  97. styler:::style_active_file()
  98. system("ogr2ogr --long-usage")
  99. styler:::style_active_file()
  100. styler:::style_active_file()
  101. library(ruut)
  102. #'
  103. #' INSPIRE grid map
  104. #'
  105. library(dplyr)
  106. library(ruut)
  107. # Source: https://www.eea.europa.eu/data-and-maps/data/eea-reference-grids-2
  108. # Temp directory
  109. tmp_dir <- tempdir()
  110. # Download link
  111. url <- "https://www.eea.europa.eu/data-and-maps/data/eea-reference-grids-2/gis-files/estonia-shapefile/download"
  112. # Estonia shapefile (ZIP archive)
  113. map_shapefile <- "Estonia_shapefile.zip"
  114. # Download and sav
  115. saveTo <- sprintf("%s/%s", tmp_dir, map_shapefile)
  116. download.file(
  117. url = download_url,
  118. destfile = saveTo, method = "curl", extra = "-L"
  119. )
  120. # Unzip
  121. unzip(saveTo, overwrite = T, exdir = tmp_dir)
  122. # List of files
  123. ls <- list.files(path = tmp_dir, pattern = ".shp")
  124. ls_long <- list.files(path = tmp_dir, pattern = ".shp", full.names = T)
  125. tbl_names <- strsplit(x = ls, split = ".shp") %>% unlist()
  126. # Export to postgis
  127. schema <- "inspire"
  128. i <- 1
  129. config <- get_config()
  130. config$schema <- schema
  131. # New schema
  132. db_create_new_schema(conf = config)
  133. library(dplyr)
  134. library(ruut)
  135. # Source: https://www.eea.europa.eu/data-and-maps/data/eea-reference-grids-2
  136. # Temp directory
  137. tmp_dir <- tempdir()
  138. # Download link
  139. url <- "https://www.eea.europa.eu/data-and-maps/data/eea-reference-grids-2/gis-files/estonia-shapefile/download"
  140. # Estonia shapefile (ZIP archive)
  141. map_shapefile <- "Estonia_shapefile.zip"
  142. # Download and sav
  143. saveTo <- sprintf("%s/%s", tmp_dir, map_shapefile)
  144. download.file(
  145. url = url,
  146. destfile = saveTo, method = "curl", extra = "-L"
  147. )
  148. # Unzip
  149. unzip(saveTo, overwrite = T, exdir = tmp_dir)
  150. # List of files
  151. ls <- list.files(path = tmp_dir, pattern = ".shp")
  152. ls_long <- list.files(path = tmp_dir, pattern = ".shp", full.names = T)
  153. tbl_names <- strsplit(x = ls, split = ".shp") %>% unlist()
  154. # Export to postgis
  155. schema <- "inspire"
  156. i <- 1
  157. config <- get_config()
  158. config$schema <- schema
  159. # New schema
  160. db_create_new_schema(conf = config)
  161. print(tbl_names[i])
  162. config$table <- tbl_names[i]
  163. source <- sprintf('"%s" "%s"', tmp_dir, tbl_names[i])
  164. crs_source <- "-s_srs EPSG:3035"
  165. crs_target <- "-t_srs EPSG:4326"
  166. fid <- "fid"
  167. ruut::copy_shp_to_db(dir = tmp_dir, layer = tbl_names[i], conf = config,
  168. id = fid, crs_source = crs_source, crs_target = crs_target,
  169. geometry_type = 'POLYGON')
  170. dir = tmp_dir; layer = tbl_names[i]; conf = config;
  171. id = fid; crs_source = crs_source; crs_target = crs_target;
  172. geometry_type = 'POLYGON'
  173. length(list.files(path = dir, pattern = sprintf("%s*", layer)))
  174. length(list.files(path = dir, pattern = sprintf("%s*", layer))) > 0
  175. source <- sprintf('"%s" "%s"', dir, layer)
  176. source
  177. cmd <- sprintf(
  178. paste0(
  179. "ogr2ogr -progress --conf PG_USE_COPY YES -f PostgreSQL ",
  180. "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
  181. "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
  182. "-lco GEOMETRY_NAME=geometry -lco FID=%s -nln %s.%s ",
  183. "%s %s -nlt %s"
  184. ),
  185. conf$dbname, conf$host, conf$port, conf$user, conf$password,
  186. conf$sslmode, conf$schema, source, id, conf$schema, conf$table,
  187. crs_source, crs_target, geometry_type
  188. )
  189. cmd
  190. system(cmd)
  191. dir = tmp_dir; layer = tbl_names[i]; conf = config;
  192. id = fid; crs_source = crs_source; crs_target = crs_target;
  193. geometry_type = 'PROMOTE_TO_MULTI'
  194. cmd <- sprintf(
  195. paste0(
  196. "ogr2ogr -progress --conf PG_USE_COPY YES -f PostgreSQL ",
  197. "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
  198. "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
  199. "-lco GEOMETRY_NAME=geometry -lco FID=%s -nln %s.%s ",
  200. "%s %s -nlt %s"
  201. ),
  202. conf$dbname, conf$host, conf$port, conf$user, conf$password,
  203. conf$sslmode, conf$schema, source, id, conf$schema, conf$table,
  204. crs_source, crs_target, geometry_type
  205. )
  206. cmd
  207. ruut::db_create_new_schema(conf)
  208. system(cmd)
  209. cmd <- sprintf(
  210. paste0(
  211. "ogr2ogr -progress --config PG_USE_COPY YES -f PostgreSQL ",
  212. "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
  213. "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
  214. "-lco GEOMETRY_NAME=geometry -lco FID=%s -nln %s.%s ",
  215. "%s %s -nlt PROMOTE_TO_MULTI"
  216. ),
  217. config$dbname, config$host, config$port, config$user, config$password,
  218. config$sslmode, config$schema, source, fid, config$schema, config$table,
  219. crs_source, crs_target
  220. )
  221. cmd
  222. system(cmd)
  223. geometry_type = 'POLYGON'
  224. cmd <- sprintf(
  225. paste0(
  226. "ogr2ogr -progress --config PG_USE_COPY YES -f PostgreSQL ",
  227. "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
  228. "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
  229. "-lco GEOMETRY_NAME=geometry -lco FID=%s -nln %s.%s ",
  230. "%s %s -nlt %s"
  231. ),
  232. config$dbname, config$host, config$port, config$user, config$password,
  233. config$sslmode, config$schema, source, fid, config$schema, config$table,
  234. crs_source, crs_target, geometry_type
  235. )
  236. cmd
  237. system(cmd)
  238. system("ogr2ogr --long-usage")
  239. cmd <- sprintf(
  240. paste0(
  241. "ogr2ogr -progress --config PG_USE_COPY YES -f PostgreSQL ",
  242. "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
  243. "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
  244. "-lco GEOMETRY_NAME=geometry -lco FID=%s -nln %s.%s ",
  245. "-s_srs%s -t_srs -nlt %s"
  246. ),
  247. config$dbname, config$host, config$port, config$user, config$password,
  248. config$sslmode, config$schema, source, fid, config$schema, config$table,
  249. crs_source, crs_target, geometry_type
  250. )
  251. system(cmd)
  252. cmd <- sprintf(
  253. paste0(
  254. "ogr2ogr -progress --config PG_USE_COPY YES -f PostgreSQL ",
  255. "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
  256. "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
  257. "-lco GEOMETRY_NAME=geometry -lco FID=%s -nln %s.%s ",
  258. "%s %s -nlt %s"
  259. ),
  260. config$dbname, config$host, config$port, config$user, config$password,
  261. config$sslmode, config$schema, source, fid, config$schema, config$table,
  262. crs_source, crs_target, geometry_type
  263. )
  264. system(cmd)
  265. crs_target
  266. crs_source
  267. cmd
  268. cmd <- sprintf(
  269. paste0(
  270. "ogr2ogr -progress --conf PG_USE_COPY YES -f PostgreSQL ",
  271. "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
  272. "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
  273. "-lco GEOMETRY_NAME=geometry -lco FID=%s -nln %s.%s ",
  274. "%s %s -nlt %s"
  275. ),
  276. conf$dbname, conf$host, conf$port, conf$user, conf$password,
  277. conf$sslmode, conf$schema, source, id, conf$schema, conf$table,
  278. crs_source, crs_target, geometry_type
  279. )
  280. cmd
  281. crs_target
  282. crs_source = "EPSG:4326"
  283. cmd <- sprintf(
  284. paste0(
  285. "ogr2ogr -progress --conf PG_USE_COPY YES -f PostgreSQL ",
  286. "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
  287. "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
  288. "-lco GEOMETRY_NAME=geometry -lco FID=%s -nln %s.%s ",
  289. "%s %s -nlt %s"
  290. ),
  291. conf$dbname, conf$host, conf$port, conf$user, conf$password,
  292. conf$sslmode, conf$schema, source, id, conf$schema, conf$table,
  293. crs_source, crs_target, geometry_type
  294. )
  295. source('~/apps/R/packages/ruut/R/copy_shp_to_db.R', echo=TRUE)
  296. cmd
  297. cmd <- sprintf(
  298. paste0(
  299. "ogr2ogr -progress --conf PG_USE_COPY YES -f PostgreSQL ",
  300. "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
  301. "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
  302. "-lco GEOMETRY_NAME=geometry -lco FID=%s -nln %s.%s ",
  303. "-s_srs %s -t_srs %s -nlt %s"
  304. ),
  305. conf$dbname, conf$host, conf$port, conf$user, conf$password,
  306. conf$sslmode, conf$schema, source, id, conf$schema, conf$table,
  307. crs_source, crs_target, geometry_type
  308. )
  309. copy_shp_to_db <- function(dir = NULL, layer = NULL, conf = NULL, id = "fid",
  310. crs_source = "EPSG:4326",
  311. crs_target = "EPSG:4326",
  312. geometry_type = "PROMOTE_TO_MULTI") {
  313. # Command 'ogr2ogr' help
  314. # system("ogr2ogr --long-usage")
  315. # Kontrollime kas etteantud kataloogis paiknevad failid
  316. if (length(list.files(path = dir, pattern = sprintf("%s*", layer))) > 0) {
  317. source <- sprintf('"%s" "%s"', dir, layer)
  318. cmd <- sprintf(
  319. paste0(
  320. "ogr2ogr -progress --conf PG_USE_COPY YES -f PostgreSQL ",
  321. "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
  322. "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
  323. "-lco GEOMETRY_NAME=geometry -lco FID=%s -nln %s.%s ",
  324. "-s_srs %s -t_srs %s -nlt %s"
  325. ),
  326. conf$dbname, conf$host, conf$port, conf$user, conf$password,
  327. conf$sslmode, conf$schema, source, id, conf$schema, conf$table,
  328. crs_source, crs_target, geometry_type
  329. )
  330. ruut::db_create_new_schema(conf)
  331. Sys.sleep(1)
  332. system(cmd)
  333. } else {
  334. cat("\nEi leitud antud kataloogist faile.")
  335. return(NULL)
  336. }
  337. }
  338. ruut::copy_shp_to_db(dir = tmp_dir, layer = tbl_names[i], conf = config,
  339. id = fid, crs_source = crs_source, crs_target = crs_target,
  340. geometry_type = 'POLYGON')
  341. cmd <- sprintf(
  342. paste0(
  343. "ogr2ogr -progress --config PG_USE_COPY YES -f PostgreSQL ",
  344. "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
  345. "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
  346. "-lco GEOMETRY_NAME=geometry -lco FID=%s -nln %s.%s ",
  347. "-s_srs %s -t_srs %s -nlt %s"
  348. ),
  349. conf$dbname, conf$host, conf$port, conf$user, conf$password, conf$sslmode,
  350. conf$schema, x, id, conf$schema, conf$table, crs_source, crs_target,
  351. geometry_type
  352. )
  353. source <- sprintf('"%s" "%s"', dir, layer)
  354. cmd <- sprintf(
  355. paste0(
  356. "ogr2ogr -progress --conf PG_USE_COPY YES -f PostgreSQL ",
  357. "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
  358. "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
  359. "-lco GEOMETRY_NAME=geometry -lco FID=%s -nln %s.%s ",
  360. "-s_srs %s -t_srs %s -nlt %s"
  361. ),
  362. conf$dbname, conf$host, conf$port, conf$user, conf$password,
  363. conf$sslmode, conf$schema, source, id, conf$schema, conf$table,
  364. crs_source, crs_target, geometry_type
  365. )
  366. cmd
  367. system(cmd)
  368. cmd <- sprintf(
  369. paste0(
  370. "ogr2ogr -progress --config PG_USE_COPY YES -f PostgreSQL ",
  371. "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
  372. "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
  373. "-lco GEOMETRY_NAME=geometry -lco FID=%s -nln %s.%s ",
  374. "%s %s -nlt %s"
  375. ),
  376. config$dbname, config$host, config$port, config$user, config$password,
  377. config$sslmode, config$schema, source, fid, config$schema, config$table,
  378. crs_source, crs_target, geometry_type
  379. )
  380. system(cmd)
  381. source <- sprintf('"%s" "%s"', tmp_dir, tbl_names[i])
  382. crs_source <- "EPSG:3035"
  383. crs_target <- "EPSG:4326"
  384. fid <- "fid"
  385. cmd <- sprintf(
  386. paste0(
  387. "ogr2ogr -progress --config PG_USE_COPY YES -f PostgreSQL ",
  388. "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
  389. "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
  390. "-lco GEOMETRY_NAME=geometry -lco FID=%s -nln %s.%s ",
  391. "-s_srs %s -t_srs %s -nlt %s"
  392. ),
  393. config$dbname, config$host, config$port, config$user, config$password,
  394. config$sslmode, config$schema, source, fid, config$schema, config$table,
  395. crs_source, crs_target, geometry_type
  396. )
  397. system(cmd)
  398. config
  399. conf
  400. config
  401. cmd <- sprintf(
  402. paste0(
  403. "ogr2ogr -progress --config PG_USE_COPY YES -f PostgreSQL ",
  404. "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
  405. "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
  406. "-lco GEOMETRY_NAME=geometry -lco FID=%s -nln %s.%s ",
  407. "-s_srs %s -t_srs %s -nlt %s"
  408. ),
  409. config$dbname, config$host, config$port, config$user, config$password,
  410. config$sslmode, config$schema, source, fid, config$schema, config$table,
  411. crs_source, crs_target, geometry_type
  412. )
  413. system(cmd)
  414. cmd <- sprintf(
  415. paste0(
  416. "ogr2ogr -progress --conf PG_USE_COPY YES -f PostgreSQL ",
  417. "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
  418. "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
  419. "-lco GEOMETRY_NAME=geometry -lco FID=%s -nln %s.%s ",
  420. "-s_srs %s -t_srs %s -nlt %s"
  421. ),
  422. conf$dbname, conf$host, conf$port, conf$user, conf$password,
  423. conf$sslmode, conf$schema, source, id, conf$schema, conf$table,
  424. crs_source, crs_target, geometry_type
  425. )
  426. system(cmd)
  427. cmd <- sprintf(
  428. paste0(
  429. "ogr2ogr -progress --config PG_USE_COPY YES -f PostgreSQL ",
  430. "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
  431. "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
  432. "-lco GEOMETRY_NAME=geometry -lco FID=%s -nln %s.%s ",
  433. "-s_srs %s -t_srs %s -nlt %s"
  434. ),
  435. conf$dbname, conf$host, conf$port, conf$user, conf$password,
  436. conf$sslmode, conf$schema, source, fid, conf$schema, conf$table,
  437. crs_source, crs_target, geometry_type
  438. )
  439. system(cmd)
  440. styler:::style_active_file()
  441. library(ruut)
  442. styler:::style_active_file()
  443. styler:::style_active_file()
  444. library(ruut)
  445. styler:::style_active_file()
  446. styler:::style_active_file()
  447. library(ruut)
  448. styler:::style_active_file()
  449. library(ruut)
  450. styler:::style_active_file()
  451. styler:::style_active_file()
  452. library(ruut)
  453. styler:::style_active_file()
  454. styler:::style_active_file()
  455. styler:::style_active_file()
  456. styler:::style_active_file()
  457. library(ruut)
  458. conf <- ruut::get_config()
  459. conf
  460. styler:::style_active_file()
  461. library(ruut)
  462. library(ruut)
  463. conn <- ruut::db_connect()
  464. config <- get_config()
  465. config$schema <- "public"
  466. conf = config
  467. q <- sprintf("select t.table_name
  468. from information_schema.tables t
  469. where t.table_schema = '%s'
  470. and t.table_type = 'BASE TABLE'
  471. order by t.table_name;", conf$schema)
  472. conf$schema
  473. res <- DBI::dbGetQuery(conn, q)
  474. res
  475. res <- as.array(DBI::dbGetQuery(conn, q))
  476. res <- DBI::dbGetQuery(conn, q)
  477. res[,'table_name']
  478. styler:::style_active_file()
  479. library(ruut)
  480. config
  481. config$schema <- 'maaamet'
  482. db_schema_tablenames(conf = config)
  483. library(ruut)
  484. styler:::style_active_file()
  485. library(ruut)
  486. library(ruut)
  487. styler:::style_active_file()
  488. construct_qgis_output_result_to_beter_format <- function(str = "") {
  489. #' str - Processing algorithm… Algorithm '......' starting…
  490. #' Input parameters: -> kopeerin need loogilistes sulgudes
  491. #' olevad väärtused argumendi "str" väärtuseks.
  492. str <- "{ 'CREATEINDEX' : True, 'DATABASE' : 'Data', 'DROP_STRING_LENGTH' : False, 'ENCODING' : 'UTF-8', 'FORCE_SINGLEPART' : False, 'GEOMETRY_COLUMN' : 'geometry', 'INPUT' : '/data/gpkg/teed/teed_l.gpkg|layername=teed_l', 'LOWERCASE_NAMES' : True, 'OVERWRITE' : True, 'PRIMARY_KEY' : 'fid', 'SCHEMA' : 'data', 'TABLENAME' : 'mikihiir' }"
  493. str <- gsub("'", "", str)
  494. str <- gsub(":", "=", str)
  495. str <- gsub(" ", "", str)
  496. str <- gsub(",", "',", str)
  497. str <- gsub("=", "='", str)
  498. str <- gsub("'True'", "1", str)
  499. str <- gsub("'False'", "0", str)
  500. str <- gsub(",", ",\n", str)
  501. str <- gsub("[{]", "\nalgorithm=algorithm,\n", str)
  502. str <- gsub("[}]", "'\n", str)
  503. str <- gsub("layername='", "layername=", str)
  504. cat(str)
  505. str
  506. }
  507. str <- "{ 'CREATEINDEX' : True, 'DATABASE' : 'Data', 'DROP_STRING_LENGTH' : False, 'ENCODING' : 'UTF-8', 'FORCE_SINGLEPART' : False, 'GEOMETRY_COLUMN' : 'geometry', 'INPUT' : '/data/gpkg/teed/teed_l.gpkg|layername=teed_l', 'LOWERCASE_NAMES' : True, 'OVERWRITE' : True, 'PRIMARY_KEY' : 'fid', 'SCHEMA' : 'data', 'TABLENAME' : 'mikihiir' }"
  508. params <- construct_qgis_output_result_to_beter_format(str = str)
  509. styler:::style_active_file()
  510. styler:::style_active_file()
  511. library(ruut)
  512. library(ruut)