Mercurial > gemma
annotate pkg/imports/wa.go @ 3092:7dc9660df743
Fixed c&p sign error in Nash Sutcliffe calculation.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 23 Apr 2019 10:12:31 +0200 |
parents | ecb1e34157a3 |
children | 4acbee65275d |
rev | line source |
---|---|
1785
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
1 // This is Free Software under GNU Affero General Public License v >= 3.0 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
2 // without warranty, see README.md and license for details. |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
3 // |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
4 // SPDX-License-Identifier: AGPL-3.0-or-later |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
5 // License-Filename: LICENSES/AGPL-3.0.txt |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
6 // |
2649
9b6a02923bb4
Allow sys_admin to import waterway axis and area without clipping
Tom Gottfried <tom@intevation.de>
parents:
2622
diff
changeset
|
7 // Copyright (C) 2018, 2019 by via donau |
1785
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
8 // – Österreichische Wasserstraßen-Gesellschaft mbH |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
9 // Software engineering by Intevation GmbH |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
10 // |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
11 // Author(s): |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
12 // * Sascha L. Teichmann <sascha.teichmann@intevation.de> |
2649
9b6a02923bb4
Allow sys_admin to import waterway axis and area without clipping
Tom Gottfried <tom@intevation.de>
parents:
2622
diff
changeset
|
13 // * Tom Gottfried <tom.gottfried@intevation.de> |
1785
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
14 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
15 package imports |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
16 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
17 import ( |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
18 "context" |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
19 "database/sql" |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
20 "encoding/json" |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
21 "errors" |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
22 "fmt" |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
23 "io" |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
24 "strconv" |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
25 "time" |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
26 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
27 "gemma.intevation.de/gemma/pkg/wfs" |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
28 ) |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
29 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
30 // WaterwayArea is an import job to import |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
31 // the waterway area in form of polygon geometries |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
32 // and attribute data from a WFS service. |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
33 type WaterwayArea struct { |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
34 // URL the GetCapabilities URL of the WFS service. |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
35 URL string `json:"url"` |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
36 // FeatureType selects the feature type of the WFS service. |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
37 FeatureType string `json:"feature-type"` |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
38 // SortBy works around misconfigured services to |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
39 // establish a sort order to get the features. |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
40 SortBy string `json:"sort-by"` |
2723
a10022399e24
WFS downloads: Fetch user and password from config.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2721
diff
changeset
|
41 // User is an optional username for Basic Auth. |
a10022399e24
WFS downloads: Fetch user and password from config.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2721
diff
changeset
|
42 User string `json:"user,omitempty"` |
a10022399e24
WFS downloads: Fetch user and password from config.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2721
diff
changeset
|
43 // Password is an optional password for Basic Auth. |
a10022399e24
WFS downloads: Fetch user and password from config.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2721
diff
changeset
|
44 Password string `json:"password,omitempty"` |
1785
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
45 } |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
46 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
47 // WAJobKind is the import queue type identifier. |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
48 const WAJobKind JobKind = "wa" |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
49 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
50 type waJobCreator struct{} |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
51 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
52 func init() { |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
53 RegisterJobCreator(WAJobKind, waJobCreator{}) |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
54 } |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
55 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
56 func (waJobCreator) Description() string { return "waterway area" } |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
57 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
58 func (waJobCreator) AutoAccept() bool { return true } |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
59 |
2187
7c83b5277c1c
Import queue: Removed boilerplate code to deserialize jobs from JSON by making it part of the import queue.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2168
diff
changeset
|
60 func (waJobCreator) Create() Job { return new(WaterwayArea) } |
1785
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
61 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
62 func (waJobCreator) Depends() []string { |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
63 return []string{ |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
64 "waterway_area", |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
65 } |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
66 } |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
67 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
68 // StageDone is a NOP for waterway area imports. |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
69 func (waJobCreator) StageDone(context.Context, *sql.Tx, int64) error { |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
70 return nil |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
71 } |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
72 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
73 // CleanUp for waterway area imports is a NOP. |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
74 func (*WaterwayArea) CleanUp() error { return nil } |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
75 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
76 type waterwayAreaProperties struct { |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
77 Catccl *string `json:"ienc_catccl"` |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
78 Dirimp *string `json:"ienc_dirimp"` |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
79 } |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
80 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
81 const ( |
1796
904c7e853adc
Waterway area import: Clip features against responsibility area.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1786
diff
changeset
|
82 deleteWaterwayAreaSQL = ` |
904c7e853adc
Waterway area import: Clip features against responsibility area.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1786
diff
changeset
|
83 WITH resp AS ( |
2912
93fa55bce126
Add utility function to get users area of responsibility
Tom Gottfried <tom@intevation.de>
parents:
2855
diff
changeset
|
84 SELECT users.current_user_area_utm() AS a |
1796
904c7e853adc
Waterway area import: Clip features against responsibility area.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1786
diff
changeset
|
85 ) |
904c7e853adc
Waterway area import: Clip features against responsibility area.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1786
diff
changeset
|
86 DELETE FROM waterway.waterway_area |
2649
9b6a02923bb4
Allow sys_admin to import waterway axis and area without clipping
Tom Gottfried <tom@intevation.de>
parents:
2622
diff
changeset
|
87 WHERE pg_has_role('sys_admin', 'MEMBER') |
9b6a02923bb4
Allow sys_admin to import waterway axis and area without clipping
Tom Gottfried <tom@intevation.de>
parents:
2622
diff
changeset
|
88 OR ST_Covers((SELECT a FROM resp), |
2912
93fa55bce126
Add utility function to get users area of responsibility
Tom Gottfried <tom@intevation.de>
parents:
2855
diff
changeset
|
89 ST_Transform(area::geometry, (SELECT ST_SRID(a) FROM resp))) |
1796
904c7e853adc
Waterway area import: Clip features against responsibility area.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1786
diff
changeset
|
90 ` |
1785
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
91 insertWaterwayAreaSQL = ` |
1796
904c7e853adc
Waterway area import: Clip features against responsibility area.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1786
diff
changeset
|
92 WITH resp AS ( |
2912
93fa55bce126
Add utility function to get users area of responsibility
Tom Gottfried <tom@intevation.de>
parents:
2855
diff
changeset
|
93 SELECT users.current_user_area_utm() AS a |
1796
904c7e853adc
Waterway area import: Clip features against responsibility area.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1786
diff
changeset
|
94 ) |
1785
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
95 INSERT INTO waterway.waterway_area (area, catccl, dirimp) |
2855
8a8a929182f9
Enable import of axis and area independently from areas of responsibility
Tom Gottfried <tom@intevation.de>
parents:
2833
diff
changeset
|
96 SELECT dmp.geom, $3, $4 |
8a8a929182f9
Enable import of axis and area independently from areas of responsibility
Tom Gottfried <tom@intevation.de>
parents:
2833
diff
changeset
|
97 FROM ST_GeomFromWKB($1, $2::integer) AS new_area (new_area), |
8a8a929182f9
Enable import of axis and area independently from areas of responsibility
Tom Gottfried <tom@intevation.de>
parents:
2833
diff
changeset
|
98 ST_Dump(ST_Transform(ST_CollectionExtract( |
2649
9b6a02923bb4
Allow sys_admin to import waterway axis and area without clipping
Tom Gottfried <tom@intevation.de>
parents:
2622
diff
changeset
|
99 CASE WHEN pg_has_role('sys_admin', 'MEMBER') |
2855
8a8a929182f9
Enable import of axis and area independently from areas of responsibility
Tom Gottfried <tom@intevation.de>
parents:
2833
diff
changeset
|
100 THEN ST_MakeValid(ST_Transform(new_area, |
8a8a929182f9
Enable import of axis and area independently from areas of responsibility
Tom Gottfried <tom@intevation.de>
parents:
2833
diff
changeset
|
101 best_utm(ST_Transform(new_area, 4326)))) |
8a8a929182f9
Enable import of axis and area independently from areas of responsibility
Tom Gottfried <tom@intevation.de>
parents:
2833
diff
changeset
|
102 ELSE ST_Intersection((SELECT a FROM resp), |
2912
93fa55bce126
Add utility function to get users area of responsibility
Tom Gottfried <tom@intevation.de>
parents:
2855
diff
changeset
|
103 ST_MakeValid(ST_Transform(new_area, (SELECT ST_SRID(a) FROM resp)))) |
2855
8a8a929182f9
Enable import of axis and area independently from areas of responsibility
Tom Gottfried <tom@intevation.de>
parents:
2833
diff
changeset
|
104 END, |
8a8a929182f9
Enable import of axis and area independently from areas of responsibility
Tom Gottfried <tom@intevation.de>
parents:
2833
diff
changeset
|
105 3), 4326)) AS dmp |
2938
ecb1e34157a3
Fix logging in area import
Tom Gottfried <tom@intevation.de>
parents:
2912
diff
changeset
|
106 RETURNING id |
1796
904c7e853adc
Waterway area import: Clip features against responsibility area.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1786
diff
changeset
|
107 ` |
1785
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
108 ) |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
109 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
110 // Do executes the actual waterway axis import. |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
111 func (wx *WaterwayArea) Do( |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
112 ctx context.Context, |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
113 importID int64, |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
114 conn *sql.Conn, |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
115 feedback Feedback, |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
116 ) (interface{}, error) { |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
117 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
118 start := time.Now() |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
119 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
120 feedback.Info("Import waterway area") |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
121 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
122 feedback.Info("Loading capabilities from %s", wx.URL) |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
123 caps, err := wfs.GetCapabilities(wx.URL) |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
124 if err != nil { |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
125 feedback.Error("Loading capabilities failed: %v", err) |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
126 return nil, err |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
127 } |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
128 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
129 ft := caps.FindFeatureType(wx.FeatureType) |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
130 if ft == nil { |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
131 return nil, fmt.Errorf("Unknown feature type '%s'", wx.FeatureType) |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
132 } |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
133 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
134 feedback.Info("Found feature type '%s", wx.FeatureType) |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
135 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
136 epsg, err := wfs.CRSToEPSG(ft.DefaultCRS) |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
137 if err != nil { |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
138 feedback.Error("Unsupported CRS name '%s'", ft.DefaultCRS) |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
139 return nil, err |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
140 } |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
141 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
142 if wx.SortBy != "" { |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
143 feedback.Info("Features will be sorted by '%s'", wx.SortBy) |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
144 } |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
145 |
2721
56c8ef515d93
WFS downloader: Use new GML/GeoJSON factory function in gemma.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2719
diff
changeset
|
146 dl, err := wfs.GetFeatures(caps, wx.FeatureType, wx.SortBy) |
1785
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
147 if err != nil { |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
148 feedback.Error("Cannot create GetFeature URLs. %v", err) |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
149 return nil, err |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
150 } |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
151 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
152 tx, err := conn.BeginTx(ctx, nil) |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
153 if err != nil { |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
154 return nil, err |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
155 } |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
156 defer tx.Rollback() |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
157 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
158 insertStmt, err := tx.PrepareContext(ctx, insertWaterwayAreaSQL) |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
159 if err != nil { |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
160 return nil, err |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
161 } |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
162 defer insertStmt.Close() |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
163 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
164 // Delete the old features. |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
165 if _, err := tx.ExecContext(ctx, deleteWaterwayAreaSQL); err != nil { |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
166 return nil, err |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
167 } |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
168 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
169 var ( |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
170 unsupported = stringCounter{} |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
171 missingProperties int |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
172 badProperties int |
2938
ecb1e34157a3
Fix logging in area import
Tom Gottfried <tom@intevation.de>
parents:
2912
diff
changeset
|
173 outside int |
1785
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
174 features int |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
175 ) |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
176 |
2729
7cb027be277d
WFS downloader: Really use username and password from parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2723
diff
changeset
|
177 if err := dl.Download(wx.User, wx.Password, func(url string, r io.Reader) error { |
2106
2b72f5e005aa
WFS imports: Write get GetFeature URLs into import log.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1899
diff
changeset
|
178 feedback.Info("Get features from: '%s'", url) |
1785
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
179 rfc, err := wfs.ParseRawFeatureCollection(r) |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
180 if err != nil { |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
181 return fmt.Errorf("parsing GetFeature document failed: %v", err) |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
182 } |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
183 if rfc.CRS != nil { |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
184 crsName := rfc.CRS.Properties.Name |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
185 if epsg, err = wfs.CRSToEPSG(crsName); err != nil { |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
186 feedback.Error("Unsupported CRS: %d", crsName) |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
187 return err |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
188 } |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
189 } |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
190 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
191 // No features -> ignore. |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
192 if rfc.Features == nil { |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
193 return nil |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
194 } |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
195 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
196 feedback.Info("Using EPSG: %d", epsg) |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
197 |
2758
a996f2ca9fa5
Simplified savepoint handling.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2729
diff
changeset
|
198 savepoint := Savepoint(ctx, tx, "feature") |
2659
00b0a7b2225a
Waterway area import: do not fail if INSERT of one item fails
Tom Gottfried <tom@intevation.de>
parents:
2649
diff
changeset
|
199 |
1785
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
200 for _, feature := range rfc.Features { |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
201 if feature.Properties == nil || feature.Geometry.Coordinates == nil { |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
202 missingProperties++ |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
203 continue |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
204 } |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
205 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
206 var props waterwayAreaProperties |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
207 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
208 if err := json.Unmarshal(*feature.Properties, &props); err != nil { |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
209 badProperties++ |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
210 continue |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
211 } |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
212 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
213 var catccl sql.NullInt64 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
214 if props.Catccl != nil { |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
215 if value, err := strconv.ParseInt(*props.Catccl, 10, 64); err == nil { |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
216 catccl = sql.NullInt64{Int64: value, Valid: true} |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
217 } |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
218 } |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
219 var dirimp sql.NullInt64 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
220 if props.Dirimp != nil { |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
221 if value, err := strconv.ParseInt(*props.Dirimp, 10, 64); err == nil { |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
222 dirimp = sql.NullInt64{Int64: value, Valid: true} |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
223 } |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
224 } |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
225 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
226 switch feature.Geometry.Type { |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
227 case "Polygon": |
1786
09349ca27dd7
Imports: Removed duplicated code path to store WKB polygons into database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1785
diff
changeset
|
228 var p polygonSlice |
1785
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
229 if err := json.Unmarshal(*feature.Geometry.Coordinates, &p); err != nil { |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
230 return err |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
231 } |
2938
ecb1e34157a3
Fix logging in area import
Tom Gottfried <tom@intevation.de>
parents:
2912
diff
changeset
|
232 var waid int64 |
ecb1e34157a3
Fix logging in area import
Tom Gottfried <tom@intevation.de>
parents:
2912
diff
changeset
|
233 err := savepoint(func() error { |
ecb1e34157a3
Fix logging in area import
Tom Gottfried <tom@intevation.de>
parents:
2912
diff
changeset
|
234 err := insertStmt.QueryRowContext( |
2758
a996f2ca9fa5
Simplified savepoint handling.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2729
diff
changeset
|
235 ctx, |
a996f2ca9fa5
Simplified savepoint handling.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2729
diff
changeset
|
236 p.asWKB(), |
a996f2ca9fa5
Simplified savepoint handling.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2729
diff
changeset
|
237 epsg, |
a996f2ca9fa5
Simplified savepoint handling.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2729
diff
changeset
|
238 catccl, |
a996f2ca9fa5
Simplified savepoint handling.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2729
diff
changeset
|
239 dirimp, |
2938
ecb1e34157a3
Fix logging in area import
Tom Gottfried <tom@intevation.de>
parents:
2912
diff
changeset
|
240 ).Scan(&waid) |
2659
00b0a7b2225a
Waterway area import: do not fail if INSERT of one item fails
Tom Gottfried <tom@intevation.de>
parents:
2649
diff
changeset
|
241 return err |
2938
ecb1e34157a3
Fix logging in area import
Tom Gottfried <tom@intevation.de>
parents:
2912
diff
changeset
|
242 }) |
ecb1e34157a3
Fix logging in area import
Tom Gottfried <tom@intevation.de>
parents:
2912
diff
changeset
|
243 switch { |
ecb1e34157a3
Fix logging in area import
Tom Gottfried <tom@intevation.de>
parents:
2912
diff
changeset
|
244 case err == sql.ErrNoRows: |
ecb1e34157a3
Fix logging in area import
Tom Gottfried <tom@intevation.de>
parents:
2912
diff
changeset
|
245 outside++ |
ecb1e34157a3
Fix logging in area import
Tom Gottfried <tom@intevation.de>
parents:
2912
diff
changeset
|
246 // ignore -> filtered by responsibility_areas |
ecb1e34157a3
Fix logging in area import
Tom Gottfried <tom@intevation.de>
parents:
2912
diff
changeset
|
247 case err != nil: |
2659
00b0a7b2225a
Waterway area import: do not fail if INSERT of one item fails
Tom Gottfried <tom@intevation.de>
parents:
2649
diff
changeset
|
248 feedback.Warn(handleError(err).Error()) |
2938
ecb1e34157a3
Fix logging in area import
Tom Gottfried <tom@intevation.de>
parents:
2912
diff
changeset
|
249 default: |
2659
00b0a7b2225a
Waterway area import: do not fail if INSERT of one item fails
Tom Gottfried <tom@intevation.de>
parents:
2649
diff
changeset
|
250 features++ |
1785
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
251 } |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
252 default: |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
253 unsupported[feature.Geometry.Type]++ |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
254 } |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
255 } |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
256 return nil |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
257 }); err != nil { |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
258 return nil, err |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
259 } |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
260 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
261 if badProperties > 0 { |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
262 feedback.Warn("Bad properties: %d", badProperties) |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
263 } |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
264 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
265 if missingProperties > 0 { |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
266 feedback.Warn("Missing properties: %d", missingProperties) |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
267 } |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
268 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
269 if len(unsupported) != 0 { |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
270 feedback.Warn("Unsupported types found: %s", unsupported) |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
271 } |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
272 |
2938
ecb1e34157a3
Fix logging in area import
Tom Gottfried <tom@intevation.de>
parents:
2912
diff
changeset
|
273 if outside > 0 { |
ecb1e34157a3
Fix logging in area import
Tom Gottfried <tom@intevation.de>
parents:
2912
diff
changeset
|
274 feedback.Info("Features outside responsibility area: %d", outside) |
ecb1e34157a3
Fix logging in area import
Tom Gottfried <tom@intevation.de>
parents:
2912
diff
changeset
|
275 } |
ecb1e34157a3
Fix logging in area import
Tom Gottfried <tom@intevation.de>
parents:
2912
diff
changeset
|
276 |
1828
1ecfcf46e4da
Waterway area/axis: Be more informative if features are bad.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1796
diff
changeset
|
277 if features == 0 { |
1ecfcf46e4da
Waterway area/axis: Be more informative if features are bad.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1796
diff
changeset
|
278 err := errors.New("No features found") |
1ecfcf46e4da
Waterway area/axis: Be more informative if features are bad.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1796
diff
changeset
|
279 feedback.Error("%v", err) |
1ecfcf46e4da
Waterway area/axis: Be more informative if features are bad.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1796
diff
changeset
|
280 return nil, err |
1ecfcf46e4da
Waterway area/axis: Be more informative if features are bad.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1796
diff
changeset
|
281 } |
1ecfcf46e4da
Waterway area/axis: Be more informative if features are bad.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1796
diff
changeset
|
282 |
1785
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
283 if err = tx.Commit(); err == nil { |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
284 feedback.Info("Storing %d features took %s", |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
285 features, time.Since(start)) |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
286 } |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
287 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
288 return nil, err |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
289 } |