changeset 4905:8cb201b551b3 fairway-marks-import

Replace bogus usage of pointer for type intrusion
author Tom Gottfried <tom@intevation.de>
date Fri, 07 Feb 2020 12:23:46 +0100
parents 53d929f658f3
children 21fea90f4002
files pkg/imports/fm.go pkg/imports/fm_bcnlat.go
diffstat 2 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/pkg/imports/fm.go	Thu Feb 06 19:09:14 2020 +0100
+++ b/pkg/imports/fm.go	Fri Feb 07 12:23:46 2020 +0100
@@ -59,8 +59,8 @@
 func getFMFeatures(
 	feedback Feedback,
 	fm FairwayMarks,
-	// Pointer to a struct representing featuretype's properties
-	props interface{},
+	// Constructor returning a struct representing featuretype's properties
+	newProps func() interface{},
 ) (
 	// Elements can be converted to []interface{}{p, fp} with
 	// p being a pointSlice and fp of the type of argument props.
@@ -133,7 +133,8 @@
 				continue
 			}
 
-			if err := json.Unmarshal(*feature.Properties, props); err != nil {
+			props := newProps()
+			if err := json.Unmarshal(*feature.Properties, &props); err != nil {
 				badProperties++
 				continue
 			}
--- a/pkg/imports/fm_bcnlat.go	Thu Feb 06 19:09:14 2020 +0100
+++ b/pkg/imports/fm_bcnlat.go	Fri Feb 07 12:23:46 2020 +0100
@@ -132,11 +132,10 @@
 
 	feedback.Info("Import fairway marks of type BCNLAT/bcnlat")
 
-	var props bcnlatProperties
 	fms, epsg, err := getFMFeatures(
 		feedback,
 		fm.FairwayMarks,
-		&props,
+		func() interface{} { return new(bcnlatProperties) },
 	)
 	if err != nil {
 		return nil, err