Code

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#4797 closed (fixed)

Dimensioned units of measure for Distance and Area

Reported by: robert.coup@… Owned by: jdunck
Component: GIS Version: master
Severity: Keywords:
Cc: jbronn, jdunck@… Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

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 (1)

gis_measure_0_r5634.diff (15.9 KB) - added by robert.coup@… 7 years ago.
Initial patch against r5634

Download all attachments as: .zip

Change History (4)

Changed 7 years ago by robert.coup@…

Initial patch against r5634

comment:1 Changed 7 years ago by jdunck

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to fixed
  • Status changed from new to closed
  • Triage Stage changed from Unreviewed to Ready for checkin

comment:2 Changed 7 years ago by jdunck

Closed in [5635].

comment:3 Changed 7 years ago by jbronn

  • Description modified (diff)

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.