Changes between Version 9 and Version 10 of GeoDjangoDatabaseAPI


Ignore:
Timestamp:
12/08/2007 10:08:30 PM (8 years ago)
Author:
jbronn
Comment:

added distance stub; updated queryset manager method usage.

Legend:

Unmodified
Added
Removed
Modified
  • GeoDjangoDatabaseAPI

    v9 v10  
    224224= !GeoQuerySet Methods =
    225225
     226'''Note:''' All of these methods may take an optional `field_name` keyword parameter that will specify the field on the model to perform the method on.  If no field name is specified, then the first geographic field encountered in the model will be assumed.
     227
     228== distance ==
     229''Availability'': PostGIS, Oracle
     230The `distance` method takes a geometry as a parameter, and will attach a `distance` attribute to every model in the returned queryset that contains the distance (in units of the field) to the given geometry.
     231
    226232== gml ==
    227233''Availability'': PostGIS, Oracle
    228234
    229 The `gml` method takes the name of the geographic field (a string) as a parameter, and will attach a `gml` attribute to every model in the queryset that contains the [http://en.wikipedia.org/wiki/Geography_Markup_Language Geographic Markup Language] (GML) representation of the geometry.
    230 {{{
    231 >>> qs = Zip.objects.all().gml('poly')
     235The `gml` method attaches a `gml` attribute to every model in the queryset that contains the [http://en.wikipedia.org/wiki/Geography_Markup_Language Geographic Markup Language] (GML) representation of the geometry.
     236{{{
     237>>> qs = Zip.objects.all().gml()
    232238>>> print qs[0].gml
    233239<gml:Polygon srsName="EPSG:4326"><gml:OuterBoundaryIs>-147.78711,70.245363 ...  -147.78711,70.245363</gml:OuterBoundaryIs></gml:Polygon>
     
    242248''Availability'': PostGIS 1.2.1+
    243249
    244 The `kml` method takes the name of the geographic field (a string) as a parameter, and will attach a `kml` attribute to every model in the queryset that contains the [http://code.google.com/apis/kml/documentation/ Keyhole Markup Language] (KML) representation of the geometry.  It should be noted that the contents of the KML are in WGS84, and will be transformed if necessary -- the geometry field attribute itself is not affected.
    245 
    246 {{{
    247 >>> qs = Zip.objects.all().kml('poly')
     250The `kml` method attaches a `kml` attribute to every model in the queryset that contains the [http://code.google.com/apis/kml/documentation/ Keyhole Markup Language] (KML) representation of the geometry.  It should be noted that the contents of the KML are in WGS84, and will be transformed if necessary -- the geometry field attribute itself is not affected.
     251
     252{{{
     253>>> qs = Zip.objects.all().kml()
    248254>>> print qs[0].kml
    249255<Polygon><outerBoundaryIs><LinearRing><coordinates>-103.04135,36.217596,0 ... -103.04135,36.217596,0</coordinates></LinearRing></outerBoundaryIs></Polygon>
     
    257263''Availability'': PostGIS, Oracle
    258264
    259 The `transform` method takes the name of the geographic field (a string) as a parameter, and transforms the geometries to a different spatial refrence system.  If the `srid` keyword is not specified, WGS84 is used by default.
    260 
    261 {{{
    262 >>> qs = Zip.objects.all().transform('poly') # Transforms to WGS84
    263 >>> qs = Zip.objects.all().transform('poly', 32140) # Transforming to "NAD83 / Texas South Central"
     265The `transform` method transforms the geometries in a model to a different spatial reference system.  If the `srid` parameter is not specified, WGS84 is used by default.
     266
     267{{{
     268>>> qs = Zip.objects.all().transform() # Transforms to WGS84
     269>>> qs = Zip.objects.all().transform(32140) # Transforming to "NAD83 / Texas South Central"
    264270>>> print qs[0].poly.srid
    26527132140
     
    275281''Availability'': PostGIS, Oracle
    276282
    277 This `union` method takes the name of the geographic field (a string) as a parameter, and returns a `GEOSGeometry` object comprising the union of every geometry in the queryset.  Please note that use of `union` is processor intensive and may take a significant amount of time on large querysets.
    278 
    279 {{{
    280 >>> u = Zip.objects.union('poly') # This may take a LONG time, but returns a geometry representing the union of all Zip code polygons.
    281 >>> u = Zip.objects.filter(poly__within=bbox).union('poly') # A more sensible approach.
     283This `union` method returns a `GEOSGeometry` object comprising the union of every geometry in the queryset.  Please note that use of `union` is processor intensive and may take a significant amount of time on large querysets.
     284
     285{{{
     286>>> u = Zip.objects.union() # This may take a LONG time, but returns a geometry representing the union of all Zip code polygons.
     287>>> u = Zip.objects.filter(poly__within=bbox).union() # A more sensible approach.
    282288}}}
    283289
Back to Top