Mercurial > gemma
changeset 1680:de8089944b19
Waterway axis import: Started extracting properties from the features.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 27 Dec 2018 13:35:51 +0100 |
parents | 2dc7768be0e4 |
children | 4d6ce621379e |
files | pkg/imports/wx.go |
diffstat | 1 files changed, 36 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/pkg/imports/wx.go Wed Dec 26 21:01:29 2018 +0100 +++ b/pkg/imports/wx.go Thu Dec 27 13:35:51 2018 +0100 @@ -16,8 +16,10 @@ import ( "context" "database/sql" + "encoding/json" "fmt" "io" + "log" "strings" "time" @@ -65,6 +67,11 @@ // CleanUp for waterway imports is a NOP. func (*WaterwayAxis) CleanUp() error { return nil } +type waterwayAxisProperties struct { + ObjNam string `json:"hydro_objnam"` + NObjNnm *string `json:"hydro_nobjnm"` +} + // Do executes the actual waterway exis import. func (wx *WaterwayAxis) Do( ctx context.Context, @@ -98,9 +105,12 @@ return nil, err } - var crsName string - - unsupportedTypes := map[string]int{} + var ( + crsName string + unsupportedTypes = map[string]int{} + missingProperties int + badProperties int + ) if err := wfs.DownloadURLs(urls, func(r io.Reader) error { rfc, err := wfs.ParseRawFeatureCollection(r) @@ -115,7 +125,22 @@ if rfc.Features == nil { return nil } + for _, feature := range rfc.Features { + if feature.Properties == nil { + missingProperties++ + continue + } + + var props waterwayAxisProperties + + if err := json.Unmarshal(*feature.Properties, &props); err != nil { + badProperties++ + continue + } + + log.Printf("properties: %s\n", props.ObjNam) + switch feature.Geometry.Type { case "LineString": // TODO: Parse concrete features. @@ -131,6 +156,14 @@ return nil, err } + if badProperties > 0 { + feedback.Warn("Bad properties: %d", badProperties) + } + + if missingProperties > 0 { + feedback.Warn("Missing properties: %d", missingProperties) + } + if len(unsupportedTypes) != 0 { var b strings.Builder for t, c := range unsupportedTypes {