Package madrona :: Package unit_converter :: Module models
[hide private]

Module models

source code

Functions [hide private]
 
srid_list()
Return a list of numberic srids by looking in the spatial_ref_sys table of the db.
source code
 
units_from_srid(srid)
Get the linear units name from the srid definition.
source code
 
area_unit_code_from_srid_unit(srid_unit)
Look at Area.LALIAS (a dictionary of lower case aliases found in srid definitions for units) and return the proper unit abbreviation used in the django.contrib.gis.measure.Area class.
source code
 
distance_unit_code_from_srid_unit(srid_unit)
Look at Distance.LALIAS (a dictionary of lower case aliases found in srid definitions for units) and return the proper unit abbreviation used in the django.contrib.gis.measure.Distance class.
source code
 
area_unit_code_from_srid(srid)
Return the unit code used in django.contrib.gis.measure.Area to represent the units of the given srid.
source code
 
distance_unit_code_from_srid(srid)
Return the unit code used in django.contrib.gis.measure.Distance to represent the units of the given srid.
source code
 
units_list()
Return a non repeating list of all the linear units from the spatial_ref_sys table.
source code
 
units_count_dict()
Return a dictionary with linear units as keys and a count of how many projections in the spatial_ref_sys table use those units as values.
source code
 
units(self)
Returns the name of the units, derived from the projection, for a given geometry.
source code
 
distance_object(self)
Return the django.contrib.gis.measure.Distance object for a given geometry with origin units determined by the geometry's srid.
source code
 
area_object(self)
Return the django.contrib.gis.measure.Area object for a given geometry with origin units determined by the geometry's srid.
source code
 
add_dist_meth(cls, unit)
Add a method to cls called length_UNIT (where UNIT is the value of unit) that will return the length in those units.
source code
 
add_area_meth(cls, unit)
Add a method to cls called area_UNIT (where UNIT is the value of unit) that will return the length in those units.
source code
 
add_conversion_methods_to_GEOSGeometry()
Add a bunch of methods to the GEOSGeometry object.
source code
 
convert_float_to_length_display_units(float_value)
Given a float value, this method will convert from the units found in settings.GEOMETRY_DB_SRID to the units defined in settings.DISPLAY_LENGTH_UNITS.
source code
 
convert_float_to_area_display_units(float_value)
Given a float value, this method will convert from the units found in settings.GEOMETRY_DB_SRID to the units defined in settings.DISPLAY_AREA_UNITS.
source code
 
geometry_length_in_display_units(geom)
For a given geometry, return the geometry length in the units specified as settings.DISPLAY_LENGTH_UNITS.
source code
 
geometry_area_in_display_units(geom)
For a given geometry, return the geometry area in the units specified as settings.DISPLAY_AREA_UNITS.
source code
 
length_in_display_units(geom_or_num)
Take either a geometry or a numeric length value and convert to display units.
source code
 
area_in_display_units(geom_or_num)
Take either a geometry or a numeric area value and convert to display units.
source code
Function Details [hide private]

area_unit_code_from_srid(srid)

source code 

Return the unit code used in django.contrib.gis.measure.Area to represent the units of the given srid. For example srid 3310 (California Albers) has a linear unit value of 'metre'. django.contrib.gis.measure.Area uses 'sq_m' to represent square meters so that's what this method will return for srid 3310.

distance_unit_code_from_srid(srid)

source code 

Return the unit code used in django.contrib.gis.measure.Distance to represent the units of the given srid. For example srid 3310 (California Albers) has a linear unit value of 'metre'. django.contrib.gis.measure.Distance uses 'm' to represent meters so that's what this method will return for srid 3310.

units(self)

source code 

Returns the name of the units, derived from the projection, for a given geometry.

Decorators:
  • @property

distance_object(self)

source code 

Return the django.contrib.gis.measure.Distance object for a given geometry with origin units determined by the geometry's srid. This object can be evaluated by looking at the attribute named after the proper units. For instance if you want to see the distance in miles, call distance_object.mi

Decorators:
  • @property

area_object(self)

source code 

Return the django.contrib.gis.measure.Area object for a given geometry with origin units determined by the geometry's srid. This object can be evaluated by looking at the attribute named after the proper units. For instance if you want to see the area in square miles, call distance_object.sq_mi

Decorators:
  • @property

add_dist_meth(cls, unit)

source code 

Add a method to cls called length_UNIT (where UNIT is the value of unit) that will return the length in those units. unit must be one of the values found in django.contrib.gis.measure.Distance.UNITS Most common will be mi, m, km, nm, ft

add_area_meth(cls, unit)

source code 

Add a method to cls called area_UNIT (where UNIT is the value of unit) that will return the length in those units. unit must be one of the values found in django.contrib.gis.measure.Area.UNITS Most common will be sq_mi, sq_m, sq_km, sq_nm, sq_ft

add_conversion_methods_to_GEOSGeometry()

source code 

Add a bunch of methods to the GEOSGeometry object. After running this method once, all subsequent geos geometries will have methods to report out their length and area in any of the units listed in Area.UNITS or Distance.UNITS. If you have a polygon called poly and want its length in mi, you can just call poly.length_mi. If you want the area in square centimeters, call poly.area_sq_cm. Additionally, you can call poly.area_in_display_units or poly.length_in_display_units and get the measurments in the units specified in settings.

geometry_length_in_display_units(geom)

source code 

For a given geometry, return the geometry length in the units specified as settings.DISPLAY_LENGTH_UNITS. If the geometry has an srid, assume the origin units are the ones appropriate to that srid. If there is no assigned srid, assume the srid is the one in settings.GEOMETRY_DB_SRID.

geometry_area_in_display_units(geom)

source code 

For a given geometry, return the geometry area in the units specified as settings.DISPLAY_AREA_UNITS. If the geometry has an srid, assume the origin units are the ones appropriate to that srid. If there is no assigned srid, assume the srid is the one in settings.GEOMETRY_DB_SRID.