[Tile-serving] [osm2pgsql-dev/osm2pgsql] as_linestring() and likely other geometry transform functions can only be called from the process_way() function, not custom functions. (Issue #2171)

Jochen Topf notifications at github.com
Wed Apr 10 19:34:00 UTC 2024


What do you propose `as_linestring()` generate when called on a relation? What would happen if the relation doesn't "fit" into a LineString?

Typically you'd use something like this on a `route` relation where the result could be a LineString, but it could also be a MultiLineString. That's why there is only the `as_multilinestring()` function for relations. That function also exists for ways, although in that case it will always create a MultiLineString with a single LineString in it. You can then either use that MultiLineString as is or iterate over the geometries in it and work with each LineString. So common code for both ways and relations can just use the `as_multilinestring()` function.

See https://osm2pgsql.org/doc/tutorials/switching-from-add-row-to-insert/ for some more infos.

You can also look at the [unitable.lua](https://github.com/osm2pgsql-dev/osm2pgsql/blob/master/flex-config/unitable.lua) example config to see how you can write code that's mostly shared between nodes, ways, and relations but still handles geometries differently.

And finally: Functions are first-class objects in Lua, you can define your own. For an example see [the themepark code](https://github.com/osm2pgsql-dev/osm2pgsql-themepark/blob/master/lua/themepark.lua#L456-L484).


-- 
Reply to this email directly or view it on GitHub:
https://github.com/osm2pgsql-dev/osm2pgsql/issues/2171#issuecomment-2048296102
You are receiving this because you are subscribed to this thread.

Message ID: <osm2pgsql-dev/osm2pgsql/issues/2171/2048296102 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/tile-serving/attachments/20240410/4f3d7f45/attachment-0001.htm>


More information about the Tile-serving mailing list