Changeset 6993
- Timestamp:
- 01/04/08 00:41:13 (6 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/gis/django/contrib/gis/gdal/libgdal.py
r6914 r6993 15 15 elif os.name == 'nt': 16 16 # Windows NT shared library 17 lib_name = ' libgdal-1.dll'17 lib_name = 'gdal15.dll' 18 18 elif os.name == 'posix': 19 19 platform = os.uname()[0] … … 29 29 # This loads the GDAL/OGR C library 30 30 lgdal = CDLL(lib_name) 31 32 # On Windows, the GDAL binaries have some OSR routines exported with 33 # STDCALL, while others are not. Thus, the library will also need to 34 # be loaded up as WinDLL for said OSR functions that require the 35 # different calling convention. 36 if os.name == 'nt': 37 from ctypes import WinDLL 38 lwingdal = WinDLL(lib_name) 39 40 def std_call(func): 41 """ 42 Returns the correct STDCALL function for certain OSR routines on Win32 43 platforms. 44 """ 45 if os.name == 'nt': 46 return lwingdal[func] 47 else: 48 return lgdal[func] 31 49 32 50 #### Version-information functions. #### django/branches/gis/django/contrib/gis/gdal/prototypes/__init__.py
r6686 r6993 1 """2 This routine provides shortuct functions to generate ctypes prototypes3 for the GDAL routines.4 """5 # OGR Geometry prototypes.6 from django.contrib.gis.gdal.prototypes.geom import \7 assign_srs, clone_geom, create_geom, destroy_geom, from_wkb, from_wkt, \8 get_area, get_coord_dims, get_dims, get_envelope, get_geom_count, get_geom_name, get_geom_srs, get_geom_type, get_point_count, get_wkbsize, \9 getx, get_geom_ref, gety, getz, to_gml, to_wkt10 11 # Spatial Reference prototypes.12 from django.contrib.gis.gdal.prototypes.srs import \13 clone_srs14 15 # TEMPORARY16 from generation import double_output, string_output, void_outputdjango/branches/gis/django/contrib/gis/gdal/prototypes/srs.py
r6914 r6993 1 1 from ctypes import c_char_p, c_int, c_void_p, POINTER 2 from django.contrib.gis.gdal.libgdal import lgdal 2 from django.contrib.gis.gdal.libgdal import lgdal, std_call 3 3 from django.contrib.gis.gdal.prototypes.generation import \ 4 4 const_string_output, double_output, int_output, \ … … 21 21 22 22 # Creation & destruction. 23 clone_srs = srs_output( lgdal.OSRClone, [c_void_p])24 new_srs = srs_output( lgdal.OSRNewSpatialReference, [c_char_p])23 clone_srs = srs_output(std_call('OSRClone'), [c_void_p]) 24 new_srs = srs_output(std_call('OSRNewSpatialReference'), [c_char_p]) 25 25 release_srs = void_output(lgdal.OSRRelease, [c_void_p], errcheck=False) 26 destroy_srs = void_output( lgdal.OSRDestroySpatialReference, [c_void_p], errcheck=False)26 destroy_srs = void_output(std_call('OSRDestroySpatialReference'), [c_void_p], errcheck=False) 27 27 srs_validate = void_output(lgdal.OSRValidate, [c_void_p]) 28 28 … … 35 35 from_wkt = void_output(lgdal.OSRImportFromWkt, [c_void_p, POINTER(c_char_p)]) 36 36 from_proj = void_output(lgdal.OSRImportFromProj4, [c_void_p, c_char_p]) 37 from_epsg = void_output( lgdal.OSRImportFromEPSG, [c_void_p, c_int])37 from_epsg = void_output(std_call('OSRImportFromEPSG'), [c_void_p, c_int]) 38 38 from_xml = void_output(lgdal.OSRImportFromXML, [c_void_p, c_char_p]) 39 39 … … 50 50 51 51 # For exporting to WKT, PROJ.4, "Pretty" WKT, and XML. 52 to_wkt = string_output( lgdal.OSRExportToWkt, [c_void_p, POINTER(c_char_p)])53 to_proj = string_output( lgdal.OSRExportToProj4, [c_void_p, POINTER(c_char_p)])54 to_pretty_wkt = string_output( lgdal.OSRExportToPrettyWkt, [c_void_p, POINTER(c_char_p), c_int], offset=-2)52 to_wkt = string_output(std_call('OSRExportToWkt'), [c_void_p, POINTER(c_char_p)]) 53 to_proj = string_output(std_call('OSRExportToProj4'), [c_void_p, POINTER(c_char_p)]) 54 to_pretty_wkt = string_output(std_call('OSRExportToPrettyWkt'), [c_void_p, POINTER(c_char_p), c_int], offset=-2) 55 55 56 # FIXME: This leaks memory, still don't know why.56 # Memory leak fixed in GDAL 1.5; still exists in 1.4. 57 57 to_xml = string_output(lgdal.OSRExportToXML, [c_void_p, POINTER(c_char_p), c_char_p], offset=-2) 58 58 59 59 # String attribute retrival routines. 60 get_attr_value = const_string_output( lgdal.OSRGetAttrValue, [c_void_p, c_char_p, c_int])60 get_attr_value = const_string_output(std_call('OSRGetAttrValue'), [c_void_p, c_char_p, c_int]) 61 61 get_auth_name = const_string_output(lgdal.OSRGetAuthorityName, [c_void_p, c_char_p]) 62 62 get_auth_code = const_string_output(lgdal.OSRGetAuthorityCode, [c_void_p, c_char_p]) … … 68 68 69 69 # Coordinate transformation 70 new_ct= srs_output( lgdal.OCTNewCoordinateTransformation, [c_void_p, c_void_p])71 destroy_ct = void_output( lgdal.OCTDestroyCoordinateTransformation, [c_void_p], errcheck=False)70 new_ct= srs_output(std_call('OCTNewCoordinateTransformation'), [c_void_p, c_void_p]) 71 destroy_ct = void_output(std_call('OCTDestroyCoordinateTransformation'), [c_void_p], errcheck=False)
