Code

Changes between Version 60 and Version 61 of GeoDjango


Ignore:
Timestamp:
04/07/07 01:01:33 (7 years ago)
Author:
jbronn
Comment:

desigin issues cleanup, better GEOS non-maintenence resource, code syntax highlighting

Legend:

Unmodified
Added
Removed
Modified
  • GeoDjango

    v60 v61  
    11= Contents = 
    2 The [http://code.djangoproject.com/browser/django/branches/gis gis] branch intends to add a contrib app allowing for Geographic-enabled fields and queries. 
     2The [http://code.djangoproject.com/browser/django/branches/gis GIS] branch intends to be a world-class geographic web framework.  Our goal is to make it as easy as possible to build GIS web applications and harness the power of spatially enabled data. 
    33 * [GeoDjango#Background Background] 
    44   * [GeoDjango#WhatsGIS What's GIS?] 
     
    9191== Phase 3 == 
    9292 * Support MySQL databases. 
     93 * Geocoding framework. 
    9394 
    9495== Design Issues == 
    95  * Mapping JS framework -- do we want to support OpenLayers, the Google Maps API, the Yahoo API? 
     96 * Client JS/Flash framework, ''i.e.'', do we want to support OpenLayers, the Google Maps API, the Yahoo API?   
     97   * So far, Google Maps looks the most promising for being supported first (people are familiar with it, and it's more stable than open layers). 
     98   * [http://developer.yahoo.com/maps/ Yahoo!] has a really slick flash interface, I'd like to support this eventually. 
     99 * Mapping Framework (generating custom tiles, layers, labels, etc.) 
     100   * [http://www.mapnik.org/ Mapnik] is modern, but very early on in development and ''completely'' lacks documentation.  However, the code is elegant and clean, and it was designed for integration with Python -- we're leaning towards this right now. 
     101   * [http://mapserver.gis.umn.edu/ Mapserver] has been around for a while, strong backing in the community (e.g. native support in [http://qgis.org/ QGIS]).  Even with documentation, the code looks less inviting than Mapnik (all in C); also has archaic text-based configuration files (pre-dating markup languages). 
    96102 * 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) 
     103   * GEOS is no longer maintained by Sean Gillies.  ''See'' Sean Gillies, ''[http://zcologia.com/news/150/geometries-for-python/ Geometries for Python]'' (blog post explaining rationale for abandoning GEOS support); ''see also'' Sean's message on the [http://geos.refractions.net/pipermail/geos-devel/2007-March/002851.html GEOS-Devel Mailing List] (Mar. 5, 2007). 
    98104   * 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). 
    99105 * 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. 
     106   * 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?  (OWSLib looks good, see below) 
     107    
    102108 
    103109== Collaboration == 
     
    105111 * Strong opportunities for collaboration with regards to: 
    106112   * Mapping framework 
     113   * WMS/WMF Framework -- '''[http://trac.gispython.org/projects/PCL/browser/OWSLib/trunk OWSLib]''' looks excellent for this (BSD licensed and has unit tests!) 
    107114   * Utilities 
    108115   * Database representation ideas 
    109    * WMS/WMF Framework 
    110116   * GEOS support, Sean Gilles (lead developer of PCL) looking for help maintaining Python/SWIG interface to GEOS.  If SWIG interface no longer maintained, might have to move to PCL for up-to-date GEOS library support. 
    111117 
     
    115121Here is an example of how the model API currently works (assume this example is in geo_app/models.py): 
    116122{{{ 
     123#!python 
    117124from django.contrib.gis.db import models 
    118125 
     
    136143Use the {{{manage.py}}} to invoke {{{syncdb}}} like you normally would: 
    137144{{{ 
     145#!sql 
    138146$ python manage.py sqlall geo_app 
    139147BEGIN; 
     
    160168After 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. 
    161169{{{ 
     170#!python 
    162171>>> from geo_app.models import District, School 
    163172>>> qs1 = District.objects.filter(poly__bbcontains='POINT(-95.362293 29.756539)')  
     
    167176Both spatial queries and normal queries using {{{filter()}}} may be used in the same query.  For example, the following query set will only show school districts that have 'Houston' in their name and contain the given point within their polygon boundary: 
    168177{{{ 
     178#!python 
    169179>>> qs = District.objects.filter(name__contains='Houston').filter(poly__contains='POINT(-95.362293 29.756539)') 
    170180}}} 
     
    172182Or combine both the bounding box routines (less accurate, fast) with the GEOS routines (most accurate, slower) to get a query that is both fast and accurate: 
    173183{{{ 
     184#!python 
    174185>>> qs = District.objects.filter(poly__bbcontains='POINT(-95.362293 29.756539)').filter(poly__contains='POINT(-95.362293 29.756539)') 
    175186}}} 
    176187 
    177188= Installation = 
    178 Installation of the GeoDjango module will also require the installation of existing open source geographic libraries and a spatial database (currently only PostGIS).  This section will describe the installation process for these libraries.  Initially, these instructions will pertain only to a Linux platform (particularly Debian or Ubuntu).  Mac & Windows support will be considered later; however, these instructions will most likely work through the Mac shell.  Don't hold your breath for Windows support. 
     189Installation of the GeoDjango module will also require the installation of existing open source geographic libraries and a spatial database (currently only PostGIS).  This section will describe the installation process for these libraries.  Initially, these instructions will pertain only to a Linux platform (particularly Debian or Ubuntu).  Mac & Windows support will be considered later; however, these instructions will most likely work through the Mac shell.  ~~Don't hold your breath for Windows support.~~ Community support for prerequisites is better than previously believed, Windows support will come much earlier than expected. 
    179190== Django == 
    180191 * GeoDjango exists in the {{{gis}}} branch from SVN: 
     
    187198 * Latest [http://geos.refractions.net/ GEOS] version is 3.0.0RC4 
    188199   * Also requires SWIG >= 1.3.28.  (Ubuntu Dapper comes with 1.3.27.) 
    189    * If there's trouble locating your python, include PYTHON=/path/to/your/python. 
     200   * If there's trouble locating your python, include {{{PYTHON=/path/to/python}}}, or {{{--enable-python=/path/to/python}}}. 
     201 * Configure (enabling python), make, and install. 
    190202{{{ 
    191203$ ./configure --enable-python 
     
    253265 * Field keywords are used during model creation, for example: 
    254266{{{ 
     267#!python 
    255268from django.contrib.gis.db import models 
    256269 
     
    271284 
    272285{{{ 
     286#!python 
    273287>>> from zipcode.models import Zip 
    274288>>> z = Zip(code=77096, poly='POLYGON(( 10 10, 10 20, 20 20, 20 15, 10 10))') 
     
    287301 
    288302{{{ 
    289 >>> qs = Zip.objects.filter(<Zip geo field A>__<geo lookup type>=<geo string B>) 
     303#!python 
     304>>> qs = Zip.objects.filter(<geo field A>__<geo lookup type>=<geo string B>) 
    290305>>> qs = Zip.objects.exclude(...) 
    291306}}} 
     
    371386 
    372387{{{ 
     388#!python 
    373389>>> skool = School.objects.get(name='PSAS') 
    374390>>> print skool.get_point_wkt() 
     
    381397 
    382398{{{ 
     399#!python 
    383400>>> dist = District.objects.get(name='Houston ISD') 
    384401>>> print dist.get_poly_centroid() 
     
    391408 
    392409{{{ 
     410#!python 
    393411>>> dist = District.objects.get(name='Houston ISD') 
    394412>>> print dist.get_poly_area()