PostGIS : postgis-devel Archive

List Statistics

  • Total Threads: 2668
  • Total Posts: 4311

Phrases Used to Find This Thread

  #1  
24-02-2011 09:05 AM
PostGIS : postgis-devel member admin is online now
User
 

#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------
This query returns false, but the box and point intersect:
{{{
select st_intersects('POINT(169.69960846592 -46.5061209281002)'::geometry,
'POLYGON((169.699607857174 -46.5061218662,169.699607857174
-46.5061195965597,169.699608806526 -46.5061195965597,169.699608806526
-46.5061218662,169.699607857174 -46.5061218662))'::geometry);
st_intersects
---------------
f
(1 row)
}}}

More info:

{{{
st_relate | st_intersects | st_disjoint
-----------+---------------+-------------
0FFFFF212 | f | f

ST_Relate is correct, ST_Disjoint is correct, ST_Intersects is _wrong_

I B E
-----
I 0 F F
B F F F
E 2 1 2
}}}

Tested on postgis 1.5.2. postgis_version(): 1.5 USE_GEOS=1 USE_PROJ=1
USE_STATS=1

Using geos via python it works:

{{{
>>> from django.contrib.gis import geos
>>> p = geos.GEOSGeometry('POLYGON((169.699607857174
-46.5061218662,169.699607857174 -46.5061195965597,169.699608806526
-46.5061195965597,169.699608806526 -46.5061218662,169.699607857174
-46.5061218662))')
>>> pt = geos.GEOSGeometry('POINT(169.69960846592 -46.5061209281002)')
>>> pt.intersects(p)
True
}}}

Probably a precision error, since this polygon is very small.

[http://postgis.refractions.net/pipermail/postgis-
users/2011-February/028965.html postgis-users thread]

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)

  #2  
24-02-2011 09:10 AM
PostGIS : postgis-devel member admin is online now
User
 

#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------
This query returns false, but the box and point intersect:
{{{
select st_intersects('POINT(169.69960846592 -46.5061209281002)'::geometry,
'POLYGON((169.699607857174 -46.5061218662,169.699607857174
-46.5061195965597,169.699608806526 -46.5061195965597,169.699608806526
-46.5061218662,169.699607857174 -46.5061218662))'::geometry);
st_intersects
---------------
f
(1 row)
}}}

More info:

{{{
st_relate | st_intersects | st_disjoint
-----------+---------------+-------------
0FFFFF212 | f | f

ST_Relate is correct, ST_Disjoint is correct, ST_Intersects is _wrong_

I B E
-----
I 0 F F
B F F F
E 2 1 2
}}}

Tested on postgis 1.5.2. postgis_version(): 1.5 USE_GEOS=1 USE_PROJ=1
USE_STATS=1

Using geos via python it works:

{{{
>>> from django.contrib.gis import geos
>>> p = geos.GEOSGeometry('POLYGON((169.699607857174
-46.5061218662,169.699607857174 -46.5061195965597,169.699608806526
-46.5061195965597,169.699608806526 -46.5061218662,169.699607857174
-46.5061218662))')
>>> pt = geos.GEOSGeometry('POINT(169.69960846592 -46.5061209281002)')
>>> pt.intersects(p)
True
}}}

Probably a precision error, since this polygon is very small.

[http://postgis.refractions.net/pipermail/postgis-
users/2011-February/028965.html postgis-users thread]

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

Not a precision issue, or ST_Relate and ST_Disjoint would also be wrong.
Sounds more like a conceptual bug like a shortcut or something.
Quick, easy test:
{{{
select (a && b) as "&&", st_relate(a, b), st_intersects(a, b),
_st_intersects(a,b), st_disjoint(a,b) from
(select
'POINT(169.69960846592 -46.5061209281002)'::geometry
as a,
'POLYGON((169.699607857174 -46.5061218662,169.699607857174
-46.5061195965597,169.699608806526 -46.5061195965597,169.699608806526
-46.5061218662,169.699607857174 -46.5061218662))'::geometry
as b) as foo;
}}}

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)

  #3  
24-02-2011 09:16 AM
PostGIS : postgis-devel member admin is online now
User
 

#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------
This query returns false, but the box and point intersect:
{{{
select st_intersects('POINT(169.69960846592 -46.5061209281002)'::geometry,
'POLYGON((169.699607857174 -46.5061218662,169.699607857174
-46.5061195965597,169.699608806526 -46.5061195965597,169.699608806526
-46.5061218662,169.699607857174 -46.5061218662))'::geometry);
st_intersects
---------------
f
(1 row)
}}}

More info:

{{{
st_relate | st_intersects | st_disjoint
-----------+---------------+-------------
0FFFFF212 | f | f

ST_Relate is correct, ST_Disjoint is correct, ST_Intersects is _wrong_

I B E
-----
I 0 F F
B F F F
E 2 1 2
}}}

Tested on postgis 1.5.2. postgis_version(): 1.5 USE_GEOS=1 USE_PROJ=1
USE_STATS=1

Using geos via python it works:

{{{
>>> from django.contrib.gis import geos
>>> p = geos.GEOSGeometry('POLYGON((169.699607857174
-46.5061218662,169.699607857174 -46.5061195965597,169.699608806526
-46.5061195965597,169.699608806526 -46.5061218662,169.699607857174
-46.5061218662))')
>>> pt = geos.GEOSGeometry('POINT(169.69960846592 -46.5061209281002)')
>>> pt.intersects(p)
True
}}}

Probably a precision error, since this polygon is very small.

[http://postgis.refractions.net/pipermail/postgis-
users/2011-February/028965.html postgis-users thread]

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

Not a precision issue, or ST_Relate and ST_Disjoint would also be wrong.
Sounds more like a conceptual bug like a shortcut or something.
Quick, easy test:
{{{
select (a && b) as "&&", st_relate(a, b), st_intersects(a, b),
_st_intersects(a,b), st_disjoint(a,b) from
(select
'POINT(169.69960846592 -46.5061209281002)'::geometry
as a,
'POLYGON((169.699607857174 -46.5061218662,169.699607857174
-46.5061195965597,169.699608806526 -46.5061195965597,169.699608806526
-46.5061218662,169.699607857174 -46.5061218662))'::geometry
as b) as foo;
}}}

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

point_in_polygon returned -1

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)

  #4  
24-02-2011 09:24 AM
PostGIS : postgis-devel member admin is online now
User
 

#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------
This query returns false, but the box and point intersect:
{{{
select st_intersects('POINT(169.69960846592 -46.5061209281002)'::geometry,
'POLYGON((169.699607857174 -46.5061218662,169.699607857174
-46.5061195965597,169.699608806526 -46.5061195965597,169.699608806526
-46.5061218662,169.699607857174 -46.5061218662))'::geometry);
st_intersects
---------------
f
(1 row)
}}}

More info:

{{{
st_relate | st_intersects | st_disjoint
-----------+---------------+-------------
0FFFFF212 | f | f

ST_Relate is correct, ST_Disjoint is correct, ST_Intersects is _wrong_

I B E
-----
I 0 F F
B F F F
E 2 1 2
}}}

Tested on postgis 1.5.2. postgis_version(): 1.5 USE_GEOS=1 USE_PROJ=1
USE_STATS=1

Using geos via python it works:

{{{
>>> from django.contrib.gis import geos
>>> p = geos.GEOSGeometry('POLYGON((169.699607857174
-46.5061218662,169.699607857174 -46.5061195965597,169.699608806526
-46.5061195965597,169.699608806526 -46.5061218662,169.699607857174
-46.5061218662))')
>>> pt = geos.GEOSGeometry('POINT(169.69960846592 -46.5061209281002)')
>>> pt.intersects(p)
True
}}}

Probably a precision error, since this polygon is very small.

[http://postgis.refractions.net/pipermail/postgis-
users/2011-February/028965.html postgis-users thread]

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

Not a precision issue, or ST_Relate and ST_Disjoint would also be wrong.
Sounds more like a conceptual bug like a shortcut or something.
Quick, easy test:
{{{
select (a && b) as "&&", st_relate(a, b), st_intersects(a, b),
_st_intersects(a,b), st_disjoint(a,b) from
(select
'POINT(169.69960846592 -46.5061209281002)'::geometry
as a,
'POLYGON((169.699607857174 -46.5061218662,169.699607857174
-46.5061195965597,169.699608806526 -46.5061195965597,169.699608806526
-46.5061218662,169.699607857174 -46.5061218662))'::geometry
as b) as foo;
}}}

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

point_in_polygon returned -1

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

Distance between the point and the polygon boundary: 3.40605993187637e-07
Being a different path (non-GEOS) the precision issue _might_ indeed have
a role here.

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)

  #5  
24-02-2011 11:11 AM
PostGIS : postgis-devel member admin is online now
User
 

#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------
This query returns false, but the box and point intersect:
{{{
select st_intersects('POINT(169.69960846592 -46.5061209281002)'::geometry,
'POLYGON((169.699607857174 -46.5061218662,169.699607857174
-46.5061195965597,169.699608806526 -46.5061195965597,169.699608806526
-46.5061218662,169.699607857174 -46.5061218662))'::geometry);
st_intersects
---------------
f
(1 row)
}}}

More info:

{{{
st_relate | st_intersects | st_disjoint
-----------+---------------+-------------
0FFFFF212 | f | f

ST_Relate is correct, ST_Disjoint is correct, ST_Intersects is _wrong_

I B E
-----
I 0 F F
B F F F
E 2 1 2
}}}

Tested on postgis 1.5.2. postgis_version(): 1.5 USE_GEOS=1 USE_PROJ=1
USE_STATS=1

Using geos via python it works:

{{{
>>> from django.contrib.gis import geos
>>> p = geos.GEOSGeometry('POLYGON((169.699607857174
-46.5061218662,169.699607857174 -46.5061195965597,169.699608806526
-46.5061195965597,169.699608806526 -46.5061218662,169.699607857174
-46.5061218662))')
>>> pt = geos.GEOSGeometry('POINT(169.69960846592 -46.5061209281002)')
>>> pt.intersects(p)
True
}}}

Probably a precision error, since this polygon is very small.

[http://postgis.refractions.net/pipermail/postgis-
users/2011-February/028965.html postgis-users thread]

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

Not a precision issue, or ST_Relate and ST_Disjoint would also be wrong.
Sounds more like a conceptual bug like a shortcut or something.
Quick, easy test:
{{{
select (a && b) as "&&", st_relate(a, b), st_intersects(a, b),
_st_intersects(a,b), st_disjoint(a,b) from
(select
'POINT(169.69960846592 -46.5061209281002)'::geometry
as a,
'POLYGON((169.699607857174 -46.5061218662,169.699607857174
-46.5061195965597,169.699608806526 -46.5061195965597,169.699608806526
-46.5061218662,169.699607857174 -46.5061218662))'::geometry
as b) as foo;
}}}

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

point_in_polygon returned -1

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

Distance between the point and the polygon boundary: 3.40605993187637e-07
Being a different path (non-GEOS) the precision issue _might_ indeed have
a role here.

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

The FP_CONTAINS_BOTTOM macros always return false, with the consequence of
winding number never changing. The computed side (determineSide) is
correct.

Nicklas: is that your code ?

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)

  #6  
24-02-2011 11:40 AM
PostGIS : postgis-devel member admin is online now
User
 

#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------
This query returns false, but the box and point intersect:
{{{
select st_intersects('POINT(169.69960846592 -46.5061209281002)'::geometry,
'POLYGON((169.699607857174 -46.5061218662,169.699607857174
-46.5061195965597,169.699608806526 -46.5061195965597,169.699608806526
-46.5061218662,169.699607857174 -46.5061218662))'::geometry);
st_intersects
---------------
f
(1 row)
}}}

More info:

