Django

Code

Changeset 6421

Show
Ignore:
Timestamp:
09/24/07 22:55:29 (1 year ago)
Author:
jbronn
Message:

gis: gdal: The feature and layer modules now uses OGRIndexError.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/gis/django/contrib/gis/gdal/feature.py

    r5749 r6421  
    55# The GDAL C library, OGR exception, and the Field object 
    66from django.contrib.gis.gdal.libgdal import lgdal 
    7 from django.contrib.gis.gdal.error import OGRException 
     7from django.contrib.gis.gdal.error import OGRException, OGRIndexError 
    88from django.contrib.gis.gdal.field import Field 
    99from django.contrib.gis.gdal.geometries import OGRGeometry, OGRGeomType 
     
    3636        else: 
    3737            if index < 0 or index > self.num_fields: 
    38                 raise IndexError, 'index out of range' 
     38                raise OGRIndexError, 'index out of range' 
    3939            i = index 
    4040        return Field(lgdal.OGR_F_GetFieldDefnRef(self._feat, c_int(i)), 
    4141                     string_at(lgdal.OGR_F_GetFieldAsString(self._feat, c_int(i)))) 
    42  
     42     
    4343    def __iter__(self): 
    4444        "Iterates over each field in the Feature." 
     
    9595    #### Feature Methods #### 
    9696    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        """ 
    98102        field_name = getattr(field, 'name', field) 
    99103        return self.__getitem__(field_name).value 
     
    102106        "Returns the index of the given field name." 
    103107        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_name 
     108        if i < 0: raise OGRIndexError, 'invalid OFT field name given: "%s"' % field_name 
    105109        return i 
    106110 
  • django/branches/gis/django/contrib/gis/gdal/layer.py

    r6059 r6421  
    99from django.contrib.gis.gdal.feature import Feature 
    1010from django.contrib.gis.gdal.geometries import OGRGeomType 
    11 from django.contrib.gis.gdal.error import OGRException, check_err 
     11from django.contrib.gis.gdal.error import OGRException, OGRIndexError, check_err 
    1212from django.contrib.gis.gdal.srs import SpatialReference 
    1313 
     
    4949                index = end - index 
    5050            if index < 0 or index >= self.num_feat: 
    51                 raise IndexError, 'index out of range' 
     51                raise OGRIndexError, 'index out of range' 
    5252            return make_feature(index) 
    5353        else: