From 34bdaeab71a4cf1fdad882dfebc796e055b51657 Mon Sep 17 00:00:00 2001 From: Ray Miller Date: Sun, 11 Apr 2021 18:39:17 +0100 Subject: [PATCH] Suppress duplicates in the output --- cmd/gpx-anomalies/main.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd/gpx-anomalies/main.go b/cmd/gpx-anomalies/main.go index d162a31..22c43ab 100644 --- a/cmd/gpx-anomalies/main.go +++ b/cmd/gpx-anomalies/main.go @@ -63,6 +63,7 @@ func main() { } func findDuplicates(points []RoutePoint, fuzz, minDist, maxDist float64) { + var lastError *RoutePoint for i := range points { p := points[i] for j := i + 1; j < len(points); j++ { @@ -72,7 +73,8 @@ func findDuplicates(points []RoutePoint, fuzz, minDist, maxDist float64) { } d := euclideanDistance(p.Coordinate, q.Coordinate) D := q.Distance - p.Distance - if d < fuzz && D > minDist && D < maxDist { + if d < fuzz && D > minDist && D < maxDist && (lastError == nil || p.Distance-lastError.Distance > 500) { + lastError = &p fmt.Printf("Point (%0.f, %0.f) revisited at %0.2f km and %0.2f km\n", p.Coordinate.Easting, p.Coordinate.Northing, p.Distance/1000.0, q.Distance/1000.0) }