diff options
author | Étienne Loks <etienne.loks@peacefrogs.net> | 2012-05-09 17:20:18 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@peacefrogs.net> | 2012-05-09 17:20:18 +0200 |
commit | 7f3a63273cff751956ff4e5f6dd9f6f02f8c903c (patch) | |
tree | 0ae6fbc20f022aa6f8d4f813435d7ee770917932 /chimere | |
parent | 3e5905baa8c30e82a296261287850c30f08376cf (diff) | |
download | Chimère-7f3a63273cff751956ff4e5f6dd9f6f02f8c903c.tar.bz2 Chimère-7f3a63273cff751956ff4e5f6dd9f6f02f8c903c.zip |
Make GDAL dependancy optional
Diffstat (limited to 'chimere')
-rw-r--r-- | chimere/utils.py | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/chimere/utils.py b/chimere/utils.py index 09255d0..c7502db 100644 --- a/chimere/utils.py +++ b/chimere/utils.py @@ -31,7 +31,6 @@ import unicodedata import zipfile from lxml import etree -from osgeo import osr from django.conf import settings from django.contrib.gis.gdal import DataSource, Driver, OGRGeometry, \ @@ -237,12 +236,16 @@ class ShapefileManager(ImportManager): srid = self.importer_instance.srid if not srid: prjfilename = tmpdir + os.sep + sources[2] - with open(prjfilename, 'r') as prj_file: - prj_txt = prj_file.read() - srs = osr.SpatialReference() - srs.ImportFromESRI([prj_txt]) - srs.AutoIdentifyEPSG() - srid = srs.GetAuthorityCode(None) + try: + from osgeo import osr + with open(prjfilename, 'r') as prj_file: + prj_txt = prj_file.read() + srs = osr.SpatialReference() + srs.ImportFromESRI([prj_txt]) + srs.AutoIdentifyEPSG() + srid = srs.GetAuthorityCode(None) + except ImportError: + pass if not srid: # try with the default projection srid = settings.CHIMERE_EPSG_DISPLAY_PROJECTION |