changeset 4855:01b593ea2311

Added missing doc strings for the STR tree in the mesh package.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 19 Nov 2019 17:48:02 +0100
parents b9599e5e8004
children 22db634be8be
files pkg/mesh/strtree.go
diffstat 1 files changed, 24 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/pkg/mesh/strtree.go	Tue Nov 19 17:20:45 2019 +0100
+++ b/pkg/mesh/strtree.go	Tue Nov 19 17:48:02 2019 +0100
@@ -23,13 +23,19 @@
 	"sort"
 )
 
+// STRTreeDefaultEntries is the default number of children per node and leaf.
 const STRTreeDefaultEntries = 8
 
+// STRTree is a Sort Tile Recurse tree.
 type STRTree struct {
+	// Entries is the total number of entries.
 	Entries int
-	tin     *Tin
-	index   []int32
-	bboxes  []Box2D
+	// tin is a reference to the TIN this tree is build from.
+	tin *Tin
+	// index is the internal tree representation.
+	index []int32
+	// bboxes are the bounding boxes used in nodes and leaves.
+	bboxes []Box2D
 }
 
 // Vertical does a vertical cross cut from (x1, y1) to (x2, y2).
@@ -88,10 +94,17 @@
 	}
 }
 
-func (s *STRTree) Min() Vertex  { return s.tin.Min }
-func (s *STRTree) Max() Vertex  { return s.tin.Max }
+// Min return the minimum vertex of the TIN this tree is build from.
+func (s *STRTree) Min() Vertex { return s.tin.Min }
+
+// Max return the maximum vertex of the TIN this tree is build from.
+func (s *STRTree) Max() Vertex { return s.tin.Max }
+
+// EPSG return the EPSF code of the TIN this tree is build from.
 func (s *STRTree) EPSG() uint32 { return s.tin.EPSG }
 
+// Value returns the Z Value for a given X/Y point.
+// Second return value is false if the point is out of bound.
 func (s *STRTree) Value(x, y float64) (float64, bool) {
 
 	if len(s.index) == 0 {
@@ -133,6 +146,7 @@
 	return 0, false
 }
 
+// Build builds a tree for a given TIN.
 func (s *STRTree) Build(t *Tin) {
 
 	if s.Entries == 0 {
@@ -154,6 +168,8 @@
 	s.index[0] = root
 }
 
+// BuildWithout builds a tree for a given TIN ignoring the triangles
+// with the indices given in the remove map.
 func (s *STRTree) BuildWithout(t *Tin, remove map[int32]struct{}) {
 
 	if s.Entries == 0 {
@@ -178,6 +194,8 @@
 	s.index[0] = root
 }
 
+// Clip returns the indices of the triangles of the TIN
+// which are not fully covered by the given polygon.
 func (s *STRTree) Clip(p *Polygon) map[int32]struct{} {
 
 	removed := make(map[int32]struct{})
@@ -290,6 +308,7 @@
 	return err
 }
 
+// Bytes serializes this tree to a byte slice.
 func (s *STRTree) Bytes() ([]byte, error) {
 
 	var buf bytes.Buffer