#3511 closed defect (invalid)
ST_Intersects returns false positives at equator and anti/prime meridian
Reported by: | jgm1972 | Owned by: | pramsey |
---|---|---|---|
Priority: | medium | Milestone: | PostGIS 2.4.0 |
Component: | postgis | Version: | 2.2.x |
Keywords: | ST_Intersects | Cc: |
Description
Using PGAdmin3 v1.22.0 and the Postres App version 9.5.0.0 on a MacBook running OSX 10.11.3, ST_Intersects returns false positives when intersecting two lines.
When running an intersection with the anitmeridian, if the second line contains a vertex at longitude 0 and any vertex > longitude 90 or < -90, the intersection returns true. For example,
SELECT ST_Intersects(line, line2) as inter from ST_GeogFromText('LINESTRING(180 -90, 180 0, 180 90)') As line, ST_GeogFromText('LineString (90.1 1, 0 0.1, -90 -1)') as line2;
and
SELECT ST_Intersects(line, line2) as inter from ST_GeogFromText('LINESTRING(180 -90, 180 0, 180 90)') As line, ST_GeogFromText('LineString (90 1, 0 0.1, -90.1 -1)') as line2;
return true, but
SELECT ST_Intersects(line, line2) as inter from ST_GeogFromText('LINESTRING(180 -90, 180 0, 180 90)') As line, ST_GeogFromText('LineString (90 1, 0 0.1, -90 -1)') as line2;
and
SELECT ST_Intersects(line, line2) as inter from ST_GeogFromText('LINESTRING(180 -90, 180 0, 180 90)') As line, ST_GeogFromText('LineString (90 1, 0 0, -90 -1)') as line2;
return false.
Additionally, if the end vertices of the line are on the equator and > longitude 90 or < -90 ST_intersects returns true if the line has another vertex with latitude or longitude 0 .
For example,
SELECT ST_Intersects(line, line2) as inter from ST_GeogFromText('LINESTRING(180 -90, 180 0, 180 90)') As line, ST_GeogFromText('LineString (90 0, 0.1 0, -90.1 0)') as line2;
and
SELECT ST_Intersects(line, line2) as inter from ST_GeogFromText('LINESTRING(180 -90, 180 0, 180 90)') As line, ST_GeogFromText('LineString (90 0, 0 0.1, -90.1 0)') as line2;
return true, but
SELECT ST_Intersects(line, line2) as inter from ST_GeogFromText('LINESTRING(180 -90, 180 0, 180 90)') As line, ST_GeogFromText('LineString (90 0, 0.1 0, -90 0)') as line2;
and
SELECT ST_Intersects(line, line2) as inter from ST_GeogFromText('LINESTRING(180 -90, 180 0, 180 90)') As line, ST_GeogFromText('LineString (90 0, 0 0.1, -90 0)') as line2;
and
SELECT ST_Intersects(line, line2) as inter from ST_GeogFromText('LINESTRING(180 -90, 180 0, 180 90)') As line, ST_GeogFromText('LineString (90 0, 0 0, -90 0)') as line2;
return false.
Change History (5)
comment:2 by , 9 years ago
Milestone: | PostGIS PostgreSQL → PostGIS 2.2.3 |
---|
comment:3 by , 8 years ago
Milestone: | PostGIS 2.2.3 → PostGIS 2.4.0 |
---|
comment:4 by , 8 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
Great circles between antipodes do not have a deterministic path. What is the shortest paths between the north and south pole? It's any line you wish, they are all the shortest/longest paths. As you found, adding mid-points to lines allows you to direct the line where you "want", because each segment in the line is now shorter than an antipodal segment and has a deterministic path. Moral of the story: use segments of < 180 degrees.
comment:5 by , 8 years ago
Can you elaborate on why
SELECT ST_Intersects(line, line2) as inter from ST_GeogFromText('LINESTRING(180 -90, 180 0, 180 90)') As line, ST_GeogFromText('LineString? (90 1, 0 0.1, -90.1 -1)') as line2;
returns true
but
SELECT ST_Intersects(line, line2) as inter from ST_GeogFromText('LINESTRING(180 -90, 180 0, 180 90)') As line, ST_GeogFromText('LineString? (90 1, 0 0, -90 -1)') as line2;
returns false?
The segments are <180 deg.
For the fourth examples, I meant to include
SELECT ST_Intersects(line, line2) as inter from ST_GeogFromText('LINESTRING(180 -90, 180 0, 180 90)') As line, ST_GeogFromText('LineString? (90 1, 0.1 0, -90 -1)') as line2;
returns false.