[Tile-serving] [osm2pgsql-dev/osm2pgsql] [flex output] Get the first node and last node of a linestring using lua, and insert into as a point in the database (Discussion #2091)

Jochen Topf notifications at github.com
Thu Oct 12 14:01:19 UTC 2023


I am not sure I understand your use case sufficiently. Getting at the first and last points in a linestring from PostgreSQL/PostGIS is reasonably easy and should be fast enough. Does this not work in your case? Because you are doing that distance calculation in PostGIS anyway, aren't you?

I can imagine that osm2pgsql will support such a function in the future, but want to understand all the issues there first. I see two different ways to implement this:
1. A function to get the nth point in a linestring as you proposed (`object:as_linestring():pointn(1)`)
2. A function to directly get the nth point from the OSM object (`object:node(1):as_point()` or `object:as_point(1)` or so)

The second option would potentially be much faster if you don't need the whole linestring, but just one or two points like in your case, because we don't have to get the coordinates of the nodes we are not using. But it might be a bit harder for the user to understand and would be a bit more effort to implement. (We have a similar issue with members of relations.)

-- 
Reply to this email directly or view it on GitHub:
https://github.com/osm2pgsql-dev/osm2pgsql/discussions/2091#discussioncomment-7263984
You are receiving this because you are subscribed to this thread.

Message ID: <osm2pgsql-dev/osm2pgsql/repo-discussions/2091/comments/7263984 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/tile-serving/attachments/20231012/639c8716/attachment.htm>


More information about the Tile-serving mailing list