Changes between Version 1 and Version 2 of GeoDjangoDatabaseAPI


Ignore:
Timestamp:
Jun 10, 2007, 1:13:05 AM (18 years ago)
Author:
jbronn
Comment:

updated with new extra instance keywords with API changes from r5448, updated spatial lookup types documentation

Legend:

Unmodified
Added
Removed
Modified
  • GeoDjangoDatabaseAPI

    v1 v2  
    1 [[TOC]]
     1[[TOC(GeoDjangoDatabaseAPI)]]
    22= Database API =
    33
    4 '''Note:''' The following database lookup types can only be used with on geographic fields with {{{filter()}}}.  Filters on 'normal' fields (e.g. {{{CharField}}}) may be chained with those on geographic fields.  Thus, geographic queries take the following form (assuming the {{{Zip}}} model used in the [GeoDjangoModelAPI GeoDjango Model API docs]:
     4'''Note:''' The following database lookup types can only be used with on geographic fields with {{{filter()}}}.  Filters on 'normal' fields (e.g. {{{CharField}}}) may be chained with those on geographic fields.  Thus, geographic queries take the following form (assuming the {{{Zip}}} model used in the [wiki:GeoDjangoModelAPI GeoDjango Model API docs]:
    55{{{
    66#!python
     
    7979   * Returns 1 (TRUE) if the Geometries are "spatially disjoint".
    8080   * PostGIS equivalent {{{Disjoint(geometry, geometry)}}}
    81  * {{{intersects}}}
    82    * PostGIS equivalent {{{Intersects(geometry, geometry)}}}
    8381 * {{{touches}}}
     82   * Returns 1 (TRUE) if the Geometries "spatially touch".
    8483   * PostGIS equivalent {{{Touches(geometry, geometry)}}}
    8584 * {{{crosses}}}
     85   * Returns 1 (TRUE) if the Geometries "spatially cross".
    8686   * PostGIS equivalent {{{Crosses(geometry, geometry)}}}
     87 * {{{within}}}
     88   * Returns 1 (TRUE) if Geometry A is "spatially within" Geometry B.
     89   * PostGIS equivalent {{{Within(geometry, geometry)}}}
    8790 * {{{overlaps}}}
     91   * Returns 1 (TRUE) if the Geometries "spatially overlap".
    8892   * PostGIS equivalent {{{Overlaps(geometry, geometry)}}}
    8993 * {{{contains}}}
     94   * Returns 1 (TRUE) if Geometry A "spatially contains" Geometry B.
    9095   * PostGIS equivalent {{{Contains(geometry, geometry)}}}
    91  * {{{intersects}}}
    92    * PostGIS equivalent {{{Intersects(geometry, geometry)}}}
    9396 * {{{relate}}}
     97   * Returns the DE-9IM (dimensionally extended nine-intersection matrix) between the two geometries.
    9498   * PostGIS equivelent {{{Relate(geometry, geometry)}}}
    9599
     
    99103
    100104== get_GEOM_ogr ==
    101 Returns a {{{OGRGeometry}}} instance for the geometry.
     105Returns a {{{OGRGeometry}}} instance for the geometry.  For example, using the {{{Zip}}} model, as above:
     106
     107{{{
     108#!python
     109>>> from django.contrib.gis.gdal import OGRGeometry # Where to import from
     110>>> z = Zip.objects.get(code='77096')
     111>>> geom = z.get_poly_ogr()
     112>>> print geom
     113POLYGON(( 10 10, 10 20, 20 20, 20 15, 10 10))
     114>>> for ring in poly:
     115...    print ring
     116...    for point in ring:
     117...        print point
     118...
     119LINEARRING (10 10,10 20,20 20,20 15,10 10)
     120(10.0, 10.0)
     121(10.0, 20.0)
     122(20.0, 20.0)
     123(20.0, 15.0)
     124(10.0, 10.0)
     125}}}
    102126
    103127== get_GEOM_geos ==
    104 Returns a {{{GEOSGeometry}}} instance for the geometry.  For example (using the {{{District}}} model from above):
    105 
    106 {{{
    107 #!python
    108 >>> from django.contrib.gis.geos import GEOSGeometry
     128Returns a {{{GEOSGeometry}}} instance for the geometry.  For example (using the {{{District}}} model from the [wiki:GeoDjango#Example example]):
     129
     130{{{
     131#!python
     132>>> from django.contrib.gis.geos import GEOSGeometry # Where to import from
    109133>>> dist = District.objects.get(name='Houston ISD')
    110134>>> geom = dist.get_poly_geos()
     
    121145}}}
    122146
     147== get_GEOM_srid ==
     148
     149Returns the SRID (source reference identifier) for the geometry.
     150
     151== get_GEOM_srs ==
     152
     153Returns the OGR {{{SpatialReference}}} object for this geometry.
     154
     155{{{
     156#!python
     157>>> from django.contrib.gis.gdal import SpatialReference # Where these related classes reside
     158>>> z = Zip.objects.get(code='77096')
     159>>> srs = z.get_poly_srs()
     160>>> print srs
     161GEOGCS["WGS 84",
     162    DATUM["WGS_1984",
     163        SPHEROID["WGS 84",6378137,298.257223563,
     164            AUTHORITY["EPSG","7030"]],
     165        TOWGS84[0,0,0,0,0,0,0],
     166        AUTHORITY["EPSG","6326"]],
     167    PRIMEM["Greenwich",0,
     168        AUTHORITY["EPSG","8901"]],
     169    UNIT["degree",0.01745329251994328,
     170        AUTHORITY["EPSG","9122"]],
     171    AUTHORITY["EPSG","4326"]]
     172>>> print srs.semi_major, srs.semi_minor, srs.inverse_flattening
     1736378137.0 6356752.31425 298.257223563
     174>>> print srs.geographic
     175True
     176}}}
     177
    123178== get_GEOM_wkt ==
    124179
    125 Returns the OGC WKT (Well Known Text) for the geometry.  For example (using the {{{School}}} model from above):
     180Returns the OGC WKT (Well Known Text) for the geometry.  For example (using the {{{School}}} model from the [wiki:GeoDjango#Example example]):
    126181
    127182{{{
Back to Top