From a5931eb9eca9bf347c05a93654c0b82bdf622c7a Mon Sep 17 00:00:00 2001 From: Patrick Brosi Date: Fri, 6 Sep 2019 15:19:11 +0200 Subject: [PATCH] update util --- src/util/geo/Geo.h | 2 +- src/util/geo/PolyLine.tpp | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/util/geo/Geo.h b/src/util/geo/Geo.h index 1cb696e..ffbfada 100644 --- a/src/util/geo/Geo.h +++ b/src/util/geo/Geo.h @@ -1277,7 +1277,7 @@ inline size_t convexHullImpl(const MultiPoint& a, size_t p1, size_t p2, for (const auto& p : a) { double tmpDist = distToSegment((*h)[p1], (*h)[p2], p); double cp = crossProd(p, LineSegment((*h)[p1], (*h)[p2])); - if ((cp > 0) && tmpDist > maxDist) { + if ((cp > 0 + EPSILON) && tmpDist > maxDist) { pa = p; found = true; maxDist = tmpDist; diff --git a/src/util/geo/PolyLine.tpp b/src/util/geo/PolyLine.tpp index 8d34c14..1563874 100644 --- a/src/util/geo/PolyLine.tpp +++ b/src/util/geo/PolyLine.tpp @@ -499,17 +499,23 @@ SharedSegments PolyLine::getSharedSegments(const PolyLine& pl, double totalDist = dist(s, e); while (curSegDist <= totalDist) { - const Point& curPointer = interpolate(s, e, curSegDist); + const auto& curPointer = interpolate(s, e, curSegDist); if (pl.distTo(curPointer) <= dmax) { LinePoint curCmpPointer = pl.projectOn(curPointer); LinePoint curBackProjectedPointer = projectOn(curCmpPointer.p); + + skips = 0; if (in) { curEndCand = curBackProjectedPointer; curEndCandCmp = curCmpPointer; + if (curEndCand.totalPos < curStartCand.totalPos) { + curEndCand = curStartCand; + } + single = false; comp = fabs(curStartCand.totalPos * length - @@ -530,6 +536,7 @@ SharedSegments PolyLine::getSharedSegments(const PolyLine& pl, curEndCand.totalPos * length) > MIN_SEG_LENGTH && fabs(curStartCandCmp.totalPos * plLength - curEndCandCmp.totalPos * plLength) > MIN_SEG_LENGTH)) { + assert(curStartCand.totalPos < curEndCand.totalPos); ret.segments.push_back( SharedSegment(std::pair, LinePoint>( curStartCand, curStartCandCmp), @@ -566,6 +573,7 @@ SharedSegments PolyLine::getSharedSegments(const PolyLine& pl, MIN_SEG_LENGTH && fabs(curStartCandCmp.totalPos * plLength - curEndCandCmp.totalPos * plLength) > MIN_SEG_LENGTH)) { + assert(curStartCand.totalPos < curEndCand.totalPos); ret.segments.push_back(SharedSegment( std::pair, LinePoint>(curStartCand, curStartCandCmp), std::pair, LinePoint>(curEndCand, curEndCandCmp)));