Opened 7 years ago

Closed 7 years ago

Last modified 19 months ago

#6440 closed Uncategorized (fixed)

Issues with Distance conversion from meters to degrees

Reported by: anonymous Owned by: jbronn
Component: GIS Version: gis
Severity: Normal Keywords: measure distance degree conversion
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Short example :

>>> from django.contrib.gis.measure import Distance
>>> d = Distance(m=1)
>>> print d
1.0 m
>>> print d.degree
57.2957795132

When converting, the following is executed (in measure.py) :

return self.m / self.UNITS[name]

Shouldn't it be :

return self.m * self.UNITS[name]

Or is the degree declaration wrong ?

UNITS = {
    ....
    'degree' : 0.0174532925199,
    ....
}

Change History (4)

comment:1 Changed 7 years ago by jbronn

  • Cc jbronn@… added
  • Keywords measure distance degree conversion added
  • Needs documentation unset
  • Needs tests unset
  • Owner changed from nobody to jbronn
  • Patch needs improvement unset
  • Status changed from new to assigned
  • Triage Stage changed from Unreviewed to Accepted

Yeah, its a bug. Looks like I put in the wrong conversion factor here.

comment:2 Changed 7 years ago by jbronn

  • Triage Stage changed from Accepted to Design decision needed

The conversion factor was taken from EPSG:9122 (GML), and is equal to "= pi/180 radians" -- thus, it's not a valid meter conversion factor. Because the degree distance will vary depending on one's location on the globe, it should probably be removed from this module.

Unless I hear otherwise I'll remove -- questions, comments, ideas?

comment:3 Changed 7 years ago by jbronn

  • Cc jbronn@… removed
  • Resolution set to fixed
  • Status changed from assigned to closed
  • Triage Stage changed from Design decision needed to Accepted

(In [7047]) gis: Removed degree conversion from Distance -- should not have been placed here because it is a spherical conversion factor in radians (not meters).

comment:4 Changed 19 months ago by simon29

  • Easy pickings unset
  • Severity set to Normal
  • Type set to Uncategorized
  • UI/UX unset
Last edited 19 months ago by simon29 (previous) (diff)
Note: See TracTickets for help on using tickets.
Back to Top