Changeset 7840
- Timestamp:
- 07/05/08 11:59:51 (5 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/gis/django/contrib/gis/db/models/fields/__init__.py
r7836 r7840 121 121 def get_srid(self, geom): 122 122 """ 123 Has logic for retrieving the default SRID taking into account 124 the SRID of the field. 125 """ 126 if geom.srid is None or (geom.srid == -1 and self._srid != -1): 123 Returns the default SRID for the given geometry, taking into account 124 the SRID set for the field. For example, if the input geometry 125 has no SRID, then that of the field will be returned. 126 """ 127 gsrid = geom.srid # SRID of given geometry. 128 if gsrid is None or self._srid == -1 or (gsrid == -1 and self._srid != -1): 127 129 return self._srid 128 130 else: 129 return g eom.srid131 return gsrid 130 132 131 133 ### Routines overloaded from Field ### … … 172 174 def get_db_prep_save(self, value): 173 175 "Prepares the value for saving in the database." 174 if isinstance(value, SpatialBackend.Geometry): 175 return SpatialBackend.Adaptor(value) 176 elif value is None: 176 if value is None: 177 177 return None 178 178 else: 179 r aise TypeError('Geometry Proxy should only return Geometry objects or None.')179 return SpatialBackend.Adaptor(self.get_geometry(value)) 180 180 181 181 def get_manipulator_field_objs(self): django/branches/gis/django/contrib/gis/tests/geoapp/models.py
r6886 r7840 28 28 objects = models.GeoManager() 29 29 def __unicode__(self): return self.name 30 31 class MinusOneSRID(models.Model): 32 geom = models.PointField(srid=-1) # Minus one SRID. 33 objects = models.GeoManager() django/branches/gis/django/contrib/gis/tests/geoapp/tests.py
r7836 r7840 1 1 import os, unittest 2 from models import Country, City, State, Feature 2 from models import Country, City, State, Feature, MinusOneSRID 3 3 from django.contrib.gis import gdal 4 4 from django.contrib.gis.db.backend import SpatialBackend … … 302 302 self.assertAlmostEqual(wgs_pnt.x, sa.point.x, 6) 303 303 self.assertAlmostEqual(wgs_pnt.y, sa.point.y, 6) 304 305 # If the GeometryField SRID is -1, then we shouldn't perform any 306 # transformation if the SRID of the input geometry is different. 307 m1 = MinusOneSRID(geom=Point(17, 23, srid=4326)) 308 m1.save() 309 self.assertEqual(-1, m1.geom.srid) 304 310 305 311 # Oracle does not support NULL geometries in its spatial index for
