Opened 6 years ago

Closed 8 months ago

#15165 closed Bug (fixed)

GeoQuerySet.perimeter returns invalid results on geometry fields with geodetic coordinate systems

Reported by: jbronn Owned by: Tim Graham <timograham@…>
Component: GIS Version: 1.2
Severity: Normal Keywords: perimeter
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

The method GeoQuerySet.perimeter returns Distance objects with erroneous values when called on a geometry field that has a geodetic coordinate system (e.g., srid=4326). The values in the returned distance objects are really perimeter measurements in degrees of latitude/longitude, rather than meters.

Here's an example using the models and data from the GeoDjango tutorial:

>>> from world.models import WorldBorders
>>> us = WorldBorders.objects.perimeter().get(name='United States')
>>> print us.perimeter
771.493229562 m

Obviously, the perimeter of the United States is greater than a kilometer. To fix, the helper method GeoQuerySet._distance_attribute needs to be modified to raise an exception or return a raw numeric value when attempting to calculate perimeters on geodetic coordinate systems.

Change History (8)

comment:1 Changed 6 years ago by jbronn

  • Needs documentation unset
  • Needs tests unset
  • Owner changed from nobody to jbronn
  • Patch needs improvement unset
  • Status changed from new to assigned

comment:2 Changed 6 years ago by russellm

  • Triage Stage changed from Unreviewed to Accepted

comment:3 Changed 5 years ago by lrekucki

  • Severity set to Normal
  • Type set to Bug

comment:4 Changed 5 years ago by aaugustin

  • UI/UX unset

Change UI/UX from NULL to False.

comment:5 Changed 5 years ago by aaugustin

  • Easy pickings unset

Change Easy pickings from NULL to False.

comment:6 Changed 11 months ago by claudep

  • Has patch set
  • Owner jbronn deleted
  • Status changed from assigned to new

comment:7 Changed 10 months ago by timgraham

  • Patch needs improvement set

A resolution for the test failure on Oracle is needed.

comment:8 Changed 8 months ago by Tim Graham <timograham@…>

  • Owner set to Tim Graham <timograham@…>
  • Resolution set to fixed
  • Status changed from new to closed

In 00cb9e13:

Fixed #15165 -- Prevented wrong results with perimeter on geodetic fields.

Note: See TracTickets for help on using tickets.
Back to Top