|
0
|
1 |
""" |
|
|
2 |
This module holds the base `SpatialBackend` object, which is |
|
|
3 |
instantiated by each spatial backend with the features it has. |
|
|
4 |
""" |
|
|
5 |
# TODO: Create a `Geometry` protocol and allow user to use |
|
|
6 |
# different Geometry objects -- for now we just use GEOSGeometry. |
|
|
7 |
from django.contrib.gis.geos import GEOSGeometry, GEOSException |
|
|
8 |
|
|
|
9 |
class BaseSpatialBackend(object): |
|
|
10 |
Geometry = GEOSGeometry |
|
|
11 |
GeometryException = GEOSException |
|
|
12 |
|
|
|
13 |
def __init__(self, **kwargs): |
|
|
14 |
kwargs.setdefault('distance_functions', {}) |
|
|
15 |
kwargs.setdefault('limited_where', {}) |
|
|
16 |
for k, v in kwargs.iteritems(): setattr(self, k, v) |
|
|
17 |
|
|
|
18 |
def __getattr__(self, name): |
|
|
19 |
""" |
|
|
20 |
All attributes of the spatial backend return False by default. |
|
|
21 |
""" |
|
|
22 |
try: |
|
|
23 |
return self.__dict__[name] |
|
|
24 |
except KeyError: |
|
|
25 |
return False |
|
|
26 |
|