Changeset 1186 for Core/trunk/bycycle/core/model/data/sqltypes.py
- Timestamp:
- 07/17/09 14:29:31 (3 years ago)
- Files:
-
- 1 modified
-
Core/trunk/bycycle/core/model/data/sqltypes.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
Core/trunk/bycycle/core/model/data/sqltypes.py
r1155 r1186 2 2 3 3 from shapely import geometry, wkb 4 import pyproj5 6 from binascii import a2b_hex, b2a_hex7 4 8 5 … … 13 10 super(Geometry, self).__init__() 14 11 self.SRID = SRID 15 self.proj = pyproj.Proj(init='epsg:%s' % SRID)16 12 self.type = type_.upper() 17 13 self.dimension = dimension … … 23 19 """Convert from Python type to database type.""" 24 20 def process(value): 21 """``value`` is a Python/Shapely geometry object.""" 25 22 if value is None: 26 23 return None 27 24 else: 28 return 'SRID=%s;%s' % (self.SRID, b2a_hex(value.to_wkb()))25 return 'SRID=%s;%s' % (self.SRID, value) 29 26 return process 30 27 … … 32 29 """Convert from database type to Python type.""" 33 30 def process(value): 31 """``value`` is a hex-encoded WKB string.""" 34 32 if value is None: 35 33 return None 36 34 else: 37 return wkb.loads( a2b_hex(value))35 return wkb.loads(value.decode('hex')) 38 36 return process 39 37