Changes between Version 56 and Version 57 of GeoDjango


Ignore:
Timestamp:
Apr 3, 2007, 9:16:04 AM (17 years ago)
Author:
jbronn
Comment:

split example up; references; TOC edits

Legend:

Unmodified
Added
Removed
Modified
  • GeoDjango

    v56 v57  
    77 * [GeoDjango#FAQ FAQ]
    88 * [GeoDjango#Implementation Implementation]
     9   * [GeoDjango#Phase1 Phase 1]
     10   * [GeoDjango#Phase2 Phase 2]
     11   * [GeoDjango#Phase3 Phase 3]
     12   * [GeoDjango#DesignIssues Design Issues]
     13   * [GeoDjango#Collaboration Collaboration]
    914 * [GeoDjango#Example Example]
     15   * [GeoDjango#GeographicModels Geographic Models]
     16   * [GeoDjango#Usingsyncdb Using syncdb]
     17   * [GeoDjango#SpatialQueries Spatial Queries]
    1018 * [GeoDjango#Installation Installation]
    1119   * [GeoDjango#Django GeoDjango Branch from SVN] ('''required''')
     
    7482 * '''Pending'''
    7583   * Add geometry-enabled routines to the fields that call directly on GEOS routines -- like area(), centroid(), etc. (partially complete as of r4884. ''See'' [GeoDjango#ExtraInstanceMethods Extra Instance Methods] section below)
    76    * Admin fields and forms (WKT field currently as of r4884, but we want widgets to view and manipulate geographic objects).
    7784   * Add as much from the PostGIS API as possible.
    78    * Support for mapping frameworks (e.g. Google Maps/Earth, Yahoo Maps, MS Live, etc.)
     85   * Support for a mapping framework (e.g. Google Maps/Earth, Yahoo Maps, MS Live, etc.)
     86     * Admin fields and forms (WKT field currently as of r4884, but we want widgets to view and manipulate geographic objects).
    7987   * Utilities for importing raster data (SHP files first) directly into Django models.
    8088 * '''Complete'''
     
    8391== Phase 3 ==
    8492 * Support MySQL databases.
     93
     94== Design Issues ==
     95 * Mapping JS framework -- do we want to support OpenLayers, the Google Maps API, the Yahoo API?
     96 * GEOS
     97   * GEOS is no longer maintained by Sean Gillies. ''See'' Sean's message on the [http://geos.refractions.net/pipermail/geos-devel/2007-March/002851.html GEOS-Devel Mailing List] (Mar. 5, 2007)
     98   * Might consider either using PCL or implement a {{{ctypes}}} wrapper for the routines that we need -- can't really port PCL code here because it is GPL (Django is licensed under BSD).
     99 * WMS Server
     100   * I'm not satisfied with any of the current WMS/WFS implementations.   One implemented in Django would be desirable, e.g., {{{django.contrib.gis.wms}}}.  Thoughts anyone?
     101   * MapNik is modern, but very early on in development and lacks documentation.
    85102
    86103== Collaboration ==
     
    94111
    95112= Example =
     113
     114== Geographic Models ==
    96115Here is an example of how the model API currently works (assume this example is in geo_app/models.py):
    97116{{{
     
    114133'''Notes''':  The {{{GeoMixin}}} class allows for [GeoDjango#ExtraInstanceMethods extra instance methods]. The {{{index}}} keyword is used to indicate that a GiST index be created for the School {{{PointField}}}s fields.
    115134
    116 Use the {{{manage.py}}} just like you normally would:
     135== Using syncdb ==
     136Use the {{{manage.py}}} to invoke {{{syncdb}}} like you normally would:
    117137{{{
    118138$ python manage.py sqlall geo_app
     
    135155}}}
    136156
    137 PostGIS additions to the API may now be used.  Geographic queries are done by normally by using {{{filter()}}} and {{{exclude}}} on geometry-enabled models.  In the following example, the {{{bbcontains}}} lookup type is used which is the same as the PostGIS {{{&&}}} operator.  It looks to see if the ''bounding box'' of the polygon contains the specific point.  The next example uses the PostGIS Contains() function, which calls GEOS library to test if the ''polygon'' actually contains the specific point, not just the bounding box.
     157'''Note:'''  The geometry columns are created outside of the {{{CREATE TABLE}}} statements by the {{{AddGeometryColumn}}}.  This is done according to the OpenGIS specfication.  ''See''  ''See'' Open GIS Consortium, Inc., ''[http://www.opengis.org/docs/99-049.pdf OpenGIS Simple Feature Specification For SQL]'', Document 99-049 (May 5, 1999), at  Ch. 2.3.8 (Geometry Values and Spatial Reference Systems, pg. 39).
     158
     159== Spatial Queries ==
     160After a geographic model has been created, the PostGIS additions to the API may be used.  Geographic queries are done by normally by using {{{filter()}}} and {{{exclude()}}} on geometry-enabled models using geographic lookup types (''see'' the [GeoDjango#DatabaseAPI Database API] below for lookup types).  In the following example, the {{{bbcontains}}} lookup type is used which is the same as the PostGIS {{{&&}}} operator.  It looks to see if the ''bounding box'' of the polygon contains the specific point.  The next example uses the PostGIS {{{Contains()}}} function, which calls GEOS library to test if the ''polygon'' actually contains the specific point, not just the bounding box.
    138161{{{
    139162>>> from geo_app.models import District, School
     
    238261
    239262 * {{{srid}}}
    240    * Sets the SRID (Source Reference Identifier) of geometry to the given value.  Defaults to 4326 (WGS84)
     263   * Sets the SRID (Spatial Reference System Identity) of geometry to the given value.  Defaults to 4326 (WGS84).  ''See'' Open GIS Consortium, Inc., ''[http://www.opengis.org/docs/99-049.pdf OpenGIS Simple Feature Specification For SQL]'', Document 99-049 (May 5, 1999), at  Ch. 3.2.5 (SQL Textual Representation of Geometry, pg. 53)
    241264 * {{{index}}}
    242265   * If set to True, will create a GiST index for the given geometry.  Update the index with the PostgreSQL command {{{VACUUM ANALYZE}}} (may take a while to execute depending on how large your geographic-enabled tables are).
     
    253276Geometries 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:
    254277 * WKT Polygon: {{{'POLYGON(( 10 10, 10 20, 20 20, 20 15, 10 10))'}}}
    255    * ''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).
     278   * ''See'' Open GIS Consortium, Inc., ''[http://www.opengis.org/docs/99-049.pdf OpenGIS Simple Feature Specification For SQL]'', Document 99-049 (May 5, 1999), at  Ch. 3.2.5 (SQL Textual Representation of Geometry, pg. 53).
    256279 * HEXEWKB Polygon: '{{{0103000000010000000 ... 00000000000002440'}}}
    257280   * ''See'' [http://postgis.refractions.net/docs/ch04.html#id2904792 "PostGIS EWKB, EWKT and Canonical Forms"], PostGIS documentation at Ch. 4.1.2.
     
    268291== PostGIS Operator Field Lookup Types ==
    269292
    270  * ''See generally'', [http://postgis.refractions.net/docs/ch06.html#id2618041 "Operators", PostGIS Documentation at Ch. 6.2.2]
     293 * ''See generally'', [http://postgis.refractions.net/docs/ch06.html#id2854381 "Operators", PostGIS Documentation at Ch. 6.2.2]
    271294 * '''Note:'''  This API is subject to some change -- we're open to suggestions.
    272295 * {{{overlaps_left}}}
     
    363386== get_GEOM_area ==
    364387
    365 For every geometry field, the model object will have a {{{get_GEOM_area}}} method, where {{{GEOM}} is the name of the geometry field.  This routine will return the area of the geometry.
     388For every geometry field, the model object will have a {{{get_GEOM_area}}} method, where {{{GEOM}}} is the name of the geometry field.  This routine will return the area of the geometry.
    366389
    367390{{{
Back to Top