annotate pkg/imports/fm.go @ 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4894
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
1 // This is Free Software under GNU Affero General Public License v >= 3.0
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
2 // without warranty, see README.md and license for details.
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
3 //
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
4 // SPDX-License-Identifier: AGPL-3.0-or-later
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
5 // License-Filename: LICENSES/AGPL-3.0.txt
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
6 //
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
7 // Copyright (C) 2020 by via donau
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
8 // – Österreichische Wasserstraßen-Gesellschaft mbH
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
9 // Software engineering by Intevation GmbH
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
10 //
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
11 // Author(s):
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
12 // * Tom Gottfried <tom.gottfried@intevation.de>
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
13
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
14 package imports
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
15
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
16 import (
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
17 "encoding/json"
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
18 "fmt"
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
19 "io"
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
20
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
21 "gemma.intevation.de/gemma/pkg/wfs"
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
22 )
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
23
4904
53d929f658f3 Separate code common to all types of fairway mark imports
Tom Gottfried <tom@intevation.de>
parents: 4895
diff changeset
24 // FairwayMarks is a struct
53d929f658f3 Separate code common to all types of fairway mark imports
Tom Gottfried <tom@intevation.de>
parents: 4895
diff changeset
25 // to be used as the basis for imports of
53d929f658f3 Separate code common to all types of fairway mark imports
Tom Gottfried <tom@intevation.de>
parents: 4895
diff changeset
26 // specific types for fairway marks.
4894
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
27 type FairwayMarks struct {
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
28 // URL the GetCapabilities URL of the WFS service.
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
29 URL string `json:"url"`
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
30 // FeatureType selects the feature type of the WFS service.
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
31 FeatureType string `json:"feature-type"`
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
32 // SortBy works around misconfigured services to
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
33 // establish a sort order to get the features.
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
34 SortBy string `json:"sort-by"`
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
35 // User is an optional username for Basic Auth.
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
36 User string `json:"user,omitempty"`
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
37 // Password is an optional password for Basic Auth.
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
38 Password string `json:"password,omitempty"`
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
39 }
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
40
4904
53d929f658f3 Separate code common to all types of fairway mark imports
Tom Gottfried <tom@intevation.de>
parents: 4895
diff changeset
41 // Properties common to all types of fairway marks
53d929f658f3 Separate code common to all types of fairway mark imports
Tom Gottfried <tom@intevation.de>
parents: 4895
diff changeset
42 type fairwayMarksProperties struct {
53d929f658f3 Separate code common to all types of fairway mark imports
Tom Gottfried <tom@intevation.de>
parents: 4895
diff changeset
43 Datsta *string `json:"hydro_datsta"`
53d929f658f3 Separate code common to all types of fairway mark imports
Tom Gottfried <tom@intevation.de>
parents: 4895
diff changeset
44 Datend *string `json:"hydro_datend"`
53d929f658f3 Separate code common to all types of fairway mark imports
Tom Gottfried <tom@intevation.de>
parents: 4895
diff changeset
45 Persta *string `json:"hydro_persta"`
53d929f658f3 Separate code common to all types of fairway mark imports
Tom Gottfried <tom@intevation.de>
parents: 4895
diff changeset
46 Perend *string `json:"hydro_perend"`
53d929f658f3 Separate code common to all types of fairway mark imports
Tom Gottfried <tom@intevation.de>
parents: 4895
diff changeset
47 Objnam *string `json:"hydro_objnam"`
53d929f658f3 Separate code common to all types of fairway mark imports
Tom Gottfried <tom@intevation.de>
parents: 4895
diff changeset
48 Nobjnm *string `json:"hydro_nobjnm"`
53d929f658f3 Separate code common to all types of fairway mark imports
Tom Gottfried <tom@intevation.de>
parents: 4895
diff changeset
49 Inform *string `json:"hydro_inform"`
53d929f658f3 Separate code common to all types of fairway mark imports
Tom Gottfried <tom@intevation.de>
parents: 4895
diff changeset
50 Ninfom *string `json:"hydro_ninfom"`
53d929f658f3 Separate code common to all types of fairway mark imports
Tom Gottfried <tom@intevation.de>
parents: 4895
diff changeset
51 Scamin *int `json:"hydro_scamin"`
53d929f658f3 Separate code common to all types of fairway mark imports
Tom Gottfried <tom@intevation.de>
parents: 4895
diff changeset
52 Picrep *string `json:"hydro_picrep"`
53d929f658f3 Separate code common to all types of fairway mark imports
Tom Gottfried <tom@intevation.de>
parents: 4895
diff changeset
53 Txtdsc *string `json:"hydro_txtdsc"`
53d929f658f3 Separate code common to all types of fairway mark imports
Tom Gottfried <tom@intevation.de>
parents: 4895
diff changeset
54 Sordat *string `json:"hydro_sordat"`
53d929f658f3 Separate code common to all types of fairway mark imports
Tom Gottfried <tom@intevation.de>
parents: 4895
diff changeset
55 Sorind *string `json:"hydro_sorind"`
4894
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
56 }
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
57
4904
53d929f658f3 Separate code common to all types of fairway mark imports
Tom Gottfried <tom@intevation.de>
parents: 4895
diff changeset
58 // Common operation of FM imports to get features from WFS service
53d929f658f3 Separate code common to all types of fairway mark imports
Tom Gottfried <tom@intevation.de>
parents: 4895
diff changeset
59 func getFMFeatures(
4894
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
60 feedback Feedback,
4904
53d929f658f3 Separate code common to all types of fairway mark imports
Tom Gottfried <tom@intevation.de>
parents: 4895
diff changeset
61 fm FairwayMarks,
4905
8cb201b551b3 Replace bogus usage of pointer for type intrusion
Tom Gottfried <tom@intevation.de>
parents: 4904
diff changeset
62 // Constructor returning a struct representing featuretype's properties
8cb201b551b3 Replace bogus usage of pointer for type intrusion
Tom Gottfried <tom@intevation.de>
parents: 4904
diff changeset
63 newProps func() interface{},
4904
53d929f658f3 Separate code common to all types of fairway mark imports
Tom Gottfried <tom@intevation.de>
parents: 4895
diff changeset
64 ) (
53d929f658f3 Separate code common to all types of fairway mark imports
Tom Gottfried <tom@intevation.de>
parents: 4895
diff changeset
65 // Elements can be converted to []interface{}{p, fp} with
53d929f658f3 Separate code common to all types of fairway mark imports
Tom Gottfried <tom@intevation.de>
parents: 4895
diff changeset
66 // p being a pointSlice and fp of the type of argument props.
53d929f658f3 Separate code common to all types of fairway mark imports
Tom Gottfried <tom@intevation.de>
parents: 4895
diff changeset
67 fms [][]interface{},
53d929f658f3 Separate code common to all types of fairway mark imports
Tom Gottfried <tom@intevation.de>
parents: 4895
diff changeset
68 epsg int,
53d929f658f3 Separate code common to all types of fairway mark imports
Tom Gottfried <tom@intevation.de>
parents: 4895
diff changeset
69 err error,
53d929f658f3 Separate code common to all types of fairway mark imports
Tom Gottfried <tom@intevation.de>
parents: 4895
diff changeset
70 ) {
4894
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
71
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
72 feedback.Info("Loading capabilities from %s", fm.URL)
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
73 caps, err := wfs.GetCapabilities(fm.URL)
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
74 if err != nil {
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
75 feedback.Error("Loading capabilities failed: %v", err)
4904
53d929f658f3 Separate code common to all types of fairway mark imports
Tom Gottfried <tom@intevation.de>
parents: 4895
diff changeset
76 return
4894
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
77 }
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
78
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
79 ft := caps.FindFeatureType(fm.FeatureType)
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
80 if ft == nil {
4904
53d929f658f3 Separate code common to all types of fairway mark imports
Tom Gottfried <tom@intevation.de>
parents: 4895
diff changeset
81 err = fmt.Errorf("unknown feature type '%s'", fm.FeatureType)
53d929f658f3 Separate code common to all types of fairway mark imports
Tom Gottfried <tom@intevation.de>
parents: 4895
diff changeset
82 return
4894
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
83 }
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
84
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
85 feedback.Info("Found feature type '%s", fm.FeatureType)
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
86
4904
53d929f658f3 Separate code common to all types of fairway mark imports
Tom Gottfried <tom@intevation.de>
parents: 4895
diff changeset
87 epsg, err = wfs.CRSToEPSG(ft.DefaultCRS)
4894
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
88 if err != nil {
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
89 feedback.Error("Unsupported CRS: '%s'", ft.DefaultCRS)
4904
53d929f658f3 Separate code common to all types of fairway mark imports
Tom Gottfried <tom@intevation.de>
parents: 4895
diff changeset
90 return
4894
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
91 }
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
92
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
93 if fm.SortBy != "" {
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
94 feedback.Info("Features will be sorted by '%s'", fm.SortBy)
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
95 }
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
96
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
97 dl, err := wfs.GetFeatures(caps, fm.FeatureType, fm.SortBy)
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
98 if err != nil {
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
99 feedback.Error("Cannot create GetFeature URLs. %v", err)
4904
53d929f658f3 Separate code common to all types of fairway mark imports
Tom Gottfried <tom@intevation.de>
parents: 4895
diff changeset
100 return
4894
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
101 }
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
102
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
103 var (
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
104 unsupported = stringCounter{}
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
105 missingProperties int
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
106 badProperties int
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
107 )
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
108
4904
53d929f658f3 Separate code common to all types of fairway mark imports
Tom Gottfried <tom@intevation.de>
parents: 4895
diff changeset
109 err = dl.Download(fm.User, fm.Password, func(url string, r io.Reader) error {
4894
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
110 feedback.Info("Get features from: '%s'", url)
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
111 rfc, err := wfs.ParseRawFeatureCollection(r)
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
112 if err != nil {
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
113 return fmt.Errorf("parsing GetFeature document failed: %v", err)
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
114 }
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
115 if rfc.CRS != nil {
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
116 crsName := rfc.CRS.Properties.Name
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
117 if epsg, err = wfs.CRSToEPSG(crsName); err != nil {
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
118 feedback.Error("Unsupported CRS: %d", crsName)
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
119 return err
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
120 }
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
121 }
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
122
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
123 // No features -> ignore.
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
124 if rfc.Features == nil {
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
125 return nil
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
126 }
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
127
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
128 feedback.Info("Using EPSG: %d", epsg)
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
129
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
130 for _, feature := range rfc.Features {
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
131 if feature.Properties == nil || feature.Geometry.Coordinates == nil {
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
132 missingProperties++
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
133 continue
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
134 }
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
135
4905
8cb201b551b3 Replace bogus usage of pointer for type intrusion
Tom Gottfried <tom@intevation.de>
parents: 4904
diff changeset
136 props := newProps()
8cb201b551b3 Replace bogus usage of pointer for type intrusion
Tom Gottfried <tom@intevation.de>
parents: 4904
diff changeset
137 if err := json.Unmarshal(*feature.Properties, &props); err != nil {
4894
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
138 badProperties++
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
139 continue
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
140 }
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
141
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
142 switch feature.Geometry.Type {
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
143 case "Point":
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
144 var p pointSlice
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
145 if err := json.Unmarshal(*feature.Geometry.Coordinates, &p); err != nil {
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
146 return err
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
147 }
4904
53d929f658f3 Separate code common to all types of fairway mark imports
Tom Gottfried <tom@intevation.de>
parents: 4895
diff changeset
148
53d929f658f3 Separate code common to all types of fairway mark imports
Tom Gottfried <tom@intevation.de>
parents: 4895
diff changeset
149 f := []interface{}{p, props}
53d929f658f3 Separate code common to all types of fairway mark imports
Tom Gottfried <tom@intevation.de>
parents: 4895
diff changeset
150 fms = append(fms, f)
4894
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
151 default:
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
152 unsupported[feature.Geometry.Type]++
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
153 }
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
154 }
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
155 return nil
4904
53d929f658f3 Separate code common to all types of fairway mark imports
Tom Gottfried <tom@intevation.de>
parents: 4895
diff changeset
156 })
53d929f658f3 Separate code common to all types of fairway mark imports
Tom Gottfried <tom@intevation.de>
parents: 4895
diff changeset
157 if err != nil {
53d929f658f3 Separate code common to all types of fairway mark imports
Tom Gottfried <tom@intevation.de>
parents: 4895
diff changeset
158 return
4894
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
159 }
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
160
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
161 if badProperties > 0 {
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
162 feedback.Warn("Bad properties: %d", badProperties)
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
163 }
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
164
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
165 if missingProperties > 0 {
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
166 feedback.Warn("Missing properties: %d", missingProperties)
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
167 }
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
168
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
169 if len(unsupported) != 0 {
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
170 feedback.Warn("Unsupported types found: %s", unsupported)
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
171 }
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
172
4904
53d929f658f3 Separate code common to all types of fairway mark imports
Tom Gottfried <tom@intevation.de>
parents: 4895
diff changeset
173 feedback.Info("Found %d usable features in data source", len(fms))
4894
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
174
4904
53d929f658f3 Separate code common to all types of fairway mark imports
Tom Gottfried <tom@intevation.de>
parents: 4895
diff changeset
175 return
4894
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
176 }