-
Notifications
You must be signed in to change notification settings - Fork 0
/
KeepNode.go
58 lines (48 loc) · 947 Bytes
/
KeepNode.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
package osm
import (
//"github.com/pkg/errors"
)
import (
"github.com/spatialcurrent/go-dfl/dfl"
)
func KeepNode(planet *Planet, fi *Filter, n *Node, dfl_cache *dfl.Cache) (bool, error) {
if fi == nil {
return true, nil
}
m := planet.GetTagsAsMap(n.GetTagsIndex())
m["timestamp"] = n.Timestamp
m["version"] = n.Version
m["uid"] = n.UserId
m["user"] = n.UserName
if fi.HasKeysToKeep() {
keep := false
for _, k := range fi.KeysToKeep {
if _, ok := m[k]; ok {
keep = true
break
}
}
if !keep {
return false, nil
}
}
if fi.HasKeysToDrop() {
keep := true
for _, k := range fi.KeysToDrop {
if _, ok := m[k]; ok {
keep = false
break
}
}
if !keep {
return false, nil
}
}
if !fi.ContainsPoint(n.Longitude, n.Latitude) {
return false, nil
}
if !fi.HasExpression() {
return true, nil
}
return EvaluateExpression(m, fi.Expression, fi.Functions, fi.Attributes, dfl_cache)
}