Anonymous committed 7b28d6f

gis: gdal: Fixed #7434 (no real defect, just clarified how to disable GDAL); fixed `!=` operator and added support for 'Unknown` on `OGRGeomType`.

  • Participants
  • Parent commits cc52aa0
  • Branches gis

Comments (0)

Files changed (3)

File django/contrib/gis/gdal/

  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.
   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

File django/contrib/gis/gdal/

     "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',
-    __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."
             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()

File django/contrib/gis/tests/

             g = OGRGeomType('point')
             g = OGRGeomType('GeometrycollectioN')
             g = OGRGeomType('LINearrING')
+            g = OGRGeomType('Unknown')
   'Could not create an OGRGeomType object!')
         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: