Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
  • Loading branch information...
commit 6fdd9254e68f64d83a8e5a02db1a9b45bb3b93ba 1 parent 842dae0
Justin Bronn authored June 16, 2008
13  django/contrib/gis/gdal/__init__.py
... ...
@@ -1,6 +1,6 @@
1 1
 """
2 2
  This module houses ctypes interfaces for GDAL objects.  The following GDAL
3  
-  objects are supported:
  3
+ objects are supported:
4 4
 
5 5
  CoordTransform: Used for coordinate transformations from one spatial
6 6
   reference system to another.
@@ -19,6 +19,17 @@
19 19
   types (GDAL library not required).
20 20
 
21 21
  SpatialReference: Represents OSR Spatial Reference objects.
  22
+
  23
+ The GDAL library will be imported from the system path using the default  
  24
+ library name for the current OS. The default library path may be overridden
  25
+ by setting `GDAL_LIBRARY_PATH` in your settings with the path to the GDAL C 
  26
+ library on your system.  
  27
+
  28
+ GDAL links to a large number of external libraries that consume RAM when 
  29
+ loaded.  Thus, it may desirable to disable GDAL on systems with limited
  30
+ RAM resources -- this may be accomplished by setting `GDAL_LIBRARY_PATH`
  31
+ to a non-existant file location (e.g., `GDAL_LIBRARY_PATH='/null/path'`; 
  32
+ setting to None/False/'' will not work as a string must be given).
22 33
 """
23 34
 # Attempting to import objects that depend on the GDAL library.  The
24 35
 # HAS_GDAL flag will be set to True if the library is present on
7  django/contrib/gis/gdal/geomtype.py
@@ -5,10 +5,10 @@ class OGRGeomType(object):
5 5
     "Encapulates OGR Geometry Types."
6 6
 
7 7
     # Ordered array of acceptable strings and their corresponding OGRwkbGeometryType
8  
-    __ogr_str = ['Point', 'LineString', 'Polygon', 'MultiPoint',
  8
+    __ogr_str = ['Unknown', 'Point', 'LineString', 'Polygon', 'MultiPoint',
9 9
                  'MultiLineString', 'MultiPolygon', 'GeometryCollection',
10 10
                  'LinearRing']
11  
-    __ogr_int = [1, 2, 3, 4, 5, 6, 7, 101]
  11
+    __ogr_int = [0, 1, 2, 3, 4, 5, 6, 7, 101]
12 12
 
13 13
     def __init__(self, type_input):
14 14
         "Figures out the correct OGR Type based upon the input."
@@ -47,6 +47,9 @@ def __eq__(self, other):
47 47
         else:
48 48
             raise TypeError('Cannot compare with type: %s' % str(type(other)))
49 49
 
  50
+    def __ne__(self, other):
  51
+        return not (self == other)
  52
+
50 53
     def _has_str(self, arr, s):
51 54
         "Case-insensitive search of the string array for the given pattern."
52 55
         s_low = s.lower()
6  django/contrib/gis/tests/test_gdal_geom.py
@@ -17,6 +17,7 @@ def test00_geomtype(self):
17 17
             g = OGRGeomType('point')
18 18
             g = OGRGeomType('GeometrycollectioN')
19 19
             g = OGRGeomType('LINearrING')
  20
+            g = OGRGeomType('Unknown')
20 21
         except:
21 22
             self.fail('Could not create an OGRGeomType object!')
22 23
 
@@ -30,8 +31,11 @@ def test00_geomtype(self):
30 31
         self.assertEqual(True, OGRGeomType(7) == 'GeometryCollection')
31 32
         self.assertEqual(True, OGRGeomType('point') == 'POINT')
32 33
         self.assertEqual(False, OGRGeomType('point') == 2)
  34
+        self.assertEqual(True, OGRGeomType('unknown') == 0)
33 35
         self.assertEqual(True, OGRGeomType(6) == 'MULtiPolyGON')
34  
-        
  36
+        self.assertEqual(False, OGRGeomType(1) != OGRGeomType('point'))
  37
+        self.assertEqual(True, OGRGeomType('POINT') != OGRGeomType(6))
  38
+
35 39
     def test01a_wkt(self):
36 40
         "Testing WKT output."
37 41
         for g in wkt_out:

0 notes on commit 6fdd925

Please sign in to comment.
Something went wrong with that request. Please try again.