Changes between Version 32 and Version 33 of GeoDjango


Ignore:
Timestamp:
03/11/2007 07:01:03 PM (8 years ago)
Author:
jbronn
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • GeoDjango

    v32 v33  
    3737
    3838== Phase 1 ==
    39   Assume existing data and columns, and that the UOM given is same as backing data.
    40   Support a custom manager (and queryset) to support lookups.
     39 * Create Geometry-enabled fields and manager.  Status: complete (not yet in SVN).
     40 * Allow for Geometry-enabled queries.  Status: complete (not yet in SVN).
     41 * Here is an example of how the model API currently works (assume this example is in geo_app/models.py):
    4142
    42 === GeoTypes ===
    43   GeoTypes 0.7 supports both psycopg1 and psycopg2.  Upside is conversion from type params to SQL.  Simplifies (avoids?) QuerySet modification.  Maintainer of GeoTypes has been responsive as of Feb 26 2007 on the psycopg mailing list.
    44   Example code, where point and box are types from GeoTypes.OG*:
    4543{{{
    46 from django.db import models
    47 from django.contrib.gis import db as gis_db
     44from django.contrib.gis.db import models
    4845
    49 class School(meta.Model):
    50   name = ...
    51   objects = gis_db.Manager()
     46class District(models.Model):
     47    name = models.CharField(maxlength=35)
     48    num  = models.IntegerField()
     49    poly = models.MultiPolygonField()
    5250
    53 Assume a location column has already been added to the DB, e.g.
    54 select addgeometrycolumn('','schools_school','location',-1, 'POINT', 2);
     51    objects = models.GeoManager()
    5552
    56 Then this would work:
    57 from django.contrib.gis.geometry import Point
    58 x = Point(-95.36819458007812, 30.2184318620219)
    59 School.objects.geo_near('location', point=x, radius=1.0)
     53class School(models.Model):
     54    name  = models.CharField(maxlength=35)
     55    point = models.PointField()
    6056
    61 This could construct a LinearRing approximating the circle around x
    62 and issue something like:
    63 
    64 poly = "POLYGON (...points from curve approximation...)"
    65 _where.append("""
    66 where schools_school.location && %s and
    67 within(schools_school.location, %s)
    68 """)
    69 _params.append(poly, poly)
     57    objects = models.GeoManager()
    7058}}}
    7159
    72 === Geos ===
    73   I'm not sure how we can use GEOS without also doing something like GeoTypes down in the QuerySet.  Ideas?
     60 * Use the manage.py just like you normally would:
    7461
     62{{{
     63$ python manage.py sqlall geo_app
     64BEGIN;
     65CREATE TABLE "geo_app_school" (
     66    "id" serial NOT NULL PRIMARY KEY,
     67    "name" varchar(35) NOT NULL
     68);
     69CREATE TABLE "geo_app_district" (
     70    "id" serial NOT NULL PRIMARY KEY,
     71    "name" varchar(35) NOT NULL,
     72    "num" integer NOT NULL
     73);
     74SELECT AddGeometryColumn('geo_app_school', 'point', 4326, 'POINT', 2);
     75SELECT AddGeometryColumn('geo_app_district', 'poly', 4326, 'MULTIPOLYGON', 2);
     76COMMIT;
     77$ python manage.py syncdb geo_app
    7578
     79}}}
     80
     81  * PostGIS additions to the API may now be used:
     82
     83{{{
     84>>> from geo_app.models import District, School
     85>>> qs1 = District.objects.filter(poly__bbcontains='POINT(-95.362293 29.756539)') # Same as PostGIS '&&' operator
     86>>> qs2 = District.objects.filter(poly__intersects='POINT(-95.362293 29.756539)') # Same as PostGIS Intersects() (from GEOS)
     87
     88}}}
    7689
    7790== Phase 2 ==
    78 === Field Types ===
    79  * To allow update through ORM, new fieldtypes would be needed.
    80 
    81 
    82 === GIS utilities ===
    83 wrapper for geos, have the ability to do something like
    84 
    85 {{{
    86 from django.contrib.gis import area
    87 area(bbox.geom)
    88 }}}
     91 * Add as much from the PostGIS as possible.
     92 * Add geometry-enabled routines to the fields that call directly on GEOS routines -- like area(), centroid(), etc.
     93 * 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.
    8994
    9095= Installation =
Back to Top