[Tile-serving] [openstreetmap/osm2pgsql] Work-in-progress: Add geometry functions in Lua / new insert syntax (PR #1736)

Jochen Topf notifications at github.com
Sun Aug 7 12:51:13 UTC 2022


This is the future of geometry processing in Lua. Geometries are not something happening magically behind the scenes as before, but they are (mostly) normal objects that can be manipulated in Lua. There are several functions to create those geometry objects from the OSM objects:

* as_point() (for nodes)
* as_linestring() (for ways)
* as_polygon() (for ways)
* as_multilinestring() (for relations)
* as_multipolygon() (for relations)
* as_geometrycollection() (for relations)

Geometries can be manipulated with the following functions (all based on their equivalents in PostGIS):

* area() (for polygons)
* centroid() (for polygons)
* geometries() for iterating over (multi)geometries
* geometry_n() return the nth geometry from a (multi)geometry.
* geometry_type() returns type as string ('POINT', 'LINESTRING', ...)
* is_null() returns true if this is a null geometry
* num_geometries() returns the number of geometries (0 for null geom, 1 for point/linestring/polygon, n for multi* and geometrycollection geoms)
* simplify(tolerance) (for linestrings)
* srid()
* transform(target_srid)

Some of these functions are using boost::geometry for their implementation. More functions can be implemented in the future as needed.

There is a new syntax for inserting rows into a table. Instead of "add_row" the "insert" function is used. "add_row" is still available
and it works as before. But the new geometry types only work with the "insert" command. The "insert" function also allows multiple geometry columns which wasn't possible with "add_row".

See the file flex-config/new-insert-syntax.lua for an example that shows how to use the new capabilities.
You can view, comment on, or merge this pull request online at:

  https://github.com/openstreetmap/osm2pgsql/pull/1736

-- Commit Summary --

  * Work-in-progress: Add geometry functions in Lua / new insert syntax

-- File Changes --

    A flex-config/new-insert-syntax.lua (215)
    M src/flex-table.cpp (3)
    M src/flex-table.hpp (8)
    M src/init.lua (10)
    M src/middle-ram.cpp (7)
    M src/output-flex.cpp (544)
    M src/output-flex.hpp (26)
    A tests/bdd/flex/collection.feature (69)
    A tests/bdd/flex/geometry-processing.feature (97)
    A tests/bdd/flex/geometry-split-multi.feature (39)
    A tests/bdd/flex/insert-area.feature (67)
    A tests/bdd/flex/invalid-lua.feature (12)
    A tests/bdd/flex/null-geom.feature (85)
    M tests/lua/tests.lua (2)

-- Patch Links --

https://github.com/openstreetmap/osm2pgsql/pull/1736.patch
https://github.com/openstreetmap/osm2pgsql/pull/1736.diff

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/osm2pgsql/pull/1736
You are receiving this because you are subscribed to this thread.

Message ID: <openstreetmap/osm2pgsql/pull/1736 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/tile-serving/attachments/20220807/158d4abc/attachment.htm>


More information about the Tile-serving mailing list