Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#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

Change History (2)

comment:1 by pramsey, 7 years ago

Resolution: fixed
Status: newclosed

In 16161:

Use original vertex values where available in contructing new pointarray (closes #3941)

comment:2 by pramsey, 7 years ago

In 16163:

Use original vertex values where available in contructing new pointarray (references #3941)

Note: See TracTickets for help on using tickets.