{{{
st_relate | st_intersects | st_disjoint
-----------+---------------+-------------
0FFFFF212 | f | f

ST_Relate is correct, ST_Disjoint is correct, ST_Intersects is _wrong_

I B E
-----
I 0 F F
B F F F
E 2 1 2
}}}

Tested on postgis 1.5.2. postgis_version(): 1.5 USE_GEOS=1 USE_PROJ=1
USE_STATS=1

Using geos via python it works:

{{{
>>> from django.contrib.gis import geos
>>> p = geos.GEOSGeometry('POLYGON((169.699607857174
-46.5061218662,169.699607857174 -46.5061195965597,169.699608806526
-46.5061195965597,169.699608806526 -46.5061218662,169.699607857174
-46.5061218662))')
>>> pt = geos.GEOSGeometry('POINT(169.69960846592 -46.5061209281002)')
>>> pt.intersects(p)
True
}}}

Probably a precision error, since this polygon is very small.

[http://postgis.refractions.net/pipermail/postgis-
users/2011-February/028965.html postgis-users thread]

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

Not a precision issue, or ST_Relate and ST_Disjoint would also be wrong.
Sounds more like a conceptual bug like a shortcut or something.
Quick, easy test:
{{{
select (a && b) as "&&", st_relate(a, b), st_intersects(a, b),
_st_intersects(a,b), st_disjoint(a,b) from
(select
'POINT(169.69960846592 -46.5061209281002)'::geometry
as a,
'POLYGON((169.699607857174 -46.5061218662,169.699607857174
-46.5061195965597,169.699608806526 -46.5061195965597,169.699608806526
-46.5061218662,169.699607857174 -46.5061218662))'::geometry
as b) as foo;
}}}

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

point_in_polygon returned -1

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

Distance between the point and the polygon boundary: 3.40605993187637e-07
Being a different path (non-GEOS) the precision issue _might_ indeed have
a role here.

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

The FP_CONTAINS_BOTTOM macros always return false, with the consequence of
winding number never changing. The computed side (determineSide) is
correct.

Nicklas: is that your code ?

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by nicklas):

No, It's not.

In distance functions the pt_in_ring function is used for point in polygon
tests. I guess that is why ST_Distance returns 0.0. pt_in_ring is a stab-
line algorithm implementation that is old. So we also have a winding
number algorithm implementation.

Is there a reason to have two different? I have read somewhere that the
winding number algorithm is more stable (when bugs are fixed) and the same
performance.

In 3D I have rewritten pt_in_ring to project the polygon to 2D and then
use stabline algorithm. Maybe it is time top clean up and get winding
algorithm working and move to that also in distance?

What is the name on that function?

/Nicklas

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)

  #7  
24-02-2011 11:44 AM
PostGIS : postgis-devel member admin is online now
User
 

#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------
This query returns false, but the box and point intersect:
{{{
select st_intersects('POINT(169.69960846592 -46.5061209281002)'::geometry,
'POLYGON((169.699607857174 -46.5061218662,169.699607857174
-46.5061195965597,169.699608806526 -46.5061195965597,169.699608806526
-46.5061218662,169.699607857174 -46.5061218662))'::geometry);
st_intersects
---------------
f
(1 row)
}}}

More info:

{{{
st_relate | st_intersects | st_disjoint
-----------+---------------+-------------
0FFFFF212 | f | f

ST_Relate is correct, ST_Disjoint is correct, ST_Intersects is _wrong_

I B E
-----
I 0 F F
B F F F
E 2 1 2
}}}

Tested on postgis 1.5.2. postgis_version(): 1.5 USE_GEOS=1 USE_PROJ=1
USE_STATS=1

Using geos via python it works:

{{{
>>> from django.contrib.gis import geos
>>> p = geos.GEOSGeometry('POLYGON((169.699607857174
-46.5061218662,169.699607857174 -46.5061195965597,169.699608806526
-46.5061195965597,169.699608806526 -46.5061218662,169.699607857174
-46.5061218662))')
>>> pt = geos.GEOSGeometry('POINT(169.69960846592 -46.5061209281002)')
>>> pt.intersects(p)
True
}}}

Probably a precision error, since this polygon is very small.

[http://postgis.refractions.net/pipermail/postgis-
users/2011-February/028965.html postgis-users thread]

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

Not a precision issue, or ST_Relate and ST_Disjoint would also be wrong.
Sounds more like a conceptual bug like a shortcut or something.
Quick, easy test:
{{{
select (a && b) as "&&", st_relate(a, b), st_intersects(a, b),
_st_intersects(a,b), st_disjoint(a,b) from
(select
'POINT(169.69960846592 -46.5061209281002)'::geometry
as a,
'POLYGON((169.699607857174 -46.5061218662,169.699607857174
-46.5061195965597,169.699608806526 -46.5061195965597,169.699608806526
-46.5061218662,169.699607857174 -46.5061218662))'::geometry
as b) as foo;
}}}

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

point_in_polygon returned -1

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

Distance between the point and the polygon boundary: 3.40605993187637e-07
Being a different path (non-GEOS) the precision issue _might_ indeed have
a role here.

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

The FP_CONTAINS_BOTTOM macros always return false, with the consequence of
winding number never changing. The computed side (determineSide) is
correct.

Nicklas: is that your code ?

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by nicklas):

No, It's not.

In distance functions the pt_in_ring function is used for point in polygon
tests. I guess that is why ST_Distance returns 0.0. pt_in_ring is a stab-
line algorithm implementation that is old. So we also have a winding
number algorithm implementation.

Is there a reason to have two different? I have read somewhere that the
winding number algorithm is more stable (when bugs are fixed) and the same
performance.

In 3D I have rewritten pt_in_ring to project the polygon to 2D and then
use stabline algorithm. Maybe it is time top clean up and get winding
algorithm working and move to that also in distance?

What is the name on that function?

/Nicklas

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by nicklas):

Ok, I see that the name was point in ring.

So we have pt_in_ring and
point_in_ring

As far as I understand they are supposed to do the same thing.

here is a good discussion about the two approaches:

http://softsurfer.com/Archive/algorithm_0103/algorithm_0103.htm

/Nicklas

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)

  #8  
24-02-2011 12:11 PM
PostGIS : postgis-devel member admin is online now
User
 

#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------
This query returns false, but the box and point intersect:
{{{
select st_intersects('POINT(169.69960846592 -46.5061209281002)'::geometry,
'POLYGON((169.699607857174 -46.5061218662,169.699607857174
-46.5061195965597,169.699608806526 -46.5061195965597,169.699608806526
-46.5061218662,169.699607857174 -46.5061218662))'::geometry);
st_intersects
---------------
f
(1 row)
}}}

More info:

{{{
st_relate | st_intersects | st_disjoint
-----------+---------------+-------------
0FFFFF212 | f | f

ST_Relate is correct, ST_Disjoint is correct, ST_Intersects is _wrong_

I B E
-----
I 0 F F
B F F F
E 2 1 2
}}}

Tested on postgis 1.5.2. postgis_version(): 1.5 USE_GEOS=1 USE_PROJ=1
USE_STATS=1

Using geos via python it works:

{{{
>>> from django.contrib.gis import geos
>>> p = geos.GEOSGeometry('POLYGON((169.699607857174
-46.5061218662,169.699607857174 -46.5061195965597,169.699608806526
-46.5061195965597,169.699608806526 -46.5061218662,169.699607857174
-46.5061218662))')
>>> pt = geos.GEOSGeometry('POINT(169.69960846592 -46.5061209281002)')
>>> pt.intersects(p)
True
}}}

Probably a precision error, since this polygon is very small.

[http://postgis.refractions.net/pipermail/postgis-
users/2011-February/028965.html postgis-users thread]

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

Not a precision issue, or ST_Relate and ST_Disjoint would also be wrong.
Sounds more like a conceptual bug like a shortcut or something.
Quick, easy test:
{{{
select (a && b) as "&&", st_relate(a, b), st_intersects(a, b),
_st_intersects(a,b), st_disjoint(a,b) from
(select
'POINT(169.69960846592 -46.5061209281002)'::geometry
as a,
'POLYGON((169.699607857174 -46.5061218662,169.699607857174
-46.5061195965597,169.699608806526 -46.5061195965597,169.699608806526
-46.5061218662,169.699607857174 -46.5061218662))'::geometry
as b) as foo;
}}}

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

point_in_polygon returned -1

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

Distance between the point and the polygon boundary: 3.40605993187637e-07
Being a different path (non-GEOS) the precision issue _might_ indeed have
a role here.

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

The FP_CONTAINS_BOTTOM macros always return false, with the consequence of
winding number never changing. The computed side (determineSide) is
correct.

Nicklas: is that your code ?

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by nicklas):

No, It's not.

In distance functions the pt_in_ring function is used for point in polygon
tests. I guess that is why ST_Distance returns 0.0. pt_in_ring is a stab-
line algorithm implementation that is old. So we also have a winding
number algorithm implementation.

Is there a reason to have two different? I have read somewhere that the
winding number algorithm is more stable (when bugs are fixed) and the same
performance.

In 3D I have rewritten pt_in_ring to project the polygon to 2D and then
use stabline algorithm. Maybe it is time top clean up and get winding
algorithm working and move to that also in distance?

What is the name on that function?

/Nicklas

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by nicklas):

Ok, I see that the name was point in ring.

So we have pt_in_ring and
point_in_ring

As far as I understand they are supposed to do the same thing.

here is a good discussion about the two approaches:

http://softsurfer.com/Archive/algorithm_0103/algorithm_0103.htm

/Nicklas

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

I understand point_in_ring is the winding one.
Do you confirm pt_in_ring is the crossing one instead ?

Surely GEOS is using the crossing algorithm.

There's no unit testing for pt_in_ring, nor for point_in_ring.
Also, point_in_ring is still in postgis/ rather than liblwgeom/

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)

  #9  
24-02-2011 12:18 PM
PostGIS : postgis-devel member admin is online now
User
 

#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------
This query returns false, but the box and point intersect:
{{{
select st_intersects('POINT(169.69960846592 -46.5061209281002)'::geometry,
'POLYGON((169.699607857174 -46.5061218662,169.699607857174
-46.5061195965597,169.699608806526 -46.5061195965597,169.699608806526
-46.5061218662,169.699607857174 -46.5061218662))'::geometry);
st_intersects
---------------
f
(1 row)
}}}

More info:

{{{
st_relate | st_intersects | st_disjoint
-----------+---------------+-------------
0FFFFF212 | f | f

ST_Relate is correct, ST_Disjoint is correct, ST_Intersects is _wrong_

I B E
-----
I 0 F F
B F F F
E 2 1 2
}}}

Tested on postgis 1.5.2. postgis_version(): 1.5 USE_GEOS=1 USE_PROJ=1
USE_STATS=1

Using geos via python it works:

{{{
>>> from django.contrib.gis import geos
>>> p = geos.GEOSGeometry('POLYGON((169.699607857174
-46.5061218662,169.699607857174 -46.5061195965597,169.699608806526
-46.5061195965597,169.699608806526 -46.5061218662,169.699607857174
-46.5061218662))')
>>> pt = geos.GEOSGeometry('POINT(169.69960846592 -46.5061209281002)')
>>> pt.intersects(p)
True
}}}

Probably a precision error, since this polygon is very small.

[http://postgis.refractions.net/pipermail/postgis-
users/2011-February/028965.html postgis-users thread]

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

Not a precision issue, or ST_Relate and ST_Disjoint would also be wrong.
Sounds more like a conceptual bug like a shortcut or something.
Quick, easy test:
{{{
select (a && b) as "&&", st_relate(a, b), st_intersects(a, b),
_st_intersects(a,b), st_disjoint(a,b) from
(select
'POINT(169.69960846592 -46.5061209281002)'::geometry
as a,
'POLYGON((169.699607857174 -46.5061218662,169.699607857174
-46.5061195965597,169.699608806526 -46.5061195965597,169.699608806526
-46.5061218662,169.699607857174 -46.5061218662))'::geometry
as b) as foo;
}}}

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

