| 19 | | |
|---|
| 20 | | # These routines (needed by GeoManager), default to False. |
|---|
| 21 | | ASGML, ASKML, DISTANCE, DISTANCE_SPHEROID, EXTENT, TRANSFORM, UNION, VERSION = tuple(False for i in range(8)) |
|---|
| 22 | | |
|---|
| 23 | | # Lookup types in which the rest of the parameters are not |
|---|
| 24 | | # needed to be substitute in the WHERE SQL (e.g., the 'relate' |
|---|
| 25 | | # operation on Oracle does not need the mask substituted back |
|---|
| 26 | | # into the query SQL.). |
|---|
| 27 | | LIMITED_WHERE = [] |
|---|
| 31 | | from django.contrib.gis.db.backend.postgis.adaptor import \ |
|---|
| 32 | | PostGISAdaptor as GeoAdaptor |
|---|
| 33 | | from django.contrib.gis.db.backend.postgis.field import \ |
|---|
| 34 | | PostGISField as GeoBackendField |
|---|
| 35 | | from django.contrib.gis.db.backend.postgis.creation import create_spatial_db |
|---|
| 36 | | from django.contrib.gis.db.backend.postgis.query import \ |
|---|
| 37 | | get_geo_where_clause, POSTGIS_TERMS as GIS_TERMS, \ |
|---|
| 38 | | ASGML, ASKML, DISTANCE, DISTANCE_SPHEROID, DISTANCE_FUNCTIONS, \ |
|---|
| 39 | | EXTENT, GEOM_SELECT, TRANSFORM, UNION, \ |
|---|
| 40 | | MAJOR_VERSION, MINOR_VERSION1, MINOR_VERSION2 |
|---|
| 41 | | # PostGIS version info is needed to determine calling order of some |
|---|
| 42 | | # stored procedures (e.g., AsGML()). |
|---|
| 43 | | VERSION = (MAJOR_VERSION, MINOR_VERSION1, MINOR_VERSION2) |
|---|
| 44 | | SPATIAL_BACKEND = 'postgis' |
|---|
| | 12 | from django.contrib.gis.db.backend.postgis import create_spatial_db, get_geo_where_clause, SpatialBackend |
|---|
| 46 | | from django.contrib.gis.db.backend.adaptor import WKTAdaptor as GeoAdaptor |
|---|
| 47 | | from django.contrib.gis.db.backend.oracle.field import \ |
|---|
| 48 | | OracleSpatialField as GeoBackendField |
|---|
| 49 | | from django.contrib.gis.db.backend.oracle.creation import create_spatial_db |
|---|
| 50 | | from django.contrib.gis.db.backend.oracle.query import \ |
|---|
| 51 | | get_geo_where_clause, ORACLE_SPATIAL_TERMS as GIS_TERMS, \ |
|---|
| 52 | | ASGML, DISTANCE, DISTANCE_FUNCTIONS, GEOM_SELECT, TRANSFORM, UNION |
|---|
| 53 | | SPATIAL_BACKEND = 'oracle' |
|---|
| 54 | | LIMITED_WHERE = ['relate'] |
|---|
| | 14 | from django.contrib.gis.db.backend.oracle import create_spatial_db, get_geo_where_clause, SpatialBackend |
|---|
| 56 | | from django.contrib.gis.db.backend.adaptor import WKTAdaptor as GeoAdaptor |
|---|
| 57 | | from django.contrib.gis.db.backend.mysql.field import \ |
|---|
| 58 | | MySQLGeoField as GeoBackendField |
|---|
| 59 | | from django.contrib.gis.db.backend.mysql.creation import create_spatial_db |
|---|
| 60 | | from django.contrib.gis.db.backend.mysql.query import \ |
|---|
| 61 | | get_geo_where_clause, MYSQL_GIS_TERMS as GIS_TERMS, GEOM_SELECT |
|---|
| 62 | | DISTANCE_FUNCTIONS = {} |
|---|
| 63 | | SPATIAL_BACKEND = 'mysql' |
|---|
| | 16 | from django.contrib.gis.db.backend.mysql import create_spatial_db, get_geo_where_clause, SpatialBackend |
|---|
| 66 | | |
|---|
| 67 | | class SpatialBackend(object): |
|---|
| 68 | | "A container for properties of the SpatialBackend." |
|---|
| 69 | | # Stored procedure names used by the `GeoManager`. |
|---|
| 70 | | as_kml = ASKML |
|---|
| 71 | | as_gml = ASGML |
|---|
| 72 | | distance = DISTANCE |
|---|
| 73 | | distance_spheroid = DISTANCE_SPHEROID |
|---|
| 74 | | extent = EXTENT |
|---|
| 75 | | name = SPATIAL_BACKEND |
|---|
| 76 | | select = GEOM_SELECT |
|---|
| 77 | | transform = TRANSFORM |
|---|
| 78 | | union = UNION |
|---|
| 79 | | |
|---|
| 80 | | # Version information, if defined. |
|---|
| 81 | | version = VERSION |
|---|
| 82 | | |
|---|
| 83 | | # All valid GIS lookup terms, and distance functions. |
|---|
| 84 | | gis_terms = GIS_TERMS |
|---|
| 85 | | distance_functions = DISTANCE_FUNCTIONS |
|---|
| 86 | | |
|---|
| 87 | | # Lookup types where additional WHERE parameters are excluded. |
|---|
| 88 | | limited_where = LIMITED_WHERE |
|---|
| 89 | | |
|---|
| 90 | | # Shortcut booleans. |
|---|
| 91 | | mysql = SPATIAL_BACKEND == 'mysql' |
|---|
| 92 | | oracle = SPATIAL_BACKEND == 'oracle' |
|---|
| 93 | | postgis = SPATIAL_BACKEND == 'postgis' |
|---|
| 94 | | |
|---|
| 95 | | # Class for the backend field. |
|---|
| 96 | | Field = GeoBackendField |
|---|
| 97 | | |
|---|
| 98 | | # Adaptor class used for quoting GEOS geometries in the database. |
|---|
| 99 | | Adaptor = GeoAdaptor |
|---|