[PostGIS] #5703: ST_Intersects function is returning the wrong results for a simple rectangle that crosses any two quarter longitude lines
PostGIS
trac at osgeo.org
Wed Mar 27 16:25:10 PDT 2024
#5703: ST_Intersects function is returning the wrong results for a simple
rectangle that crosses any two quarter longitude lines
-----------------------+---------------------------
Reporter: hangstrap | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 3.4.3
Component: postgis | Version: 3.4.x
Keywords: |
-----------------------+---------------------------
the ST_Intersects function is returning the wrong results for a simple
rectangle that crosses any two quarter longitude lines (e.g 0, 90, 180,
-90).
Running the following query returns the points outside the polygon as well
as the expected points inside
{{{
select postgis.st_astext( point_) from
(
with foo ( point_ ) as ( values
( postgis.ST_GeogFromText( 'POINT (-6 0)')),
( postgis.ST_GeogFromText( 'POINT (-4 0)')),
( postgis.ST_GeogFromText( 'POINT (94 0)')),
( postgis.ST_GeogFromText( 'POINT (96 0)'))
)
select * from foo
) bar
where postgis.ST_Intersects( point_, postgis.ST_GeogFromText('POLYGON ((
-5 -10, -5 10, 95.0 10, 95.0 -10 , -5 -10))'));
}}}
The select statement should return the points (-4 0) and (94 0), but
returns all four points.
This select statement, that does not cross two quarter longitude lines,
works correctly
{{{
--works only closses 0 line
select postgis.st_astext( point_) from
(
with foo ( point_ ) as ( values
( postgis.ST_GeogFromText( 'POINT (-51 0)')),
( postgis.ST_GeogFromText( 'POINT (-49 0)')),
( postgis.ST_GeogFromText( 'POINT (49 0)')),
( postgis.ST_GeogFromText( 'POINT (51 0)'))
)
select * from foo
) bar
where postgis.ST_Intersects( point_, postgis.ST_GeogFromText('POLYGON ((
-50 -10, -50 10, 50 10, 50 -10 , -50 -10))'));
}}}
Tested on
''PostgreSQL 12.18 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 8.5.0
20210514 (Red Hat 8.5.0-20), 64-bit''
With Postgis
''POSTGIS="3.1.11 ca03d62" [EXTENSION] PGSQL="120"
GEOS="3.12.1-CAPI-1.18.1" PROJ="9.2.1" LIBXML="2.9.7" LIBJSON="0.13.1"
LIBPROTOBUF="1.3.0" WAGYU="0.5.0 (Internal)"''
and
''POSTGIS="3.4.2 c19ce56" [EXTENSION] PGSQL="120"
GEOS="3.12.1-CAPI-1.18.1" PROJ="9.2.1 NETWORK_ENABLED=OFF
URL_ENDPOINT=https://cdn.proj.org
USER_WRITABLE_DIRECTORY=/var/lib/pgsql/.local/share/proj
DATABASE_PATH=/usr/proj92/share/proj/proj.db" LIBXML="2.9.7"
LIBJSON="0.13.1" LIBPROTOBUF="1.3.0" WAGYU="0.5.0 (Internal)" (core procs
from "3.1.11 ca03d62" need upgrade)''
The queries do work as expected on postgres 10, postgis 2.4.8
--
Ticket URL: <https://trac.osgeo.org/postgis/ticket/5703>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.
More information about the postgis-tickets
mailing list