Changes between Version 37 and Version 38 of GeoDjango
- Timestamp:
- Mar 22, 2007, 6:22:20 PM (18 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
GeoDjango
v37 v38 78 78 }}} 79 79 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. 81 81 {{{ 82 82 >>> 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)') 85 90 }}} 86 91 87 92 == Phase 2 == 88 * Add as much from the PostGIS as possible.93 * Add as much from the PostGIS API as possible. 89 94 * Add geometry-enabled routines to the fields that call directly on GEOS routines -- like area(), centroid(), etc. 90 95 * 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. … … 130 135 }}} 131 136 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'}}}. 133 138 == 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.