Changes between Version 37 and Version 38 of GeoDjango


Ignore:
Timestamp:
Mar 22, 2007, 6:22:20 PM (18 years ago)
Author:
jbronn
Comment:

Updated instructions, API now uses geo_filter()

Legend:

Unmodified
Added
Removed
Modified
  • GeoDjango

    v37 v38  
    7878}}}
    7979
    80   * PostGIS additions to the API may now be used:
     80  * PostGIS additions to the API may now be used.  Geographic queries are done by calling {{{geo_filter()}}} and {{{geo_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 for '''actual''' intersection of the two geometries, not just the bounding box.
    8181{{{
    8282>>> from geo_app.models import District, School
    83 >>> qs1 = District.objects.filter(poly__bbcontains='POINT(-95.362293 29.756539)') # Same as PostGIS '&&' operator
    84 >>> qs2 = District.objects.filter(poly__intersects='POINT(-95.362293 29.756539)') # Same as PostGIS Intersects() (from GEOS)
     83>>> qs1 = District.objects.geo_filter(poly__bbcontains='POINT(-95.362293 29.756539)')
     84>>> qs2 = District.objects.geo_filter(poly__contains='POINT(-95.362293 29.756539)')
     85}}}
     86
     87  * Both {{{geo_filter()}}} and {{{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:
     88{{{
     89>>> qs = District.objects.filter(name__contains='Houston').geo_filter(poly__contains='POINT(-95.362293 29.756539)')
    8590}}}
    8691
    8792== Phase 2 ==
    88  * Add as much from the PostGIS as possible.
     93 * Add as much from the PostGIS API as possible.
    8994 * Add geometry-enabled routines to the fields that call directly on GEOS routines -- like area(), centroid(), etc.
    9095 * Contemplate a JS framework for mapping.  I know Django community is against including any type of JS/AJAX framework, but having a way to generate maps would be a great addition.  Also, any type of framework would be limited to the contrib package only.
     
    130135}}}
    131136 
    132  * Finally, update your settings.py to reflect the name and user for the spatially enabled database.  So far, we only plan to support the psycopg2 backend, thus: DATABASE_ENGINE='postgresql_psycopg2'.
     137 * Finally, update your {{{settings.py}}} to reflect the name and user for the spatially enabled database.  So far, we only plan to support the psycopg2 backend, thus: {{{DATABASE_ENGINE='postgresql_psycopg2'}}}.
    133138== GDAL ==
    134  * Optional, but useful for coordinate transformations.
     139 * Optional, but highly useful for coordinate transformations and reading/writing ''both'' vector (e.g. SHP) and raster (e.g. TIFF) geographic data.
     140 * Latest GDAL version is 1.4.0.  Configure with GEOS and Python support, then make and install:
     141{{{
     142$ ./configure --with-geos --with-python
     143$ make
     144# make install
     145}}}
     146 * ''Note'': This is done without the 'next generation' SWIG Python bindings. I've had trouble getting them to work, and the rumor is this only works on Windows. The compilation flag to enable these is --with-ngpython, but our packages currently only use the old bindings.
Back to Top