point_in_polygon returned -1

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

Distance between the point and the polygon boundary: 3.40605993187637e-07
Being a different path (non-GEOS) the precision issue _might_ indeed have
a role here.

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

The FP_CONTAINS_BOTTOM macros always return false, with the consequence of
winding number never changing. The computed side (determineSide) is
correct.

Nicklas: is that your code ?

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by nicklas):

No, It's not.

In distance functions the pt_in_ring function is used for point in polygon
tests. I guess that is why ST_Distance returns 0.0. pt_in_ring is a stab-
line algorithm implementation that is old. So we also have a winding
number algorithm implementation.

Is there a reason to have two different? I have read somewhere that the
winding number algorithm is more stable (when bugs are fixed) and the same
performance.

In 3D I have rewritten pt_in_ring to project the polygon to 2D and then
use stabline algorithm. Maybe it is time top clean up and get winding
algorithm working and move to that also in distance?

What is the name on that function?

/Nicklas

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by nicklas):

Ok, I see that the name was point in ring.

So we have pt_in_ring and
point_in_ring

As far as I understand they are supposed to do the same thing.

here is a good discussion about the two approaches:

http://softsurfer.com/Archive/algorithm_0103/algorithm_0103.htm

/Nicklas

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

I understand point_in_ring is the winding one.
Do you confirm pt_in_ring is the crossing one instead ?

Surely GEOS is using the crossing algorithm.

There's no unit testing for pt_in_ring, nor for point_in_ring.
Also, point_in_ring is still in postgis/ rather than liblwgeom/

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by mcayland):

Yes - please can we pick just one algorithm, move it to liblwgeom, fix up
the callers and regress it for trunk?

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)

  #10  
24-02-2011 12:34 PM
PostGIS : postgis-devel member admin is online now
User
 

#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------
This query returns false, but the box and point intersect:
{{{
select st_intersects('POINT(169.69960846592 -46.5061209281002)'::geometry,
'POLYGON((169.699607857174 -46.5061218662,169.699607857174
-46.5061195965597,169.699608806526 -46.5061195965597,169.699608806526
-46.5061218662,169.699607857174 -46.5061218662))'::geometry);
st_intersects
---------------
f
(1 row)
}}}

More info:

{{{
st_relate | st_intersects | st_disjoint
-----------+---------------+-------------
0FFFFF212 | f | f

ST_Relate is correct, ST_Disjoint is correct, ST_Intersects is _wrong_

I B E
-----
I 0 F F
B F F F
E 2 1 2
}}}

Tested on postgis 1.5.2. postgis_version(): 1.5 USE_GEOS=1 USE_PROJ=1
USE_STATS=1

Using geos via python it works:

{{{
>>> from django.contrib.gis import geos
>>> p = geos.GEOSGeometry('POLYGON((169.699607857174
-46.5061218662,169.699607857174 -46.5061195965597,169.699608806526
-46.5061195965597,169.699608806526 -46.5061218662,169.699607857174
-46.5061218662))')
>>> pt = geos.GEOSGeometry('POINT(169.69960846592 -46.5061209281002)')
>>> pt.intersects(p)
True
}}}

Probably a precision error, since this polygon is very small.

[http://postgis.refractions.net/pipermail/postgis-
users/2011-February/028965.html postgis-users thread]

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

Not a precision issue, or ST_Relate and ST_Disjoint would also be wrong.
Sounds more like a conceptual bug like a shortcut or something.
Quick, easy test:
{{{
select (a && b) as "&&", st_relate(a, b), st_intersects(a, b),
_st_intersects(a,b), st_disjoint(a,b) from
(select
'POINT(169.69960846592 -46.5061209281002)'::geometry
as a,
'POLYGON((169.699607857174 -46.5061218662,169.699607857174
-46.5061195965597,169.699608806526 -46.5061195965597,169.699608806526
-46.5061218662,169.699607857174 -46.5061218662))'::geometry
as b) as foo;
}}}

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

point_in_polygon returned -1

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

Distance between the point and the polygon boundary: 3.40605993187637e-07
Being a different path (non-GEOS) the precision issue _might_ indeed have
a role here.

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

The FP_CONTAINS_BOTTOM macros always return false, with the consequence of
winding number never changing. The computed side (determineSide) is
correct.

Nicklas: is that your code ?

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by nicklas):

No, It's not.

In distance functions the pt_in_ring function is used for point in polygon
tests. I guess that is why ST_Distance returns 0.0. pt_in_ring is a stab-
line algorithm implementation that is old. So we also have a winding
number algorithm implementation.

Is there a reason to have two different? I have read somewhere that the
winding number algorithm is more stable (when bugs are fixed) and the same
performance.

In 3D I have rewritten pt_in_ring to project the polygon to 2D and then
use stabline algorithm. Maybe it is time top clean up and get winding
algorithm working and move to that also in distance?

What is the name on that function?

/Nicklas

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by nicklas):

Ok, I see that the name was point in ring.

So we have pt_in_ring and
point_in_ring

As far as I understand they are supposed to do the same thing.

here is a good discussion about the two approaches:

http://softsurfer.com/Archive/algorithm_0103/algorithm_0103.htm

/Nicklas

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

I understand point_in_ring is the winding one.
Do you confirm pt_in_ring is the crossing one instead ?

Surely GEOS is using the crossing algorithm.

There's no unit testing for pt_in_ring, nor for point_in_ring.
Also, point_in_ring is still in postgis/ rather than liblwgeom/

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by mcayland):

Yes - please can we pick just one algorithm, move it to liblwgeom, fix up
the callers and regress it for trunk?

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

I think whoever introduced the new algorithm should take care of that.

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)

  #11  
24-02-2011 12:45 PM
PostGIS : postgis-devel member admin is online now
User
 

#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------
This query returns false, but the box and point intersect:
{{{
select st_intersects('POINT(169.69960846592 -46.5061209281002)'::geometry,
'POLYGON((169.699607857174 -46.5061218662,169.699607857174
-46.5061195965597,169.699608806526 -46.5061195965597,169.699608806526
-46.5061218662,169.699607857174 -46.5061218662))'::geometry);
st_intersects
---------------
f
(1 row)
}}}

More info:

{{{
st_relate | st_intersects | st_disjoint
-----------+---------------+-------------
0FFFFF212 | f | f

ST_Relate is correct, ST_Disjoint is correct, ST_Intersects is _wrong_

I B E
-----
I 0 F F
B F F F
E 2 1 2
}}}

Tested on postgis 1.5.2. postgis_version(): 1.5 USE_GEOS=1 USE_PROJ=1
USE_STATS=1

Using geos via python it works:

{{{
>>> from django.contrib.gis import geos
>>> p = geos.GEOSGeometry('POLYGON((169.699607857174
-46.5061218662,169.699607857174 -46.5061195965597,169.699608806526
-46.5061195965597,169.699608806526 -46.5061218662,169.699607857174
-46.5061218662))')
>>> pt = geos.GEOSGeometry('POINT(169.69960846592 -46.5061209281002)')
>>> pt.intersects(p)
True
}}}

Probably a precision error, since this polygon is very small.

[http://postgis.refractions.net/pipermail/postgis-
users/2011-February/028965.html postgis-users thread]

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

Not a precision issue, or ST_Relate and ST_Disjoint would also be wrong.
Sounds more like a conceptual bug like a shortcut or something.
Quick, easy test:
{{{
select (a && b) as "&&", st_relate(a, b), st_intersects(a, b),
_st_intersects(a,b), st_disjoint(a,b) from
(select
'POINT(169.69960846592 -46.5061209281002)'::geometry
as a,
'POLYGON((169.699607857174 -46.5061218662,169.699607857174
-46.5061195965597,169.699608806526 -46.5061195965597,169.699608806526
-46.5061218662,169.699607857174 -46.5061218662))'::geometry
as b) as foo;
}}}

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

point_in_polygon returned -1

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

Distance between the point and the polygon boundary: 3.40605993187637e-07
Being a different path (non-GEOS) the precision issue _might_ indeed have
a role here.

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

The FP_CONTAINS_BOTTOM macros always return false, with the consequence of
winding number never changing. The computed side (determineSide) is
correct.

Nicklas: is that your code ?

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by nicklas):

No, It's not.

In distance functions the pt_in_ring function is used for point in polygon
tests. I guess that is why ST_Distance returns 0.0. pt_in_ring is a stab-
line algorithm implementation that is old. So we also have a winding
number algorithm implementation.

Is there a reason to have two different? I have read somewhere that the
winding number algorithm is more stable (when bugs are fixed) and the same
performance.

In 3D I have rewritten pt_in_ring to project the polygon to 2D and then
use stabline algorithm. Maybe it is time top clean up and get winding
algorithm working and move to that also in distance?

What is the name on that function?

/Nicklas

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by nicklas):

Ok, I see that the name was point in ring.

So we have pt_in_ring and
point_in_ring

As far as I understand they are supposed to do the same thing.

here is a good discussion about the two approaches:

http://softsurfer.com/Archive/algorithm_0103/algorithm_0103.htm

/Nicklas

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

I understand point_in_ring is the winding one.
Do you confirm pt_in_ring is the crossing one instead ?

Surely GEOS is using the crossing algorithm.

There's no unit testing for pt_in_ring, nor for point_in_ring.
Also, point_in_ring is still in postgis/ rather than liblwgeom/

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by mcayland):

Yes - please can we pick just one algorithm, move it to liblwgeom, fix up
the callers and regress it for trunk?

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

I think whoever introduced the new algorithm should take care of that.

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by nicklas):

Which one is the new algoritm?

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)

  #12  
24-02-2011 12:46 PM
PostGIS : postgis-devel member admin is online now
User
 

#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------
This query returns false, but the box and point intersect:
{{{
select st_intersects('POINT(169.69960846592 -46.5061209281002)'::geometry,
'POLYGON((169.699607857174 -46.5061218662,169.699607857174
-46.5061195965597,169.699608806526 -46.5061195965597,169.699608806526
-46.5061218662,169.699607857174 -46.5061218662))'::geometry);
st_intersects
---------------
f
(1 row)
}}}

More info:

{{{
st_relate | st_intersects | st_disjoint
-----------+---------------+-------------
0FFFFF212 | f | f

ST_Relate is correct, ST_Disjoint is correct, ST_Intersects is _wrong_

I B E
-----
I 0 F F
B F F F
E 2 1 2
}}}

Tested on postgis 1.5.2. postgis_version(): 1.5 USE_GEOS=1 USE_PROJ=1
USE_STATS=1

Using geos via python it works:

{{{
>>> from django.contrib.gis import geos
>>> p = geos.GEOSGeometry('POLYGON((169.699607857174
-46.5061218662,169.699607857174 -46.5061195965597,169.699608806526
-46.5061195965597,169.699608806526 -46.5061218662,169.699607857174
-46.5061218662))')
>>> pt = geos.GEOSGeometry('POINT(169.69960846592 -46.5061209281002)')
>>> pt.intersects(p)
True
}}}

Probably a precision error, since this polygon is very small.

[http://postgis.refractions.net/pipermail/postgis-
users/2011-February/028965.html postgis-users thread]

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

Not a precision issue, or ST_Relate and ST_Disjoint would also be wrong.
Sounds more like a conceptual bug like a shortcut or something.
Quick, easy test:
{{{
select (a && b) as "&&", st_relate(a, b), st_intersects(a, b),
_st_intersects(a,b), st_disjoint(a,b) from
(select
'POINT(169.69960846592 -46.5061209281002)'::geometry
as a,
'POLYGON((169.699607857174 -46.5061218662,169.699607857174
-46.5061195965597,169.699608806526 -46.5061195965597,169.699608806526
-46.5061218662,169.699607857174 -46.5061218662))'::geometry
as b) as foo;
}}}

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

