Mercurial > gemma
diff pkg/wkb/data.go @ 5601:1222b777f51f
Made golint finally happy.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Sat, 06 Aug 2022 02:09:57 +0200 |
parents | 0ddb308fed37 |
children | 2dd155cc95ec |
line wrap: on
line diff
--- a/pkg/wkb/data.go Sat Aug 06 00:46:21 2022 +0200 +++ b/pkg/wkb/data.go Sat Aug 06 02:09:57 2022 +0200 @@ -21,15 +21,20 @@ ) type ( + // PointGeom is a 2D point, PointGeom struct { X float64 Y float64 } - LinearRingGeom []PointGeom - PolygonGeom []LinearRingGeom + // LinearRingGeom is a ring of points. + LinearRingGeom []PointGeom + // PolygonGeom is a polygon. + PolygonGeom []LinearRingGeom + // MultiPolygonGeom is a multi polygon. MultiPolygonGeom []PolygonGeom ) +// AsWKB serializes a multi polygon as WKB. func (mpg MultiPolygonGeom) AsWKB() []byte { size := 1 + 4 + 4 @@ -65,6 +70,7 @@ return buf.Bytes() } +// FromWKB deserializes a multi polygon from WKB. func (mpg *MultiPolygonGeom) FromWKB(data []byte) error { r := bytes.NewReader(data) @@ -152,6 +158,7 @@ return nil } +// CCW tells if the ring is oriented counter clock wise. func (lr LinearRingGeom) CCW() bool { var sum float64 for i, v1 := range lr { @@ -161,6 +168,7 @@ return sum > 0 } +// Reverse changes the orientation of the ring. func (lr LinearRingGeom) Reverse() { for i, j := 0, len(lr)-1; i < j; i, j = i+1, j-1 { lr[i], lr[j] = lr[j], lr[i]