-
Notifications
You must be signed in to change notification settings - Fork 0
/
simpler.go
63 lines (60 loc) · 1.51 KB
/
simpler.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package catTrackslib
import (
"fmt"
"math"
)
// nope nope nope nope, hm. TODO.
// scale comes from ass/leaf-socket.js getZoomLevel()
func getEpsFromScale(scale float64) float64 {
n := math.Pow((scale / math.Pi), -1) // ~ 3.34916212
fmt.Println("Scale", scale, " yields eps ", n)
return n
}
//
// func limitTrackPoints(query *query, tps trackPoint.TPs) (limitedTps trackPoint.TPs, e error) {
//
// start := time.Now()
// originalPointsCount := len(tps)
//
// var tpsSimple []simpleline.Point
// for _, tp := range tps {
// tpsSimple = append(tpsSimple, tp)
// }
//
// var epsilon = query.Epsilon
// // if query.Scale > 0.1 {
// // epsilon = getEpsFromScale(query.Scale)
// // }
//
// res, e := simpleline.RDP(tpsSimple, epsilon, simpleline.Euclidean, true)
// if e != nil {
// fmt.Println(e)
// return tps, e
// }
//
// for len(res) > query.Limit {
// epsilon = epsilon + epsilon/(1-epsilon)
//
// // could be rdp-ing the already rdp-ed?
// res2, e := simpleline.RDP(tpsSimple, epsilon, simpleline.Euclidean, true)
// if e != nil {
// fmt.Println("Error wiggling epsy.", e)
// res = tpsSimple
// continue
// } else {
// res = res2
// }
// }
//
// for _, simpleP := range res {
// tp, ok := simpleP.(*TrackPoint)
// if !ok {
// fmt.Println("shittt notok")
// }
// // could send channeler??
// limitedTps = append(limitedTps, tp)
// }
//
// fmt.Println("Limited ", originalPointsCount, " points to ", len(limitedTps), " in ", time.Since(start))
// return limitedTps, e
// }