| 189 | = !GeoQuerySet Methods = |
| 190 | |
| 191 | == gml == |
| 192 | ''Availability'': PostGIS, Oracle |
| 193 | |
| 194 | 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. |
| 195 | {{{ |
| 196 | >>> qs = Zip.objects.all().gml('poly') |
| 197 | >>> print qs[0].gml |
| 198 | <gml:Polygon srsName="EPSG:4326"><gml:OuterBoundaryIs>-147.78711,70.245363 ... -147.78711,70.245363</gml:OuterBoundaryIs></gml:Polygon> |
| 199 | }}} |
| 200 | |
| 201 | Keyword arguments: |
| 202 | === precision === |
| 203 | This keyword may be used to specify the number of significant digits for the coordinates in the GML representation -- the default value is 8. This keyword may not be used on Oracle. |
| 204 | |
| 205 | == kml == |
| 206 | |
| 207 | ''Availability'': PostGIS 1.2.1+ |
| 208 | |
| 209 | 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. |
| 210 | |
| 211 | {{{ |
| 212 | >>> qs = Zip.objects.all().kml('poly') |
| 213 | >>> print qs[0].kml |
| 214 | <Polygon><outerBoundaryIs><LinearRing><coordinates>-103.04135,36.217596,0 ... -103.04135,36.217596,0</coordinates></LinearRing></outerBoundaryIs></Polygon> |
| 215 | }}} |
| 216 | |
| 217 | Keyword arguments: |
| 218 | === precision === |
| 219 | This keyword may be used to specify the number of significant digits for the coordinates in the KML representation -- the default value is 8. |
| 220 | |
| 221 | == transform == |
| 222 | ''Availability'': PostGIS, Oracle |
| 223 | |
| 224 | 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. |
| 225 | |
| 226 | {{{ |
| 227 | >>> qs = Zip.objects.all().transform('poly') # Transforms to WGS84 |
| 228 | >>> qs = Zip.objects.all().transform('poly', 32140) # Transforming to "NAD83 / Texas South Central" |
| 229 | >>> print qs[0].poly.srid |
| 230 | 32140 |
| 231 | >>> print qs[0].poly |
| 232 | POLYGON ((234055.1698884720099159 4937796.9232223574072123 ... |
| 233 | }}} |
| 234 | |
| 235 | Keyword arguments: |
| 236 | === srid === |
| 237 | The `srid` keyword may be used to specify the spatial reference system identifier. Please note that this may depend on your spatial database backend, ''e.g.'', those used for Oracle are not the same as those used by PostGIS. |
| 238 | |
| 239 | == union == |
| 240 | ''Availability'': PostGIS, Oracle |
| 241 | |
| 242 | 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. |
| 243 | |
| 244 | {{{ |
| 245 | >>> u = Zip.objects.union('poly') # This may take a LONG time, but returns a geometry representing the union of all Zip code polygons. |
| 246 | >>> u = Zip.objects.filter(poly__within=bbox).union('poly') # A more sensible approach. |
| 247 | }}} |
| 248 | |
| 249 | Keyword arguments: |
| 250 | === tolerance === |
| 251 | This keyword is only available on Oracle platforms, and is for the tolerance value for `SDOAGGRTYPE`. ''See'' the Oracle [http://download.oracle.com/docs/html/B14255_01/sdo_intro.htm#sthref150 documentation] for more details. |
| 252 | |