~ubuntu-branches/ubuntu/quantal/python-django/quantal-security

« back to all changes in this revision

Viewing changes to django/contrib/gis/gdal/libgdal.py

  • Committer: Bazaar Package Importer
  • Author(s): Chris Lamb
  • Date: 2010-05-21 07:52:55 UTC
  • mfrom: (1.3.6 upstream)
  • mto: This revision was merged to the branch mainline in revision 28.
  • Revision ID: james.westby@ubuntu.com-20100521075255-ii78v1dyfmyu3uzx
Tags: upstream-1.2
ImportĀ upstreamĀ versionĀ 1.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
import os, sys
 
1
import os, re, sys
2
2
from ctypes import c_char_p, CDLL
3
3
from ctypes.util import find_library
4
4
from django.contrib.gis.gdal.error import OGRException
81
81
    d = date_type(yy, mm, dd)
82
82
    if date: return d
83
83
    else: return d.strftime('%Y/%m/%d')
 
84
 
 
85
version_regex = re.compile(r'^(?P<major>\d+)\.(?P<minor>\d+)(\.(?P<subminor>\d+))?')
 
86
def gdal_version_info():
 
87
    ver = gdal_version()
 
88
    m = version_regex.match(ver)
 
89
    if not m: raise OGRException('Could not parse GDAL version string "%s"' % ver)
 
90
    return dict([(key, m.group(key)) for key in ('major', 'minor', 'subminor')])
 
91
 
 
92
_verinfo = gdal_version_info()
 
93
GDAL_MAJOR_VERSION = int(_verinfo['major'])
 
94
GDAL_MINOR_VERSION = int(_verinfo['minor'])
 
95
GDAL_SUBMINOR_VERSION = _verinfo['subminor'] and int(_verinfo['subminor'])
 
96
GDAL_VERSION = (GDAL_MAJOR_VERSION, GDAL_MINOR_VERSION, GDAL_SUBMINOR_VERSION)
 
97
del _verinfo
 
98
 
 
99
# GeoJSON support is available only in GDAL 1.5+.
 
100
if GDAL_VERSION >= (1, 5):
 
101
    GEOJSON = True
 
102
else:
 
103
    GEOJSON = False
 
104