1
0
mirror of https://github.com/django/django.git synced 2025-10-24 22:26:08 +00:00

Fixed #24207 -- Added 25D-type geometry field support to ogrinspect

Thanks Michael Diener for the report and sample data, and Tim Graham
for the review.
This commit is contained in:
Claude Paroz
2015-05-06 11:57:43 +02:00
parent 10f7cfeb2d
commit d1df1fd2bb
7 changed files with 19 additions and 9 deletions

View File

@@ -85,3 +85,11 @@ class OGRGeomType(object):
elif s == 'Unknown':
s = 'Geometry'
return s + 'Field'
def to_multi(self):
"""
Transform Point, LineString, Polygon, and their 25D equivalents
to their Multi... counterpart.
"""
if self.name.startswith(('Point', 'LineString', 'Polygon')):
self.num += 3

View File

@@ -43,11 +43,9 @@ def mapping(data_source, geom_name='geom', layer_key=0, multi_geom=False):
mfield += 'field'
_mapping[mfield] = field
gtype = data_source[layer_key].geom_type
if multi_geom and gtype.num in (1, 2, 3):
prefix = 'MULTI'
else:
prefix = ''
_mapping[geom_name] = prefix + str(gtype).upper()
if multi_geom:
gtype.to_multi()
_mapping[geom_name] = str(gtype).upper()
return _mapping
@@ -210,10 +208,9 @@ def _ogrinspect(data_source, model_name, geom_name='geom', layer_key=0, srid=Non
# TODO: Autodetection of multigeometry types (see #7218).
gtype = layer.geom_type
if multi_geom and gtype.num in (1, 2, 3):
geom_field = 'Multi%s' % gtype.django
else:
geom_field = gtype.django
if multi_geom:
gtype.to_multi()
geom_field = gtype.django
# Setting up the SRID keyword string.
if srid is None: