diff options
| author | Claude Paroz <claude@2xlibre.net> | 2015-05-06 11:57:43 +0200 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2015-05-06 20:31:36 +0200 |
| commit | d1df1fd2bb274574fd895f6984892b3aba372f48 (patch) | |
| tree | 1e8a083601ddb43a8bb7e58b2a16c7c44b181e8b /django | |
| parent | 10f7cfeb2df35c5f7775d59c9d654952971897fb (diff) | |
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.
Diffstat (limited to 'django')
| -rw-r--r-- | django/contrib/gis/gdal/geomtype.py | 8 | ||||
| -rw-r--r-- | django/contrib/gis/utils/ogrinspect.py | 15 |
2 files changed, 14 insertions, 9 deletions
diff --git a/django/contrib/gis/gdal/geomtype.py b/django/contrib/gis/gdal/geomtype.py index abb184e2f9..0c672e4227 100644 --- a/django/contrib/gis/gdal/geomtype.py +++ b/django/contrib/gis/gdal/geomtype.py @@ -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 diff --git a/django/contrib/gis/utils/ogrinspect.py b/django/contrib/gis/utils/ogrinspect.py index 9c9a4c7f8c..c4697fe242 100644 --- a/django/contrib/gis/utils/ogrinspect.py +++ b/django/contrib/gis/utils/ogrinspect.py @@ -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: |
