Opened 2 years ago

Closed 20 months ago

Last modified 11 months ago

#4727 closed defect (fixed)

polygon and point intersection calculated wrong for huge polygon

Reported by: prytvinsky Owned by: pramsey
Priority: medium Milestone: PostGIS 3.1.0
Component: postgis Version: 3.0.x
Keywords: Cc:

Description

postgis version: POSTGIS="3.0.1 ec2a9aa" [EXTENSION] PGSQL="120" GEOS="3.8.1-CAPI-1.13.3" PROJ="7.1.0" LIBXML="2.9.10" LIBJSON="0.14" LIBPROTOBUF="1.3.3" WAGYU="0.4.3 (Internal)" TOPOLOGY

sql query example:

create table geometry_real_shape as (
select
    _ST_DWithinUncached(
    		ST_Split(geom, 'SRID=4326;LINESTRING(-180 0, 180 0)')::geography, 
    		ST_MakePoint(x,y)::geography, 
		0
	) = 
	ST_Dwithin(geom::geography, ST_MakePoint(x,y), 0
	) as passed, 
	_ST_DWithinUncached(
    		ST_Split(geom, 'SRID=4326;LINESTRING(-180 0, 180 0)')::geography, 
    		ST_MakePoint(x,y)::geography, 
		0
	) as expected,
	ST_Dwithin(geom::geography, ST_MakePoint(x,y), 0) as actual,
	x, 
	y,
	ST_MakePoint(x,y)::geography as geom
from
	(select'SRID=4326;POLYGON ((-180 -85.05112877980659, -180 74.99999999999997, -152 80, -130 84.99999999999997, -115 85.05112877980659, -60 85.05112877980659, -60 79, -70 70, -130 50, -80 6, -65 -53, -100 -85.05112877980659, -180 -85.05112877980659))'::geometry as geom) as z,
	generate_series(-180,180) x, generate_series(-90,90) y
    );

in this query same result expected for "_ST_DWithinUncached" and "ST_Dwithin"

The difference is for "_ST_DWithinUncached" polygon is splitted by equator and intersection is correct.

When i use ST_Dwithin the intersection is wrong.

Change History (5)

comment:1 by Paul Ramsey <pramsey@…>, 20 months ago

Resolution: fixed
Status: newclosed

In 9a9241c/git:

Long-standing bug in pole adjustment code for bounding boxes.
Results in incorrect box for shapes wrapping the negative Y geocentric axis (-90,0)
Closes #4727

comment:2 by Paul Ramsey <pramsey@…>, 20 months ago

In 7b6d177/git:

Long-standing bug in pole adjustment code for bounding boxes.
Results in incorrect box for shapes wrapping the negative Y geocentric axis (-90,0)
Closes #4727

comment:3 by pramsey, 20 months ago

So, this big polygon winds around POINT(-90, 0) which in geocentric terms is the -Y pole. And it turns out, I had made mistake in the logic for that case! Whoops! Fortunately not many things wind around that pole, but for those that do… problems would ensue.

comment:4 by Paul Ramsey <pramsey@…>, 16 months ago

In 9826b5cc/git:

Long-standing bug in pole adjustment code for bounding boxes.
Results in incorrect box for shapes wrapping the negative Y geocentric axis (-90,0)
Closes #4727

comment:5 by Paul Ramsey <pramsey@…>, 11 months ago

In d0ceaf8/git:

Long-standing bug in pole adjustment code for bounding boxes.
Results in incorrect box for shapes wrapping the negative Y geocentric axis (-90,0)
Closes #4727

Note: See TracTickets for help on using tickets.