point_in_polygon returned -1

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

Distance between the point and the polygon boundary: 3.40605993187637e-07
Being a different path (non-GEOS) the precision issue _might_ indeed have
a role here.

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

The FP_CONTAINS_BOTTOM macros always return false, with the consequence of
winding number never changing. The computed side (determineSide) is
correct.

Nicklas: is that your code ?

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by nicklas):

No, It's not.

In distance functions the pt_in_ring function is used for point in polygon
tests. I guess that is why ST_Distance returns 0.0. pt_in_ring is a stab-
line algorithm implementation that is old. So we also have a winding
number algorithm implementation.

Is there a reason to have two different? I have read somewhere that the
winding number algorithm is more stable (when bugs are fixed) and the same
performance.

In 3D I have rewritten pt_in_ring to project the polygon to 2D and then
use stabline algorithm. Maybe it is time top clean up and get winding
algorithm working and move to that also in distance?

What is the name on that function?

/Nicklas

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by nicklas):

Ok, I see that the name was point in ring.

So we have pt_in_ring and
point_in_ring

As far as I understand they are supposed to do the same thing.

here is a good discussion about the two approaches:

http://softsurfer.com/Archive/algorithm_0103/algorithm_0103.htm

/Nicklas

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

I understand point_in_ring is the winding one.
Do you confirm pt_in_ring is the crossing one instead ?

Surely GEOS is using the crossing algorithm.

There's no unit testing for pt_in_ring, nor for point_in_ring.
Also, point_in_ring is still in postgis/ rather than liblwgeom/

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by mcayland):

Yes - please can we pick just one algorithm, move it to liblwgeom, fix up
the callers and regress it for trunk?

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

I think whoever introduced the new algorithm should take care of that.

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by nicklas):

Which one is the new algoritm?

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by nicklas):

strk, you are right, pt_in_ring is counting crossings.

As I understand now we have different point in polygon code in 4 places

1) point_in_ring (winding number)
2) pt_in_ring (crossing number)
3) pt_in_ring_3d (winding number)
4) There is also some implementation for geography somewhere (crossing
number I think from a discussion some time ago)

The geography implementation have to be separate of course.

All the three others can be more or less merged.

I have not studied winding number enough to understand it. But at the
softsurfer link above that is what they recommend.

My reason for rewriting the iterations in 3d-version even if it is the
same thing happening as 2d-version is that it gets quite messy if I
project the polygon to, say x-z plane instead of x-y since x and y is hard
coded in the functions. If we can write the function so it just takes
coord1 and coord2 instead of x and y it can be used more widely.

How is that done in a robust way.

In other words, is this possible to do in some efficient robust way?

coord1=x;
pt.coord1;

instead of
pt.x;

a macro can do that?

Will it be to ugly (unefficient) or is it worth it to share more code?

/Nicklas

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)

  #13  
24-02-2011 12:56 PM
PostGIS : postgis-devel member admin is online now
User
 

#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------
This query returns false, but the box and point intersect:
{{{
select st_intersects('POINT(169.69960846592 -46.5061209281002)'::geometry,
'POLYGON((169.699607857174 -46.5061218662,169.699607857174
-46.5061195965597,169.699608806526 -46.5061195965597,169.699608806526
-46.5061218662,169.699607857174 -46.5061218662))'::geometry);
st_intersects
---------------
f
(1 row)
}}}

More info:

{{{
st_relate | st_intersects | st_disjoint
-----------+---------------+-------------
0FFFFF212 | f | f

ST_Relate is correct, ST_Disjoint is correct, ST_Intersects is _wrong_

I B E
-----
I 0 F F
B F F F
E 2 1 2
}}}

Tested on postgis 1.5.2. postgis_version(): 1.5 USE_GEOS=1 USE_PROJ=1
USE_STATS=1

Using geos via python it works:

{{{
>>> from django.contrib.gis import geos
>>> p = geos.GEOSGeometry('POLYGON((169.699607857174
-46.5061218662,169.699607857174 -46.5061195965597,169.699608806526
-46.5061195965597,169.699608806526 -46.5061218662,169.699607857174
-46.5061218662))')
>>> pt = geos.GEOSGeometry('POINT(169.69960846592 -46.5061209281002)')
>>> pt.intersects(p)
True
}}}

Probably a precision error, since this polygon is very small.

[http://postgis.refractions.net/pipermail/postgis-
users/2011-February/028965.html postgis-users thread]

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

Not a precision issue, or ST_Relate and ST_Disjoint would also be wrong.
Sounds more like a conceptual bug like a shortcut or something.
Quick, easy test:
{{{
select (a && b) as "&&", st_relate(a, b), st_intersects(a, b),
_st_intersects(a,b), st_disjoint(a,b) from
(select
'POINT(169.69960846592 -46.5061209281002)'::geometry
as a,
'POLYGON((169.699607857174 -46.5061218662,169.699607857174
-46.5061195965597,169.699608806526 -46.5061195965597,169.699608806526
-46.5061218662,169.699607857174 -46.5061218662))'::geometry
as b) as foo;
}}}

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

point_in_polygon returned -1

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

Distance between the point and the polygon boundary: 3.40605993187637e-07
Being a different path (non-GEOS) the precision issue _might_ indeed have
a role here.

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

The FP_CONTAINS_BOTTOM macros always return false, with the consequence of
winding number never changing. The computed side (determineSide) is
correct.

Nicklas: is that your code ?

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by nicklas):

No, It's not.

In distance functions the pt_in_ring function is used for point in polygon
tests. I guess that is why ST_Distance returns 0.0. pt_in_ring is a stab-
line algorithm implementation that is old. So we also have a winding
number algorithm implementation.

Is there a reason to have two different? I have read somewhere that the
winding number algorithm is more stable (when bugs are fixed) and the same
performance.

In 3D I have rewritten pt_in_ring to project the polygon to 2D and then
use stabline algorithm. Maybe it is time top clean up and get winding
algorithm working and move to that also in distance?

What is the name on that function?

/Nicklas

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by nicklas):

Ok, I see that the name was point in ring.

So we have pt_in_ring and
point_in_ring

As far as I understand they are supposed to do the same thing.

here is a good discussion about the two approaches:

http://softsurfer.com/Archive/algorithm_0103/algorithm_0103.htm

/Nicklas

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

I understand point_in_ring is the winding one.
Do you confirm pt_in_ring is the crossing one instead ?

Surely GEOS is using the crossing algorithm.

There's no unit testing for pt_in_ring, nor for point_in_ring.
Also, point_in_ring is still in postgis/ rather than liblwgeom/

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by mcayland):

Yes - please can we pick just one algorithm, move it to liblwgeom, fix up
the callers and regress it for trunk?

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

I think whoever introduced the new algorithm should take care of that.

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by nicklas):

Which one is the new algoritm?

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by nicklas):

strk, you are right, pt_in_ring is counting crossings.

As I understand now we have different point in polygon code in 4 places

1) point_in_ring (winding number)
2) pt_in_ring (crossing number)
3) pt_in_ring_3d (winding number)
4) There is also some implementation for geography somewhere (crossing
number I think from a discussion some time ago)

The geography implementation have to be separate of course.

All the three others can be more or less merged.

I have not studied winding number enough to understand it. But at the
softsurfer link above that is what they recommend.

My reason for rewriting the iterations in 3d-version even if it is the
same thing happening as 2d-version is that it gets quite messy if I
project the polygon to, say x-z plane instead of x-y since x and y is hard
coded in the functions. If we can write the function so it just takes
coord1 and coord2 instead of x and y it can be used more widely.

How is that done in a robust way.

In other words, is this possible to do in some efficient robust way?

coord1=x;
pt.coord1;

instead of
pt.x;

a macro can do that?

Will it be to ugly (unefficient) or is it worth it to share more code?

/Nicklas

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

Let's try not to make things even more confusing than they are already.
First of all I'd move _all_ implementations in a single file, under
liblwgeom.

lwalgorithm.{c,h} would seem a sensible candidate for this.

I've seen pt_in_ring in liblwgeom/measures.c and point_in_ring in
postgis/lwgeom_functions_analitic.c ... no idea where the others are.

I was assuming point_in_ring was the new one (but could be wrong)

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)

  #14  
24-02-2011 12:57 PM
PostGIS : postgis-devel member admin is online now
User
 

#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------
This query returns false, but the box and point intersect:
{{{
select st_intersects('POINT(169.69960846592 -46.5061209281002)'::geometry,
'POLYGON((169.699607857174 -46.5061218662,169.699607857174
-46.5061195965597,169.699608806526 -46.5061195965597,169.699608806526
-46.5061218662,169.699607857174 -46.5061218662))'::geometry);
st_intersects
---------------
f
(1 row)
}}}

More info:

{{{
st_relate | st_intersects | st_disjoint
-----------+---------------+-------------
0FFFFF212 | f | f

ST_Relate is correct, ST_Disjoint is correct, ST_Intersects is _wrong_

I B E
-----
I 0 F F
B F F F
E 2 1 2
}}}

Tested on postgis 1.5.2. postgis_version(): 1.5 USE_GEOS=1 USE_PROJ=1
USE_STATS=1

Using geos via python it works:

{{{
>>> from django.contrib.gis import geos
>>> p = geos.GEOSGeometry('POLYGON((169.699607857174
-46.5061218662,169.699607857174 -46.5061195965597,169.699608806526
-46.5061195965597,169.699608806526 -46.5061218662,169.699607857174
-46.5061218662))')
>>> pt = geos.GEOSGeometry('POINT(169.69960846592 -46.5061209281002)')
>>> pt.intersects(p)
True
}}}

Probably a precision error, since this polygon is very small.

[http://postgis.refractions.net/pipermail/postgis-
users/2011-February/028965.html postgis-users thread]

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

Not a precision issue, or ST_Relate and ST_Disjoint would also be wrong.
Sounds more like a conceptual bug like a shortcut or something.
Quick, easy test:
{{{
select (a && b) as "&&", st_relate(a, b), st_intersects(a, b),
_st_intersects(a,b), st_disjoint(a,b) from
(select
'POINT(169.69960846592 -46.5061209281002)'::geometry
as a,
'POLYGON((169.699607857174 -46.5061218662,169.699607857174
-46.5061195965597,169.699608806526 -46.5061195965597,169.699608806526
-46.5061218662,169.699607857174 -46.5061218662))'::geometry
as b) as foo;
}}}

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

point_in_polygon returned -1

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

Distance between the point and the polygon boundary: 3.40605993187637e-07
Being a different path (non-GEOS) the precision issue _might_ indeed have
a role here.

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

The FP_CONTAINS_BOTTOM macros always return false, with the consequence of
winding number never changing. The computed side (determineSide) is
correct.

Nicklas: is that your code ?

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by nicklas):

No, It's not.

In distance functions the pt_in_ring function is used for point in polygon
tests. I guess that is why ST_Distance returns 0.0. pt_in_ring is a stab-
line algorithm implementation that is old. So we also have a winding
number algorithm implementation.

Is there a reason to have two different? I have read somewhere that the
winding number algorithm is more stable (when bugs are fixed) and the same
performance.

In 3D I have rewritten pt_in_ring to project the polygon to 2D and then
use stabline algorithm. Maybe it is time top clean up and get winding
algorithm working and move to that also in distance?

What is the name on that function?

/Nicklas

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by nicklas):

Ok, I see that the name was point in ring.

So we have pt_in_ring and
point_in_ring

As far as I understand they are supposed to do the same thing.

here is a good discussion about the two approaches:

http://softsurfer.com/Archive/algorithm_0103/algorithm_0103.htm

/Nicklas

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

I understand point_in_ring is the winding one.
Do you confirm pt_in_ring is the crossing one instead ?

Surely GEOS is using the crossing algorithm.

There's no unit testing for pt_in_ring, nor for point_in_ring.
Also, point_in_ring is still in postgis/ rather than liblwgeom/

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by mcayland):

Yes - please can we pick just one algorithm, move it to liblwgeom, fix up
the callers and regress it for trunk?

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

I think whoever introduced the new algorithm should take care of that.

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by nicklas):

Which one is the new algoritm?

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by nicklas):

strk, you are right, pt_in_ring is counting crossings.

As I understand now we have different point in polygon code in 4 places

1) point_in_ring (winding number)
2) pt_in_ring (crossing number)
3) pt_in_ring_3d (winding number)
4) There is also some implementation for geography somewhere (crossing
number I think from a discussion some time ago)

The geography implementation have to be separate of course.

All the three others can be more or less merged.

I have not studied winding number enough to understand it. But at the
softsurfer link above that is what they recommend.

My reason for rewriting the iterations in 3d-version even if it is the
same thing happening as 2d-version is that it gets quite messy if I
project the polygon to, say x-z plane instead of x-y since x and y is hard
coded in the functions. If we can write the function so it just takes
coord1 and coord2 instead of x and y it can be used more widely.

How is that done in a robust way.

In other words, is this possible to do in some efficient robust way?

coord1=x;
pt.coord1;

instead of
pt.x;

a macro can do that?

Will it be to ugly (unefficient) or is it worth it to share more code?

/Nicklas

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

Let's try not to make things even more confusing than they are already.
First of all I'd move _all_ implementations in a single file, under
liblwgeom.

lwalgorithm.{c,h} would seem a sensible candidate for this.

I've seen pt_in_ring in liblwgeom/measures.c and point_in_ring in
postgis/lwgeom_functions_analitic.c ... no idea where the others are.

I was assuming point_in_ring was the new one (but could be wrong)

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

I've found this interesting comment:

{{{
commit ac4fc4ee809bfcc5247f67a776d5deb7ac5fd768
Author: mleslie
Date: Thu Aug 2 19:57:38 2007 +0000

Removed a call to the deprecated point_in_ring function.

git-svn-id: http://svn.osgeo.org/postgis/trunk@2677 b70326c6-7e19-0410
-871a-916f4a2858ee
}}}

I'm hoping it referred to the same point_in_ring, as that would mean we
should be focusing on the one in liblwgeom already...

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)

  #15  
24-02-2011 12:58 PM
PostGIS : postgis-devel member admin is online now
User
 

#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------
This query returns false, but the box and point intersect:
{{{
select st_intersects('POINT(169.69960846592 -46.5061209281002)'::geometry,
'POLYGON((169.699607857174 -46.5061218662,169.699607857174
-46.5061195965597,169.699608806526 -46.5061195965597,169.699608806526
-46.5061218662,169.699607857174 -46.5061218662))'::geometry);
st_intersects
---------------
f
(1 row)
}}}

More info:

{{{
st_relate | st_intersects | st_disjoint
-----------+---------------+-------------
0FFFFF212 | f | f

ST_Relate is correct, ST_Disjoint is correct, ST_Intersects is _wrong_

I B E
-----
I 0 F F
B F F F
E 2 1 2
}}}

Tested on postgis 1.5.2. postgis_version(): 1.5 USE_GEOS=1 USE_PROJ=1
USE_STATS=1

Using geos via python it works:

{{{
>>> from django.contrib.gis import geos
>>> p = geos.GEOSGeometry('POLYGON((169.699607857174
-46.5061218662,169.699607857174 -46.5061195965597,169.699608806526
-46.5061195965597,169.699608806526 -46.5061218662,169.699607857174
-46.5061218662))')
>>> pt = geos.GEOSGeometry('POINT(169.69960846592 -46.5061209281002)')
>>> pt.intersects(p)
True
}}}

Probably a precision error, since this polygon is very small.

[http://postgis.refractions.net/pipermail/postgis-
users/2011-February/028965.html postgis-users thread]

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

Not a precision issue, or ST_Relate and ST_Disjoint would also be wrong.
Sounds more like a conceptual bug like a shortcut or something.
Quick, easy test:
{{{
select (a && b) as "&&", st_relate(a, b), st_intersects(a, b),
_st_intersects(a,b), st_disjoint(a,b) from
(select
'POINT(169.69960846592 -46.5061209281002)'::geometry
as a,
'POLYGON((169.699607857174 -46.5061218662,169.699607857174
-46.5061195965597,169.699608806526 -46.5061195965597,169.699608806526
-46.5061218662,169.699607857174 -46.5061218662))'::geometry
as b) as foo;
}}}

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

point_in_polygon returned -1

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

Distance between the point and the polygon boundary: 3.40605993187637e-07
Being a different path (non-GEOS) the precision issue _might_ indeed have
a role here.

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

The FP_CONTAINS_BOTTOM macros always return false, with the consequence of
winding number never changing. The computed side (determineSide) is
correct.

Nicklas: is that your code ?

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by nicklas):

No, It's not.

In distance functions the pt_in_ring function is used for point in polygon
tests. I guess that is why ST_Distance returns 0.0. pt_in_ring is a stab-
line algorithm implementation that is old. So we also have a winding
number algorithm implementation.

Is there a reason to have two different? I have read somewhere that the
winding number algorithm is more stable (when bugs are fixed) and the same
performance.

In 3D I have rewritten pt_in_ring to project the polygon to 2D and then
use stabline algorithm. Maybe it is time top clean up and get winding
algorithm working and move to that also in distance?

What is the name on that function?

/Nicklas

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by nicklas):

Ok, I see that the name was point in ring.

So we have pt_in_ring and
point_in_ring

As far as I understand they are supposed to do the same thing.

here is a good discussion about the two approaches:

http://softsurfer.com/Archive/algorithm_0103/algorithm_0103.htm

/Nicklas

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

I understand point_in_ring is the winding one.
Do you confirm pt_in_ring is the crossing one instead ?

Surely GEOS is using the crossing algorithm.

There's no unit testing for pt_in_ring, nor for point_in_ring.
Also, point_in_ring is still in postgis/ rather than liblwgeom/

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by mcayland):

Yes - please can we pick just one algorithm, move it to liblwgeom, fix up
the callers and regress it for trunk?

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

I think whoever introduced the new algorithm should take care of that.

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by nicklas):

Which one is the new algoritm?

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by nicklas):

strk, you are right, pt_in_ring is counting crossings.

As I understand now we have different point in polygon code in 4 places

1) point_in_ring (winding number)
2) pt_in_ring (crossing number)
3) pt_in_ring_3d (winding number)
4) There is also some implementation for geography somewhere (crossing
number I think from a discussion some time ago)

The geography implementation have to be separate of course.

All the three others can be more or less merged.

I have not studied winding number enough to understand it. But at the
softsurfer link above that is what they recommend.

My reason for rewriting the iterations in 3d-version even if it is the
same thing happening as 2d-version is that it gets quite messy if I
project the polygon to, say x-z plane instead of x-y since x and y is hard
coded in the functions. If we can write the function so it just takes
coord1 and coord2 instead of x and y it can be used more widely.

How is that done in a robust way.

In other words, is this possible to do in some efficient robust way?

coord1=x;
pt.coord1;

instead of
pt.x;

a macro can do that?

Will it be to ugly (unefficient) or is it worth it to share more code?

/Nicklas

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

Let's try not to make things even more confusing than they are already.
First of all I'd move _all_ implementations in a single file, under
liblwgeom.

lwalgorithm.{c,h} would seem a sensible candidate for this.

I've seen pt_in_ring in liblwgeom/measures.c and point_in_ring in
postgis/lwgeom_functions_analitic.c ... no idea where the others are.

I was assuming point_in_ring was the new one (but could be wrong)

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

I've found this interesting comment:

{{{
commit ac4fc4ee809bfcc5247f67a776d5deb7ac5fd768
Author: mleslie
Date: Thu Aug 2 19:57:38 2007 +0000

Removed a call to the deprecated point_in_ring function.

git-svn-id: http://svn.osgeo.org/postgis/trunk@2677 b70326c6-7e19-0410
-871a-916f4a2858ee
}}}

I'm hoping it referred to the same point_in_ring, as that would mean we
should be focusing on the one in liblwgeom already...

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

Forget previous comment:
{{{
- if(point_in_ring_deprecated(root[i], &pt) == 1)
+ if(point_in_ring(root[i], &pt) == 1)
}}}

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)

  #16  
24-02-2011 01:01 PM
PostGIS : postgis-devel member admin is online now
User
 

#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------
This query returns false, but the box and point intersect:
{{{
select st_intersects('POINT(169.69960846592 -46.5061209281002)'::geometry,
'POLYGON((169.699607857174 -46.5061218662,169.699607857174
-46.5061195965597,169.699608806526 -46.5061195965597,169.699608806526
-46.5061218662,169.699607857174 -46.5061218662))'::geometry);
st_intersects
---------------
f
(1 row)
}}}

More info:

{{{
st_relate | st_intersects | st_disjoint
-----------+---------------+-------------
0FFFFF212 | f | f

ST_Relate is correct, ST_Disjoint is correct, ST_Intersects is _wrong_

I B E
-----
I 0 F F
B F F F
E 2 1 2
}}}

Tested on postgis 1.5.2. postgis_version(): 1.5 USE_GEOS=1 USE_PROJ=1
USE_STATS=1

Using geos via python it works:

{{{
>>> from django.contrib.gis import geos
>>> p = geos.GEOSGeometry('POLYGON((169.699607857174
-46.5061218662,169.699607857174 -46.5061195965597,169.699608806526
-46.5061195965597,169.699608806526 -46.5061218662,169.699607857174
-46.5061218662))')
>>> pt = geos.GEOSGeometry('POINT(169.69960846592 -46.5061209281002)')
>>> pt.intersects(p)
True
}}}

Probably a precision error, since this polygon is very small.

[http://postgis.refractions.net/pipermail/postgis-
users/2011-February/028965.html postgis-users thread]

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

Not a precision issue, or ST_Relate and ST_Disjoint would also be wrong.
Sounds more like a conceptual bug like a shortcut or something.
Quick, easy test:
{{{
select (a && b) as "&&", st_relate(a, b), st_intersects(a, b),
_st_intersects(a,b), st_disjoint(a,b) from
(select
'POINT(169.69960846592 -46.5061209281002)'::geometry
as a,
'POLYGON((169.699607857174 -46.5061218662,169.699607857174
-46.5061195965597,169.699608806526 -46.5061195965597,169.699608806526
-46.5061218662,169.699607857174 -46.5061218662))'::geometry
as b) as foo;
}}}

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

point_in_polygon returned -1

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

Distance between the point and the polygon boundary: 3.40605993187637e-07
Being a different path (non-GEOS) the precision issue _might_ indeed have
a role here.

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

The FP_CONTAINS_BOTTOM macros always return false, with the consequence of
winding number never changing. The computed side (determineSide) is
correct.

Nicklas: is that your code ?

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by nicklas):

No, It's not.

In distance functions the pt_in_ring function is used for point in polygon
tests. I guess that is why ST_Distance returns 0.0. pt_in_ring is a stab-
line algorithm implementation that is old. So we also have a winding
number algorithm implementation.

Is there a reason to have two different? I have read somewhere that the
winding number algorithm is more stable (when bugs are fixed) and the same
performance.

In 3D I have rewritten pt_in_ring to project the polygon to 2D and then
use stabline algorithm. Maybe it is time top clean up and get winding
algorithm working and move to that also in distance?

What is the name on that function?

/Nicklas

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by nicklas):

Ok, I see that the name was point in ring.

