Changeset 5754
- Timestamp:
- 07/23/07 22:20:42 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/gis/django/contrib/gis/gdal/field.py
r5749 r5754 11 11 "A class that wraps an OGR Field, needs to be instantiated from a Feature object." 12 12 13 _fld = 0 # Initially NULL14 15 13 #### Python 'magic' routines #### 16 14 def __init__(self, fld, val=''): 17 15 "Needs a C pointer (Python integer in ctypes) in order to initialize." 16 self._fld = 0 # Initially NULL 17 18 18 if not fld: 19 19 raise OGRException, 'Cannot create OGR Field, invalid pointer given.' … … 52 52 return int(self._val) 53 53 except ValueError: 54 return 0 55 54 return None 56 55 class OFTIntegerList(Field): pass 56 57 57 class OFTReal(Field): 58 58 @property 59 59 def value(self): 60 60 "Returns a float contained in this field." 61 62 61 try: 63 62 return float(self._val) 64 63 except ValueError: 65 #FIXME: 0? None?66 return 0 64 return None 65 class OFTRealList(Field): pass 67 66 68 69 70 class OFTRealList(Field): pass71 67 class OFTString(Field): pass 72 68 class OFTStringList(Field): pass django/branches/gis/django/contrib/gis/gdal/geometries.py
r5749 r5754 56 56 # The OGR_G_* routines are relevant here. 57 57 58 #### ctypes prototypes ####58 #### ctypes prototypes for functions that return double values #### 59 59 def pnt_func(f): 60 60 "For accessing point information." … … 62 62 f.argtypes = [c_void_p, c_int] 63 63 return f 64 # GetX, GetY, GetZ all return doubles. 64 65 getx = pnt_func(lgdal.OGR_G_GetX) 65 66 gety = pnt_func(lgdal.OGR_G_GetY) 66 67 getz = pnt_func(lgdal.OGR_G_GetZ) 68 69 # GetArea returns a double. 70 get_area = lgdal.OGR_G_GetArea 71 get_area.restype = c_double 72 get_area.argtypes = [c_void_p] 67 73 68 74 #### OGRGeometry Class #### … … 212 218 def area(self): 213 219 "Returns the area for a LinearRing, Polygon, or MultiPolygon; 0 otherwise." 214 a = lgdal.OGR_G_GetArea(self._g) 215 return a.value 220 return get_area(self._g) 216 221 217 222 @property
