2008-08-06 02:13:06 +08:00
|
|
|
"""
|
|
|
|
This module houses ctypes interfaces for GDAL objects. The following GDAL
|
|
|
|
objects are supported:
|
|
|
|
|
|
|
|
CoordTransform: Used for coordinate transformations from one spatial
|
|
|
|
reference system to another.
|
|
|
|
|
|
|
|
Driver: Wraps an OGR data source driver.
|
2012-06-17 04:57:33 +08:00
|
|
|
|
2008-08-06 02:13:06 +08:00
|
|
|
DataSource: Wrapper for the OGR data source object, supports
|
|
|
|
OGR-supported data sources.
|
|
|
|
|
|
|
|
Envelope: A ctypes structure for bounding boxes (GDAL library
|
|
|
|
not required).
|
|
|
|
|
2010-01-27 11:01:13 +08:00
|
|
|
OGRGeometry: Object for accessing OGR Geometry functionality.
|
2008-08-06 02:13:06 +08:00
|
|
|
|
|
|
|
OGRGeomType: A class for representing the different OGR Geometry
|
|
|
|
types (GDAL library not required).
|
|
|
|
|
|
|
|
SpatialReference: Represents OSR Spatial Reference objects.
|
|
|
|
|
2012-06-17 04:57:33 +08:00
|
|
|
The GDAL library will be imported from the system path using the default
|
2008-08-06 02:13:06 +08:00
|
|
|
library name for the current OS. The default library path may be overridden
|
2012-06-17 04:57:33 +08:00
|
|
|
by setting `GDAL_LIBRARY_PATH` in your settings with the path to the GDAL C
|
|
|
|
library on your system.
|
2008-08-06 02:13:06 +08:00
|
|
|
|
2012-06-17 04:57:33 +08:00
|
|
|
GDAL links to a large number of external libraries that consume RAM when
|
2008-08-06 02:13:06 +08:00
|
|
|
loaded. Thus, it may desirable to disable GDAL on systems with limited
|
|
|
|
RAM resources -- this may be accomplished by setting `GDAL_LIBRARY_PATH`
|
2012-06-17 04:57:33 +08:00
|
|
|
to a non-existant file location (e.g., `GDAL_LIBRARY_PATH='/null/path'`;
|
2008-08-06 02:13:06 +08:00
|
|
|
setting to None/False/'' will not work as a string must be given).
|
|
|
|
"""
|
|
|
|
# Attempting to import objects that depend on the GDAL library. The
|
|
|
|
# HAS_GDAL flag will be set to True if the library is present on
|
|
|
|
# the system.
|
|
|
|
try:
|
|
|
|
from django.contrib.gis.gdal.driver import Driver
|
|
|
|
from django.contrib.gis.gdal.datasource import DataSource
|
2012-10-05 04:35:59 +08:00
|
|
|
from django.contrib.gis.gdal.libgdal import gdal_version, gdal_full_version, GDAL_VERSION
|
2008-08-06 02:13:06 +08:00
|
|
|
from django.contrib.gis.gdal.srs import SpatialReference, CoordTransform
|
2010-03-26 04:00:27 +08:00
|
|
|
from django.contrib.gis.gdal.geometries import OGRGeometry
|
2008-08-06 02:13:06 +08:00
|
|
|
HAS_GDAL = True
|
2012-09-24 22:03:12 +08:00
|
|
|
except Exception:
|
2012-07-16 03:07:02 +08:00
|
|
|
HAS_GDAL = False
|
2008-08-06 02:13:06 +08:00
|
|
|
|
2010-01-27 11:01:13 +08:00
|
|
|
try:
|
|
|
|
from django.contrib.gis.gdal.envelope import Envelope
|
|
|
|
except ImportError:
|
|
|
|
# No ctypes, but don't raise an exception.
|
|
|
|
pass
|
|
|
|
|
|
|
|
from django.contrib.gis.gdal.error import check_err, OGRException, OGRIndexError, SRSException
|
|
|
|
from django.contrib.gis.gdal.geomtype import OGRGeomType
|