PageRenderTime 26ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

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