Changeset 5657
- Timestamp:
- 07/12/07 01:47:40 (1 year ago)
- Files:
-
- django/branches/gis/django/contrib/gis/db/models/fields/__init__.py (modified) (2 diffs)
- django/branches/gis/django/contrib/gis/db/models/__init__.py (modified) (1 diff)
- django/branches/gis/django/contrib/gis/db/models/mixin.py (moved) (moved from django/branches/gis/django/contrib/gis/db/models/GeoMixin.py) (4 diffs)
- django/branches/gis/django/contrib/gis/db/models/postgis.py (modified) (1 diff)
- django/branches/gis/django/contrib/gis/db/models/proxy.py (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/gis/django/contrib/gis/db/models/fields/__init__.py
r5448 r5657 1 1 # The Django base Field class. 2 2 from django.db.models.fields import Field 3 from django.contrib.gis.db.models.proxy import GeometryProxy 3 4 from django.contrib.gis.db.models.postgis import POSTGIS_TERMS, quotename 4 5 from django.contrib.gis.oldforms import WKTField … … 87 88 return post_sql 88 89 90 def _post_delete_sql(self, style, db_table): 91 "Drops the geometry column." 92 sql = style.SQL_KEYWORD('SELECT ') + \ 93 style.SQL_KEYWORD('DropGeometryColumn') + '(' + \ 94 style.SQL_TABLE(quotename(db_table)) + ', ' + \ 95 style.SQL_FIELD(quotename(self.column)) + ');' 96 return sql 97 89 98 def contribute_to_class(self, cls, name): 90 99 super(GeometryField, self).contribute_to_class(cls, name) 100 101 # setup for lazy-instantiated GEOSGeometry objects 102 setattr(cls, self.attname, GeometryProxy(self)) 91 103 92 104 # Adding needed accessor functions django/branches/gis/django/contrib/gis/db/models/__init__.py
r5008 r5657 15 15 16 16 # The geographic mixin class. 17 from GeoMixin import GeoMixin17 from mixin import GeoMixin django/branches/gis/django/contrib/gis/db/models/mixin.py
r5448 r5657 1 1 # GEOS Routines 2 from warnings import warn 2 3 from django.contrib.gis.geos import GEOSGeometry, hex_to_wkt, centroid, area 3 4 from django.contrib.gis.gdal import OGRGeometry, SpatialReference … … 12 13 def _get_GEOM_geos(self, field): 13 14 "Returns a GEOS Python object for the geometry." 14 return GEOSGeometry(getattr(self, field.attname), 'hex') 15 warn("use model.%s" % field.attname, DeprecationWarning) 16 return getattr(self, field.attname) 15 17 16 18 def _get_GEOM_ogr(self, field, srid): … … 21 23 def _get_GEOM_srid(self, srid): 22 24 "Returns the spatial reference identifier (SRID) of the geometry." 25 warn("use model.geometry_field.srid", DeprecationWarning) 23 26 return srid 24 27 … … 29 32 def _get_GEOM_wkt(self, field): 30 33 "Returns the WKT of the geometry." 31 hex = getattr(self, field.attname)32 return hex_to_wkt(hex)34 warn("use model.%s.centroid.wkt" % field.attname, DeprecationWarning) 35 return getattr(self, field.attname).wkt 33 36 34 37 def _get_GEOM_centroid(self, field): 35 38 "Returns the centroid of the geometry, in WKT." 36 hex = getattr(self, field.attname)37 return centroid(hex)39 warn("use model.%s.centroid.wkt" % field.attname, DeprecationWarning) 40 return getattr(self, field.attname).centroid.wkt 38 41 39 42 def _get_GEOM_area(self, field): 40 43 "Returns the area of the geometry, in projected units." 41 hex = getattr(self, field.attname)42 return area(hex)44 warn("use model.%s.area" % field.attname, DeprecationWarning) 45 return getattr(self, field.attname).area 43 46 44 47 django/branches/gis/django/contrib/gis/db/models/postgis.py
r5397 r5657 39 39 # PostGIS Geometry Functions -- most of these use GEOS. 40 40 POSTGIS_GEOMETRY_FUNCTIONS = { 41 'distance' : 'Distance',41 #'distance' : 'Distance', -- doesn't work right now. 42 42 'equals' : 'Equals', 43 43 'disjoint' : 'Disjoint',
