summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Bronn <jbronn@gmail.com>2008-06-16 16:39:36 +0000
committerJustin Bronn <jbronn@gmail.com>2008-06-16 16:39:36 +0000
commit6fdd9254e68f64d83a8e5a02db1a9b45bb3b93ba (patch)
tree803dd478841fce7475f332cc9589c7cbd50312b1
parent842dae0ed59cc7566cf35090093222ea3a61ec79 (diff)
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
-rw-r--r--django/contrib/gis/gdal/__init__.py13
-rw-r--r--django/contrib/gis/gdal/geomtype.py7
-rw-r--r--django/contrib/gis/tests/test_gdal_geom.py6
3 files changed, 22 insertions, 4 deletions
diff --git a/django/contrib/gis/gdal/__init__.py b/django/contrib/gis/gdal/__init__.py
index e3eddc80ef..cedf165ef1 100644
--- a/django/contrib/gis/gdal/__init__.py
+++ b/django/contrib/gis/gdal/__init__.py
@@ -1,6 +1,6 @@
"""
This module houses ctypes interfaces for GDAL objects. The following GDAL
- objects are supported:
+ objects are supported:
CoordTransform: Used for coordinate transformations from one spatial
reference system to another.
@@ -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
diff --git a/django/contrib/gis/gdal/geomtype.py b/django/contrib/gis/gdal/geomtype.py
index 1062723f09..3bcd0db9b1 100644
--- a/django/contrib/gis/gdal/geomtype.py
+++ b/django/contrib/gis/gdal/geomtype.py
@@ -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()
diff --git a/django/contrib/gis/tests/test_gdal_geom.py b/django/contrib/gis/tests/test_gdal_geom.py
index 37fa2e7071..3775bd46fc 100644
--- a/django/contrib/gis/tests/test_gdal_geom.py
+++ b/django/contrib/gis/tests/test_gdal_geom.py
@@ -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,8 +31,11 @@ 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."
for g in wkt_out: