|
1 """ |
|
2 This module houses ctypes interfaces for GDAL objects. The following GDAL |
|
3 objects are supported: |
|
4 |
|
5 CoordTransform: Used for coordinate transformations from one spatial |
|
6 reference system to another. |
|
7 |
|
8 Driver: Wraps an OGR data source driver. |
|
9 |
|
10 DataSource: Wrapper for the OGR data source object, supports |
|
11 OGR-supported data sources. |
|
12 |
|
13 Envelope: A ctypes structure for bounding boxes (GDAL library |
|
14 not required). |
|
15 |
|
16 OGRGeometry: Object for accessing OGR Geometry functionality. |
|
17 |
|
18 OGRGeomType: A class for representing the different OGR Geometry |
|
19 types (GDAL library not required). |
|
20 |
|
21 SpatialReference: Represents OSR Spatial Reference objects. |
|
22 |
|
23 The GDAL library will be imported from the system path using the default |
|
24 library name for the current OS. The default library path may be overridden |
|
25 by setting `GDAL_LIBRARY_PATH` in your settings with the path to the GDAL C |
|
26 library on your system. |
|
27 |
|
28 GDAL links to a large number of external libraries that consume RAM when |
|
29 loaded. Thus, it may desirable to disable GDAL on systems with limited |
|
30 RAM resources -- this may be accomplished by setting `GDAL_LIBRARY_PATH` |
|
31 to a non-existant file location (e.g., `GDAL_LIBRARY_PATH='/null/path'`; |
|
32 setting to None/False/'' will not work as a string must be given). |
|
33 """ |
|
34 # Attempting to import objects that depend on the GDAL library. The |
|
35 # HAS_GDAL flag will be set to True if the library is present on |
|
36 # the system. |
|
37 try: |
|
38 from django.contrib.gis.gdal.driver import Driver |
|
39 from django.contrib.gis.gdal.datasource import DataSource |
|
40 from django.contrib.gis.gdal.libgdal import gdal_version, gdal_full_version, gdal_release_date, GEOJSON, GDAL_VERSION |
|
41 from django.contrib.gis.gdal.srs import SpatialReference, CoordTransform |
|
42 from django.contrib.gis.gdal.geometries import OGRGeometry |
|
43 HAS_GDAL = True |
|
44 except: |
|
45 HAS_GDAL, GEOJSON = False, False |
|
46 |
|
47 try: |
|
48 from django.contrib.gis.gdal.envelope import Envelope |
|
49 except ImportError: |
|
50 # No ctypes, but don't raise an exception. |
|
51 pass |
|
52 |
|
53 from django.contrib.gis.gdal.error import check_err, OGRException, OGRIndexError, SRSException |
|
54 from django.contrib.gis.gdal.geomtype import OGRGeomType |