Changes between Version 44 and Version 45 of GeoDjango


Ignore:
Timestamp:
03/25/2007 03:16:15 PM (8 years ago)
Author:
jbronn
Comment:

improved reference citing, and clarified Model & DB API docs

Legend:

Unmodified
Added
Removed
Modified
  • GeoDjango

    v44 v45  
     1= Contents =
    12The [http://code.djangoproject.com/browser/django/branches/gis gis] branch intends to add a contrib app allowing for Geographic-enabled fields and queries.
    2 
    3 '''Table of Contents'''
    43 * [GeoDjango#Background Background]
    54 * [GeoDjango#FAQ FAQ]
     
    186185
    187186= Model API =
    188 == Field Keywords ==
    189  * Field keywords are used during model creation, for example:
    190 {{{
    191 class Zip(models.Model):
    192   code = models.IntegerField()
    193   poly = models.PolygonField(srid=-1, index=True)
    194 }}}
    195 
    196  * {{{srid}}}
    197    * Sets the SRID of geometry to the value.  Defaults to 4326 (WGS84)
    198  * {{{index}}}
    199    * If set to True, will create an index for the given geometry.
    200    * '''Disabled.'''  Implemented, but there's a bug and won't allow syncdb to execute.
    201 
    202187== Fields ==
    203188
     
    211196 * {{{GeometryCollectionField}}}
    212197
    213 == Creating a Geometry Object and Saving ==
     198== Field Keywords ==
     199 * Field keywords are used during model creation, for example:
     200{{{
     201from django.contrib.gis.db import models
     202
     203class Zip(models.Model):
     204  code = models.IntegerField()
     205  poly = models.PolygonField(srid=-1, index=True)
     206}}}
     207
     208 * {{{srid}}}
     209   * Sets the SRID of geometry to the value.  Defaults to 4326 (WGS84)
     210 * {{{index}}}
     211   * If set to True, will create an index for the given geometry.
     212   * '''Disabled.'''  Implemented, but there's a bug and won't allow syncdb to execute.
     213
     214== Creating and Saving Models with Geometry Fields ==
    214215Here is an example of how to create a geometry object (assuming the {{{Zip}}} model example above):
    215216
     
    222223Geometries are represented as '''strings''' in either of the formats WKT (Well Known Text) or HEXEWKB (PostGIS specific, essentially a WKB geometry in hexadecimal).  For example:
    223224 * WKT Polygon: {{{'POLYGON(( 10 10, 10 20, 20 20, 20 15, 10 10))'}}}
     225   * ''See'' Open GIS Consortium, Inc., ''[http://portal.opengeospatial.org/files/?artifact_id=829&ei=Z5oGRv6aCZ-IwQKh2LXwAw&usg=__4YgoHsbqjocl8Z01SwMAyN84aW0=&sig2=4DpSpm83ZDEIBKSivWcYGQ OpenGIS Simple Feature Specification For SQL]'', Document 99-049 (May 5, 1999), at  Ch. 3.2.5 (SQL Textual Representation of Geometry, pg. 53).
    224226 * HEXEWKB Polygon: '{{{0103000000010000000 ... 00000000000002440'}}}
    225 
    226 '''References:'''
    227  * ''See'' Open GIS Consortium, Inc., ''[http://portal.opengeospatial.org/files/?artifact_id=829&ei=Z5oGRv6aCZ-IwQKh2LXwAw&usg=__4YgoHsbqjocl8Z01SwMAyN84aW0=&sig2=4DpSpm83ZDEIBKSivWcYGQ OpenGIS Simple Feature Specification For SQL]'', Document 99-049 (May 5, 1999), at  Ch. 3.2.5 (SQL Textual Representation of Geometry, pg. 53).
    228  * ''See also'' [http://postgis.refractions.net/docs/ch04.html#id2904792 "PostGIS EWKB, EWKT and Canonical Forms"], PostGIS documentation at Ch. 4.1.2.
     227   * ''See'' [http://postgis.refractions.net/docs/ch04.html#id2904792 "PostGIS EWKB, EWKT and Canonical Forms"], PostGIS documentation at Ch. 4.1.2.
    229228
    230229= Database API =
     230
     231'''Note:''' The following database lookup types can only be used with {{{geo_filter()}}}.  All geographic queries are done with {{{geo_filter()}}} and {{{geo_exclude()}}}, thus separating the normal database API lookups from geographic-specific field queries.  However chains containing both {{{filter}}} and {{{geo_filter}}} may still be used.  Thus, geographic queries take the following form (assuming the {{{Zip}}} model used in the [GeoDjango#ModelAPI Model API] section):
     232
     233{{{
     234>>> qs = Zip.objects.geo_filter(<Zip geo field A>__<geo lookup type>=<geo string B>)
     235>>> qs = Zip.objects.geo_exclude(...)
     236}}}
    231237
    232238== PostGIS Operator Field Lookup Types ==
     
    272278
    273279== PostGIS GEOS Function Field Lookup Types ==
    274  * ''See generally'' [http://postgis.refractions.net/docs/ch06.html#id2615853 "Geometry Relationship Functions", PostGIS Documentation at Ch. 6.1.2].  This documentation will be updated completely with the content from the aforementioned PostGIS docs.
     280 * ''See generally'' [http://postgis.refractions.net/docs/ch06.html#id2615853 "Geometry Relationship Functions", PostGIS Documentation at Ch. 6.1.2].   
     281 * This documentation will be updated completely with the content from the aforementioned PostGIS docs.
    275282 * {{{distance}}}
    276283   * Return the cartesian distance between two geometries in projected units.
Back to Top