From 6135951d08164d3a7d2e911668461d9a34250e2b Mon Sep 17 00:00:00 2001 From: Ray Miller Date: Mon, 27 Apr 2020 07:41:25 +0100 Subject: [PATCH] Bugfix tool for condensing POI. --- cmd/condense/main.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/cmd/condense/main.go b/cmd/condense/main.go index c82e199..c97c636 100644 --- a/cmd/condense/main.go +++ b/cmd/condense/main.go @@ -73,6 +73,22 @@ func condenseMinDist(xs []placenames.POI, minDist float64) []placenames.POI { cont = true break } + if i == len(xs)-2 || p1 < p2 { + xs = deleteElement(xs, i) + cont = true + break + } + d1 := xs[i].Distance - xs[i-1].Distance + d2 := xs[i+1].Distance - xs[i].Distance + if d1 < d2 { + xs = deleteElement(xs, i) + cont = true + break + } else { + xs = deleteElement(xs, i+1) + cont = true + break + } } } }