Changes between Version 9 and Version 10 of GeoDjangoDatabaseAPI
- Timestamp:
- Dec 8, 2007, 10:08:30 PM (17 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
GeoDjangoDatabaseAPI
v9 v10 224 224 = !GeoQuerySet Methods = 225 225 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 230 The `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 226 232 == gml == 227 233 ''Availability'': PostGIS, Oracle 228 234 229 The `gml` method takes the name of the geographic field (a string) as a parameter, and will attacha `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')235 The `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() 232 238 >>> print qs[0].gml 233 239 <gml:Polygon srsName="EPSG:4326"><gml:OuterBoundaryIs>-147.78711,70.245363 ... -147.78711,70.245363</gml:OuterBoundaryIs></gml:Polygon> … … 242 248 ''Availability'': PostGIS 1.2.1+ 243 249 244 The `kml` method takes the name of the geographic field (a string) as a parameter, and will attacha `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')250 The `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() 248 254 >>> print qs[0].kml 249 255 <Polygon><outerBoundaryIs><LinearRing><coordinates>-103.04135,36.217596,0 ... -103.04135,36.217596,0</coordinates></LinearRing></outerBoundaryIs></Polygon> … … 257 263 ''Availability'': PostGIS, Oracle 258 264 259 The `transform` method t akes the name of the geographic field (a string) as a parameter, and transforms the geometries to a different spatial refrence system. If the `srid` keywordis not specified, WGS84 is used by default.260 261 {{{ 262 >>> qs = Zip.objects.all().transform( 'poly') # Transforms to WGS84263 >>> qs = Zip.objects.all().transform( 'poly',32140) # Transforming to "NAD83 / Texas South Central"265 The `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" 264 270 >>> print qs[0].poly.srid 265 271 32140 … … 275 281 ''Availability'': PostGIS, Oracle 276 282 277 This `union` method takes the name of the geographic field (a string) as a parameter, andreturns 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.283 This `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. 282 288 }}} 283 289