changeset 5011:2d7af72bb7ac

Fix geometry type wrapping Do not prevent wrapping as soon as the type requested by the consumer can be serialized. If the type of the geometry in the imported feature can be serialized and is the requested type, take it as is. If it's not the requested type, check if it can be wrapped in the requested type.
author Tom Gottfried <tom@intevation.de>
date Wed, 11 Mar 2020 19:29:07 +0100
parents 1d1be6bd5304
children ae3a1392f9d0
files pkg/imports/wfsjob.go
diffstat 1 files changed, 8 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/pkg/imports/wfsjob.go	Wed Mar 11 17:31:45 2020 +0100
+++ b/pkg/imports/wfsjob.go	Wed Mar 11 19:29:07 2020 +0100
@@ -202,16 +202,17 @@
 			// Optional wrapping
 			wrap := func(x interface{}) interface{} { return x }
 
-			makeGeom := kindToGeometry[kind]
+			// Look if we can deserialize given type
+			makeGeom := kindToGeometry[feature.Geometry.Type]
 			if makeGeom == nil {
-				// Look if we can deserialize it
-				if makeGeom = kindToGeometry[feature.Geometry.Type]; makeGeom == nil {
-					unsupported[feature.Geometry.Type]++
-					continue
-				}
+				unsupported[feature.Geometry.Type]++
+				continue
+			}
+
+			if feature.Geometry.Type != kind {
 				// Look if we can wrap it
 				if wrap = wrapGeomKind[[2]string{feature.Geometry.Type, kind}]; wrap == nil {
-					unsupported[kind]++
+					unsupported[feature.Geometry.Type]++
 					continue
 				}
 			}