Mercurial > gemma
comparison pkg/imports/wfsjob.go @ 5012:ae3a1392f9d0
Cosmetics: Tightened code a bit.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Wed, 11 Mar 2020 23:40:44 +0100 |
parents | 2d7af72bb7ac |
children | 59a99655f34d |
comparison
equal
deleted
inserted
replaced
5011:2d7af72bb7ac | 5012:ae3a1392f9d0 |
---|---|
197 if err := json.Unmarshal(*feature.Properties, props); err != nil { | 197 if err := json.Unmarshal(*feature.Properties, props); err != nil { |
198 badProperties++ | 198 badProperties++ |
199 continue | 199 continue |
200 } | 200 } |
201 | 201 |
202 // Optional wrapping | |
203 wrap := func(x interface{}) interface{} { return x } | |
204 | |
205 // Look if we can deserialize given type | 202 // Look if we can deserialize given type |
206 makeGeom := kindToGeometry[feature.Geometry.Type] | 203 makeGeom := kindToGeometry[feature.Geometry.Type] |
207 if makeGeom == nil { | 204 if makeGeom == nil { |
208 unsupported[feature.Geometry.Type]++ | 205 unsupported[feature.Geometry.Type]++ |
209 continue | 206 continue |
210 } | 207 } |
211 | 208 |
209 // Optional wrapping | |
210 wrap := func(x interface{}) interface{} { return x } | |
212 if feature.Geometry.Type != kind { | 211 if feature.Geometry.Type != kind { |
213 // Look if we can wrap it | 212 // Look if we can wrap it |
214 if wrap = wrapGeomKind[[2]string{feature.Geometry.Type, kind}]; wrap == nil { | 213 if wrap = wrapGeomKind[[2]string{feature.Geometry.Type, kind}]; wrap == nil { |
215 unsupported[feature.Geometry.Type]++ | 214 unsupported[feature.Geometry.Type]++ |
216 continue | 215 continue |
217 } | 216 } |
218 } | 217 } |
219 | 218 |
220 geom := makeGeom() | 219 geom := makeGeom() |
221 | |
222 if err := json.Unmarshal(*feature.Geometry.Coordinates, geom); err != nil { | 220 if err := json.Unmarshal(*feature.Geometry.Coordinates, geom); err != nil { |
223 return err | 221 return err |
224 } | 222 } |
225 | 223 |
226 err := consumer.Consume(wrap(geom), props, epsg) | 224 switch err := consumer.Consume(wrap(geom), props, epsg); { |
227 switch { | |
228 case err == ErrFeatureDuplicated: | 225 case err == ErrFeatureDuplicated: |
229 dupes++ | 226 dupes++ |
230 case err == ErrFeatureIgnored: | 227 case err == ErrFeatureIgnored: |
231 // be silent | 228 // be silent |
232 case err != nil: | 229 case err != nil: |