Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#1018 closed defect (invalid)

Bbox search on geography can miss polygons

Reported by: aaime Owned by: pramsey
Priority: high Milestone: PostGIS 1.5.3
Component: postgis Version: 1.5.X
Keywords: Cc:

Description

The && operator seems to miss polygons in the result set even if the bbox queried is smaller than a quadrant (no arcs longer than 180°).

To reproduce:

SELECT name FROM "public"."world" WHERE "geog" && ST_GeogFromText('POLYGON ((-33.7060546875 40.25390625, -33.7060546875 66.97265625, 32.5634765625 66.97265625, 32.5634765625 40.25390625, -33.7060546875 40.25390625))') order by name;

The result should contain both "SPAIN" and "ANDORRA", but it does not. Just tweaking a little the bbox makes Spain appear, but Andorra is still missing:

SELECT name FROM "public"."world" WHERE "geog" && ST_GeogFromText('POLYGON ((-33.4423828125 38.671875, -33.4423828125 65.390625, 32.8271484375 65.390625, 32.8271484375 38.671875, -33.4423828125 38.671875))') order by name;

System information:

  • Ubuntu 10.04 64bit
  • Postgis 1.5.2 or trunk at revision 7111, both exhibit similar behavior
  • queries are run from psql

Attachments (1)

map.png (55.2 KB ) - added by aaime 13 years ago.

Download all attachments as: .zip

Change History (6)

by aaime, 13 years ago

Attachment: map.png added

comment:2 by aaime, 13 years ago

I see it. At the same time it seems to make geography data support unusable for WMS purposes. Should I cast everything to geometry when doing the typical wms bbox query? And in that case, wouldn't that result in indexing not being used?

comment:3 by aaime, 13 years ago

Another option could be, I guess, to densify the geometry used for querying, but it would still be just an approximation...

comment:4 by pramsey, 13 years ago

Well... "I want to use geography, but I don't want geography semantics" seems like a hard mandate to fulfill in general. If you really don't want geography semantics, use geometry instead, right? Densification seems the obvious first route to fixing particular rectangle issues, in much the same way one would have to densify a correct great circle line to get geography semantics inside geometry. As a more general proposition, your post is the second in as many days with the same issue ("square" boxes not being treated as people expect, probably as the result of query rectangles being drawn on projected maps) so if there's a general utility function that makes sense we should provide it.

comment:5 by aaime, 13 years ago

Eh well, I guess that people want to use geographic for the right reasons (like dwithin filter support in meter) but at the same time they need to use it for WMS mapping as well. I am actually looking at this one following up a GeoServer bug report, I'm not using it myself: http://jira.codehaus.org/browse/GEOS-4400

Note: See TracTickets for help on using tickets.