Changeset 6421
- Timestamp:
- 09/24/07 22:55:29 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/gis/django/contrib/gis/gdal/feature.py
r5749 r6421 5 5 # The GDAL C library, OGR exception, and the Field object 6 6 from django.contrib.gis.gdal.libgdal import lgdal 7 from django.contrib.gis.gdal.error import OGRException 7 from django.contrib.gis.gdal.error import OGRException, OGRIndexError 8 8 from django.contrib.gis.gdal.field import Field 9 9 from django.contrib.gis.gdal.geometries import OGRGeometry, OGRGeomType … … 36 36 else: 37 37 if index < 0 or index > self.num_fields: 38 raise IndexError, 'index out of range'38 raise OGRIndexError, 'index out of range' 39 39 i = index 40 40 return Field(lgdal.OGR_F_GetFieldDefnRef(self._feat, c_int(i)), 41 41 string_at(lgdal.OGR_F_GetFieldAsString(self._feat, c_int(i)))) 42 42 43 43 def __iter__(self): 44 44 "Iterates over each field in the Feature." … … 95 95 #### Feature Methods #### 96 96 def get(self, field): 97 "Returns the value of the field, instead of an instance of the Field object." 97 """ 98 Returns the value of the field, instead of an instance of the Field 99 object. May take a string of the field name or a Field object as 100 parameters. 101 """ 98 102 field_name = getattr(field, 'name', field) 99 103 return self.__getitem__(field_name).value … … 102 106 "Returns the index of the given field name." 103 107 i = lgdal.OGR_F_GetFieldIndex(self._feat, c_char_p(field_name)) 104 if i < 0: raise IndexError, 'invalid OFT field name given: "%s"' % field_name108 if i < 0: raise OGRIndexError, 'invalid OFT field name given: "%s"' % field_name 105 109 return i 106 110 django/branches/gis/django/contrib/gis/gdal/layer.py
r6059 r6421 9 9 from django.contrib.gis.gdal.feature import Feature 10 10 from django.contrib.gis.gdal.geometries import OGRGeomType 11 from django.contrib.gis.gdal.error import OGRException, check_err11 from django.contrib.gis.gdal.error import OGRException, OGRIndexError, check_err 12 12 from django.contrib.gis.gdal.srs import SpatialReference 13 13 … … 49 49 index = end - index 50 50 if index < 0 or index >= self.num_feat: 51 raise IndexError, 'index out of range'51 raise OGRIndexError, 'index out of range' 52 52 return make_feature(index) 53 53 else:
