Just some context first, I have a postgres database with PostGIS extension, running under a GeoDjango wrapper. I have a weird bug that hopefully someone can shed some light on.
I'm running a query like this
geom = Polygon.from_bbox(bbox) query = Venue.objects.filter(location__within=geom)
This works fine for most cases and is doing exactly what I want, except for in one specific situation where I get a result that looks like this
(for reference, the bbox param above is always defined by the SW and NE corners of the map which in this case are
sw_lat:50.98777649091917 sw_lng:-0.9302881336211613 ne_lat:52.15534947527341 ne_lng:0.06946772575383875
I've been trying to narrow down the problem, and I'm starting to think it might be something to do with crossing from negative to positive longitude, but I'm not sure. Or maybe it is something to do with indexing on the database level?
Here is the SQL that is generated:
SELECT * FROM "web_venue" WHERE ST_Within("web_venue"."location", ST_GeomFromEWKB('\001\003\000\000 \346\020\000\000\001\000\000\000\005\000\000\000(\366\304G\026|I@\000(\\\317C\266\362\277(\366\304G\026|I@\000@\341z\036\272\305\277y\006C\216\230\021J@\000@\341z\036\272\305\277y\006C\216\230\021J@\000(\\\317C\266\362\277(\366\304G\026|I@\000(\\\317C\266\362\277'::bytea)) LIMIT 50
(I took out all the explicit select statements and just put '*' for brevity.)