Mercurial > gemma
comparison pkg/imports/dma.go @ 2928:074f2bb85584
Do not count skipped features as stored
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Wed, 03 Apr 2019 18:47:37 +0200 |
parents | 899b591493b4 |
children | a5642ee4c6d0 |
comparison
equal
deleted
inserted
replaced
2927:80815b0a665c | 2928:074f2bb85584 |
---|---|
99 ) | 99 ) |
100 ) | 100 ) |
101 )).geom AS geom | 101 )).geom AS geom |
102 ) AS clipped | 102 ) AS clipped |
103 WHERE clipped.geom IS NOT NULL | 103 WHERE clipped.geom IS NOT NULL |
104 RETURNING id | |
104 ` | 105 ` |
105 ) | 106 ) |
106 | 107 |
107 // Do executes the actual fairway dimension import. | 108 // Do executes the actual fairway dimension import. |
108 func (dma *DistanceMarksAshore) Do( | 109 func (dma *DistanceMarksAshore) Do( |
161 | 162 |
162 var ( | 163 var ( |
163 unsupported = stringCounter{} | 164 unsupported = stringCounter{} |
164 missingProperties int | 165 missingProperties int |
165 badProperties int | 166 badProperties int |
167 outside int | |
166 features int | 168 features int |
167 ) | 169 ) |
168 | 170 |
169 if err := dl.Download(dma.User, dma.Password, func(url string, r io.Reader) error { | 171 if err := dl.Download(dma.User, dma.Password, func(url string, r io.Reader) error { |
170 feedback.Info("Get features from: '%s'", url) | 172 feedback.Info("Get features from: '%s'", url) |
203 case "Point": | 205 case "Point": |
204 var p pointSlice | 206 var p pointSlice |
205 if err := json.Unmarshal(*feature.Geometry.Coordinates, &p); err != nil { | 207 if err := json.Unmarshal(*feature.Geometry.Coordinates, &p); err != nil { |
206 return err | 208 return err |
207 } | 209 } |
208 if _, err := insertStmt.ExecContext( | 210 var dmaid int64 |
211 err := insertStmt.QueryRowContext( | |
209 ctx, | 212 ctx, |
210 p.asWKB(), | 213 p.asWKB(), |
211 epsg, | 214 epsg, |
212 props.HydroCatdis, | 215 props.HydroCatdis, |
213 ); err != nil { | 216 ).Scan(&dmaid) |
217 switch { | |
218 case err == sql.ErrNoRows: | |
219 outside++ | |
220 // ignore -> filtered by responsibility area | |
221 continue | |
222 case err != nil: | |
214 return err | 223 return err |
215 } | 224 } |
216 features++ | 225 features++ |
217 default: | 226 default: |
218 unsupported[feature.Geometry.Type]++ | 227 unsupported[feature.Geometry.Type]++ |
233 | 242 |
234 if len(unsupported) != 0 { | 243 if len(unsupported) != 0 { |
235 feedback.Warn("Unsupported types found: %s", unsupported) | 244 feedback.Warn("Unsupported types found: %s", unsupported) |
236 } | 245 } |
237 | 246 |
247 if outside > 0 { | |
248 feedback.Info("Features outside responsibility area: %d", outside) | |
249 } | |
250 | |
238 if features == 0 { | 251 if features == 0 { |
239 err := errors.New("No features found") | 252 err := errors.New("No features found") |
240 feedback.Error("%v", err) | 253 feedback.Error("%v", err) |
241 return nil, err | 254 return nil, err |
242 } | 255 } |