changeset 4548:befb94e3a953 iso-areas

More debug output.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 30 Sep 2019 11:22:41 +0200
parents 6247f5a42226
children 9c65cef72753
files cmd/isoareas/main.go
diffstat 1 files changed, 29 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/cmd/isoareas/main.go	Fri Sep 27 18:20:13 2019 +0200
+++ b/cmd/isoareas/main.go	Mon Sep 30 11:22:41 2019 +0200
@@ -23,6 +23,7 @@
 	"math/bits"
 	"math/rand"
 	"os"
+	"sort"
 	"strconv"
 	"strings"
 	"time"
@@ -248,11 +249,25 @@
 			if len(cut) >= 2 {
 				arc := int32(len(arcs))
 				arcs = append(arcs, cut)
-				cuts[j] = append(cuts[j], indexedArc{arc, i / 3})
+				cuts[j] = append(cuts[j], indexedArc{arc: arc, index: i / 3})
 			}
 		}
 	}
 
+	for l, c := range classes {
+		sorted := sort.SliceIsSorted(c, func(i, j int) bool {
+			return c[i] < c[j]
+		})
+		log.Printf("class[%d] sorted: %t\n", l, sorted)
+	}
+
+	for l, c := range cuts {
+		sorted := sort.SliceIsSorted(c, func(i, j int) bool {
+			return c[i].index < c[j].index
+		})
+		log.Printf("cut[%d] sorted: %t\n", l, sorted)
+	}
+
 	// connect the arcs in a cut list to longer arcs.
 
 	for _, c := range cuts {
@@ -269,7 +284,7 @@
 		usedArcs := map[int32]struct{}{}
 		var dupes int
 
-		var isolated, inside int
+		var isolated, inside, found int
 	allInClass:
 		for _, idx := range c {
 			ns := neighbors(tri, idx)
@@ -291,10 +306,7 @@
 			default:
 				ti := tri.Triangles[idx*3 : idx*3+3]
 				for j := 0; j < 3; j++ {
-					if mask&(1<<j) == 0 {
-
-						// TODO: Look into cuts to see
-						// if there are real intersections
+					if (mask & (1 << j)) == 0 {
 
 						var curr octree.LineStringZ
 
@@ -302,10 +314,11 @@
 							if l < 0 || l >= len(cuts) {
 								continue
 							}
-							arcIdx := findArc(ns[j], cuts[l])
+							arcIdx := findArc(ns[j]/3, cuts[l])
 							if arcIdx == -1 {
 								continue
 							}
+							found++
 							aIdx := cuts[l][arcIdx].arc
 							if _, already := usedArcs[aIdx]; already {
 								dupes++
@@ -348,8 +361,15 @@
 			}
 		}
 
-		log.Printf("\t%d: inside: %d / isolated: %d open: %d closed: %d dupes: %d\n",
-			i, inside, isolated, pb.open.Len(), len(pb.polygons), dupes)
+		log.Printf("\t%d: inside: %d / isolated: %d open: %d closed: %d dupes: %d found: %d\n",
+			i, inside, isolated, pb.open.Len(), len(pb.polygons), dupes, found)
+
+		/*
+			for e := pb.open.Front(); e != nil; e = e.Next() {
+				line := e.Value.(octree.LineStringZ)
+				pb.polygons = append(pb.polygons, line)
+			}
+		*/
 
 		result[i] = pb.polygons
 	}