1
0
mirror of https://github.com/django/django.git synced 2025-07-04 01:39:20 +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:
Justin Bronn 2008-06-16 16:39:36 +00:00
parent 842dae0ed5
commit 6fdd9254e6
3 changed files with 22 additions and 4 deletions

View File

@ -19,6 +19,17 @@
types (GDAL library not required).
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
# HAS_GDAL flag will be set to True if the library is present on

View File

@ -5,10 +5,10 @@ class OGRGeomType(object):
"Encapulates OGR Geometry Types."
# 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',
'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):
"Figures out the correct OGR Type based upon the input."
@ -47,6 +47,9 @@ class OGRGeomType(object):
else:
raise TypeError('Cannot compare with type: %s' % str(type(other)))
def __ne__(self, other):
return not (self == other)
def _has_str(self, arr, s):
"Case-insensitive search of the string array for the given pattern."
s_low = s.lower()

View File

@ -17,6 +17,7 @@ class OGRGeomTest(unittest.TestCase):
g = OGRGeomType('point')
g = OGRGeomType('GeometrycollectioN')
g = OGRGeomType('LINearrING')
g = OGRGeomType('Unknown')
except:
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('point') == 'POINT')
self.assertEqual(False, OGRGeomType('point') == 2)
self.assertEqual(True, OGRGeomType('unknown') == 0)
self.assertEqual(True, OGRGeomType(6) == 'MULtiPolyGON')
self.assertEqual(False, OGRGeomType(1) != OGRGeomType('point'))
self.assertEqual(True, OGRGeomType('POINT') != OGRGeomType(6))
def test01a_wkt(self):
"Testing WKT output."