changeset 5257:0446a6e230b4 new-fwa

Removed now unused code.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Wed, 13 May 2020 11:37:31 +0200
parents ed62f138528a
children b373213d8e7c 771984cb74d8
files pkg/common/round.go
diffstat 1 files changed, 0 insertions(+), 70 deletions(-) [+]
line wrap: on
line diff
--- a/pkg/common/round.go	Wed May 13 11:34:25 2020 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,70 +0,0 @@
-// This is Free Software under GNU Affero General Public License v >= 3.0
-// without warranty, see README.md and license for details.
-//
-// SPDX-License-Identifier: AGPL-3.0-or-later
-// License-Filename: LICENSES/AGPL-3.0.txt
-//
-// Copyright (C) 2019 by via donau
-//   – Österreichische Wasserstraßen-Gesellschaft mbH
-// Software engineering by Intevation GmbH
-//
-// Author(s):
-//  * Sascha Wilde <wilde@sha-bang.de>
-
-package common
-
-import (
-	"math"
-	"sort"
-	"time"
-)
-
-// SumPreservingRound rounds the values of arr preserving the sum.
-func SumPreservingRound(arr []float64) []int {
-
-	type rest struct {
-		key  int
-		rest float64
-	}
-
-	var (
-		result = make([]int, len(arr))
-		rests  = make([]rest, len(arr))
-		sum    float64
-		newSum int
-	)
-
-	// floor all values
-	for i, v := range arr {
-		sum += v
-		result[i] = int(v)
-		newSum += int(v)
-		rests[i] = rest{key: i, rest: v - float64(result[i])}
-	}
-
-	// spread delta over values with highest rest
-	sort.Slice(rests, func(i, j int) bool {
-		return rests[i].rest > rests[j].rest
-	})
-
-	// find the difference in sums
-	delta := int(math.Round(sum)) - newSum
-	for _, v := range rests {
-		if delta <= 0 {
-			break
-		}
-		result[v.key]++
-		delta--
-	}
-
-	return result
-}
-
-// RoundToFullDays rounds durations to full days.
-func RoundToFullDays(durations []time.Duration) []int {
-	days := make([]float64, len(durations))
-	for i, v := range durations {
-		days[i] = v.Hours() / 24
-	}
-	return SumPreservingRound(days)
-}