[flex output] Get the first node and last node of a linestring using lua, and insert into as a point in the database #2091
Replies: 2 comments 2 replies
-
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:
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.) |
Beta Was this translation helpful? Give feedback.
-
Yes, of course. |
Beta Was this translation helpful? Give feedback.
-
First, thanks for developing flex, this is a pleasure to use it.
This is our use case: we are developing a spatial analysis which will compute the distance between different points on the same level (a platform in a station). We would like to know, for instance, the distance between the steps and a
railway=platform_marker
node.For this, we summary every object on the train's platform on a point geometry.
This is very easy with elevator, which, for instance, are already a point.
For steps, we are currently using the centroid of the linestring. But, for accuracy, we would like to take the step where it does reach the platform level. Steps are a linestring. So, for this, we have to analyze the first and the last node of the linestring, and the content of the
level=*
key to know if it is going up or down. This will create two points in the table: one with the step's start and the corresponding level, and another with the step's end and the corresponding level. Later in the database, our queries will do a processing to compare the platform's level with the step's one.So, it would be nice to be able to extract the first and last from a linestring, and be able to create a "geometry" from that.
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions