3333from django .contrib .gis .gdal .error import SRSException
3434from django .contrib .gis .gdal .prototypes import srs as capi
3535
36+ from django .utils import six
37+
3638#### Spatial Reference class. ####
3739class SpatialReference (GDALBase ):
3840 """
3941 A wrapper for the OGRSpatialReference object. According to the GDAL Web site,
40- the SpatialReference object "provide[s] services to represent coordinate
42+ the SpatialReference object "provide[s] services to represent coordinate
4143 systems (projections and datums) and to transform between them."
4244 """
4345
4446 #### Python 'magic' routines ####
4547 def __init__ (self , srs_input = '' ):
4648 """
4749 Creates a GDAL OSR Spatial Reference object from the given input.
48- The input may be string of OGC Well Known Text (WKT), an integer
49- EPSG code, a PROJ.4 string, and/or a projection "well known" shorthand
50+ The input may be string of OGC Well Known Text (WKT), an integer
51+ EPSG code, a PROJ.4 string, and/or a projection "well known" shorthand
5052 string (one of 'WGS84', 'WGS72', 'NAD27', 'NAD83').
5153 """
5254 buf = c_char_p ('' )
@@ -63,7 +65,7 @@ def __init__(self, srs_input=''):
6365 srs_input = 'EPSG:%d' % srid
6466 except ValueError :
6567 pass
66- elif isinstance (srs_input , ( int , long ) ):
68+ elif isinstance (srs_input , six . integer_types ):
6769 # EPSG integer code was input.
6870 srs_type = 'epsg'
6971 elif isinstance (srs_input , self .ptr_type ):
@@ -97,8 +99,8 @@ def __del__(self):
9799
98100 def __getitem__ (self , target ):
99101 """
100- Returns the value of the given string attribute node, None if the node
101- doesn't exist. Can also take a tuple as a parameter, (target, child),
102+ Returns the value of the given string attribute node, None if the node
103+ doesn't exist. Can also take a tuple as a parameter, (target, child),
102104 where child is the index of the attribute in the WKT. For example:
103105
104106 >>> wkt = 'GEOGCS["WGS 84", DATUM["WGS_1984, ... AUTHORITY["EPSG","4326"]]')
@@ -140,7 +142,7 @@ def attr_value(self, target, index=0):
140142 def auth_name (self , target ):
141143 "Returns the authority name for the given string target node."
142144 return capi .get_auth_name (self .ptr , target )
143-
145+
144146 def auth_code (self , target ):
145147 "Returns the authority code for the given string target node."
146148 return capi .get_auth_code (self .ptr , target )
@@ -167,7 +169,7 @@ def to_esri(self):
167169 def validate (self ):
168170 "Checks to see if the given spatial reference is valid."
169171 capi .srs_validate (self .ptr )
170-
172+
171173 #### Name & SRID properties ####
172174 @property
173175 def name (self ):
@@ -184,7 +186,7 @@ def srid(self):
184186 return int (self .attr_value ('AUTHORITY' , 1 ))
185187 except (TypeError , ValueError ):
186188 return None
187-
189+
188190 #### Unit Properties ####
189191 @property
190192 def linear_name (self ):
@@ -213,7 +215,7 @@ def angular_units(self):
213215 @property
214216 def units (self ):
215217 """
216- Returns a 2-tuple of the units value and the units name,
218+ Returns a 2-tuple of the units value and the units name,
217219 and will automatically determines whether to return the linear
218220 or angular units.
219221 """
@@ -252,7 +254,7 @@ def inverse_flattening(self):
252254 @property
253255 def geographic (self ):
254256 """
255- Returns True if this SpatialReference is geographic
257+ Returns True if this SpatialReference is geographic
256258 (root node is GEOGCS).
257259 """
258260 return bool (capi .isgeographic (self .ptr ))
@@ -265,7 +267,7 @@ def local(self):
265267 @property
266268 def projected (self ):
267269 """
268- Returns True if this SpatialReference is a projected coordinate system
270+ Returns True if this SpatialReference is a projected coordinate system
269271 (root node is PROJCS).
270272 """
271273 return bool (capi .isprojected (self .ptr ))
0 commit comments