So we have pt_in_ring and
point_in_ring

As far as I understand they are supposed to do the same thing.

here is a good discussion about the two approaches:

http://softsurfer.com/Archive/algorithm_0103/algorithm_0103.htm

/Nicklas

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

I understand point_in_ring is the winding one.
Do you confirm pt_in_ring is the crossing one instead ?

Surely GEOS is using the crossing algorithm.

There's no unit testing for pt_in_ring, nor for point_in_ring.
Also, point_in_ring is still in postgis/ rather than liblwgeom/

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by mcayland):

Yes - please can we pick just one algorithm, move it to liblwgeom, fix up
the callers and regress it for trunk?

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

I think whoever introduced the new algorithm should take care of that.

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by nicklas):

Which one is the new algoritm?

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by nicklas):

strk, you are right, pt_in_ring is counting crossings.

As I understand now we have different point in polygon code in 4 places

1) point_in_ring (winding number)
2) pt_in_ring (crossing number)
3) pt_in_ring_3d (winding number)
4) There is also some implementation for geography somewhere (crossing
number I think from a discussion some time ago)

The geography implementation have to be separate of course.

All the three others can be more or less merged.

I have not studied winding number enough to understand it. But at the
softsurfer link above that is what they recommend.

My reason for rewriting the iterations in 3d-version even if it is the
same thing happening as 2d-version is that it gets quite messy if I
project the polygon to, say x-z plane instead of x-y since x and y is hard
coded in the functions. If we can write the function so it just takes
coord1 and coord2 instead of x and y it can be used more widely.

How is that done in a robust way.

In other words, is this possible to do in some efficient robust way?

coord1=x;
pt.coord1;

instead of
pt.x;

a macro can do that?

Will it be to ugly (unefficient) or is it worth it to share more code?

/Nicklas

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

Let's try not to make things even more confusing than they are already.
First of all I'd move _all_ implementations in a single file, under
liblwgeom.

lwalgorithm.{c,h} would seem a sensible candidate for this.

I've seen pt_in_ring in liblwgeom/measures.c and point_in_ring in
postgis/lwgeom_functions_analitic.c ... no idea where the others are.

I was assuming point_in_ring was the new one (but could be wrong)

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

I've found this interesting comment:

{{{
commit ac4fc4ee809bfcc5247f67a776d5deb7ac5fd768
Author: mleslie
Date: Thu Aug 2 19:57:38 2007 +0000

Removed a call to the deprecated point_in_ring function.

git-svn-id: http://svn.osgeo.org/postgis/trunk@2677 b70326c6-7e19-0410
-871a-916f4a2858ee
}}}

I'm hoping it referred to the same point_in_ring, as that would mean we
should be focusing on the one in liblwgeom already...

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

Forget previous comment:
{{{
- if(point_in_ring_deprecated(root[i], &pt) == 1)
+ if(point_in_ring(root[i], &pt) == 1)
}}}

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

pt_in_ring_2d is surely pretty old, anyway:
{{{
commit db0ccc046165153cc1f2db84775d2f8f483aa541
Author: strk
Date: Mon Nov 29 16:37:12 2004 +0000

Fixed a bug in pt_in_ring_2d.


git-svn-id: http://svn.osgeo.org/postgis/trunk@1123 b70326c6-7e19-0410
-871a-916f4a2858ee
}}}

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)

  #17  
24-02-2011 01:06 PM
PostGIS : postgis-devel member admin is online now
User
 

#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------
This query returns false, but the box and point intersect:
{{{
select st_intersects('POINT(169.69960846592 -46.5061209281002)'::geometry,
'POLYGON((169.699607857174 -46.5061218662,169.699607857174
-46.5061195965597,169.699608806526 -46.5061195965597,169.699608806526
-46.5061218662,169.699607857174 -46.5061218662))'::geometry);
st_intersects
---------------
f
(1 row)
}}}

More info:

{{{
st_relate | st_intersects | st_disjoint
-----------+---------------+-------------
0FFFFF212 | f | f

ST_Relate is correct, ST_Disjoint is correct, ST_Intersects is _wrong_

I B E
-----
I 0 F F
B F F F
E 2 1 2
}}}

Tested on postgis 1.5.2. postgis_version(): 1.5 USE_GEOS=1 USE_PROJ=1
USE_STATS=1

Using geos via python it works:

{{{
>>> from django.contrib.gis import geos
>>> p = geos.GEOSGeometry('POLYGON((169.699607857174
-46.5061218662,169.699607857174 -46.5061195965597,169.699608806526
-46.5061195965597,169.699608806526 -46.5061218662,169.699607857174
-46.5061218662))')
>>> pt = geos.GEOSGeometry('POINT(169.69960846592 -46.5061209281002)')
>>> pt.intersects(p)
True
}}}

Probably a precision error, since this polygon is very small.

[http://postgis.refractions.net/pipermail/postgis-
users/2011-February/028965.html postgis-users thread]

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

Not a precision issue, or ST_Relate and ST_Disjoint would also be wrong.
Sounds more like a conceptual bug like a shortcut or something.
Quick, easy test:
{{{
select (a && b) as "&&", st_relate(a, b), st_intersects(a, b),
_st_intersects(a,b), st_disjoint(a,b) from
(select
'POINT(169.69960846592 -46.5061209281002)'::geometry
as a,
'POLYGON((169.699607857174 -46.5061218662,169.699607857174
-46.5061195965597,169.699608806526 -46.5061195965597,169.699608806526
-46.5061218662,169.699607857174 -46.5061218662))'::geometry
as b) as foo;
}}}

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

point_in_polygon returned -1

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

Distance between the point and the polygon boundary: 3.40605993187637e-07
Being a different path (non-GEOS) the precision issue _might_ indeed have
a role here.

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

The FP_CONTAINS_BOTTOM macros always return false, with the consequence of
winding number never changing. The computed side (determineSide) is
correct.

Nicklas: is that your code ?

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by nicklas):

No, It's not.

In distance functions the pt_in_ring function is used for point in polygon
tests. I guess that is why ST_Distance returns 0.0. pt_in_ring is a stab-
line algorithm implementation that is old. So we also have a winding
number algorithm implementation.

Is there a reason to have two different? I have read somewhere that the
winding number algorithm is more stable (when bugs are fixed) and the same
performance.

In 3D I have rewritten pt_in_ring to project the polygon to 2D and then
use stabline algorithm. Maybe it is time top clean up and get winding
algorithm working and move to that also in distance?

What is the name on that function?

/Nicklas

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by nicklas):

Ok, I see that the name was point in ring.

So we have pt_in_ring and
point_in_ring

As far as I understand they are supposed to do the same thing.

here is a good discussion about the two approaches:

http://softsurfer.com/Archive/algorithm_0103/algorithm_0103.htm

/Nicklas

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

I understand point_in_ring is the winding one.
Do you confirm pt_in_ring is the crossing one instead ?

Surely GEOS is using the crossing algorithm.

There's no unit testing for pt_in_ring, nor for point_in_ring.
Also, point_in_ring is still in postgis/ rather than liblwgeom/

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by mcayland):

Yes - please can we pick just one algorithm, move it to liblwgeom, fix up
the callers and regress it for trunk?

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

I think whoever introduced the new algorithm should take care of that.

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by nicklas):

Which one is the new algoritm?

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by nicklas):

strk, you are right, pt_in_ring is counting crossings.

As I understand now we have different point in polygon code in 4 places

1) point_in_ring (winding number)
2) pt_in_ring (crossing number)
3) pt_in_ring_3d (winding number)
4) There is also some implementation for geography somewhere (crossing
number I think from a discussion some time ago)

The geography implementation have to be separate of course.

All the three others can be more or less merged.

I have not studied winding number enough to understand it. But at the
softsurfer link above that is what they recommend.

My reason for rewriting the iterations in 3d-version even if it is the
same thing happening as 2d-version is that it gets quite messy if I
project the polygon to, say x-z plane instead of x-y since x and y is hard
coded in the functions. If we can write the function so it just takes
coord1 and coord2 instead of x and y it can be used more widely.

How is that done in a robust way.

In other words, is this possible to do in some efficient robust way?

coord1=x;
pt.coord1;

instead of
pt.x;

a macro can do that?

Will it be to ugly (unefficient) or is it worth it to share more code?

/Nicklas

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

Let's try not to make things even more confusing than they are already.
First of all I'd move _all_ implementations in a single file, under
liblwgeom.

lwalgorithm.{c,h} would seem a sensible candidate for this.

I've seen pt_in_ring in liblwgeom/measures.c and point_in_ring in
postgis/lwgeom_functions_analitic.c ... no idea where the others are.

I was assuming point_in_ring was the new one (but could be wrong)

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

I've found this interesting comment:

{{{
commit ac4fc4ee809bfcc5247f67a776d5deb7ac5fd768
Author: mleslie
Date: Thu Aug 2 19:57:38 2007 +0000

Removed a call to the deprecated point_in_ring function.

git-svn-id: http://svn.osgeo.org/postgis/trunk@2677 b70326c6-7e19-0410
-871a-916f4a2858ee
}}}

I'm hoping it referred to the same point_in_ring, as that would mean we
should be focusing on the one in liblwgeom already...

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

Forget previous comment:
{{{
- if(point_in_ring_deprecated(root[i], &pt) == 1)
+ if(point_in_ring(root[i], &pt) == 1)
}}}

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

pt_in_ring_2d is surely pretty old, anyway:
{{{
commit db0ccc046165153cc1f2db84775d2f8f483aa541
Author: strk
Date: Mon Nov 29 16:37:12 2004 +0000

Fixed a bug in pt_in_ring_2d.


git-svn-id: http://svn.osgeo.org/postgis/trunk@1123 b70326c6-7e19-0410
-871a-916f4a2858ee
}}}

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

I've tried switching point_in_polygon to use the crossing pt_in_ring_2d
and got failures with within and contains:

{{{
--- regress_ogc_expected 2011-01-04 09:54:58.000000000 +0100
+++ /tmp/pgis_reg_12408/test_39_out 2011-02-24 14:04:39.000000000
+0100
@@ -10,9 +10,9 @@
crosses|f
crosses|t
within100|t
-within101|f
+within101|t
within102|f
-within103|f
+within103|t
within104|f
within105|t
within106|t
@@ -45,9 +45,9 @@
intersects155|t
intersects156|f
contains100|t
-contains101|f
+contains101|t
contains102|f
-contains103|f
+contains103|t
contains104|f
contains105|t
contains106|t
}}}

Those tests might need a double-check for correctness, but anyway both
'within' and 'contains' make a distinction between _inside_ and
_on_the_boundary_, which pt_in_ring_2d doesnt' do.

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)

  #18  
24-02-2011 01:15 PM
PostGIS : postgis-devel member admin is online now
User
 

#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------
This query returns false, but the box and point intersect:
{{{
select st_intersects('POINT(169.69960846592 -46.5061209281002)'::geometry,
'POLYGON((169.699607857174 -46.5061218662,169.699607857174
-46.5061195965597,169.699608806526 -46.5061195965597,169.699608806526
-46.5061218662,169.699607857174 -46.5061218662))'::geometry);
st_intersects
---------------
f
(1 row)
}}}

More info:

{{{
st_relate | st_intersects | st_disjoint
-----------+---------------+-------------
0FFFFF212 | f | f

ST_Relate is correct, ST_Disjoint is correct, ST_Intersects is _wrong_

I B E
-----
I 0 F F
B F F F
E 2 1 2
}}}

Tested on postgis 1.5.2. postgis_version(): 1.5 USE_GEOS=1 USE_PROJ=1
USE_STATS=1

Using geos via python it works:

