diff --git a/django/contrib/gis/gdal/libgdal.py b/django/contrib/gis/gdal/libgdal.py index f409252861..fe5be2a3f3 100644 --- a/django/contrib/gis/gdal/libgdal.py +++ b/django/contrib/gis/gdal/libgdal.py @@ -7,7 +7,7 @@ from django.contrib.gis.gdal.error import OGRException try: from django.conf import settings lib_name = settings.GDAL_LIBRARY_PATH -except (AttributeError, EnvironmentError): +except (AttributeError, EnvironmentError, ImportError): lib_name = None if lib_name: @@ -15,7 +15,6 @@ if lib_name: elif os.name == 'nt': # Windows NT shared library lib_name = 'libgdal-1.dll' - errcheck_flag = False elif os.name == 'posix': platform = os.uname()[0] if platform == 'Darwin': @@ -24,7 +23,6 @@ elif os.name == 'posix': else: # Attempting to use .so extension for all other platforms. lib_name = 'libgdal.so' - errcheck_flag = True else: raise OGRException('Unsupported OS "%s"' % os.name) diff --git a/django/contrib/gis/gdal/prototypes/ds.py b/django/contrib/gis/gdal/prototypes/ds.py index 18d8e4c884..3a7fb05833 100644 --- a/django/contrib/gis/gdal/prototypes/ds.py +++ b/django/contrib/gis/gdal/prototypes/ds.py @@ -5,7 +5,7 @@ """ from ctypes import c_char_p, c_int, c_long, c_void_p, POINTER from django.contrib.gis.gdal.envelope import OGREnvelope -from django.contrib.gis.gdal.libgdal import lgdal, errcheck_flag +from django.contrib.gis.gdal.libgdal import lgdal from django.contrib.gis.gdal.prototypes.generation import \ const_string_output, double_output, geom_output, int_output, \ srs_output, void_output, voidptr_output @@ -47,7 +47,7 @@ get_field_defn = voidptr_output(lgdal.OGR_FD_GetFieldDefn, [c_void_p, c_int]) ### Feature Routines ### clone_feature = voidptr_output(lgdal.OGR_F_Clone, [c_void_p]) -destroy_feature = void_output(lgdal.OGR_F_Destroy, [c_void_p], errcheck=errcheck_flag) +destroy_feature = void_output(lgdal.OGR_F_Destroy, [c_void_p], errcheck=False) feature_equal = int_output(lgdal.OGR_F_Equal, [c_void_p, c_void_p]) get_feat_geom_ref = geom_output(lgdal.OGR_F_GetGeometryRef, [c_void_p]) get_feat_field_count = int_output(lgdal.OGR_F_GetFieldCount, [c_void_p]) diff --git a/django/contrib/gis/gdal/prototypes/geom.py b/django/contrib/gis/gdal/prototypes/geom.py index 8b1167eea3..dd449ae024 100644 --- a/django/contrib/gis/gdal/prototypes/geom.py +++ b/django/contrib/gis/gdal/prototypes/geom.py @@ -1,6 +1,6 @@ from ctypes import c_char, c_char_p, c_double, c_int, c_ubyte, c_void_p, POINTER from django.contrib.gis.gdal.envelope import OGREnvelope -from django.contrib.gis.gdal.libgdal import lgdal, errcheck_flag +from django.contrib.gis.gdal.libgdal import lgdal from django.contrib.gis.gdal.prototypes.errcheck import check_bool, check_envelope from django.contrib.gis.gdal.prototypes.generation import \ const_string_output, double_output, geom_output, int_output, \ @@ -72,7 +72,7 @@ get_geom_name = const_string_output(lgdal.OGR_G_GetGeometryName, [c_void_p]) get_geom_type = int_output(lgdal.OGR_G_GetGeometryType, [c_void_p]) get_point_count = int_output(lgdal.OGR_G_GetPointCount, [c_void_p]) get_point = void_output(lgdal.OGR_G_GetPoint, [c_void_p, c_int, POINTER(c_double), POINTER(c_double), POINTER(c_double)], errcheck=False) -geom_close_rings = void_output(lgdal.OGR_G_CloseRings, [c_void_p], errcheck=errcheck_flag) +geom_close_rings = void_output(lgdal.OGR_G_CloseRings, [c_void_p], errcheck=False) # Topology routines. ogr_contains = topology_func(lgdal.OGR_G_Contains) @@ -85,8 +85,8 @@ ogr_touches = topology_func(lgdal.OGR_G_Touches) ogr_within = topology_func(lgdal.OGR_G_Within) # Transformation routines. -geom_transform = void_output(lgdal.OGR_G_Transform, [c_void_p, c_void_p], errcheck=True) -geom_transform_to = void_output(lgdal.OGR_G_TransformTo, [c_void_p, c_void_p], errcheck=True) +geom_transform = void_output(lgdal.OGR_G_Transform, [c_void_p, c_void_p]) +geom_transform_to = void_output(lgdal.OGR_G_TransformTo, [c_void_p, c_void_p]) # For retrieving the envelope of the geometry. get_envelope = lgdal.OGR_G_GetEnvelope diff --git a/django/contrib/gis/gdal/prototypes/srs.py b/django/contrib/gis/gdal/prototypes/srs.py index 620f9558a5..ecac32de20 100644 --- a/django/contrib/gis/gdal/prototypes/srs.py +++ b/django/contrib/gis/gdal/prototypes/srs.py @@ -1,5 +1,5 @@ from ctypes import c_char_p, c_int, c_void_p, POINTER -from django.contrib.gis.gdal.libgdal import lgdal, errcheck_flag +from django.contrib.gis.gdal.libgdal import lgdal from django.contrib.gis.gdal.prototypes.generation import \ const_string_output, double_output, int_output, \ srs_output, string_output, void_output @@ -22,8 +22,8 @@ def units_func(f): # Creation & destruction. clone_srs = srs_output(lgdal.OSRClone, [c_void_p]) new_srs = srs_output(lgdal.OSRNewSpatialReference, [c_char_p]) -release_srs = void_output(lgdal.OSRRelease, [c_void_p], errcheck=errcheck_flag) -destroy_srs = void_output(lgdal.OSRDestroySpatialReference, [c_void_p], errcheck=errcheck_flag) +release_srs = void_output(lgdal.OSRRelease, [c_void_p], errcheck=False) +destroy_srs = void_output(lgdal.OSRDestroySpatialReference, [c_void_p], errcheck=False) srs_validate = void_output(lgdal.OSRValidate, [c_void_p]) # Getting the semi_major, semi_minor, and flattening functions. @@ -68,4 +68,4 @@ isprojected = int_output(lgdal.OSRIsProjected, [c_void_p]) # Coordinate transformation new_ct= srs_output(lgdal.OCTNewCoordinateTransformation, [c_void_p, c_void_p]) -destroy_ct = void_output(lgdal.OCTDestroyCoordinateTransformation, [c_void_p], errcheck=errcheck_flag) +destroy_ct = void_output(lgdal.OCTDestroyCoordinateTransformation, [c_void_p], errcheck=False)