comparison pkg/octree/contours.go @ 1692:f4dcbe8941a1

Octree: Resolved the remaing golint issues with this package.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 31 Dec 2018 11:13:49 +0100
parents 5443f5c9154c
children c85b16db8a02
comparison
equal deleted inserted replaced
1691:de09bd3b5c05 1692:f4dcbe8941a1
17 import ( 17 import (
18 "runtime" 18 "runtime"
19 "sync" 19 "sync"
20 ) 20 )
21 21
22 // ContourResult stores an calculated iso line for a given height.
23 // Is used as a future variable in the concurrent iso line calculation.
22 type ContourResult struct { 24 type ContourResult struct {
23 Height float64 25 Height float64
24 Lines MultiLineStringZ 26 Lines MultiLineStringZ
25 27
26 done bool 28 done bool
27 mu sync.Mutex 29 mu sync.Mutex
28 cond *sync.Cond 30 cond *sync.Cond
29 } 31 }
30 32
33 // NewContourResult prepares a future variable to later hold
34 // the result of the iso line calculation.
31 func NewContourResult(height float64) *ContourResult { 35 func NewContourResult(height float64) *ContourResult {
32 cr := ContourResult{Height: height} 36 cr := ContourResult{Height: height}
33 cr.cond = sync.NewCond(&cr.mu) 37 cr.cond = sync.NewCond(&cr.mu)
34 return &cr 38 return &cr
35 } 39 }
54 cr.Lines = lines 58 cr.Lines = lines
55 cr.done = true 59 cr.done = true
56 cr.cond.Signal() 60 cr.cond.Signal()
57 } 61 }
58 62
63 // DoContours calculates the iso line for the given heights.
64 // This is done concurrently.
65 // It is guaranteed that the results are given to the store
66 // function in order of the original heights values.
59 func DoContours(tree *Tree, heights []float64, store func(*ContourResult)) { 67 func DoContours(tree *Tree, heights []float64, store func(*ContourResult)) {
60 68
61 contours := make([]*ContourResult, len(heights)) 69 contours := make([]*ContourResult, len(heights))
62 70
63 for i, h := range heights { 71 for i, h := range heights {