{{{
>>> from django.contrib.gis import geos
>>> p = geos.GEOSGeometry('POLYGON((169.699607857174
-46.5061218662,169.699607857174 -46.5061195965597,169.699608806526
-46.5061195965597,169.699608806526 -46.5061218662,169.699607857174
-46.5061218662))')
>>> pt = geos.GEOSGeometry('POINT(169.69960846592 -46.5061209281002)')
>>> pt.intersects(p)
True
}}}

Probably a precision error, since this polygon is very small.

[http://postgis.refractions.net/pipermail/postgis-
users/2011-February/028965.html postgis-users thread]

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

Not a precision issue, or ST_Relate and ST_Disjoint would also be wrong.
Sounds more like a conceptual bug like a shortcut or something.
Quick, easy test:
{{{
select (a && b) as "&&", st_relate(a, b), st_intersects(a, b),
_st_intersects(a,b), st_disjoint(a,b) from
(select
'POINT(169.69960846592 -46.5061209281002)'::geometry
as a,
'POLYGON((169.699607857174 -46.5061218662,169.699607857174
-46.5061195965597,169.699608806526 -46.5061195965597,169.699608806526
-46.5061218662,169.699607857174 -46.5061218662))'::geometry
as b) as foo;
}}}

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

point_in_polygon returned -1

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

Distance between the point and the polygon boundary: 3.40605993187637e-07
Being a different path (non-GEOS) the precision issue _might_ indeed have
a role here.

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

The FP_CONTAINS_BOTTOM macros always return false, with the consequence of
winding number never changing. The computed side (determineSide) is
correct.

Nicklas: is that your code ?

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by nicklas):

No, It's not.

In distance functions the pt_in_ring function is used for point in polygon
tests. I guess that is why ST_Distance returns 0.0. pt_in_ring is a stab-
line algorithm implementation that is old. So we also have a winding
number algorithm implementation.

Is there a reason to have two different? I have read somewhere that the
winding number algorithm is more stable (when bugs are fixed) and the same
performance.

In 3D I have rewritten pt_in_ring to project the polygon to 2D and then
use stabline algorithm. Maybe it is time top clean up and get winding
algorithm working and move to that also in distance?

What is the name on that function?

/Nicklas

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by nicklas):

Ok, I see that the name was point in ring.

So we have pt_in_ring and
point_in_ring

As far as I understand they are supposed to do the same thing.

here is a good discussion about the two approaches:

http://softsurfer.com/Archive/algorithm_0103/algorithm_0103.htm

/Nicklas

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

I understand point_in_ring is the winding one.
Do you confirm pt_in_ring is the crossing one instead ?

Surely GEOS is using the crossing algorithm.

There's no unit testing for pt_in_ring, nor for point_in_ring.
Also, point_in_ring is still in postgis/ rather than liblwgeom/

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by mcayland):

Yes - please can we pick just one algorithm, move it to liblwgeom, fix up
the callers and regress it for trunk?

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

I think whoever introduced the new algorithm should take care of that.

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by nicklas):

Which one is the new algoritm?

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by nicklas):

strk, you are right, pt_in_ring is counting crossings.

As I understand now we have different point in polygon code in 4 places

1) point_in_ring (winding number)
2) pt_in_ring (crossing number)
3) pt_in_ring_3d (winding number)
4) There is also some implementation for geography somewhere (crossing
number I think from a discussion some time ago)

The geography implementation have to be separate of course.

All the three others can be more or less merged.

I have not studied winding number enough to understand it. But at the
softsurfer link above that is what they recommend.

My reason for rewriting the iterations in 3d-version even if it is the
same thing happening as 2d-version is that it gets quite messy if I
project the polygon to, say x-z plane instead of x-y since x and y is hard
coded in the functions. If we can write the function so it just takes
coord1 and coord2 instead of x and y it can be used more widely.

How is that done in a robust way.

In other words, is this possible to do in some efficient robust way?

coord1=x;
pt.coord1;

instead of
pt.x;

a macro can do that?

Will it be to ugly (unefficient) or is it worth it to share more code?

/Nicklas

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

Let's try not to make things even more confusing than they are already.
First of all I'd move _all_ implementations in a single file, under
liblwgeom.

lwalgorithm.{c,h} would seem a sensible candidate for this.

I've seen pt_in_ring in liblwgeom/measures.c and point_in_ring in
postgis/lwgeom_functions_analitic.c ... no idea where the others are.

I was assuming point_in_ring was the new one (but could be wrong)

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

I've found this interesting comment:

{{{
commit ac4fc4ee809bfcc5247f67a776d5deb7ac5fd768
Author: mleslie
Date: Thu Aug 2 19:57:38 2007 +0000

Removed a call to the deprecated point_in_ring function.

git-svn-id: http://svn.osgeo.org/postgis/trunk@2677 b70326c6-7e19-0410
-871a-916f4a2858ee
}}}

I'm hoping it referred to the same point_in_ring, as that would mean we
should be focusing on the one in liblwgeom already...

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

Forget previous comment:
{{{
- if(point_in_ring_deprecated(root[i], &pt) == 1)
+ if(point_in_ring(root[i], &pt) == 1)
}}}

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

pt_in_ring_2d is surely pretty old, anyway:
{{{
commit db0ccc046165153cc1f2db84775d2f8f483aa541
Author: strk
Date: Mon Nov 29 16:37:12 2004 +0000

Fixed a bug in pt_in_ring_2d.


git-svn-id: http://svn.osgeo.org/postgis/trunk@1123 b70326c6-7e19-0410
-871a-916f4a2858ee
}}}

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

I've tried switching point_in_polygon to use the crossing pt_in_ring_2d
and got failures with within and contains:

{{{
--- regress_ogc_expected 2011-01-04 09:54:58.000000000 +0100
+++ /tmp/pgis_reg_12408/test_39_out 2011-02-24 14:04:39.000000000
+0100
@@ -10,9 +10,9 @@
crosses|f
crosses|t
within100|t
-within101|f
+within101|t
within102|f
-within103|f
+within103|t
within104|f
within105|t
within106|t
@@ -45,9 +45,9 @@
intersects155|t
intersects156|f
contains100|t
-contains101|f
+contains101|t
contains102|f
-contains103|f
+contains103|t
contains104|f
contains105|t
contains106|t
}}}

Those tests might need a double-check for correctness, but anyway both
'within' and 'contains' make a distinction between _inside_ and
_on_the_boundary_, which pt_in_ring_2d doesnt' do.

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

contains101, contains103, within101 and within103 are indeed all point-on-
boundary cases.

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)

  #19  
24-02-2011 01:19 PM
PostGIS : postgis-devel member admin is online now
User
 

#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------
This query returns false, but the box and point intersect:
{{{
select st_intersects('POINT(169.69960846592 -46.5061209281002)'::geometry,
'POLYGON((169.699607857174 -46.5061218662,169.699607857174
-46.5061195965597,169.699608806526 -46.5061195965597,169.699608806526
-46.5061218662,169.699607857174 -46.5061218662))'::geometry);
st_intersects
---------------
f
(1 row)
}}}

More info:

{{{
st_relate | st_intersects | st_disjoint
-----------+---------------+-------------
0FFFFF212 | f | f

ST_Relate is correct, ST_Disjoint is correct, ST_Intersects is _wrong_

I B E
-----
I 0 F F
B F F F
E 2 1 2
}}}

Tested on postgis 1.5.2. postgis_version(): 1.5 USE_GEOS=1 USE_PROJ=1
USE_STATS=1

Using geos via python it works:

{{{
>>> from django.contrib.gis import geos
>>> p = geos.GEOSGeometry('POLYGON((169.699607857174
-46.5061218662,169.699607857174 -46.5061195965597,169.699608806526
-46.5061195965597,169.699608806526 -46.5061218662,169.699607857174
-46.5061218662))')
>>> pt = geos.GEOSGeometry('POINT(169.69960846592 -46.5061209281002)')
>>> pt.intersects(p)
True
}}}

Probably a precision error, since this polygon is very small.

[http://postgis.refractions.net/pipermail/postgis-
users/2011-February/028965.html postgis-users thread]

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

Not a precision issue, or ST_Relate and ST_Disjoint would also be wrong.
Sounds more like a conceptual bug like a shortcut or something.
Quick, easy test:
{{{
select (a && b) as "&&", st_relate(a, b), st_intersects(a, b),
_st_intersects(a,b), st_disjoint(a,b) from
(select
'POINT(169.69960846592 -46.5061209281002)'::geometry
as a,
'POLYGON((169.699607857174 -46.5061218662,169.699607857174
-46.5061195965597,169.699608806526 -46.5061195965597,169.699608806526
-46.5061218662,169.699607857174 -46.5061218662))'::geometry
as b) as foo;
}}}

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

point_in_polygon returned -1

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

Distance between the point and the polygon boundary: 3.40605993187637e-07
Being a different path (non-GEOS) the precision issue _might_ indeed have
a role here.

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

The FP_CONTAINS_BOTTOM macros always return false, with the consequence of
winding number never changing. The computed side (determineSide) is
correct.

Nicklas: is that your code ?

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by nicklas):

No, It's not.

In distance functions the pt_in_ring function is used for point in polygon
tests. I guess that is why ST_Distance returns 0.0. pt_in_ring is a stab-
line algorithm implementation that is old. So we also have a winding
number algorithm implementation.

Is there a reason to have two different? I have read somewhere that the
winding number algorithm is more stable (when bugs are fixed) and the same
performance.

In 3D I have rewritten pt_in_ring to project the polygon to 2D and then
use stabline algorithm. Maybe it is time top clean up and get winding
algorithm working and move to that also in distance?

What is the name on that function?

/Nicklas

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by nicklas):

Ok, I see that the name was point in ring.

So we have pt_in_ring and
point_in_ring

As far as I understand they are supposed to do the same thing.

here is a good discussion about the two approaches:

http://softsurfer.com/Archive/algorithm_0103/algorithm_0103.htm

/Nicklas

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

I understand point_in_ring is the winding one.
Do you confirm pt_in_ring is the crossing one instead ?

Surely GEOS is using the crossing algorithm.

There's no unit testing for pt_in_ring, nor for point_in_ring.
Also, point_in_ring is still in postgis/ rather than liblwgeom/

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by mcayland):

Yes - please can we pick just one algorithm, move it to liblwgeom, fix up
the callers and regress it for trunk?

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

I think whoever introduced the new algorithm should take care of that.

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by nicklas):

Which one is the new algoritm?

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by nicklas):

strk, you are right, pt_in_ring is counting crossings.

As I understand now we have different point in polygon code in 4 places

1) point_in_ring (winding number)
2) pt_in_ring (crossing number)
3) pt_in_ring_3d (winding number)
4) There is also some implementation for geography somewhere (crossing
number I think from a discussion some time ago)

The geography implementation have to be separate of course.

All the three others can be more or less merged.

I have not studied winding number enough to understand it. But at the
softsurfer link above that is what they recommend.

My reason for rewriting the iterations in 3d-version even if it is the
same thing happening as 2d-version is that it gets quite messy if I
project the polygon to, say x-z plane instead of x-y since x and y is hard
coded in the functions. If we can write the function so it just takes
coord1 and coord2 instead of x and y it can be used more widely.

How is that done in a robust way.

In other words, is this possible to do in some efficient robust way?

coord1=x;
pt.coord1;

instead of
pt.x;

a macro can do that?

Will it be to ugly (unefficient) or is it worth it to share more code?

/Nicklas

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

Let's try not to make things even more confusing than they are already.
First of all I'd move _all_ implementations in a single file, under
liblwgeom.

lwalgorithm.{c,h} would seem a sensible candidate for this.

I've seen pt_in_ring in liblwgeom/measures.c and point_in_ring in
postgis/lwgeom_functions_analitic.c ... no idea where the others are.

I was assuming point_in_ring was the new one (but could be wrong)

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

I've found this interesting comment:

