mirror of
https://github.com/django/django.git
synced 2025-07-04 09:49:12 +00:00
gis: gdal: Fixed #7434 (no real defect, just clarified how to disable GDAL); fixed !=
operator and added support for 'Unknown on
OGRGeomType`.
git-svn-id: http://code.djangoproject.com/svn/django/branches/gis@7665 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
842dae0ed5
commit
6fdd9254e6
@ -19,6 +19,17 @@
|
|||||||
types (GDAL library not required).
|
types (GDAL library not required).
|
||||||
|
|
||||||
SpatialReference: Represents OSR Spatial Reference objects.
|
SpatialReference: Represents OSR Spatial Reference objects.
|
||||||
|
|
||||||
|
The GDAL library will be imported from the system path using the default
|
||||||
|
library name for the current OS. The default library path may be overridden
|
||||||
|
by setting `GDAL_LIBRARY_PATH` in your settings with the path to the GDAL C
|
||||||
|
library on your system.
|
||||||
|
|
||||||
|
GDAL links to a large number of external libraries that consume RAM when
|
||||||
|
loaded. Thus, it may desirable to disable GDAL on systems with limited
|
||||||
|
RAM resources -- this may be accomplished by setting `GDAL_LIBRARY_PATH`
|
||||||
|
to a non-existant file location (e.g., `GDAL_LIBRARY_PATH='/null/path'`;
|
||||||
|
setting to None/False/'' will not work as a string must be given).
|
||||||
"""
|
"""
|
||||||
# Attempting to import objects that depend on the GDAL library. The
|
# Attempting to import objects that depend on the GDAL library. The
|
||||||
# HAS_GDAL flag will be set to True if the library is present on
|
# HAS_GDAL flag will be set to True if the library is present on
|
||||||
|
@ -5,10 +5,10 @@ class OGRGeomType(object):
|
|||||||
"Encapulates OGR Geometry Types."
|
"Encapulates OGR Geometry Types."
|
||||||
|
|
||||||
# Ordered array of acceptable strings and their corresponding OGRwkbGeometryType
|
# Ordered array of acceptable strings and their corresponding OGRwkbGeometryType
|
||||||
__ogr_str = ['Point', 'LineString', 'Polygon', 'MultiPoint',
|
__ogr_str = ['Unknown', 'Point', 'LineString', 'Polygon', 'MultiPoint',
|
||||||
'MultiLineString', 'MultiPolygon', 'GeometryCollection',
|
'MultiLineString', 'MultiPolygon', 'GeometryCollection',
|
||||||
'LinearRing']
|
'LinearRing']
|
||||||
__ogr_int = [1, 2, 3, 4, 5, 6, 7, 101]
|
__ogr_int = [0, 1, 2, 3, 4, 5, 6, 7, 101]
|
||||||
|
|
||||||
def __init__(self, type_input):
|
def __init__(self, type_input):
|
||||||
"Figures out the correct OGR Type based upon the input."
|
"Figures out the correct OGR Type based upon the input."
|
||||||
@ -47,6 +47,9 @@ class OGRGeomType(object):
|
|||||||
else:
|
else:
|
||||||
raise TypeError('Cannot compare with type: %s' % str(type(other)))
|
raise TypeError('Cannot compare with type: %s' % str(type(other)))
|
||||||
|
|
||||||
|
def __ne__(self, other):
|
||||||
|
return not (self == other)
|
||||||
|
|
||||||
def _has_str(self, arr, s):
|
def _has_str(self, arr, s):
|
||||||
"Case-insensitive search of the string array for the given pattern."
|
"Case-insensitive search of the string array for the given pattern."
|
||||||
s_low = s.lower()
|
s_low = s.lower()
|
||||||
|
@ -17,6 +17,7 @@ class OGRGeomTest(unittest.TestCase):
|
|||||||
g = OGRGeomType('point')
|
g = OGRGeomType('point')
|
||||||
g = OGRGeomType('GeometrycollectioN')
|
g = OGRGeomType('GeometrycollectioN')
|
||||||
g = OGRGeomType('LINearrING')
|
g = OGRGeomType('LINearrING')
|
||||||
|
g = OGRGeomType('Unknown')
|
||||||
except:
|
except:
|
||||||
self.fail('Could not create an OGRGeomType object!')
|
self.fail('Could not create an OGRGeomType object!')
|
||||||
|
|
||||||
@ -30,7 +31,10 @@ class OGRGeomTest(unittest.TestCase):
|
|||||||
self.assertEqual(True, OGRGeomType(7) == 'GeometryCollection')
|
self.assertEqual(True, OGRGeomType(7) == 'GeometryCollection')
|
||||||
self.assertEqual(True, OGRGeomType('point') == 'POINT')
|
self.assertEqual(True, OGRGeomType('point') == 'POINT')
|
||||||
self.assertEqual(False, OGRGeomType('point') == 2)
|
self.assertEqual(False, OGRGeomType('point') == 2)
|
||||||
|
self.assertEqual(True, OGRGeomType('unknown') == 0)
|
||||||
self.assertEqual(True, OGRGeomType(6) == 'MULtiPolyGON')
|
self.assertEqual(True, OGRGeomType(6) == 'MULtiPolyGON')
|
||||||
|
self.assertEqual(False, OGRGeomType(1) != OGRGeomType('point'))
|
||||||
|
self.assertEqual(True, OGRGeomType('POINT') != OGRGeomType(6))
|
||||||
|
|
||||||
def test01a_wkt(self):
|
def test01a_wkt(self):
|
||||||
"Testing WKT output."
|
"Testing WKT output."
|
||||||
|
Loading…
x
Reference in New Issue
Block a user