forked from twpayne/go-geom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flat_inflate.go
39 lines (35 loc) · 1018 Bytes
/
flat_inflate.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
package geom
func inflate0(flatCoords []float64, offset, end, stride int) Coord {
if offset+stride != end {
panic("geom: stride mismatch")
}
c := make([]float64, stride)
copy(c, flatCoords[offset:end])
return c
}
func inflate1(flatCoords []float64, offset, end, stride int) []Coord {
coords1 := make([]Coord, (end-offset)/stride)
for i := range coords1 {
coords1[i] = inflate0(flatCoords, offset, offset+stride, stride)
offset += stride
}
return coords1
}
func inflate2(flatCoords []float64, offset int, ends []int, stride int) [][]Coord {
coords2 := make([][]Coord, len(ends))
for i := range coords2 {
end := ends[i]
coords2[i] = inflate1(flatCoords, offset, end, stride)
offset = end
}
return coords2
}
func inflate3(flatCoords []float64, offset int, endss [][]int, stride int) [][][]Coord {
coords3 := make([][][]Coord, len(endss))
for i := range coords3 {
ends := endss[i]
coords3[i] = inflate2(flatCoords, offset, ends, stride)
offset = ends[len(ends)-1]
}
return coords3
}