{{{
commit ac4fc4ee809bfcc5247f67a776d5deb7ac5fd768
Author: mleslie
Date: Thu Aug 2 19:57:38 2007 +0000

Removed a call to the deprecated point_in_ring function.

git-svn-id: http://svn.osgeo.org/postgis/trunk@2677 b70326c6-7e19-0410
-871a-916f4a2858ee
}}}

I'm hoping it referred to the same point_in_ring, as that would mean we
should be focusing on the one in liblwgeom already...

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

Forget previous comment:
{{{
- if(point_in_ring_deprecated(root[i], &pt) == 1)
+ if(point_in_ring(root[i], &pt) == 1)
}}}

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

pt_in_ring_2d is surely pretty old, anyway:
{{{
commit db0ccc046165153cc1f2db84775d2f8f483aa541
Author: strk
Date: Mon Nov 29 16:37:12 2004 +0000

Fixed a bug in pt_in_ring_2d.


git-svn-id: http://svn.osgeo.org/postgis/trunk@1123 b70326c6-7e19-0410
-871a-916f4a2858ee
}}}

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

I've tried switching point_in_polygon to use the crossing pt_in_ring_2d
and got failures with within and contains:

{{{
--- regress_ogc_expected 2011-01-04 09:54:58.000000000 +0100
+++ /tmp/pgis_reg_12408/test_39_out 2011-02-24 14:04:39.000000000
+0100
@@ -10,9 +10,9 @@
crosses|f
crosses|t
within100|t
-within101|f
+within101|t
within102|f
-within103|f
+within103|t
within104|f
within105|t
within106|t
@@ -45,9 +45,9 @@
intersects155|t
intersects156|f
contains100|t
-contains101|f
+contains101|t
contains102|f
-contains103|f
+contains103|t
contains104|f
contains105|t
contains106|t
}}}

Those tests might need a double-check for correctness, but anyway both
'within' and 'contains' make a distinction between _inside_ and
_on_the_boundary_, which pt_in_ring_2d doesnt' do.

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

contains101, contains103, within101 and within103 are indeed all point-on-
boundary cases.

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by nicklas):

Ok, does this mean that ST_Within, ST_Contains, ST_Intersects and so on
uses native PostGIS functions for simplier cases where a point is one of
the geometries?

As you say that must be the reason that the new point in polygon is
implemented to make that distinction.

So, the wisest probably is to sit down and get a grip of the winding
algorithm and review it. As discussed in the link above there is
significant performance differences depending on how the counting winding
is implemented.

It would be nice to have the fastest and most stable way of doing it of
course.

I think I can look at it in a few days, if it is not clear to someone else
what should be done, already now.

And I suggest we leave 3d out of this. Maybe it should be rewritten to the
same algorithm but I think it has to be separate code.


/Nicklas

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)

  #20  
24-02-2011 01:30 PM
PostGIS : postgis-devel member admin is online now
User
 

#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------
This query returns false, but the box and point intersect:
{{{
select st_intersects('POINT(169.69960846592 -46.5061209281002)'::geometry,
'POLYGON((169.699607857174 -46.5061218662,169.699607857174
-46.5061195965597,169.699608806526 -46.5061195965597,169.699608806526
-46.5061218662,169.699607857174 -46.5061218662))'::geometry);
st_intersects
---------------
f
(1 row)
}}}

More info:

{{{
st_relate | st_intersects | st_disjoint
-----------+---------------+-------------
0FFFFF212 | f | f

ST_Relate is correct, ST_Disjoint is correct, ST_Intersects is _wrong_

I B E
-----
I 0 F F
B F F F
E 2 1 2
}}}

Tested on postgis 1.5.2. postgis_version(): 1.5 USE_GEOS=1 USE_PROJ=1
USE_STATS=1

Using geos via python it works:

{{{
>>> from django.contrib.gis import geos
>>> p = geos.GEOSGeometry('POLYGON((169.699607857174
-46.5061218662,169.699607857174 -46.5061195965597,169.699608806526
-46.5061195965597,169.699608806526 -46.5061218662,169.699607857174
-46.5061218662))')
>>> pt = geos.GEOSGeometry('POINT(169.69960846592 -46.5061209281002)')
>>> pt.intersects(p)
True
}}}

Probably a precision error, since this polygon is very small.

[http://postgis.refractions.net/pipermail/postgis-
users/2011-February/028965.html postgis-users thread]

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

Not a precision issue, or ST_Relate and ST_Disjoint would also be wrong.
Sounds more like a conceptual bug like a shortcut or something.
Quick, easy test:
{{{
select (a && b) as "&&", st_relate(a, b), st_intersects(a, b),
_st_intersects(a,b), st_disjoint(a,b) from
(select
'POINT(169.69960846592 -46.5061209281002)'::geometry
as a,
'POLYGON((169.699607857174 -46.5061218662,169.699607857174
-46.5061195965597,169.699608806526 -46.5061195965597,169.699608806526
-46.5061218662,169.699607857174 -46.5061218662))'::geometry
as b) as foo;
}}}

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

point_in_polygon returned -1

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

Distance between the point and the polygon boundary: 3.40605993187637e-07
Being a different path (non-GEOS) the precision issue _might_ indeed have
a role here.

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

The FP_CONTAINS_BOTTOM macros always return false, with the consequence of
winding number never changing. The computed side (determineSide) is
correct.

Nicklas: is that your code ?

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by nicklas):

No, It's not.

In distance functions the pt_in_ring function is used for point in polygon
tests. I guess that is why ST_Distance returns 0.0. pt_in_ring is a stab-
line algorithm implementation that is old. So we also have a winding
number algorithm implementation.

Is there a reason to have two different? I have read somewhere that the
winding number algorithm is more stable (when bugs are fixed) and the same
performance.

In 3D I have rewritten pt_in_ring to project the polygon to 2D and then
use stabline algorithm. Maybe it is time top clean up and get winding
algorithm working and move to that also in distance?

What is the name on that function?

/Nicklas

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by nicklas):

Ok, I see that the name was point in ring.

So we have pt_in_ring and
point_in_ring

As far as I understand they are supposed to do the same thing.

here is a good discussion about the two approaches:

http://softsurfer.com/Archive/algorithm_0103/algorithm_0103.htm

/Nicklas

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

I understand point_in_ring is the winding one.
Do you confirm pt_in_ring is the crossing one instead ?

Surely GEOS is using the crossing algorithm.

There's no unit testing for pt_in_ring, nor for point_in_ring.
Also, point_in_ring is still in postgis/ rather than liblwgeom/

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by mcayland):

Yes - please can we pick just one algorithm, move it to liblwgeom, fix up
the callers and regress it for trunk?

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

I think whoever introduced the new algorithm should take care of that.

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by nicklas):

Which one is the new algoritm?

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by nicklas):

strk, you are right, pt_in_ring is counting crossings.

As I understand now we have different point in polygon code in 4 places

1) point_in_ring (winding number)
2) pt_in_ring (crossing number)
3) pt_in_ring_3d (winding number)
4) There is also some implementation for geography somewhere (crossing
number I think from a discussion some time ago)

The geography implementation have to be separate of course.

All the three others can be more or less merged.

I have not studied winding number enough to understand it. But at the
softsurfer link above that is what they recommend.

My reason for rewriting the iterations in 3d-version even if it is the
same thing happening as 2d-version is that it gets quite messy if I
project the polygon to, say x-z plane instead of x-y since x and y is hard
coded in the functions. If we can write the function so it just takes
coord1 and coord2 instead of x and y it can be used more widely.

How is that done in a robust way.

In other words, is this possible to do in some efficient robust way?

coord1=x;
pt.coord1;

instead of
pt.x;

a macro can do that?

Will it be to ugly (unefficient) or is it worth it to share more code?

/Nicklas

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

Let's try not to make things even more confusing than they are already.
First of all I'd move _all_ implementations in a single file, under
liblwgeom.

lwalgorithm.{c,h} would seem a sensible candidate for this.

I've seen pt_in_ring in liblwgeom/measures.c and point_in_ring in
postgis/lwgeom_functions_analitic.c ... no idea where the others are.

I was assuming point_in_ring was the new one (but could be wrong)

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

I've found this interesting comment:

{{{
commit ac4fc4ee809bfcc5247f67a776d5deb7ac5fd768
Author: mleslie
Date: Thu Aug 2 19:57:38 2007 +0000

Removed a call to the deprecated point_in_ring function.

git-svn-id: http://svn.osgeo.org/postgis/trunk@2677 b70326c6-7e19-0410
-871a-916f4a2858ee
}}}

I'm hoping it referred to the same point_in_ring, as that would mean we
should be focusing on the one in liblwgeom already...

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

Forget previous comment:
{{{
- if(point_in_ring_deprecated(root[i], &pt) == 1)
+ if(point_in_ring(root[i], &pt) == 1)
}}}

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

pt_in_ring_2d is surely pretty old, anyway:
{{{
commit db0ccc046165153cc1f2db84775d2f8f483aa541
Author: strk
Date: Mon Nov 29 16:37:12 2004 +0000

Fixed a bug in pt_in_ring_2d.


git-svn-id: http://svn.osgeo.org/postgis/trunk@1123 b70326c6-7e19-0410
-871a-916f4a2858ee
}}}

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

I've tried switching point_in_polygon to use the crossing pt_in_ring_2d
and got failures with within and contains:

{{{
--- regress_ogc_expected 2011-01-04 09:54:58.000000000 +0100
+++ /tmp/pgis_reg_12408/test_39_out 2011-02-24 14:04:39.000000000
+0100
@@ -10,9 +10,9 @@
crosses|f
crosses|t
within100|t
-within101|f
+within101|t
within102|f
-within103|f
+within103|t
within104|f
within105|t
within106|t
@@ -45,9 +45,9 @@
intersects155|t
intersects156|f
contains100|t
-contains101|f
+contains101|t
contains102|f
-contains103|f
+contains103|t
contains104|f
contains105|t
contains106|t
}}}

Those tests might need a double-check for correctness, but anyway both
'within' and 'contains' make a distinction between _inside_ and
_on_the_boundary_, which pt_in_ring_2d doesnt' do.

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

contains101, contains103, within101 and within103 are indeed all point-on-
boundary cases.

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by nicklas):

Ok, does this mean that ST_Within, ST_Contains, ST_Intersects and so on
uses native PostGIS functions for simplier cases where a point is one of
the geometries?

As you say that must be the reason that the new point in polygon is
implemented to make that distinction.

So, the wisest probably is to sit down and get a grip of the winding
algorithm and review it. As discussed in the link above there is
significant performance differences depending on how the counting winding
is implemented.

It would be nice to have the fastest and most stable way of doing it of
course.

I think I can look at it in a few days, if it is not clear to someone else
what should be done, already now.

And I suggest we leave 3d out of this. Maybe it should be rewritten to the
same algorithm but I think it has to be separate code.


/Nicklas

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)
#845: ST_Intersects() precision error - returns false instead of true
------------------------+---------------------------------------------------
Reporter: cdestigter | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis | Version: 1.5.X
Keywords: |
------------------------+---------------------------------------------------

Comment(by strk):

Yes, within and contains (and intersects) all have a short-circuit using
the postgis algorithm when one operand is a polygon (or multipolygon) and
the other is a point.

Given the fact the same operations would use PreparedGeometries I'm
wondering
if that shortcut has any real advantage... After all the same operation
against
prepared geometries should be faster (as the prepared polygon would be
indexed).

--
Ticket URL:
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.
_______________________________________________
postgis-devel mailing list
postgis-
http://postgis.refractions.net/mailman/listinfo/postgis-devel
)





NewsArc Lists  |  Culture Pages   |  Computing Archive  |  Media-Pages
Link to this page on your blog or website by copying the HTML code below and pasting it into your site: