2015-01-19 23:09:41 +08:00
|
|
|
import re
|
2015-01-13 04:20:40 +08:00
|
|
|
|
2015-01-15 18:35:35 +08:00
|
|
|
from django.contrib.gis.db.models import aggregates
|
|
|
|
|
2015-01-13 04:20:40 +08:00
|
|
|
|
2017-01-19 15:39:46 +08:00
|
|
|
class BaseSpatialFeatures:
|
2015-01-13 04:20:40 +08:00
|
|
|
gis_enabled = True
|
|
|
|
|
|
|
|
# Does the database contain a SpatialRefSys model to store SRID information?
|
|
|
|
has_spatialrefsys_table = True
|
|
|
|
|
|
|
|
# Does the backend support the django.contrib.gis.utils.add_srs_entry() utility?
|
|
|
|
supports_add_srs_entry = True
|
|
|
|
# Does the backend introspect GeometryField to its subtypes?
|
|
|
|
supports_geometry_field_introspection = True
|
|
|
|
|
2014-11-04 05:03:59 +08:00
|
|
|
# Does the backend support storing 3D geometries?
|
|
|
|
supports_3d_storage = False
|
2015-01-13 04:20:40 +08:00
|
|
|
# Reference implementation of 3D functions is:
|
2017-03-17 02:01:45 +08:00
|
|
|
# https://postgis.net/docs/PostGIS_Special_Functions_Index.html#PostGIS_3D_Functions
|
2015-01-13 04:20:40 +08:00
|
|
|
supports_3d_functions = False
|
|
|
|
# Does the database support SRID transform operations?
|
|
|
|
supports_transform = True
|
|
|
|
# Do geometric relationship operations operate on real shapes (or only on bounding boxes)?
|
|
|
|
supports_real_shape_operations = True
|
|
|
|
# Can geometry fields be null?
|
|
|
|
supports_null_geometries = True
|
2016-06-17 23:03:50 +08:00
|
|
|
# Are empty geometries supported?
|
|
|
|
supports_empty_geometries = False
|
2018-07-18 23:54:15 +08:00
|
|
|
# Can the function be applied on geodetic coordinate systems?
|
2015-01-13 04:20:40 +08:00
|
|
|
supports_distance_geodetic = True
|
2015-01-24 05:45:57 +08:00
|
|
|
supports_length_geodetic = True
|
2015-10-11 01:22:42 +08:00
|
|
|
supports_perimeter_geodetic = False
|
2016-11-16 20:07:36 +08:00
|
|
|
supports_area_geodetic = True
|
2015-01-13 04:20:40 +08:00
|
|
|
# Is the database able to count vertices on polygons (with `num_points`)?
|
|
|
|
supports_num_points_poly = True
|
|
|
|
|
|
|
|
# The following properties indicate if the database backend support
|
|
|
|
# certain lookups (dwithin, left and right, relate, ...)
|
|
|
|
supports_left_right_lookups = False
|
|
|
|
|
2015-06-19 23:46:03 +08:00
|
|
|
# Does the database have raster support?
|
|
|
|
supports_raster = False
|
|
|
|
|
2015-08-20 02:37:31 +08:00
|
|
|
# Does the database support a unique index on geometry fields?
|
|
|
|
supports_geometry_field_unique_index = True
|
|
|
|
|
2015-01-13 04:20:40 +08:00
|
|
|
@property
|
|
|
|
def supports_bbcontains_lookup(self):
|
|
|
|
return 'bbcontains' in self.connection.ops.gis_operators
|
|
|
|
|
|
|
|
@property
|
|
|
|
def supports_contained_lookup(self):
|
|
|
|
return 'contained' in self.connection.ops.gis_operators
|
|
|
|
|
2015-01-17 22:43:02 +08:00
|
|
|
@property
|
|
|
|
def supports_crosses_lookup(self):
|
|
|
|
return 'crosses' in self.connection.ops.gis_operators
|
|
|
|
|
2017-07-26 15:40:19 +08:00
|
|
|
@property
|
|
|
|
def supports_distances_lookups(self):
|
|
|
|
return self.has_Distance_function
|
|
|
|
|
2015-01-13 04:20:40 +08:00
|
|
|
@property
|
|
|
|
def supports_dwithin_lookup(self):
|
|
|
|
return 'dwithin' in self.connection.ops.gis_operators
|
|
|
|
|
|
|
|
@property
|
|
|
|
def supports_relate_lookup(self):
|
|
|
|
return 'relate' in self.connection.ops.gis_operators
|
|
|
|
|
2016-04-06 19:50:25 +08:00
|
|
|
@property
|
|
|
|
def supports_isvalid_lookup(self):
|
2017-03-29 20:56:58 +08:00
|
|
|
return self.has_IsValid_function
|
2016-04-06 19:50:25 +08:00
|
|
|
|
2017-01-03 22:49:00 +08:00
|
|
|
# Is the aggregate supported by the database?
|
2015-01-13 04:20:40 +08:00
|
|
|
@property
|
|
|
|
def supports_collect_aggr(self):
|
2015-01-15 18:35:35 +08:00
|
|
|
return aggregates.Collect not in self.connection.ops.disallowed_aggregates
|
2015-01-13 04:20:40 +08:00
|
|
|
|
|
|
|
@property
|
|
|
|
def supports_extent_aggr(self):
|
2015-01-15 18:35:35 +08:00
|
|
|
return aggregates.Extent not in self.connection.ops.disallowed_aggregates
|
2015-01-13 04:20:40 +08:00
|
|
|
|
|
|
|
@property
|
|
|
|
def supports_make_line_aggr(self):
|
2015-01-15 18:35:35 +08:00
|
|
|
return aggregates.MakeLine not in self.connection.ops.disallowed_aggregates
|
2015-01-13 04:20:40 +08:00
|
|
|
|
2017-01-03 22:49:00 +08:00
|
|
|
@property
|
|
|
|
def supports_union_aggr(self):
|
|
|
|
return aggregates.Union not in self.connection.ops.disallowed_aggregates
|
|
|
|
|
2015-01-19 23:09:41 +08:00
|
|
|
def __getattr__(self, name):
|
|
|
|
m = re.match(r'has_(\w*)_function$', name)
|
|
|
|
if m:
|
|
|
|
func_name = m.group(1)
|
2015-09-15 00:19:19 +08:00
|
|
|
return func_name not in self.connection.ops.unsupported_functions
|
|
|
|
raise AttributeError
|