diff pkg/mesh/polygon.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 5f47eeea988d
children 6270951dda28
line wrap: on
line diff
--- a/pkg/mesh/polygon.go	Sat Aug 06 00:46:21 2022 +0200
+++ b/pkg/mesh/polygon.go	Sat Aug 06 02:09:57 2022 +0200
@@ -28,19 +28,26 @@
 type (
 	ring []float64
 
+	// Polygon has a border and holes.
+	// The line segments are spatially indexed.
 	Polygon struct {
 		rings   []ring
 		indices []*rtree.RTree
 	}
 
+	// IntersectionType represents an enum
+	// of the type of intersection.
 	IntersectionType byte
 
 	lineSegment []float64
 )
 
 const (
+	// IntersectionInside is inside the polygon.
 	IntersectionInside IntersectionType = iota
+	// IntersectionOutSide is outside the polygon.
 	IntersectionOutSide
+	// IntersectionOverlaps overlaps the polygon.
 	IntersectionOverlaps
 )
 
@@ -67,6 +74,7 @@
 	return min, max
 }
 
+// Indexify creates a spatial index for thw polygon.
 func (p *Polygon) Indexify() {
 	indices := make([]*rtree.RTree, len(p.rings))
 
@@ -212,6 +220,8 @@
 	return true
 }
 
+// IntersectionBox2D checks the type of intersection of the
+// given box.
 func (p *Polygon) IntersectionBox2D(box Box2D) IntersectionType {
 
 	if len(p.rings) == 0 {
@@ -253,6 +263,8 @@
 	return IntersectionOutSide
 }
 
+// IntersectionWithTriangle checks the intersection type
+// for the given triangle.
 func (p *Polygon) IntersectionWithTriangle(t *Triangle) IntersectionType {
 	box := t.BBox()
 	min, max := box.Rect()
@@ -387,6 +399,7 @@
 	return raySlope >= diagSlope
 }
 
+// NumVertices returns the number of vertices of a given ring.
 func (p *Polygon) NumVertices(ring int) int {
 	if ring < 0 || ring >= len(p.rings) {
 		return 0
@@ -394,6 +407,8 @@
 	return len(p.rings[ring]) / 2
 }
 
+// Vertices passes the vertices of a given ring
+// to the given fn function.
 func (p *Polygon) Vertices(ring int, fn func(float64, float64)) {
 	if ring < 0 || ring >= len(p.rings) {
 		return
@@ -404,6 +419,7 @@
 	}
 }
 
+// AsWKB serializes the polygon as WKB.
 func (p *Polygon) AsWKB() []byte {
 
 	size := 1 + 4 + 4
@@ -428,6 +444,7 @@
 	return buf.Bytes()
 }
 
+// FromWKB deserializes a polygon from WKB.
 func (p *Polygon) FromWKB(data []byte) error {
 
 	r := bytes.NewReader(data)
@@ -497,6 +514,7 @@
 	return nil
 }
 
+// FromLineStringZ creates a polygon from a given linestring z.
 func (p *Polygon) FromLineStringZ(ls LineStringZ) {
 	r := make([]float64, 2*len(ls))
 	var pos int