Added support for gdal 1.9.

This commit is contained in:
danger 2012-06-10 23:59:50 +02:00 committed by Florian Apolloner
parent f8ef93a657
commit 45a1a54b0b
1 changed files with 11 additions and 10 deletions

View File

@ -15,31 +15,32 @@ if lib_path:
lib_names = None lib_names = None
elif os.name == 'nt': elif os.name == 'nt':
# Windows NT shared libraries # Windows NT shared libraries
lib_names = ['gdal18', 'gdal17', 'gdal16', 'gdal15'] lib_names = ['gdal19', 'gdal18', 'gdal17', 'gdal16', 'gdal15']
elif os.name == 'posix': elif os.name == 'posix':
# *NIX library names. # *NIX library names.
lib_names = ['gdal', 'GDAL', 'gdal1.8.0', 'gdal1.7.0', 'gdal1.6.0', 'gdal1.5.0', 'gdal1.4.0'] lib_names = ['gdal', 'GDAL', 'gdal1.9.0', 'gdal1.8.0', 'gdal1.7.0',
'gdal1.6.0', 'gdal1.5.0', 'gdal1.4.0']
else: else:
raise OGRException('Unsupported OS "%s"' % os.name) raise OGRException('Unsupported OS "%s"' % os.name)
# Using the ctypes `find_library` utility to find the # Using the ctypes `find_library` utility to find the
# path to the GDAL library from the list of library names. # path to the GDAL library from the list of library names.
if lib_names: if lib_names:
for lib_name in lib_names: for lib_name in lib_names:
lib_path = find_library(lib_name) lib_path = find_library(lib_name)
if not lib_path is None: break if not lib_path is None: break
if lib_path is None: if lib_path is None:
raise OGRException('Could not find the GDAL library (tried "%s"). ' raise OGRException('Could not find the GDAL library (tried "%s"). '
'Try setting GDAL_LIBRARY_PATH in your settings.' % 'Try setting GDAL_LIBRARY_PATH in your settings.' %
'", "'.join(lib_names)) '", "'.join(lib_names))
# This loads the GDAL/OGR C library # This loads the GDAL/OGR C library
lgdal = CDLL(lib_path) lgdal = CDLL(lib_path)
# On Windows, the GDAL binaries have some OSR routines exported with # On Windows, the GDAL binaries have some OSR routines exported with
# STDCALL, while others are not. Thus, the library will also need to # STDCALL, while others are not. Thus, the library will also need to
# be loaded up as WinDLL for said OSR functions that require the # be loaded up as WinDLL for said OSR functions that require the
# different calling convention. # different calling convention.
if os.name == 'nt': if os.name == 'nt':
from ctypes import WinDLL from ctypes import WinDLL
@ -66,11 +67,11 @@ def gdal_version():
"Returns only the GDAL version number information." "Returns only the GDAL version number information."
return _version_info('RELEASE_NAME') return _version_info('RELEASE_NAME')
def gdal_full_version(): def gdal_full_version():
"Returns the full GDAL version information." "Returns the full GDAL version information."
return _version_info('') return _version_info('')
def gdal_release_date(date=False): def gdal_release_date(date=False):
""" """
Returns the release date in a string format, e.g, "2007/06/27". Returns the release date in a string format, e.g, "2007/06/27".
If the date keyword argument is set to True, a Python datetime object If the date keyword argument is set to True, a Python datetime object