Changes between Version 19 and Version 20 of GeoDjango


Ignore:
Timestamp:
02/27/07 10:22:44 (8 years ago)
Author:
Jeremy Dunck <jdunck@…>
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • GeoDjango

    v19 v20  
    2828  Example code, where point and box are types from GeoTypes:
    2929{{{
    30 Schools.objects.geo_near(point=x, radius=1.0)
    31 Schools.objects.geo_within(bound_box=box)
    32 }}}
     30from django.db import models
     31from django.contrib.gis import db as gis_db
     32
     33class School(meta.Model):
     34  name = ...
     35  objects = gis_db.Manager()
     36
     37Assume a location column has already been added to the DB, e.g.
     38select addgeometrycolumn('','schools_school','location',-1, 'POINT', 2);
     39
     40Then this would work:
     41from django.contrib.gis.geometry import Point
     42x = Point(-95.36819458007812, 30.2184318620219)
     43School.objects.geo_near('location', point=x, radius=1.0)
     44
     45This could construct a LinearRing approximating the circle around x
     46and issue something like:
     47
     48poly = "POLYGON (...points from curve approximation...)"
     49_where.append("""
     50where schools_school.location && %s and
     51within(schools_school.location, %s)
     52""")
     53_params.append(poly, poly)}}}
    3354
    3455=== Geos ===
Back to Top