Ticket #14060: 14060.1.diff
File 14060.1.diff, 3.3 KB (added by , 14 years ago) |
---|
-
django/contrib/gis/db/models/fields.py
94 94 # Is this a geography rather than a geometry column? 95 95 self.geography = geography 96 96 97 # Oracle-specific private attributes for creating the entr iein97 # Oracle-specific private attributes for creating the entry in 98 98 # `USER_SDO_GEOM_METADATA` 99 99 self._extent = kwargs.pop('extent', (-180.0, -90.0, 180.0, 90.0)) 100 100 self._tolerance = kwargs.pop('tolerance', 0.05) … … 237 237 elif isinstance(value, SQLEvaluator): 238 238 params = [] 239 239 else: 240 params = [connection.ops.Adapter(value )]240 params = [connection.ops.Adapter(value, geography=self.geography)] 241 241 242 242 return params 243 243 else: -
django/contrib/gis/db/backends/adapter.py
3 3 This provides an adaptor for Geometries sent to the 4 4 MySQL and Oracle database backends. 5 5 """ 6 def __init__(self, geom ):6 def __init__(self, geom, **kwargs): 7 7 self.wkt = geom.wkt 8 8 self.srid = geom.srid 9 9 -
django/contrib/gis/db/backends/postgis/adapter.py
6 6 from psycopg2.extensions import ISQLQuote 7 7 8 8 class PostGISAdapter(object): 9 def __init__(self, geom ):9 def __init__(self, geom, geography=False, **kwargs): 10 10 "Initializes on the geometry." 11 11 # Getting the WKB (in string form, to allow easy pickling of 12 12 # the adaptor) and the SRID from the geometry. 13 13 self.ewkb = str(geom.ewkb) 14 14 self.srid = geom.srid 15 self.geography = geography 15 16 16 17 def __conform__(self, proto): 17 18 # Does the given protocol conform to what Psycopg2 expects? … … 29 30 def getquoted(self): 30 31 "Returns a properly quoted string for use in PostgreSQL/PostGIS." 31 32 # Want to use WKB, so wrap with psycopg2 Binary() to quote properly. 32 return 'ST_GeomFromEWKB(E%s)' % Binary(self.ewkb) 33 if self.geography: 34 return 'ST_GeogFromWKB(E%s)' % Binary(self.ewkb) 35 else: 36 return 'ST_GeomFromEWKB(E%s)' % Binary(self.ewkb) 33 37 34 38 def prepare_database_save(self, unused): 35 39 return self -
django/contrib/gis/tests/geogapp/tests.py
72 72 self.assertEqual(num_poly, len(c.mpoly)) 73 73 self.assertEqual(name, c.name) 74 74 self.assertEqual(state, c.state) 75 76 def test06_geography_adapter(self): 77 # Try to get Victoria by equivalence comparison. 78 c = City.objects.get(point="POINT (-123.305196 48.462611)")