0

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"):

enter image description here enter image description here

Same on the southern hemisphere:
enter image description here

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)

Additional info:

  • The "missed area" depends on zoom level and vicinity to the pole
  • Setting geography=False fixes it! But then we have problems at the 180th meridian.

Does anyone know what might be causing this?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.