Mercurial > gemma
comparison pkg/controllers/diff.go @ 4578:c657dec6b0fa iso-areas
Removed old contours from backend and database.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 08 Oct 2019 12:10:55 +0200 |
parents | daed8a92024a |
children | 0ed1489af8b6 |
comparison
equal
deleted
inserted
replaced
4577:82029885c11b | 4578:c657dec6b0fa |
---|---|
60 ) | 60 ) |
61 INSERT INTO caching.sounding_differences (minuend, subtrahend) | 61 INSERT INTO caching.sounding_differences (minuend, subtrahend) |
62 SELECT m.id, s.id FROM soundings m, soundings s | 62 SELECT m.id, s.id FROM soundings m, soundings s |
63 WHERE m.date_info = $2::date AND s.date_info = $3::date | 63 WHERE m.date_info = $2::date AND s.date_info = $3::date |
64 RETURNING id | 64 RETURNING id |
65 ` | |
66 insertDiffContourSQL = ` | |
67 INSERT INTO caching.sounding_differences_contour_lines ( | |
68 sounding_differences_id, | |
69 height, | |
70 lines | |
71 ) | |
72 SELECT | |
73 $5, | |
74 $4, | |
75 ST_Transform( | |
76 ST_Multi( | |
77 ST_CollectionExtract( | |
78 ST_SimplifyPreserveTopology( | |
79 ST_Multi(ST_Collectionextract( | |
80 ST_MakeValid(ST_GeomFromWKB($1, $2::integer)), 2)), | |
81 $3 | |
82 ), | |
83 2 | |
84 ) | |
85 ), | |
86 4326 | |
87 ) | |
88 ` | 65 ` |
89 insertDiffIsoAreasQL = ` | 66 insertDiffIsoAreasQL = ` |
90 INSERT INTO caching.sounding_differences_iso_areas ( | 67 INSERT INTO caching.sounding_differences_iso_areas ( |
91 sounding_differences_id, | 68 sounding_differences_id, |
92 height, | 69 height, |
300 // heights = octree.InBetweenClassBreaks(heights, 0.05, 2) | 277 // heights = octree.InBetweenClassBreaks(heights, 0.05, 2) |
301 } | 278 } |
302 | 279 |
303 log.Printf("info: num heights: %d\n", len(heights)) | 280 log.Printf("info: num heights: %d\n", len(heights)) |
304 | 281 |
305 var stmt *sql.Stmt | |
306 if stmt, err = tx.PrepareContext(ctx, insertDiffContourSQL); err != nil { | |
307 return | |
308 } | |
309 defer stmt.Close() | |
310 | |
311 var isoStmt *sql.Stmt | 282 var isoStmt *sql.Stmt |
312 if isoStmt, err = tx.PrepareContext(ctx, insertDiffIsoAreasQL); err != nil { | 283 if isoStmt, err = tx.PrepareContext(ctx, insertDiffIsoAreasQL); err != nil { |
313 return | 284 return |
314 } | 285 } |
315 defer isoStmt.Close() | 286 defer isoStmt.Close() |
324 return | 295 return |
325 } | 296 } |
326 | 297 |
327 heights = common.DedupFloat64s(heights) | 298 heights = common.DedupFloat64s(heights) |
328 | 299 |
329 octree.DoContours(tree, heights, func(res *octree.ContourResult) { | |
330 if err == nil && len(res.Lines) > 0 { | |
331 _, err = stmt.ExecContext( | |
332 ctx, | |
333 res.Lines.AsWKB2D(), | |
334 minuendTree.EPSG, | |
335 contourTolerance, | |
336 res.Height, | |
337 id, | |
338 ) | |
339 } | |
340 }) | |
341 | |
342 areas := tree.TraceAreas(heights, isoCellSize) | 300 areas := tree.TraceAreas(heights, isoCellSize) |
343 | 301 |
344 for i, a := range areas { | 302 for i, a := range areas { |
345 if len(a) == 0 { | 303 if len(a) == 0 { |
346 continue | 304 continue |