#3941 closed defect (fixed)
ST_Segmentize() wraps geography coordinates on dateline
Reported by: | francoisb | Owned by: | pramsey |
---|---|---|---|
Priority: | medium | Milestone: | PostGIS 2.4.3 |
Component: | postgis | Version: | 2.4.x |
Keywords: | densify densification | Cc: |
Description
Points exactly on the dateline have two valid representations in the geography type:
SELECT ST_GeomFromText('POINT(-180 0)')::geography AS negative, ST_GeomFromText('POINT( 180 0)')::geography AS positive;
Gives:
negative | 0101000020E610000000000000008066C00000000000000000 positive | 0101000020E610000000000000008066400000000000000000
Internally these are two different values, but semantically it corresponds to the same location.
ST_Segmentize() unfortunately uses this fact to modify input geography. ST_Segmentize() is supposed to only add vertices, but it happens it may also modify given ones. Example:
SELECT ST_AsText(ST_Segmentize( ST_GeomFromText('LINESTRING(-180 0, -179 0)')::geography, 5e4 ));
Actual:
LINESTRING(180 0,-179.75 0,-179.5 0,-179.25 0,-179 0)
Note the positive 180, changed from input.
Expected:
LINESTRING(-180 0,-179.75 0,-179.5 0,-179.25 0,-179 0)
Note the negative -180, unchanged from input.
A point represented with longitude -180 in the input geography should remain with this -180 value, and not change to +180.
Setup:
SELECT postgis_full_version(); POSTGIS="2.4.2 r16113" PGSQL="100" GEOS="3.6.2-CAPI-1.10.2 4d2925d6" PROJ="Rel. 4.9.3, 15 August 2016" GDAL="GDAL 1.11.5, released 2016/07/01" LIBXML="2.9.7" LIBJSON="0.12.1" TOPOLOGY RASTER
In 16161: