Jelajahi Sumber

Muudetud kõikide funktsioonide projektsioonid.
Töötavad kõik.

Ardo Kubjas 5 tahun lalu
induk
melakukan
ee51acb575

+ 1 - 1
R/inspire_grids.R

@@ -58,7 +58,7 @@ inspire_grids <- function(conf = NULL) {
       ## Export to postgis database.
       ruut::copy_shp_to_db(
         dir = tmp_dir, layer = tbl_names[i], conf = conf,
-        id = "fid", crs_source = "EPSG:3035", crs_target = "EPSG:4326",
+        id = "fid", crs_source = "EPSG:3035", crs_target = "EPSG:3301",
         geometry_type = "POLYGON"
       )
       cat(sprintf(

+ 9 - 9
R/maaamet_aadressandmed.R

@@ -27,7 +27,6 @@
 #'
 #' conf <- ruut::get_config()
 #' maaamet_aadressandmed(conf = conf)
-#'
 #' }
 maaamet_aadressandmed <- function(conf = NULL) {
   ans <- utils::askYesNo("Do you want to import aadressandmed into database?", default = F)
@@ -149,7 +148,7 @@ maaamet_aadressandmed <- function(conf = NULL) {
       cat(cmd)
       cat("\n")
       # -overwrite vs. -append  -progress
-      # -sql ST_Transform(ST_SetSRID(ST_MakePoint(viitepunkt_x::double precision, viitepunkt_y::double precision),3301),4326) as geometry
+      # -sql ST_Transform(ST_SetSRID(ST_MakePoint(viitepunkt_x::double precision, viitepunkt_y::double precision),3301),4326) as geom
       system(cmd)
       # Add geometry column
       Sys.sleep(2)
@@ -159,9 +158,10 @@ maaamet_aadressandmed <- function(conf = NULL) {
       # COPY %s.%s FROM '%s/%s' DELIMITER ';' CSV header ENCODING 'utf8';",
       #              conf$schema, conf$table, tmp_dir, "aadressandmed.csv")
       # DBI::dbExecute(conn, q)
-      q <- sprintf("
-      -- ALTER TABLE %s.%s DROP COLUMN geometry; \
-      ALTER TABLE %s.%s ADD geometry geometry DEFAULT NULL; \
+      q <- sprintf(
+        "
+      -- ALTER TABLE %s.%s DROP COLUMN geom; \
+      ALTER TABLE %s.%s ADD geom geometry DEFAULT NULL; \
       UPDATE %s.%s SET viitepunkt_x=NULL where viitepunkt_x=''; \
       UPDATE %s.%s SET viitepunkt_y=NULL where viitepunkt_y=''; \
       ALTER TABLE %s.%s ALTER COLUMN viitepunkt_x TYPE double precision USING viitepunkt_x::double precision; \
@@ -173,23 +173,23 @@ maaamet_aadressandmed <- function(conf = NULL) {
         conf$schema, conf$table
       )
       cat(q)
-      cat('\n')
+      cat("\n")
       DBI::dbExecute(conn, q)
       # Insert data into geometry
       q <- sprintf(
         "
-      UPDATE %s.%s as a SET geometry =subquery.geom \
+      UPDATE %s.%s as a SET geom =subquery.geom \
       FROM (\
         SELECT adob_id, \
         ST_Transform(ST_SetSRID(ST_MakePoint(viitepunkt_x::double precision, \
-        viitepunkt_y::double precision),3301),4326) as geom \
+        viitepunkt_y::double precision),3301),3301) as geom \
         FROM %s.%s a \
       ) AS subquery \
       WHERE a.adob_id=subquery.adob_id;",
         conf$schema, conf$table, conf$schema, conf$table
       )
       cat(q)
-      cat('\n')
+      cat("\n")
       DBI::dbExecute(conn, q)
 
       # ogr2ogr help.

+ 1 - 1
R/maaamet_ehak.R

@@ -60,7 +60,7 @@ maaamet_ehak <- function(conf = NULL) {
         ## Export to postgis database.
         ruut::copy_shp_to_db(
           dir = tmp_dir, layer = tbl_names[i], conf = conf,
-          id = "fid", crs_source = "EPSG:3301", crs_target = "EPSG:4326",
+          id = "id", crs_source = "EPSG:3301", crs_target = "EPSG:3301",
           geometry_type = "POLYGON"
         )
         cat(sprintf(

+ 1 - 1
R/maaamet_kaardiruudud.R

@@ -61,7 +61,7 @@ maaamet_kaardiruudud <- function(conf = NULL) {
         ## Export to postgis database.
         ruut::copy_shp_to_db(
           dir = tmp_dir, layer = tbl_names[i], conf = conf,
-          id = "fid", crs_source = "EPSG:3301", crs_target = "EPSG:4326",
+          id = "id", crs_source = "EPSG:3301", crs_target = "EPSG:3301",
           geometry_type = "POLYGON"
         )
         cat(sprintf(

+ 2 - 2
R/maaamet_kataster.R

@@ -60,7 +60,7 @@ maaamet_kataster <- function(conf = NULL) {
       ## Export to postgis database.
       ruut::copy_shp_to_db(
         dir = tmp_dir, layer = tbl_names[i], conf = conf,
-        id = "fid", crs_source = "EPSG:3301", crs_target = "EPSG:4326",
+        id = "id", crs_source = "EPSG:3301", crs_target = "EPSG:3301",
         geometry_type = "POLYGON"
       )
       cat(sprintf(
@@ -69,6 +69,6 @@ maaamet_kataster <- function(conf = NULL) {
       ))
     }
     # Delete temp directory
-    # system(sprintf("rm -rf %s/*", tmp_dir))
+    system(sprintf("find %s -type f -not -name '%s' -print0 | xargs -0 rm --", tmp_dir, map_shapefile))
   }
 }

+ 1 - 1
R/osm_shp.R

@@ -60,7 +60,7 @@ osm_shp <- function(conf = NULL) {
       ## Export to postgis database.
       ruut::copy_shp_to_db(
         dir = tmp_dir, layer = tbl_names[i], conf = conf,
-        id = "fid", crs_source = "EPSG:4326", crs_target = "EPSG:4326",
+        id = "id", crs_source = "EPSG:4326", crs_target = "EPSG:3301",
         geometry_type = "PROMOTE_TO_MULTI"
       )
       cat(sprintf(

+ 3 - 3
R/teeregister_teed.R

@@ -54,7 +54,7 @@ teeregister_teed <- function(conf = NULL) {
         ## -------- Export to postgis database ----------
         ruut::copy_shp_to_db(
           dir = tmp_dir, layer = tbl_names[i], conf = conf,
-          id = "fid", crs_source = "EPSG:3301", crs_target = "EPSG:4326",
+          id = "fid", crs_source = "EPSG:3301", crs_target = "EPSG:3301",
           geometry_type = "MULTILINESTRING"
         )
         # ------- multilinestring to linestring -----------
@@ -63,12 +63,12 @@ teeregister_teed <- function(conf = NULL) {
         # cat(qgisprocess::qgis_show_help(algorithm = algorithm))
         # Run algorithm.
         input <- sprintf(
-          'postgres://dbname=\'%s\' host=%s port=%s user=\'%s\' sslmode=%s password=\'%s\' srid=4326 type=MultiLineString checkPrimaryKeyUnicity=\'1\' table=\"%s\".\"%s\" (geometry)',
+          'postgres://dbname=\'%s\' host=%s port=%s user=\'%s\' sslmode=%s password=\'%s\' srid=3301 type=MultiLineString checkPrimaryKeyUnicity=\'1\' table=\"%s\".\"%s\" (geom)',
           conf$dbname, conf$host, conf$port, conf$user, conf$sslmode, conf$password, conf$schema, conf$table
         )
         conf$table <- table
         output <- sprintf(
-          'postgres://dbname=\'%s\' host=%s port=%s user=\'%s\' sslmode=%s password=\'%s\' table=\"%s\".\"%s\" (geometry)',
+          'postgres://dbname=\'%s\' host=%s port=%s user=\'%s\' sslmode=%s password=\'%s\' table=\"%s\".\"%s\" (geom)',
           conf$dbname, conf$host, conf$port, conf$user, conf$sslmode, conf$password, conf$schema, conf$table
         )
         result <- qgisprocess::qgis_run_algorithm(

+ 0 - 1
man/maaamet_aadressandmed.Rd

@@ -38,7 +38,6 @@ Aadressiobjekti liigid (Kood, Nimetus, UnikInit, taseOrig, register)
 
 conf <- ruut::get_config()
 maaamet_aadressandmed(conf = conf)
-
 }
 }
 \seealso{