Dear all,

we have some problems / questions concerning the use of geography data with 
PostGIS. As far as I understood, it is not possible to use the latitude span 
from -90 to 90 in polygons / bounding boxes 
(https://trac.osgeo.org/postgis/ticket/2495), if you want to construct a 
polygon. Otherwise you get the follwing message

geoDB=> select ST_GeogFromText('POLYGON((-1 -90, 1 -90, 1 90, -1 90, -1 -90))');
ERROR:  Antipodal (180 degrees long) edge detected!

This is not nice but can be treated by clients with the defintion of these 
boundary conditions.

But we get also strange results for ST_DWITHIN, ST_INTERSECTS with longitude 
spans larger than 180.

-- E-W-extension of 180

geoDB=> SELECT ST_DWITHIN(ST_GeogFromText('POINT(0 0)'), 
ST_GeogFromText('POLYGON((-90 -1, 90 -1, 90 1, -90 1, -90 -1))'), 0);
 st_dwithin
------------
 t
(1 row)

geoDB=> SELECT ST_DWITHIN(ST_GeogFromText('POINT(180 0)'), 
ST_GeogFromText('POLYGON((-90 -1, 90 -1, 90 1, -90 1, -90 -1))'), 0);
 st_dwithin
------------
 f
(1 row)

-- E-W-extension of 182

geoDB=> SELECT ST_DWITHIN(ST_GeogFromText('POINT(0 0)'), 
ST_GeogFromText('POLYGON((-91 -1, 91 -1, 91 1, -91 1, -91 -1))'), 0);
 st_dwithin
------------
 f
(1 row)

geoDB=> SELECT ST_DWITHIN(ST_GeogFromText('POINT(180 0)'), 
ST_GeogFromText('POLYGON((-91 -1, 91 -1, 91 1, -91 1, -91 -1))'), 0);
 st_dwithin
------------
 t
(1 row)


The result is, that, if you enlarge the polygon, the one point (0,0) goes 
outside, the other point goes (180,0) inside. The only explanation, I can 
imagine, is, that PostGIS choose always the polygon, which has a longitude 
extension which is smaller/equal 180. If this is true, this is a real problem. 
If you are using the geography type, it is not possible to use polygons, which 
has a longitude extension larger than 180. Normally this should be solved with 
the orientation of the poylgon, but the orientation has obviously no effect.


--Clockwise Orientation

geoDB=> SELECT ST_DWITHIN(ST_GeogFromText('POINT(0 0)'), 
ST_GeogFromText('POLYGON((-91 -1, -91 1, 91 1, 91 -1, -91 -1))'), 0);
st_dwithin
------------
 f
(1 row)

geoDB=> select ST_Orientation(ST_GeomFromText('POLYGON((-91 -1, -91 1, 91 1, 91 
-1, -91 -1))'));
 st_orientation
----------------
              1
(1 row)


--Counterclockwise Orientation

geoDB=> SELECT ST_DWITHIN(ST_GeogFromText('POINT(0 0)'), 
ST_GeogFromText('POLYGON((-91 -1, 91 -1, 91 1, -91 1, -91 -1))'), 0);
 st_dwithin
------------
 f
(1 row)

geoDB=> select ST_Orientation(ST_GeomFromText('POLYGON((-91 -1, 91 -1, 91 1, 
-91 1, -91 -1))'));
 st_orientation
----------------
             -1
(1 row)

Has anybody found a workaround for this? Or did I misunderstood the concept 
behind this behaviour?

Best regards
Christian
_______________________________________________
postgis-users mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/postgis-users

Reply via email to