Mercurial > gemma
comparison pkg/imports/sr.go @ 1338:5bb1e3c1f364
merges
author | Fadi Abbud <fadi.abbud@intevation.de> |
---|---|
date | Mon, 26 Nov 2018 09:01:21 +0100 |
parents | 53057ab27ff2 785f14264426 |
children | 8d59457a5651 |
comparison
equal
deleted
inserted
replaced
1337:53057ab27ff2 | 1338:5bb1e3c1f364 |
---|---|
78 "waterway.bottlenecks", | 78 "waterway.bottlenecks", |
79 } | 79 } |
80 } | 80 } |
81 | 81 |
82 func (srJobCreator) StageDone( | 82 func (srJobCreator) StageDone( |
83 ctx context.Context, | |
83 tx *sql.Tx, | 84 tx *sql.Tx, |
84 ctx context.Context, | |
85 id int64, | 85 id int64, |
86 ) error { | 86 ) error { |
87 _, err := tx.ExecContext(ctx, srStageDoneSQL, id) | 87 _, err := tx.ExecContext(ctx, srStageDoneSQL, id) |
88 return err | 88 return err |
89 } | 89 } |
163 } | 163 } |
164 return b.String(), nil | 164 return b.String(), nil |
165 } | 165 } |
166 | 166 |
167 func (sr *SoundingResult) Do( | 167 func (sr *SoundingResult) Do( |
168 ctx context.Context, | |
168 importID int64, | 169 importID int64, |
169 ctx context.Context, | |
170 conn *sql.Conn, | 170 conn *sql.Conn, |
171 feedback Feedback, | 171 feedback Feedback, |
172 ) error { | 172 ) error { |
173 | 173 |
174 z, err := zip.OpenReader(filepath.Join(sr.Dir, "sr.zip")) | 174 z, err := zip.OpenReader(filepath.Join(sr.Dir, "sr.zip")) |
186 m, err := sr.loadMeta(mf) | 186 m, err := sr.loadMeta(mf) |
187 if err != nil { | 187 if err != nil { |
188 return err | 188 return err |
189 } | 189 } |
190 | 190 |
191 if err := m.Validate(conn, ctx); err != nil { | 191 if err := m.Validate(ctx, conn); err != nil { |
192 return common.ToError(err) | 192 return common.ToError(err) |
193 } | 193 } |
194 | 194 |
195 feedback.Info("Looking for '*.xyz'") | 195 feedback.Info("Looking for '*.xyz'") |
196 xyzf := common.FindInZIP(z, ".xyz") | 196 xyzf := common.FindInZIP(z, ".xyz") |
202 if err != nil { | 202 if err != nil { |
203 return err | 203 return err |
204 } | 204 } |
205 | 205 |
206 if len(xyz) == 0 { | 206 if len(xyz) == 0 { |
207 return errors.New("XYZ does not contain any vertices.") | 207 return errors.New("XYZ does not contain any vertices") |
208 } | 208 } |
209 | 209 |
210 // Is there a boundary shapefile in the ZIP archive? | 210 // Is there a boundary shapefile in the ZIP archive? |
211 polygon, err := loadBoundary(z) | 211 polygon, err := loadBoundary(z) |
212 if err != nil { | 212 if err != nil { |
239 | 239 |
240 feedback.Info("Best suited UTM EPSG: %d", epsg) | 240 feedback.Info("Best suited UTM EPSG: %d", epsg) |
241 | 241 |
242 feedback.Info("Triangulate...") | 242 feedback.Info("Triangulate...") |
243 start = time.Now() | 243 start = time.Now() |
244 tin, err := octree.GenerateTinByID(conn, ctx, id, epsg) | 244 tin, err := octree.GenerateTinByID(ctx, conn, id, epsg) |
245 feedback.Info("triangulation took %s", time.Since(start)) | 245 feedback.Info("triangulation took %s", time.Since(start)) |
246 if err != nil { | 246 if err != nil { |
247 return err | 247 return err |
248 } | 248 } |
249 | 249 |
283 if err != nil { | 283 if err != nil { |
284 return err | 284 return err |
285 } | 285 } |
286 | 286 |
287 // Store for potential later removal. | 287 // Store for potential later removal. |
288 if err = track(tx, ctx, importID, "waterway.sounding_results", id); err != nil { | 288 if err = track(ctx, tx, importID, "waterway.sounding_results", id); err != nil { |
289 return err | 289 return err |
290 } | 290 } |
291 | 291 |
292 if err = tx.Commit(); err == nil { | 292 if err = tx.Commit(); err == nil { |
293 feedback.Info("Storing sounding result was successful.") | 293 feedback.Info("Storing sounding result was successful.") |