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). This can also be accessed as #geom (the usual Lua length
operator)
* segmentize(max_segment_length) (for linestrings)
* 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.
The Lua helper functions clamp(), has_prefix(), has_suffix(), trim(),
and split_string() now all return nil if they are called with nil
as (first) argument. This makes them more robust, for instance when
called on non-existent tags and so simplifies user code.
Adds Lua helper functions has_prefix() and has_suffix(). This is useful
for checks like osm2pgsql.has_prefix(some_tag, 'addr:').
Also add functionality to the osm2pgsql.make_clean_tags_func() function
to also check for suffixes, so '*:sources' will check for all tags
with suffix ':sources'.