comparison pkg/octree/strtree.go @ 4768:a2f16bbcc846 direct-diff

Morph differences: Directly raster A and subtract B as a raster.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 21 Oct 2019 02:01:56 +0200
parents 9eb708176b43
children
comparison
equal deleted inserted replaced
4767:f66e5b2fa894 4768:a2f16bbcc846
482 } 482 }
483 s.index[pos] = int32(s.allocBBox(box)) 483 s.index[pos] = int32(s.allocBBox(box))
484 } 484 }
485 return int32(-(pos + 1)) 485 return int32(-(pos + 1))
486 } 486 }
487
488 func (s *STRTree) Diff(other *STRTree) PointMap {
489
490 firstVs, secondVs := s.tin.Vertices, other.tin.Vertices
491
492 result := make(PointMap, len(firstVs)+len(secondVs))
493
494 sliceWork(
495 firstVs,
496 result,
497 func(slice []Vertex, turn func([]Vertex) []Vertex) {
498 p := turn(nil)
499 for i := range slice {
500 v := &slice[i]
501 if z, found := other.Value(v.X, v.Y); found {
502 p = append(p, Vertex{v.X, v.Y, v.Z - z})
503 if len(p) == cap(p) {
504 p = turn(p)
505 }
506 }
507 }
508 if len(p) > 0 {
509 turn(p)
510 }
511 })
512
513 sliceWork(
514 secondVs,
515 result,
516 func(
517 slice []Vertex, turn func([]Vertex) []Vertex) {
518 p := turn(nil)
519 for i := range slice {
520 v := &slice[i]
521 if z, found := s.Value(v.X, v.Y); found {
522 p = append(p, Vertex{v.X, v.Y, z - v.Z})
523 if len(p) == cap(p) {
524 p = turn(p)
525 }
526 }
527 }
528 if len(p) > 0 {
529 turn(p)
530 }
531 })
532
533 return result
534 }