Mercurial > gemma
changeset 1622:a3a3fc630620
Sounding result import: Fixed reading bounding polygon from clipping shape.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 18 Dec 2018 16:37:34 +0100 |
parents | eeddc5dcb80c |
children | 20c98c2964f7 |
files | pkg/imports/polygon.go |
diffstat | 1 files changed, 11 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/pkg/imports/polygon.go Tue Dec 18 16:25:03 2018 +0100 +++ b/pkg/imports/polygon.go Tue Dec 18 16:37:34 2018 +0100 @@ -50,11 +50,18 @@ func toPolygon(numParts int32, parts []int32, points []shp.Point) polygon { out := make(polygon, numParts) - pos := 0 + var pos int32 + for i := range out { - ps := parts[i] - line := make(lineString, ps) - for j := int32(0); j < ps; j, pos = j+1, pos+1 { + var howMany int32 + if i+1 >= len(parts) { + howMany = int32(len(points)) - pos + } else { + howMany = parts[i+1] - pos + } + + line := make(lineString, howMany) + for j := int32(0); j < howMany; j, pos = j+1, pos+1 { p := &points[pos] line[j] = point{p.X, p.Y} }