2013-07-29 21:50:58 +08:00
|
|
|
from importlib import import_module
|
|
|
|
|
2009-12-22 23:18:51 +08:00
|
|
|
from django.conf import settings
|
|
|
|
from django.core.exceptions import ImproperlyConfigured
|
|
|
|
|
|
|
|
geom_backend = getattr(settings, 'GEOMETRY_BACKEND', 'geos')
|
|
|
|
|
|
|
|
try:
|
2013-07-29 21:50:58 +08:00
|
|
|
module = import_module('django.contrib.gis.geometry.backend.%s' % geom_backend)
|
2012-04-29 00:09:37 +08:00
|
|
|
except ImportError:
|
2009-12-22 23:18:51 +08:00
|
|
|
try:
|
|
|
|
module = import_module(geom_backend)
|
2012-04-29 00:09:37 +08:00
|
|
|
except ImportError:
|
2009-12-22 23:18:51 +08:00
|
|
|
raise ImproperlyConfigured('Could not import user-defined GEOMETRY_BACKEND '
|
|
|
|
'"%s".' % geom_backend)
|
|
|
|
|
|
|
|
try:
|
|
|
|
Geometry = module.Geometry
|
|
|
|
GeometryException = module.GeometryException
|
|
|
|
except AttributeError:
|
|
|
|
raise ImproperlyConfigured('Cannot import Geometry from the "%s" '
|
|
|
|
'geometry backend.' % geom_backend)
|