Changeset 5008
- Timestamp:
- 04/15/07 22:43:53 (2 years ago)
- Files:
-
- django/branches/gis/django/contrib/gis/db/models/fields/__init__.py (modified) (1 diff)
- django/branches/gis/django/contrib/gis/db/models/GeoMixin.py (modified) (3 diffs)
- django/branches/gis/django/contrib/gis/db/models/__init__.py (modified) (1 diff)
- django/branches/gis/django/contrib/gis/db/models/query.py (modified) (1 diff)
- django/branches/gis/django/contrib/gis/geos/GEOSGeometry.py (added)
- django/branches/gis/django/contrib/gis/geos/__init__.py (modified) (1 diff)
- django/branches/gis/django/contrib/gis/tests (added)
- django/branches/gis/django/contrib/gis/tests/geometries.py (added)
- django/branches/gis/django/contrib/gis/tests/__init__.py (added)
- django/branches/gis/django/contrib/gis/tests/test_geos.py (added)
- django/branches/gis/django/contrib/gis/tests/test_with_swig.py (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/gis/django/contrib/gis/db/models/fields/__init__.py
r4884 r5008 61 61 62 62 # Adding the WKT accessor function for geometry 63 setattr(cls, 'get_%s_geos' % self.name, curry(cls._get_GEOM_geos, field=self)) 63 64 setattr(cls, 'get_%s_wkt' % self.name, curry(cls._get_GEOM_wkt, field=self)) 64 65 setattr(cls, 'get_%s_centroid' % self.name, curry(cls._get_GEOM_centroid, field=self)) django/branches/gis/django/contrib/gis/db/models/GeoMixin.py
r4884 r5008 1 1 # GEOS Routines 2 from django.contrib.gis.geos import hex_to_wkt, centroid, area2 from django.contrib.gis.geos import GEOSGeometry, hex_to_wkt, centroid, area 3 3 4 4 # Until model subclassing is a possibility, a mixin class is used to add … … 9 9 # A subclass of Model is specifically needed so that these geographic 10 10 # routines are present for instantiations of the models. 11 def _get_GEOM_geos(self, field): 12 "Gets a GEOS Python object for the geometry." 13 return GEOSGeometry(getattr(self, field.attname), 'hex') 14 11 15 def _get_GEOM_wkt(self, field): 12 16 "Gets the WKT of the geometry." … … 20 24 21 25 def _get_GEOM_area(self, field): 26 "Gets the area of the geometry, in projected units." 22 27 hex = getattr(self, field.attname) 23 28 return area(hex) django/branches/gis/django/contrib/gis/db/models/__init__.py
r4884 r5008 4 4 # The GeoManager 5 5 from django.contrib.gis.db.models.manager import GeoManager 6 7 # The GeoQ object 8 from django.contrib.gis.db.models.query import GeoQ 6 9 7 10 # The various PostGIS/OpenGIS enabled fields. django/branches/gis/django/contrib/gis/db/models/query.py
r4884 r5008 1 from django.db.models.query import Q, Q Not, QuerySet1 from django.db.models.query import Q, QuerySet 2 2 from django.contrib.gis.db.models.postgis import parse_lookup 3 3 import operator django/branches/gis/django/contrib/gis/geos/__init__.py
r4882 r5008 1 from geos import geomFromWKT, geomToWKT, geomFromHEX, geomToHEX1 from GEOSGeometry import GEOSGeometry, GEOSException 2 2 3 3 def hex_to_wkt(hex): 4 "Converts EWKBHEXinto WKT."5 return geomToWKT(geomFromHEX(hex))4 "Converts HEXEWKB into WKT." 5 return GEOSGeometry(hex, 'hex').wkt 6 6 7 7 def wkt_to_hex(wkt): 8 "Converts WKT into EWKBHEX."9 return geomToHEX(geomFromWKT(wkt))8 "Converts WKT into HEXEWKB." 9 return GEOSGeometry(wkt, 'wkt').hex 10 10 11 def centroid(hex): 12 "Returns the centroid of the geometry (given in EWKBHEX)." 13 center = (geomFromHEX(hex)).getCentroid() 14 return geomToWKT(center) 11 def centroid(input, geom_type='hex'): 12 "Returns the centroid of the geometry (given in HEXEWKB)." 13 return GEOSGeometry(input, geom_type).centroid.wkt 15 14 16 def area( hex):17 "Returns the area of the geometry (given in EWKBHEX)."18 return (geomFromHEX(hex)).area()15 def area(input, geom_type='hex'): 16 "Returns the area of the geometry (given in HEXEWKB)." 17 return GEOSGeometry(input, geom_type).area 19 18
