Mercurial > gemma
annotate pkg/imports/fm_boycar.go @ 4931:e41d42be0e13 fairway-marks-import
One more callback to avoid code duplication more consequently
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Fri, 14 Feb 2020 19:34:08 +0100 |
parents | b86ce7fc4da3 |
children | 9f9d72a1d398 |
rev | line source |
---|---|
4913
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
1 // This is Free Software under GNU Affero General Public License v >= 3.0 |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
2 // without warranty, see README.md and license for details. |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
3 // |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
4 // SPDX-License-Identifier: AGPL-3.0-or-later |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
5 // License-Filename: LICENSES/AGPL-3.0.txt |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
6 // |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
7 // Copyright (C) 2020 by via donau |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
8 // – Österreichische Wasserstraßen-Gesellschaft mbH |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
9 // Software engineering by Intevation GmbH |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
10 // |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
11 // Author(s): |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
12 // * Tom Gottfried <tom.gottfried@intevation.de> |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
13 |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
14 package imports |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
15 |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
16 import ( |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
17 "context" |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
18 "database/sql" |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
19 |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
20 "gemma.intevation.de/gemma/pkg/pgxutils" |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
21 ) |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
22 |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
23 // Boycar is an import job to import |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
24 // fairway marks of type BOYCAR in form of point geometries |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
25 // and attribute data from a WFS service. |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
26 type Boycar struct { |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
27 FairwayMarks |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
28 } |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
29 |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
30 // Description gives a short info about relevant facts of this import. |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
31 func (boycar *Boycar) Description() (string, error) { |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
32 return boycar.URL + "|" + boycar.FeatureType, nil |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
33 } |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
34 |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
35 // BOYCARJobKind is the import queue type identifier. |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
36 const BOYCARJobKind JobKind = "fm_boycar" |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
37 |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
38 type boycarJobCreator struct{} |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
39 |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
40 func init() { |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
41 RegisterJobCreator(BOYCARJobKind, boycarJobCreator{}) |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
42 } |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
43 |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
44 func (boycarJobCreator) Description() string { return "fairway marks boycar" } |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
45 |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
46 func (boycarJobCreator) AutoAccept() bool { return true } |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
47 |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
48 func (boycarJobCreator) Create() Job { return new(Boycar) } |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
49 |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
50 func (boycarJobCreator) Depends() [2][]string { |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
51 return [2][]string{ |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
52 {"fairway_marks_boycar"}, |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
53 {}, |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
54 } |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
55 } |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
56 |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
57 // StageDone is a NOP for fairway marks imports. |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
58 func (boycarJobCreator) StageDone(context.Context, *sql.Tx, int64) error { |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
59 return nil |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
60 } |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
61 |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
62 // CleanUp for fairway marks imports is a NOP. |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
63 func (*Boycar) CleanUp() error { return nil } |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
64 |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
65 type boycarProperties struct { |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
66 fairwayMarksProperties |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
67 Colour *string `json:"hydro_colour"` |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
68 Colpat *string `json:"hydro_colpat"` |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
69 Conrad *int `json:"hydro_conrad"` |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
70 Marsys *int `json:"hydro_marsys"` |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
71 Boyshp *int `json:"hydro_boyshp"` |
4925
b86ce7fc4da3
Add missing BOYCAR attribute
Tom Gottfried <tom@intevation.de>
parents:
4913
diff
changeset
|
72 Catcam *int `json:"hydro_catcam"` |
4913
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
73 } |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
74 |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
75 type boycarFeaturetype struct { |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
76 geom pointSlice |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
77 props *boycarProperties |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
78 } |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
79 |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
80 const ( |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
81 insertBOYCARSQL = ` |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
82 with a as ( |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
83 select users.current_user_area_utm() AS a |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
84 ) |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
85 INSERT INTO waterway.fairway_marks_boycar ( |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
86 geom, |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
87 datsta, |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
88 datend, |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
89 persta, |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
90 perend, |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
91 objnam, |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
92 nobjnm, |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
93 inform, |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
94 ninfom, |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
95 scamin, |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
96 picrep, |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
97 txtdsc, |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
98 sordat, |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
99 sorind, |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
100 colour, |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
101 colpat, |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
102 conrad, |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
103 marsys, |
4925
b86ce7fc4da3
Add missing BOYCAR attribute
Tom Gottfried <tom@intevation.de>
parents:
4913
diff
changeset
|
104 boyshp, |
b86ce7fc4da3
Add missing BOYCAR attribute
Tom Gottfried <tom@intevation.de>
parents:
4913
diff
changeset
|
105 catcam |
4913
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
106 ) |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
107 SELECT newfm, $3, $4, $5, $6, $7, $8, $9, |
4925
b86ce7fc4da3
Add missing BOYCAR attribute
Tom Gottfried <tom@intevation.de>
parents:
4913
diff
changeset
|
108 $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21 |
4913
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
109 FROM ST_Transform(ST_GeomFromWKB($1, $2::integer), 4326) AS newfm (newfm) |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
110 WHERE pg_has_role('sys_admin', 'MEMBER') |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
111 OR ST_Intersects((select a from a), |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
112 ST_Transform(newfm, (select ST_SRID(a) from a))) |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
113 ON CONFLICT ( |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
114 CAST((geom, |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
115 datsta, datend, persta, perend, objnam, nobjnm, inform, ninfom, |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
116 scamin, picrep, txtdsc, sordat, sorind, |
4925
b86ce7fc4da3
Add missing BOYCAR attribute
Tom Gottfried <tom@intevation.de>
parents:
4913
diff
changeset
|
117 0, colour, colpat, conrad, marsys, boyshp, catcam |
4913
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
118 ) AS waterway.fairway_marks_boycar) |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
119 ) |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
120 DO NOTHING |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
121 RETURNING id |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
122 ` |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
123 ) |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
124 |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
125 // Do executes the actual import. |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
126 func (fm *Boycar) Do( |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
127 ctx context.Context, |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
128 importID int64, |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
129 conn *sql.Conn, |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
130 feedback Feedback, |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
131 ) (interface{}, error) { |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
132 |
4931
e41d42be0e13
One more callback to avoid code duplication more consequently
Tom Gottfried <tom@intevation.de>
parents:
4925
diff
changeset
|
133 err := getFMFeatures( |
e41d42be0e13
One more callback to avoid code duplication more consequently
Tom Gottfried <tom@intevation.de>
parents:
4925
diff
changeset
|
134 ctx, |
e41d42be0e13
One more callback to avoid code duplication more consequently
Tom Gottfried <tom@intevation.de>
parents:
4925
diff
changeset
|
135 conn, |
4913
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
136 feedback, |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
137 fm.FairwayMarks, |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
138 func() interface{} { return new(boycarProperties) }, |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
139 func(p pointSlice, props interface{}) interface{} { |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
140 return &boycarFeaturetype{p, props.(*boycarProperties)} |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
141 }, |
4931
e41d42be0e13
One more callback to avoid code duplication more consequently
Tom Gottfried <tom@intevation.de>
parents:
4925
diff
changeset
|
142 func( |
e41d42be0e13
One more callback to avoid code duplication more consequently
Tom Gottfried <tom@intevation.de>
parents:
4925
diff
changeset
|
143 tx *sql.Tx, epsg int, fms []interface{}, |
e41d42be0e13
One more callback to avoid code duplication more consequently
Tom Gottfried <tom@intevation.de>
parents:
4925
diff
changeset
|
144 ) (outsideOrDup int, features int, err error) { |
4913
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
145 |
4931
e41d42be0e13
One more callback to avoid code duplication more consequently
Tom Gottfried <tom@intevation.de>
parents:
4925
diff
changeset
|
146 feedback.Info("Store fairway marks of type BOYCAR") |
4913
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
147 |
4931
e41d42be0e13
One more callback to avoid code duplication more consequently
Tom Gottfried <tom@intevation.de>
parents:
4925
diff
changeset
|
148 insertStmt, err := tx.PrepareContext(ctx, insertBOYCARSQL) |
e41d42be0e13
One more callback to avoid code duplication more consequently
Tom Gottfried <tom@intevation.de>
parents:
4925
diff
changeset
|
149 if err != nil { |
e41d42be0e13
One more callback to avoid code duplication more consequently
Tom Gottfried <tom@intevation.de>
parents:
4925
diff
changeset
|
150 return |
e41d42be0e13
One more callback to avoid code duplication more consequently
Tom Gottfried <tom@intevation.de>
parents:
4925
diff
changeset
|
151 } |
e41d42be0e13
One more callback to avoid code duplication more consequently
Tom Gottfried <tom@intevation.de>
parents:
4925
diff
changeset
|
152 defer insertStmt.Close() |
4913
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
153 |
4931
e41d42be0e13
One more callback to avoid code duplication more consequently
Tom Gottfried <tom@intevation.de>
parents:
4925
diff
changeset
|
154 savepoint := Savepoint(ctx, tx, "feature") |
4913
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
155 |
4931
e41d42be0e13
One more callback to avoid code duplication more consequently
Tom Gottfried <tom@intevation.de>
parents:
4925
diff
changeset
|
156 for _, fm := range fms { |
e41d42be0e13
One more callback to avoid code duplication more consequently
Tom Gottfried <tom@intevation.de>
parents:
4925
diff
changeset
|
157 |
e41d42be0e13
One more callback to avoid code duplication more consequently
Tom Gottfried <tom@intevation.de>
parents:
4925
diff
changeset
|
158 f := fm.(*boycarFeaturetype) |
4913
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
159 |
4931
e41d42be0e13
One more callback to avoid code duplication more consequently
Tom Gottfried <tom@intevation.de>
parents:
4925
diff
changeset
|
160 var fmid int64 |
e41d42be0e13
One more callback to avoid code duplication more consequently
Tom Gottfried <tom@intevation.de>
parents:
4925
diff
changeset
|
161 err := savepoint(func() error { |
e41d42be0e13
One more callback to avoid code duplication more consequently
Tom Gottfried <tom@intevation.de>
parents:
4925
diff
changeset
|
162 err := insertStmt.QueryRowContext( |
e41d42be0e13
One more callback to avoid code duplication more consequently
Tom Gottfried <tom@intevation.de>
parents:
4925
diff
changeset
|
163 ctx, |
e41d42be0e13
One more callback to avoid code duplication more consequently
Tom Gottfried <tom@intevation.de>
parents:
4925
diff
changeset
|
164 f.geom.asWKB(), |
e41d42be0e13
One more callback to avoid code duplication more consequently
Tom Gottfried <tom@intevation.de>
parents:
4925
diff
changeset
|
165 epsg, |
e41d42be0e13
One more callback to avoid code duplication more consequently
Tom Gottfried <tom@intevation.de>
parents:
4925
diff
changeset
|
166 f.props.Datsta, |
e41d42be0e13
One more callback to avoid code duplication more consequently
Tom Gottfried <tom@intevation.de>
parents:
4925
diff
changeset
|
167 f.props.Datend, |
e41d42be0e13
One more callback to avoid code duplication more consequently
Tom Gottfried <tom@intevation.de>
parents:
4925
diff
changeset
|
168 f.props.Persta, |
e41d42be0e13
One more callback to avoid code duplication more consequently
Tom Gottfried <tom@intevation.de>
parents:
4925
diff
changeset
|
169 f.props.Perend, |
e41d42be0e13
One more callback to avoid code duplication more consequently
Tom Gottfried <tom@intevation.de>
parents:
4925
diff
changeset
|
170 f.props.Objnam, |
e41d42be0e13
One more callback to avoid code duplication more consequently
Tom Gottfried <tom@intevation.de>
parents:
4925
diff
changeset
|
171 f.props.Nobjnm, |
e41d42be0e13
One more callback to avoid code duplication more consequently
Tom Gottfried <tom@intevation.de>
parents:
4925
diff
changeset
|
172 f.props.Inform, |
e41d42be0e13
One more callback to avoid code duplication more consequently
Tom Gottfried <tom@intevation.de>
parents:
4925
diff
changeset
|
173 f.props.Ninfom, |
e41d42be0e13
One more callback to avoid code duplication more consequently
Tom Gottfried <tom@intevation.de>
parents:
4925
diff
changeset
|
174 f.props.Scamin, |
e41d42be0e13
One more callback to avoid code duplication more consequently
Tom Gottfried <tom@intevation.de>
parents:
4925
diff
changeset
|
175 f.props.Picrep, |
e41d42be0e13
One more callback to avoid code duplication more consequently
Tom Gottfried <tom@intevation.de>
parents:
4925
diff
changeset
|
176 f.props.Txtdsc, |
e41d42be0e13
One more callback to avoid code duplication more consequently
Tom Gottfried <tom@intevation.de>
parents:
4925
diff
changeset
|
177 f.props.Sordat, |
e41d42be0e13
One more callback to avoid code duplication more consequently
Tom Gottfried <tom@intevation.de>
parents:
4925
diff
changeset
|
178 f.props.Sorind, |
e41d42be0e13
One more callback to avoid code duplication more consequently
Tom Gottfried <tom@intevation.de>
parents:
4925
diff
changeset
|
179 f.props.Colour, |
e41d42be0e13
One more callback to avoid code duplication more consequently
Tom Gottfried <tom@intevation.de>
parents:
4925
diff
changeset
|
180 f.props.Colpat, |
e41d42be0e13
One more callback to avoid code duplication more consequently
Tom Gottfried <tom@intevation.de>
parents:
4925
diff
changeset
|
181 f.props.Conrad, |
e41d42be0e13
One more callback to avoid code duplication more consequently
Tom Gottfried <tom@intevation.de>
parents:
4925
diff
changeset
|
182 f.props.Marsys, |
e41d42be0e13
One more callback to avoid code duplication more consequently
Tom Gottfried <tom@intevation.de>
parents:
4925
diff
changeset
|
183 f.props.Boyshp, |
e41d42be0e13
One more callback to avoid code duplication more consequently
Tom Gottfried <tom@intevation.de>
parents:
4925
diff
changeset
|
184 f.props.Catcam, |
e41d42be0e13
One more callback to avoid code duplication more consequently
Tom Gottfried <tom@intevation.de>
parents:
4925
diff
changeset
|
185 ).Scan(&fmid) |
e41d42be0e13
One more callback to avoid code duplication more consequently
Tom Gottfried <tom@intevation.de>
parents:
4925
diff
changeset
|
186 return err |
e41d42be0e13
One more callback to avoid code duplication more consequently
Tom Gottfried <tom@intevation.de>
parents:
4925
diff
changeset
|
187 }) |
e41d42be0e13
One more callback to avoid code duplication more consequently
Tom Gottfried <tom@intevation.de>
parents:
4925
diff
changeset
|
188 switch { |
e41d42be0e13
One more callback to avoid code duplication more consequently
Tom Gottfried <tom@intevation.de>
parents:
4925
diff
changeset
|
189 case err == sql.ErrNoRows: |
e41d42be0e13
One more callback to avoid code duplication more consequently
Tom Gottfried <tom@intevation.de>
parents:
4925
diff
changeset
|
190 outsideOrDup++ |
e41d42be0e13
One more callback to avoid code duplication more consequently
Tom Gottfried <tom@intevation.de>
parents:
4925
diff
changeset
|
191 // ignore -> filtered by responsibility_areas |
e41d42be0e13
One more callback to avoid code duplication more consequently
Tom Gottfried <tom@intevation.de>
parents:
4925
diff
changeset
|
192 case err != nil: |
e41d42be0e13
One more callback to avoid code duplication more consequently
Tom Gottfried <tom@intevation.de>
parents:
4925
diff
changeset
|
193 feedback.Error(pgxutils.ReadableError{Err: err}.Error()) |
e41d42be0e13
One more callback to avoid code duplication more consequently
Tom Gottfried <tom@intevation.de>
parents:
4925
diff
changeset
|
194 default: |
e41d42be0e13
One more callback to avoid code duplication more consequently
Tom Gottfried <tom@intevation.de>
parents:
4925
diff
changeset
|
195 features++ |
e41d42be0e13
One more callback to avoid code duplication more consequently
Tom Gottfried <tom@intevation.de>
parents:
4925
diff
changeset
|
196 } |
e41d42be0e13
One more callback to avoid code duplication more consequently
Tom Gottfried <tom@intevation.de>
parents:
4925
diff
changeset
|
197 } |
e41d42be0e13
One more callback to avoid code duplication more consequently
Tom Gottfried <tom@intevation.de>
parents:
4925
diff
changeset
|
198 return |
4913
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
199 }) |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
200 |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
201 return nil, err |
8c1a3d5e3962
Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
202 } |