forked from qedus/osmpbf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
decode_tag.go
38 lines (33 loc) · 865 Bytes
/
decode_tag.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
package osmpbf
// Make tags map from stringtable and two parallel arrays of IDs.
func extractTags(stringTable []string, keyIDs, valueIDs []uint32) map[string]string {
tags := make(map[string]string, len(keyIDs))
for index, keyID := range keyIDs {
key := stringTable[keyID]
val := stringTable[valueIDs[index]]
tags[key] = val
}
return tags
}
type tagUnpacker struct {
stringTable []string
keysVals []int32
index int
}
// Make tags map from stringtable and array of IDs (used in DenseNodes encoding).
func (tu *tagUnpacker) next() map[string]string {
tags := make(map[string]string)
for tu.index < len(tu.keysVals) {
keyID := tu.keysVals[tu.index]
tu.index++
if keyID == 0 {
break
}
valID := tu.keysVals[tu.index]
tu.index++
key := tu.stringTable[keyID]
val := tu.stringTable[valID]
tags[key] = val
}
return tags
}