Changes between Version 60 and Version 61 of GeoDjango
- Timestamp:
- Apr 7, 2007, 3:01:33 AM (18 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
GeoDjango
v60 v61 1 1 = 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.2 The [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. 3 3 * [GeoDjango#Background Background] 4 4 * [GeoDjango#WhatsGIS What's GIS?] … … 91 91 == Phase 3 == 92 92 * Support MySQL databases. 93 * Geocoding framework. 93 94 94 95 == 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). 96 102 * 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). 98 104 * 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 105 * 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 102 108 103 109 == Collaboration == … … 105 111 * Strong opportunities for collaboration with regards to: 106 112 * 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!) 107 114 * Utilities 108 115 * Database representation ideas 109 * WMS/WMF Framework110 116 * 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. 111 117 … … 115 121 Here is an example of how the model API currently works (assume this example is in geo_app/models.py): 116 122 {{{ 123 #!python 117 124 from django.contrib.gis.db import models 118 125 … … 136 143 Use the {{{manage.py}}} to invoke {{{syncdb}}} like you normally would: 137 144 {{{ 145 #!sql 138 146 $ python manage.py sqlall geo_app 139 147 BEGIN; … … 160 168 After 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. 161 169 {{{ 170 #!python 162 171 >>> from geo_app.models import District, School 163 172 >>> qs1 = District.objects.filter(poly__bbcontains='POINT(-95.362293 29.756539)') … … 167 176 Both 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: 168 177 {{{ 178 #!python 169 179 >>> qs = District.objects.filter(name__contains='Houston').filter(poly__contains='POINT(-95.362293 29.756539)') 170 180 }}} … … 172 182 Or 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: 173 183 {{{ 184 #!python 174 185 >>> qs = District.objects.filter(poly__bbcontains='POINT(-95.362293 29.756539)').filter(poly__contains='POINT(-95.362293 29.756539)') 175 186 }}} 176 187 177 188 = 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.189 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.~~ Community support for prerequisites is better than previously believed, Windows support will come much earlier than expected. 179 190 == Django == 180 191 * GeoDjango exists in the {{{gis}}} branch from SVN: … … 187 198 * Latest [http://geos.refractions.net/ GEOS] version is 3.0.0RC4 188 199 * 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. 190 202 {{{ 191 203 $ ./configure --enable-python … … 253 265 * Field keywords are used during model creation, for example: 254 266 {{{ 267 #!python 255 268 from django.contrib.gis.db import models 256 269 … … 271 284 272 285 {{{ 286 #!python 273 287 >>> from zipcode.models import Zip 274 288 >>> z = Zip(code=77096, poly='POLYGON(( 10 10, 10 20, 20 20, 20 15, 10 10))') … … 287 301 288 302 {{{ 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>) 290 305 >>> qs = Zip.objects.exclude(...) 291 306 }}} … … 371 386 372 387 {{{ 388 #!python 373 389 >>> skool = School.objects.get(name='PSAS') 374 390 >>> print skool.get_point_wkt() … … 381 397 382 398 {{{ 399 #!python 383 400 >>> dist = District.objects.get(name='Houston ISD') 384 401 >>> print dist.get_poly_centroid() … … 391 408 392 409 {{{ 410 #!python 393 411 >>> dist = District.objects.get(name='Houston ISD') 394 412 >>> print dist.get_poly_area()