[Tile-serving] [openstreetmap/osm2pgsql] Use PostGIS to make sure geometries are valid (#790)

Paul Norman notifications at github.com
Sun Oct 1 22:31:10 UTC 2017


pnorman commented on this pull request.



> +                         "  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%_valid BEFORE INSERT OR UPDATE\n"
+                         "  ON %1%\n"
+                         "    FOR EACH ROW EXECUTE PROCEDURE %1%_valid();") %
+                     name)
+                        .str());

The trigger never needs to be explicitly removed. If reimporting, the entire table is dropped and the trigger goes with it. If importing more with --append, the trigger needs to be there.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/osm2pgsql/pull/790#discussion_r142042536
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/tile-serving/attachments/20171001/69ee30b0/attachment.html>


More information about the Tile-serving mailing list