Django

Code

Ticket #6440 (closed: fixed)

Opened 6 months ago

Last modified 5 months ago

Issues with Distance conversion from meters to degrees

Reported by: anonymous Assigned to: jbronn
Milestone: Component: GIS
Version: gis Keywords: measure distance degree conversion
Cc: Triage Stage: Accepted
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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,
    ....
}

Attachments

Change History

01/23/08 08:31:03 changed by jbronn

  • status changed from new to assigned.
  • cc set to jbronn@gmail.com.
  • needs_better_patch changed.
  • needs_tests changed.
  • owner changed from nobody to jbronn.
  • keywords set to measure distance degree conversion.
  • needs_docs changed.
  • stage changed from Unreviewed to Accepted.

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

01/23/08 08:52:19 changed by jbronn

  • 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?

01/28/08 10:38:32 changed by jbronn

  • cc deleted.
  • status changed from assigned to closed.
  • resolution set to fixed.
  • 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).


Add/Change #6440 (Issues with Distance conversion from meters to degrees)




Change Properties
Action