changeset 4731:dc0db4ede3b1 stack-polygons

Output based on recursive containment.
author Sascha L. Teichmann <teichmann@intevation.de>
date Fri, 18 Oct 2019 00:16:12 +0200
parents 76dbeab4a0d6
children 7083fd1da169
files pkg/octree/areas.go
diffstat 1 files changed, 19 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/pkg/octree/areas.go	Thu Oct 17 23:56:19 2019 +0200
+++ b/pkg/octree/areas.go	Fri Oct 18 00:16:12 2019 +0200
@@ -357,18 +357,31 @@
 	bf.roots = append(bf.roots, nr)
 }
 
-type bboxOutFunc func(contour, []contourmap.Contour)
+type bboxOutFunc func(contour, []contour)
 
-func (bn *bboxNode) generate(shell bool, out bboxOutFunc) {
-	if shell && len(bn.children) == 0 {
+func (bn *bboxNode) generate(out bboxOutFunc) {
+	if len(bn.children) == 0 {
 		out(bn.cnt, nil)
 		return
 	}
+
+	var grands []*bboxNode
+
+	holes := make([]contour, len(bn.children))
+
+	for i, ch := range bn.children {
+		holes[i] = ch.cnt
+		grands = append(grands, ch.children...)
+	}
+	out(bn.cnt, holes)
+	for _, grand := range grands {
+		grand.generate(out)
+	}
 }
 
 func (bf *bboxForest) generate(out bboxOutFunc) {
 	for _, r := range bf.roots {
-		r.generate(true, out)
+		r.generate(out)
 	}
 }
 
@@ -383,11 +396,11 @@
 		bf.insert(contour(cnt))
 	}
 
-	log.Printf("cnts: %d roots: %d\n", len(cnts), len(bf.roots))
+	//log.Printf("cnts: %d roots: %d\n", len(cnts), len(bf.roots))
 
 	var mp wkb.MultiPolygonGeom
 
-	out := func(sh contour, hls []contourmap.Contour) {
+	out := func(sh contour, hls []contour) {
 
 		polygon := make(wkb.PolygonGeom, 1+len(hls))