From d1df1fd2bb274574fd895f6984892b3aba372f48 Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Wed, 6 May 2015 11:57:43 +0200 Subject: [PATCH] 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. --- django/contrib/gis/gdal/geomtype.py | 8 ++++++++ django/contrib/gis/utils/ogrinspect.py | 15 ++++++--------- tests/gis_tests/data/gas_lines/gas_leitung.dbf | Bin 0 -> 5454 bytes tests/gis_tests/data/gas_lines/gas_leitung.prj | 1 + tests/gis_tests/data/gas_lines/gas_leitung.shp | Bin 0 -> 38060 bytes tests/gis_tests/data/gas_lines/gas_leitung.shx | Bin 0 -> 1804 bytes tests/gis_tests/inspectapp/tests.py | 4 ++++ 7 files changed, 19 insertions(+), 9 deletions(-) create mode 100644 tests/gis_tests/data/gas_lines/gas_leitung.dbf create mode 100644 tests/gis_tests/data/gas_lines/gas_leitung.prj create mode 100644 tests/gis_tests/data/gas_lines/gas_leitung.shp create mode 100644 tests/gis_tests/data/gas_lines/gas_leitung.shx 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: diff --git a/tests/gis_tests/data/gas_lines/gas_leitung.dbf b/tests/gis_tests/data/gas_lines/gas_leitung.dbf new file mode 100644 index 0000000000000000000000000000000000000000..6d660b9fe2232981fdaf0395fac9d0f90104b26a GIT binary patch literal 5454 zcmaKwU5@265QSUtFcK0AfTz0xE4Gu|WD{%wfz(1s%sh;S1+Yl=!#SUGnJNd-4{a&s z`Z@LQ`|Zyke*F9G?d`9(AN2qJ_s1{qpMHDi`%nJ=;hTKt*U#_2fB7H!r$0Y_eE}%r$2*!LlWM^_e)HCiK#6UD9C@k7rq|D_Lb=Z7EM%7e!S=t!FtbDsohRkdAZ4Q7`1H zbwuU$g?v_C{XqaZ6NhC>>t;NO0PI&IE?(UmlL0bWFR}_-AY^{;fi_p88flj8fS@hCFR(^ z7A_l`RPJZd5KQ8}skSjstP33Z`5 zKW?JP_Pvl-(O1-WZG{3#1j}y6Jw;cLi(sIM!yhE7*_jdfMz-&TGjeQX`(6$L7BX?O z{YGxihHjpPBAXg^Zs>DIex8agxu93^T$Bo0tU&@nJ#9Ue83sL!g zA*cI99lMcNHA{0wQM-|wU{Q$xayii)5yuX4h1Q&jK(?==qLNhx=E34K5s3M6FXx?@ z%N&bL93X#=i4)Cz8o62q9*9;wL9Xs&<%t92OW9_tm>becXGo$zuEF9ndiP1p1<-hs z4#}=v0E{Pz^3AmuoS8U4uDmjyq{GNtD`aGJ2{$#Jsl}*+uG7x4&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