[osm2pgsql] 02/07: New upstream version 0.94.0~rc2+ds

Bas Couwenberg sebastic at debian.org
Wed Oct 4 05:54:18 UTC 2017


This is an automated email from the git hooks/post-receive script.

sebastic pushed a commit to branch master
in repository osm2pgsql.

commit 2444233f198bd50376e5f955e5249c19e7e29f94
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date:   Wed Oct 4 07:33:25 2017 +0200

    New upstream version 0.94.0~rc2+ds
---
 options.cpp |  2 +-
 table.cpp   | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 51 insertions(+), 2 deletions(-)

diff --git a/options.cpp b/options.cpp
index 025dc9b..31b328c 100644
--- a/options.cpp
+++ b/options.cpp
@@ -577,7 +577,7 @@ void options_t::check_options()
     // zoom level 31 is the technical limit because we use 32-bit integers for the x and y index of a tile ID
     if (expire_tiles_zoom_min >= 32) {
         expire_tiles_zoom_min = 31;
-        fprintf(stderr, "WARNING: mimimum zoom level for tile expiry is too "
+        fprintf(stderr, "WARNING: minimum zoom level for tile expiry is too "
                         "large and has been set to 31.\n\n");
     }
 
diff --git a/table.cpp b/table.cpp
index 87ccf7d..ae6eec6 100644
--- a/table.cpp
+++ b/table.cpp
@@ -218,7 +218,32 @@ void table_t::stop()
 
         fprintf(stderr, "Sorting data and creating indexes for %s\n", name.c_str());
 
-        pgsql_exec_simple(sql_conn, PGRES_COMMAND_OK, (fmt("CREATE TABLE %1%_tmp %2% AS SELECT * FROM %1% ORDER BY ST_GeoHash(ST_Transform(ST_Envelope(way),4326),10) COLLATE \"C\"") % name % (table_space ? "TABLESPACE " + table_space.get() : "")).str());
+        if (srid == "4326") {
+            /* libosmium assures validity of geometries in 4326, so the WHERE can be skipped.
+               Because we know the geom is already in 4326, no reprojection is needed for GeoHashing */
+            pgsql_exec_simple(
+                sql_conn, PGRES_COMMAND_OK,
+                (fmt("CREATE TABLE %1%_tmp %2% AS\n"
+                     "  SELECT * FROM %1%\n"
+                     "    ORDER BY ST_GeoHash(way,10)\n"
+                     "    COLLATE \"C\"") %
+                 name % (table_space ? "TABLESPACE " + table_space.get() : ""))
+                    .str());
+        } else {
+            /* osm2pgsql's transformation from 4326 to another projection could make a geometry invalid,
+               and these need to be filtered. Also, a transformation is needed for geohashing. */
+            pgsql_exec_simple(
+                sql_conn, PGRES_COMMAND_OK,
+                (fmt("CREATE TABLE %1%_tmp %2% AS\n"
+                     "  SELECT * FROM %1%\n"
+                     "    WHERE ST_IsValid(way)\n"
+                     // clang-format off
+                     "    ORDER BY ST_GeoHash(ST_Transform(ST_Envelope(way),4326),10)\n"
+                     // clang-format on
+                     "    COLLATE \"C\"") %
+                 name % (table_space ? "TABLESPACE " + table_space.get() : ""))
+                    .str());
+        }
         pgsql_exec_simple(sql_conn, PGRES_COMMAND_OK, (fmt("DROP TABLE %1%") % name).str());
         pgsql_exec_simple(sql_conn, PGRES_COMMAND_OK, (fmt("ALTER TABLE %1%_tmp RENAME TO %1%") % name).str());
         fprintf(stderr, "Copying %s to cluster by geometry finished\n", name.c_str());
@@ -235,6 +260,30 @@ void table_t::stop()
             fprintf(stderr, "Creating osm_id index on %s\n", name.c_str());
             pgsql_exec_simple(sql_conn, PGRES_COMMAND_OK, (fmt("CREATE INDEX %1%_pkey ON %1% USING BTREE (osm_id) %2%") % name %
                 (table_space_index ? "TABLESPACE " + table_space_index.get() : "")).str());
+            if (srid != "4326") {
+                pgsql_exec_simple(
+                    sql_conn, PGRES_COMMAND_OK,
+                    (fmt("CREATE OR REPLACE FUNCTION %1%_osm2pgsql_valid()\n"
+                         "RETURNS TRIGGER AS $$\n"
+                         "BEGIN\n"
+                         "  IF ST_IsValid(NEW.way) THEN \n"
+                         "    RETURN NEW;\n"
+                         "  END IF;\n"
+                         "  RETURN NULL;\n"
+                         "END;"
+                         "$$ LANGUAGE plpgsql;") %
+                     name)
+                        .str());
+
+                pgsql_exec_simple(
+                    sql_conn, PGRES_COMMAND_OK,
+                    (fmt("CREATE TRIGGER %1%_osm2pgsql_valid BEFORE INSERT OR UPDATE\n"
+                         "  ON %1%\n"
+                         "    FOR EACH ROW EXECUTE PROCEDURE %1%_osm2pgsql_valid();") %
+                     name)
+                        .str());
+            }
+            //pgsql_exec_simple(sql_conn, PGRES_COMMAND_OK, (fmt("ALTER TABLE %1% ADD CHECK (ST_IsValid(way));") % name).str());
         }
         /* Create hstore index if selected */
         if (enable_hstore_index) {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/osm2pgsql.git



More information about the Pkg-grass-devel mailing list