Django

Code

Show
Ignore:
Timestamp:
06/15/08 14:48:57 (4 months ago)
Author:
jbronn
Message:

gis: Refactor of the GeoQuerySet; new features include:

(1) Creation of internal API that eases generation of GeoQuerySet methods.
(2) GeoQuerySet.distance now returns Distance objects instead of floats.
(3) Added the new GeoQuerySet methods: area, centroid, difference, envelope, intersection, length, make_line, mem_size, num_geom, num_points, perimeter, point_on_surface, scale, svg, sym_difference, translate, union.
(4) The model_att keyword may be used to customize the attribute that GeoQuerySet methods attach output to.
(5) Geographic distance lookups and GeoQuerySet.distance calls now use ST_distance_sphere by default (performance benefits far outweigh small loss in accuracy); ST_distance_spheroid may still be used by specifying an option.
(6) GeoQuerySet methods may now operate accross ForeignKey? relations specified via the field_name keyword (but this does not work on Oracle).
(7) Area now has the same units of measure as Distance.

Backward Incompatibilites:

  • The aggregate union method is now known as unionagg.
  • The field_name keyword used for GeoQuerySet methods may no longer be specified via positional arguments.
  • Distance objects returned instead of floats from GeoQuerySet.distance.
  • ST_Distance_sphere used by default for geographic distance calculations.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/gis/django/contrib/gis/tests/distapp/models.py

    r7104 r7641  
    55    name = models.CharField(max_length=30) 
    66    point = models.PointField(srid=32140) 
     7    objects = models.GeoManager() 
     8    def __unicode__(self): return self.name 
     9 
     10class SouthTexasCityFt(models.Model): 
     11    "Same City model as above, but U.S. survey feet are the units." 
     12    name = models.CharField(max_length=30) 
     13    point = models.PointField(srid=2278) 
    714    objects = models.GeoManager() 
    815    def __unicode__(self): return self.name 
     
    1522    def __unicode__(self): return self.name 
    1623 
    17 #class County(models.Model): 
    18 #    name = models.CharField(max_length=30) 
    19 #    mpoly = models.MultiPolygonField(srid=32140) 
    20 #    objects = models.GeoManager() 
     24class CensusZipcode(models.Model): 
     25    "Model for a few South Texas ZIP codes (in original Census NAD83)." 
     26    name = models.CharField(max_length=5) 
     27    poly = models.PolygonField(srid=4269) 
     28    objects = models.GeoManager() 
     29 
     30class SouthTexasZipcode(models.Model): 
     31    "Model for a few South Texas ZIP codes." 
     32    name = models.CharField(max_length=5) 
     33    poly = models.PolygonField(srid=32140) 
     34    objects = models.GeoManager() 
     35    def __unicode__(self): return self.name 
     36 
     37class Interstate(models.Model): 
     38    "Geodetic model for U.S. Interstates." 
     39    name = models.CharField(max_length=10) 
     40    line = models.LineStringField() 
     41    objects = models.GeoManager() 
     42    def __unicode__(self): return self.name