[postgis-devel] ST_Segmentize geography go back to old 2.2 behavior
Mike Toews
mwtoews at gmail.com
Thu Sep 21 23:44:08 PDT 2017
On 22 September 2017 at 07:47, Regina Obe <lr at pcorp.us> wrote:
> Except for this last one which I propose we fix by switching back to 2.2
> behavior. The new behavior is harder to get right in all cases and I don't
> see it as being that much of an improvement over the old behavior.
I'll admit that I haven't been following the old or new behaviours of
ST_Segmentize, but I'd suggest redesigning this based on GeographicLib
(same library used for ST_Distance, via PROJ), since it has reliable
methods to do parts of the technique. In particular, it will produce
equal-length sub-segments, probably within a few nanometres.
Charles has a few examples of interpolating points from an inverse
geodesic line, here is one for C:
https://geographiclib.sourceforge.io/html/C/geodesic_8h.html#a0b91285fb3cd572d2d77b2e062e8c800
Essentially, you create an geod_geodesicline for each vertex pair,
find the geodesic length (s12). If the geodesic segment length is
greater than the segmentize distance, then interpolate the points
along the geodesic line with geod_position by dividing s12 by the
appropriate number of points required. Each sub-segment would have
equal distance between them.
As for performance, creating each geod_geodesicline is just as
expensive as ST_Distance (2.62 µs), then geod_position to get the
interpolated points is very cheap (each 0.37 µs).
Cheers, Mike
More information about the postgis-devel
mailing list