osm2pgsql icon indicating copy to clipboard operation
osm2pgsql copied to clipboard

Add `length()` Lua function for geometries

Open joto opened this issue 3 years ago • 4 comments

It would be great to have a length() function for (multi)linestrings. Implementation similar to the area() function for polygons using the boost::geometry function of the same name.

See #1756

joto avatar Sep 08 '22 18:09 joto

Should this be the total length, or, when splitting is on, the length of the split linestring?

pnorman avatar Sep 08 '22 18:09 pnorman

Should this be the total length, or, when splitting is on, the length of the split linestring?

This would be a function on geometry objects which don't do magic auto-splitting. It should just do what it says on the box, i.e. calculate the length of that geometry.

joto avatar Sep 08 '22 18:09 joto

Hello, I am interested in contributing. This would be my first contribution so I might need some extra guidence, would that be alright?

victoriasiver26 avatar Sep 12 '22 20:09 victoriasiver26

@victoriasiver26 Sure. Try installing osm2pgsql from source and running it using the flex output. Try the geometries-using-insert.lua example from the flex-config directory. Look there for use of the area() function. Then find the places in the source where the area() function is implemented and do the equivalent for the length() function.

joto avatar Sep 13 '22 07:09 joto

Implemented in #1777.

lonvia avatar Sep 25 '22 07:09 lonvia