We use Postgis for Django to locate the objects inside a certain viewport. It works great at the equator, but the farther we move, the more distorted the viewport becomes.
Here is the result (the red line shows the "ignored area"):
We retrieve the viewport from Maps, build a Polygon and intersect it with the coordinates of the objects:
viewport = Polygon.from_bbox((southeast_lng, southeast_lat, northwest_lng, northwest_lat,)) result = queryset.filter(coordinates__intersects=viewport)
The coordinates field in the object are defined as following:
coordinates = models.PointField(_('Coordinates'), srid=4326, null=True, geography=True)
- The "missed area" depends on zoom level and vicinity to the pole
geography=Falsefixes it! But then we have problems at the 180th meridian.
Does anyone know what might be causing this?