Преглед изворни кода

Töötavad versioonid projektsioonis: 3301. 'teeregister_wfs' ja 'gtfs'.

Ardo Kubjas пре 5 година
родитељ
комит
b95eac5c6f
2 измењених фајлова са 7 додато и 6 уклоњено
  1. 6 5
      R/gtfs.R
  2. 1 1
      R/teeregister_wfs.R

+ 6 - 5
R/gtfs.R

@@ -96,6 +96,7 @@ gtfs <- function(conf = NULL) {
             # dplyr::summarise() %>%
             sf::st_cast("POINT")
           sf::st_crs(sl) <- 4326
+          sl <- sf::st_transform(sl, 3301)
           # # Test plot
           # sl %>%
           #   ggplot2::ggplot(ggplot2::aes(colour = shape_id)) +
@@ -104,7 +105,7 @@ gtfs <- function(conf = NULL) {
           # Write to database
           tabeli_suffix <- "_source"
           sf::st_write(
-            obj = sl, dsn = conn, layer_options = c("GEOMETRY=AS_XY", "OVERWRITE=yes"),
+            obj = sl, dsn = conn, layer_options = c("OVERWRITE=yes"),
             layer = sprintf("%s%s", conf$table, tabeli_suffix)
           )
           # Change schema
@@ -122,12 +123,12 @@ gtfs <- function(conf = NULL) {
           # cat(qgis_show_help(algorithm = algorithm))
           # Run algorithm.
           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
           )
           input <- sprintf(
-            'postgres://dbname=\'%s\' host=%s port=%s user=\'%s\' sslmode=%s password=\'%s\' srid=4326 type=Point checkPrimaryKeyUnicity=\'1\' table=\"%s\".\"%s_source\" (geometry)',
+            'postgres://dbname=\'%s\' host=%s port=%s user=\'%s\' sslmode=%s password=\'%s\' srid=3301 type=Point checkPrimaryKeyUnicity=\'1\' table=\"%s\".\"%s_source\" (geometry)',
             conf$dbname, conf$host, conf$port, conf$user, conf$sslmode, conf$password,
             conf$schema, conf$table
           )
@@ -138,7 +139,7 @@ gtfs <- function(conf = NULL) {
             GROUP_FIELD = "shape_id",
             INPUT = input,
             ORDER_FIELD = "shape_pt_sequence",
-            OUTPUT_TEXT_DIR = "/tmp/gtfs_output_text_dir/",
+            OUTPUT_TEXT_DIR = "/tmp/",
             OUTPUT = output,
             .quiet = TRUE
           )
@@ -147,7 +148,7 @@ gtfs <- function(conf = NULL) {
             paste0(
               "ogr2ogr -f PostgreSQL ",
               "%s -lco SCHEMA=%s -lco OVERWRITE=yes -lco FID=%s -nln \"%s\" \"%s/%s.csv\""
-            ), pg, conf$schema, "fid", conf$table, tmp_dir, tbl_names[i]
+            ), pg, conf$schema, "id", conf$table, tmp_dir, tbl_names[i]
           )
           cat(cmd)
           cat("\n\n")

+ 1 - 1
R/teeregister_wfs.R

@@ -44,7 +44,7 @@ teeregister_wfs <- function(conf = NULL) {
       if (!conf$table %in% installed_tables) {
         cat(sprintf("\n-----------------\nKihi \"%s\" kopeerimine andmebaasi.\n", wfs_layer))
         q <- sprintf(
-          "ogr2ogr -progress --config PG_USE_COPY YES -f PostgreSQL %s -lco DIM=2 %s %s -overwrite -nlt GEOMETRY -lco GEOMETRY_NAME=geometry -lco FID=id -nln %s.%s -a_srs EPSG:3301 -nlt PROMOTE_TO_MULTI ",
+          "ogr2ogr -progress --config PG_USE_COPY YES -f PostgreSQL %s -lco DIM=2 %s %s -overwrite -nlt GEOMETRY -lco GEOMETRY_NAME=geom -lco FID=id -nln %s.%s -a_srs EPSG:3301 -nlt PROMOTE_TO_MULTI ",
           pg, wfs, wfs_layer, conf$schema, conf$table
         ) #-s_srs EPSG:3301 -t_srs EPSG:3301
         cat(sprintf("\n%s\n", q))