Django

Code

Ticket #4797 (closed: fixed)

Opened 1 year ago

Last modified 1 year ago

Dimensioned units of measure for Distance and Area

Reported by: robert.coup@onetrackmind.co.nz Assigned to: jdunck
Milestone: Component: GIS
Version: SVN Keywords:
Cc: jbronn, jdunck@gmail.com Triage Stage: Ready for checkin
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description (Last modified by jbronn)

I've attached a basic implementation (Distance & Area) of dimensioned units for the GIS module. This follows on from our discussions. There are tests included.

Basic usage:

>>> from django.contrib.gis.measure import Distance, Area, D, A
>>> # Create some distances
>>> d1 = Distance(m=100)
>>> d2 = D(mi=12.5)
>>> d3 = D(ft=500)
>>> # Get values out in different units
>>> d1.mi
0.062137119223733397
>>> d3.km
0.15240000000000001
>>> d1 + d2
Distance(m=20216.8)
>>> d3 + 7
TypeError: Distance must be added with Distance

The following units are available:

  • Distance: m, km, mi, ft, yd, nm
  • Area: sq_m, sq_km, sq_mi, sq_ft, sq_yd, sq_nm

Anyway, I'd appreciate comments or suggestions.

Attachments

gis_measure_0_r5634.diff (15.9 kB) - added by robert.coup@onetrackmind.co.nz on 07/08/07 02:27:29.
Initial patch against r5634

Change History

07/08/07 02:27:29 changed by robert.coup@onetrackmind.co.nz

  • attachment gis_measure_0_r5634.diff added.

Initial patch against r5634

07/08/07 03:57:12 changed by jdunck

  • status changed from new to closed.
  • needs_better_patch changed.
  • needs_tests changed.
  • needs_docs changed.
  • resolution set to fixed.
  • stage changed from Unreviewed to Ready for checkin.

07/08/07 03:57:34 changed by jdunck

Closed in [5635].

07/08/07 14:19:18 changed by jbronn

  • description changed.

Add/Change #4797 (Dimensioned units of measure for Distance and Area)




Change Properties
Action