Mercurial > gemma
changeset 796:0cc97135717c
More fixes to vertical triangle intersection.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 27 Sep 2018 11:40:02 +0200 |
parents | bd5f38eb6153 |
children | 644172f201e8 |
files | pkg/controllers/octreecross.go pkg/octree/vertex.go |
diffstat | 2 files changed, 21 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/pkg/controllers/octreecross.go Thu Sep 27 10:57:39 2018 +0200 +++ b/pkg/controllers/octreecross.go Thu Sep 27 11:40:02 2018 +0200 @@ -108,14 +108,17 @@ var line octree.MultiLineStringZ tree.Vertical(c1.Lat, c1.Lon, c2.Lat, c2.Lon, func(t *octree.Triangle) { if ls := verticalLine.Intersection(t); len(ls) > 0 { - line = append(line) + line = append(line, ls) } }) if len(line) > 0 { + log.Printf("line length: %d\n", len(line)) // They are all on the segment (c1.Lat, c1.Lon) - (c2.Lat, c2.Lon). // Sort them by project them on this line. - segments = append(segments, line.JoinOnLine(c1.Lat, c1.Lon, c2.Lat, c2.Lon)...) + joined := line.JoinOnLine(c1.Lat, c1.Lon, c2.Lat, c2.Lon) + log.Printf("joined length: %d\n", len(joined)) + segments = append(segments, joined...) } }
--- a/pkg/octree/vertex.go Thu Sep 27 10:57:39 2018 +0200 +++ b/pkg/octree/vertex.go Thu Sep 27 11:40:02 2018 +0200 @@ -237,17 +237,27 @@ out := make(MultiLineStringZ, 0, len(positions)) + var ignored int + for i := range positions { curr := positions[i].line if l := len(out); l > 0 { - if last := out[l-1]; last[len(last)-1].EpsEquals(curr[0]) { + last := out[l-1] + + if last[len(last)-1].EpsEquals(curr[0]) { out[l-1] = append(last[:len(last)-1], curr...) continue } + if position(last[len(last)-1]) > position(curr[0]) { + ignored++ + continue + } } out = append(out, curr) } + log.Printf("ignored parts: %d\n", ignored) + return out } @@ -450,6 +460,10 @@ var out LineStringZ + defer func() { + log.Printf("length out: %d\n", len(out)) + }() + edges: for i := 0; i < 3 && len(out) < 2; i++ { j := (i + 1) % 3 @@ -461,7 +475,7 @@ o1 := onPlane(s1) o2 := onPlane(s2) - log.Printf("s1, s2: %t %t\n", o1, o2) + log.Printf("s1, s2: %t %t (%f %f)\n", o1, o2, s1, s2) switch { case o1 && o2: @@ -527,8 +541,6 @@ log.Println("Intersection -----------------------------") t1 := relative(t[i], t[j])(x, y) - log.Printf("rel p1: %f\n", relative(t[i], t[j])(t[i].X, t[i].Y)) - log.Printf("rel p2: %f\n", relative(t[i], t[j])(t[j].X, t[j].Y)) log.Printf("relative pos: %f\n", t1) if !inRange(t1) { continue edges @@ -613,8 +625,6 @@ } } - log.Printf("length out: %d\n", len(out)) - // supress single point touches. if len(out) == 1 { out = out[:0]