summaryrefslogtreecommitdiff
path: root/django/contrib/gis
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2022-02-04 08:08:27 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2022-02-07 20:37:05 +0100
commit7119f40c9881666b6f9b5cf7df09ee1d21cc8344 (patch)
treefa50869f5614295f462d9bf77fec59365c621609 /django/contrib/gis
parent9c19aff7c7561e3a82978a272ecdaad40dda5c00 (diff)
downloaddjango-7119f40c9881666b6f9b5cf7df09ee1d21cc8344.tar.gz
Refs #33476 -- Refactored code to strictly match 88 characters line length.
Diffstat (limited to 'django/contrib/gis')
-rw-r--r--django/contrib/gis/db/backends/base/operations.py6
-rw-r--r--django/contrib/gis/db/backends/oracle/features.py3
-rw-r--r--django/contrib/gis/db/backends/oracle/operations.py8
-rw-r--r--django/contrib/gis/db/backends/oracle/schema.py5
-rw-r--r--django/contrib/gis/db/backends/postgis/const.py4
-rw-r--r--django/contrib/gis/db/backends/postgis/introspection.py4
-rw-r--r--django/contrib/gis/db/backends/postgis/operations.py6
-rw-r--r--django/contrib/gis/db/models/functions.py6
-rw-r--r--django/contrib/gis/db/models/lookups.py6
-rw-r--r--django/contrib/gis/gdal/geometries.py2
-rw-r--r--django/contrib/gis/gdal/layer.py8
-rw-r--r--django/contrib/gis/gdal/srs.py3
-rw-r--r--django/contrib/gis/geos/polygon.py6
-rw-r--r--django/contrib/gis/management/commands/ogrinspect.py4
-rw-r--r--django/contrib/gis/serializers/geojson.py6
-rw-r--r--django/contrib/gis/sitemaps/kml.py3
-rw-r--r--django/contrib/gis/utils/layermapping.py6
-rw-r--r--django/contrib/gis/utils/ogrinspect.py4
18 files changed, 61 insertions, 29 deletions
diff --git a/django/contrib/gis/db/backends/base/operations.py b/django/contrib/gis/db/backends/base/operations.py
index 5e56b82a78..e7bffb11b4 100644
--- a/django/contrib/gis/db/backends/base/operations.py
+++ b/django/contrib/gis/db/backends/base/operations.py
@@ -158,12 +158,14 @@ class BaseSpatialOperations:
# Routines for getting the OGC-compliant models.
def geometry_columns(self):
raise NotImplementedError(
- "Subclasses of BaseSpatialOperations must provide a geometry_columns() method."
+ "Subclasses of BaseSpatialOperations must provide a geometry_columns() "
+ "method."
)
def spatial_ref_sys(self):
raise NotImplementedError(
- "subclasses of BaseSpatialOperations must a provide spatial_ref_sys() method"
+ "subclasses of BaseSpatialOperations must a provide spatial_ref_sys() "
+ "method"
)
distance_expr_for_lookup = staticmethod(Distance)
diff --git a/django/contrib/gis/db/backends/oracle/features.py b/django/contrib/gis/db/backends/oracle/features.py
index ee4b296c07..f346d93573 100644
--- a/django/contrib/gis/db/backends/oracle/features.py
+++ b/django/contrib/gis/db/backends/oracle/features.py
@@ -20,7 +20,8 @@ class DatabaseFeatures(BaseSpatialFeatures, OracleDatabaseFeatures):
skips.update(
{
"Oracle doesn't support spatial operators in constraints.": {
- "gis_tests.gis_migrations.test_operations.OperationTests.test_add_check_constraint",
+ "gis_tests.gis_migrations.test_operations.OperationTests."
+ "test_add_check_constraint",
},
}
)
diff --git a/django/contrib/gis/db/backends/oracle/operations.py b/django/contrib/gis/db/backends/oracle/operations.py
index 45010ef517..ba7e3ca4d8 100644
--- a/django/contrib/gis/db/backends/oracle/operations.py
+++ b/django/contrib/gis/db/backends/oracle/operations.py
@@ -40,7 +40,10 @@ class SDORelate(SpatialOperator):
sql_template = "SDO_RELATE(%(lhs)s, %(rhs)s, 'mask=%(mask)s') = 'TRUE'"
def check_relate_argument(self, arg):
- masks = "TOUCH|OVERLAPBDYDISJOINT|OVERLAPBDYINTERSECT|EQUAL|INSIDE|COVEREDBY|CONTAINS|COVERS|ANYINTERACT|ON"
+ masks = (
+ "TOUCH|OVERLAPBDYDISJOINT|OVERLAPBDYINTERSECT|EQUAL|INSIDE|COVEREDBY|"
+ "CONTAINS|COVERS|ANYINTERACT|ON"
+ )
mask_regex = re.compile(r"^(%s)(\+(%s))*$" % (masks, masks), re.I)
if not isinstance(arg, str) or not mask_regex.match(arg):
raise ValueError('Invalid SDO_RELATE mask: "%s"' % arg)
@@ -105,7 +108,8 @@ class OracleOperations(BaseSpatialOperations, DatabaseOperations):
"exact": SDOOperator(func="SDO_EQUAL"),
"overlaps": SDOOperator(func="SDO_OVERLAPS"),
"same_as": SDOOperator(func="SDO_EQUAL"),
- "relate": SDORelate(), # Oracle uses a different syntax, e.g., 'mask=inside+touch'
+ # Oracle uses a different syntax, e.g., 'mask=inside+touch'
+ "relate": SDORelate(),
"touches": SDOOperator(func="SDO_TOUCH"),
"within": SDOOperator(func="SDO_INSIDE"),
"dwithin": SDODWithin(),
diff --git a/django/contrib/gis/db/backends/oracle/schema.py b/django/contrib/gis/db/backends/oracle/schema.py
index edc692ffc7..c9192d03fa 100644
--- a/django/contrib/gis/db/backends/oracle/schema.py
+++ b/django/contrib/gis/db/backends/oracle/schema.py
@@ -16,7 +16,10 @@ class OracleGISSchemaEditor(DatabaseSchemaEditor):
),
%(srid)s
)"""
- sql_add_spatial_index = "CREATE INDEX %(index)s ON %(table)s(%(column)s) INDEXTYPE IS MDSYS.SPATIAL_INDEX"
+ sql_add_spatial_index = (
+ "CREATE INDEX %(index)s ON %(table)s(%(column)s) "
+ "INDEXTYPE IS MDSYS.SPATIAL_INDEX"
+ )
sql_drop_spatial_index = "DROP INDEX %(index)s"
sql_clear_geometry_table_metadata = (
"DELETE FROM USER_SDO_GEOM_METADATA WHERE TABLE_NAME = %(table)s"
diff --git a/django/contrib/gis/db/backends/postgis/const.py b/django/contrib/gis/db/backends/postgis/const.py
index d2ad51799f..2f4393d25e 100644
--- a/django/contrib/gis/db/backends/postgis/const.py
+++ b/django/contrib/gis/db/backends/postgis/const.py
@@ -56,7 +56,7 @@ STRUCT_SIZE = {
# whether the band data is stored as part of the datum or is to be found on the
# server's filesystem. There are currently 11 supported pixel value types, so 4
# bits are enough to account for all. Reserve the upper 4 bits for generic
-# flags.
-# See https://trac.osgeo.org/postgis/wiki/WKTRaster/RFC/RFC1_V0SerialFormat#Pixeltypeandstorageflag
+# flags. See
+# https://trac.osgeo.org/postgis/wiki/WKTRaster/RFC/RFC1_V0SerialFormat#Pixeltypeandstorageflag
BANDTYPE_PIXTYPE_MASK = 0x0F
BANDTYPE_FLAG_HASNODATA = 1 << 6
diff --git a/django/contrib/gis/db/backends/postgis/introspection.py b/django/contrib/gis/db/backends/postgis/introspection.py
index b12b7b912f..766c0fa583 100644
--- a/django/contrib/gis/db/backends/postgis/introspection.py
+++ b/django/contrib/gis/db/backends/postgis/introspection.py
@@ -22,7 +22,9 @@ class PostGISIntrospection(DatabaseIntrospection):
# dictionary isn't updated until introspection is performed here.
with self.connection.cursor() as cursor:
cursor.execute(
- "SELECT oid, typname FROM pg_type WHERE typname IN ('geometry', 'geography')"
+ "SELECT oid, typname "
+ "FROM pg_type "
+ "WHERE typname IN ('geometry', 'geography')"
)
self.postgis_oid_lookup = dict(cursor.fetchall())
self.data_types_reverse.update(
diff --git a/django/contrib/gis/db/backends/postgis/operations.py b/django/contrib/gis/db/backends/postgis/operations.py
index b11b2efcf3..36bec4ba5d 100644
--- a/django/contrib/gis/db/backends/postgis/operations.py
+++ b/django/contrib/gis/db/backends/postgis/operations.py
@@ -56,7 +56,8 @@ class PostGISOperator(SpatialOperator):
if lookup.band_lhs is not None and lhs_is_raster:
if not self.func:
raise ValueError(
- "Band indices are not allowed for this operator, it works on bbox only."
+ "Band indices are not allowed for this operator, it works on bbox "
+ "only."
)
template_params["lhs"] = "%s, %s" % (
template_params["lhs"],
@@ -66,7 +67,8 @@ class PostGISOperator(SpatialOperator):
if lookup.band_rhs is not None and rhs_is_raster:
if not self.func:
raise ValueError(
- "Band indices are not allowed for this operator, it works on bbox only."
+ "Band indices are not allowed for this operator, it works on bbox "
+ "only."
)
template_params["rhs"] = "%s, %s" % (
template_params["rhs"],
diff --git a/django/contrib/gis/db/models/functions.py b/django/contrib/gis/db/models/functions.py
index c7b071c7c9..5f6c7b5cfd 100644
--- a/django/contrib/gis/db/models/functions.py
+++ b/django/contrib/gis/db/models/functions.py
@@ -317,9 +317,11 @@ class Distance(DistanceResultMixin, OracleToleranceMixin, GeoFunc):
)
if not geography and self.geo_field.geodetic(connection):
- # Geometry fields with geodetic (lon/lat) coordinates need special distance functions
+ # Geometry fields with geodetic (lon/lat) coordinates need special
+ # distance functions.
if self.spheroid:
- # DistanceSpheroid is more accurate and resource intensive than DistanceSphere
+ # DistanceSpheroid is more accurate and resource intensive than
+ # DistanceSphere.
function = connection.ops.spatial_function_name("DistanceSpheroid")
# Replace boolean param by the real spheroid of the base field
clone.source_expressions.append(
diff --git a/django/contrib/gis/db/models/lookups.py b/django/contrib/gis/db/models/lookups.py
index 9c06922508..07762d0a13 100644
--- a/django/contrib/gis/db/models/lookups.py
+++ b/django/contrib/gis/db/models/lookups.py
@@ -202,7 +202,8 @@ class BBContainsLookup(GISLookup):
@BaseSpatialField.register_lookup
class BBOverlapsLookup(GISLookup):
"""
- The 'bboverlaps' operator returns true if A's bounding box overlaps B's bounding box.
+ The 'bboverlaps' operator returns true if A's bounding box overlaps B's
+ bounding box.
"""
lookup_name = "bboverlaps"
@@ -307,7 +308,8 @@ class DistanceLookupBase(GISLookup):
)
elif len(self.rhs_params) == 3 and self.rhs_params[2] != "spheroid":
raise ValueError(
- "For 4-element tuples the last argument must be the 'spheroid' directive."
+ "For 4-element tuples the last argument must be the 'spheroid' "
+ "directive."
)
# Check if the second parameter is a band index.
diff --git a/django/contrib/gis/gdal/geometries.py b/django/contrib/gis/gdal/geometries.py
index dbb391f75f..f74dc688b3 100644
--- a/django/contrib/gis/gdal/geometries.py
+++ b/django/contrib/gis/gdal/geometries.py
@@ -28,7 +28,7 @@
>>> print(mpnt.proj)
+proj=longlat +ellps=clrk66 +datum=NAD27 +no_defs
>>> print(mpnt)
- MULTIPOINT (-89.999930378602485 29.999797886557641,-89.999930378602485 29.999797886557641)
+ MULTIPOINT (-89.99993037860248 29.99979788655764,-89.99993037860248 29.99979788655764)
The OGRGeomType class is to make it easy to specify an OGR geometry type:
>>> from django.contrib.gis.gdal import OGRGeomType
diff --git a/django/contrib/gis/gdal/layer.py b/django/contrib/gis/gdal/layer.py
index e8f97b7552..1afa0469f6 100644
--- a/django/contrib/gis/gdal/layer.py
+++ b/django/contrib/gis/gdal/layer.py
@@ -19,7 +19,10 @@ from django.utils.encoding import force_bytes, force_str
#
# The OGR_L_* routines are relevant here.
class Layer(GDALBase):
- "A class that wraps an OGR Layer, needs to be instantiated from a DataSource object."
+ """
+ A class that wraps an OGR Layer, needs to be instantiated from a DataSource
+ object.
+ """
def __init__(self, layer_ptr, ds):
"""
@@ -192,7 +195,8 @@ class Layer(GDALBase):
capi.set_spatial_filter(self.ptr, None)
else:
raise TypeError(
- "Spatial filter must be either an OGRGeometry instance, a 4-tuple, or None."
+ "Spatial filter must be either an OGRGeometry instance, a 4-tuple, or "
+ "None."
)
spatial_filter = property(_get_spatial_filter, _set_spatial_filter)
diff --git a/django/contrib/gis/gdal/srs.py b/django/contrib/gis/gdal/srs.py
index 41477d55db..2e335fe5d5 100644
--- a/django/contrib/gis/gdal/srs.py
+++ b/django/contrib/gis/gdal/srs.py
@@ -131,7 +131,8 @@ class SpatialReference(GDALBase):
4326
>>> print(srs['TOWGS84', 4]) # the fourth value in this wkt
0
- >>> print(srs['UNIT|AUTHORITY']) # For the units authority, have to use the pipe symbole.
+ >>> # For the units authority, have to use the pipe symbole.
+ >>> print(srs['UNIT|AUTHORITY'])
EPSG
>>> print(srs['UNIT|AUTHORITY', 1]) # The authority value for the units
9122
diff --git a/django/contrib/gis/geos/polygon.py b/django/contrib/gis/geos/polygon.py
index 452e72fcb6..e384614b0b 100644
--- a/django/contrib/gis/geos/polygon.py
+++ b/django/contrib/gis/geos/polygon.py
@@ -32,7 +32,8 @@ class Polygon(GEOSGeometry):
ext_ring, *init_holes = args
n_holes = len(init_holes)
- # If initialized as Polygon(shell, (LinearRing, LinearRing)) [for backward-compatibility]
+ # If initialized as Polygon(shell, (LinearRing, LinearRing))
+ # [for backward-compatibility]
if n_holes == 1 and isinstance(init_holes[0], (tuple, list)):
if not init_holes[0]:
init_holes = ()
@@ -101,7 +102,8 @@ class Polygon(GEOSGeometry):
self,
param,
msg=(
- "Parameter must be a sequence of LinearRings or objects that can initialize to LinearRings"
+ "Parameter must be a sequence of LinearRings or objects that can "
+ "initialize to LinearRings"
),
):
"Try to construct a ring from the given parameter."
diff --git a/django/contrib/gis/management/commands/ogrinspect.py b/django/contrib/gis/management/commands/ogrinspect.py
index 133cec3e60..2d2bd63176 100644
--- a/django/contrib/gis/management/commands/ogrinspect.py
+++ b/django/contrib/gis/management/commands/ogrinspect.py
@@ -34,8 +34,8 @@ class ListOptionAction(argparse.Action):
class Command(BaseCommand):
help = (
- "Inspects the given OGR-compatible data source (e.g., a shapefile) and outputs\n"
- "a GeoDjango model with the given model name. For example:\n"
+ "Inspects the given OGR-compatible data source (e.g., a shapefile) and "
+ "outputs\na GeoDjango model with the given model name. For example:\n"
" ./manage.py ogrinspect zipcode.shp Zipcode"
)
diff --git a/django/contrib/gis/serializers/geojson.py b/django/contrib/gis/serializers/geojson.py
index f90d3544e7..865e90caec 100644
--- a/django/contrib/gis/serializers/geojson.py
+++ b/django/contrib/gis/serializers/geojson.py
@@ -25,7 +25,8 @@ class Serializer(JSONSerializer):
self._init_options()
self._cts = {} # cache of CoordTransform's
self.stream.write(
- '{"type": "FeatureCollection", "crs": {"type": "name", "properties": {"name": "EPSG:%d"}},'
+ '{"type": "FeatureCollection", '
+ '"crs": {"type": "name", "properties": {"name": "EPSG:%d"}},'
' "features": [' % self.srid
)
@@ -53,7 +54,8 @@ class Serializer(JSONSerializer):
data["properties"]["pk"] = obj._meta.pk.value_to_string(obj)
if self._geometry:
if self._geometry.srid != self.srid:
- # If needed, transform the geometry in the srid of the global geojson srid
+ # If needed, transform the geometry in the srid of the global
+ # geojson srid.
if self._geometry.srid not in self._cts:
srs = SpatialReference(self.srid)
self._cts[self._geometry.srid] = CoordTransform(
diff --git a/django/contrib/gis/sitemaps/kml.py b/django/contrib/gis/sitemaps/kml.py
index 5ec089d6f5..a84b5aef6d 100644
--- a/django/contrib/gis/sitemaps/kml.py
+++ b/django/contrib/gis/sitemaps/kml.py
@@ -42,7 +42,8 @@ class KMLSitemap(Sitemap):
elif isinstance(source, (list, tuple)):
if len(source) != 3:
raise ValueError(
- "Must specify a 3-tuple of (app_label, module_name, field_name)."
+ "Must specify a 3-tuple of (app_label, module_name, "
+ "field_name)."
)
kml_sources.append(source)
else:
diff --git a/django/contrib/gis/utils/layermapping.py b/django/contrib/gis/utils/layermapping.py
index bad4c05fb8..2dcf839603 100644
--- a/django/contrib/gis/utils/layermapping.py
+++ b/django/contrib/gis/utils/layermapping.py
@@ -233,7 +233,8 @@ class LayerMapping:
if isinstance(model_field, GeometryField):
if self.geom_field:
raise LayerMapError(
- "LayerMapping does not support more than one GeometryField per model."
+ "LayerMapping does not support more than one GeometryField per "
+ "model."
)
# Getting the coordinate dimension of the geometry field.
@@ -695,7 +696,8 @@ class LayerMapping:
# Incremental saving is requested at the given interval (step)
if default_range:
raise LayerMapError(
- "The `step` keyword may not be used in conjunction with the `fid_range` keyword."
+ "The `step` keyword may not be used in conjunction with the "
+ "`fid_range` keyword."
)
beg, num_feat, num_saved = (0, 0, 0)
indices = range(step, nfeat, step)
diff --git a/django/contrib/gis/utils/ogrinspect.py b/django/contrib/gis/utils/ogrinspect.py
index c50b39ad14..40ca0cb461 100644
--- a/django/contrib/gis/utils/ogrinspect.py
+++ b/django/contrib/gis/utils/ogrinspect.py
@@ -209,7 +209,9 @@ def _ogrinspect(
# may also be mapped to `DecimalField` if specified in the
# `decimal` keyword.
if field_name.lower() in decimal_fields:
- yield " %s = models.DecimalField(max_digits=%d, decimal_places=%d%s)" % (
+ yield (
+ " %s = models.DecimalField(max_digits=%d, decimal_places=%d%s)"
+ ) % (
mfield,
width,
precision,