[postgis-users] Why should these boxes intersect?

Sandro Santilli strk at keybit.net
Thu Jul 12 13:20:09 PDT 2012


On Thu, Jul 12, 2012 at 12:17:01PM -0700, pcreso at pcreso.com wrote:
> Coming from New Zealand, near 180, I think it is fair to say that a geometry with 
> left lon > right lon is not wrong. Just that Postgis fails to interpret such correctly.

Right, is just that PostGIS GEOMETRY has X and Y, not "longitude" and "latitude".

> A polygon such as POLYGON((179 -45,181 -45,181 -46,179 -46,179 -45))
> is obviously crossing the dateline, and is geographically identical to 
> POLYGON((179 -45,-179 -45,-179 -46,179 -46,179,-45))

Why would they be identical ?
What makes you think the second one wraps the smaller area including the
dateline rather than the larger one not including it ?

If you want, a BOX could contain more semantic about this, as it would
always tell that it encloses the portion between MIN and MAX.
With a POLYGON is harder.
And we're still talking only about GEOGRAPHY here, where the knowledge 
about being on a spheroid is present.

> However it is not interpreted as such.This is not a problem unique to Postgis, and the casting of geometries to geographies, and vice versa for some geography functions, means that in Postgis, the geography datatype is still not a complete solution.
> 
> It is a topological as well as a geometric problem. Polygons crossing 180 need to be split/merged, not just "moved".

Right. I've made such a splip/merge function some time ago, it's on the
tracker waiting for someone to bring it down to C (WrapX, IIRC).

--strk;

  ,------o-. 
  |   __/  |    Delivering high quality PostGIS 2.1
  |  / 2.1 |    http://strk.keybit.net - http://vizzuality.com
  `-o------'




More information about the postgis-users mailing list