Mercurial > gemma
changeset 3378:ff79a9b6707f
waterlevel classification: Re-enable finding a good starting points for classification intervals.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Wed, 22 May 2019 15:28:35 +0200 |
parents | ccb5455f0713 |
children | 4fa3fc4ed987 |
files | pkg/controllers/bottlenecks.go |
diffstat | 1 files changed, 15 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/pkg/controllers/bottlenecks.go Wed May 22 15:11:58 2019 +0200 +++ b/pkg/controllers/bottlenecks.go Wed May 22 15:28:35 2019 +0200 @@ -145,7 +145,21 @@ classes[i+1] = breaks[i].value } - // TODO: Find a good starting point with binary or interpolation search. + idx := sort.Search(len(measurements), func(i int) bool { + // All values before from can be ignored. + return !measurements[i].when.Before(from) + }) + + if idx >= len(measurements) { + return result + } + + // Be safe for interpolation. + if idx > 0 { + idx-- + } + + measurements = measurements[idx:] for i := 0; i < len(measurements)-1; i++ { p1 := &measurements[i]