Check that the start point is within the bounding box of its nearest neighbour

This commit is contained in:
Ray Miller 2020-12-12 13:02:07 +00:00
parent 340612e566
commit 617b12ff64
3 changed files with 80 additions and 1 deletions

View file

@ -1,6 +1,7 @@
package placenames
import (
"fmt"
"io"
"math"
"strings"
@ -124,6 +125,9 @@ func (gs *GPXSummarizer) SummarizeTrack(r io.Reader, stops *rtreego.Rtree) (*Tra
thisPoint := rtreego.Point{ngCoord.Easting, ngCoord.Northing}
nn, _ := gs.poi.NearestNeighbor(thisPoint).(*NamedBoundary)
if init {
if !nn.Contains(thisPoint) {
return nil, fmt.Errorf("start point out of range")
}
start = thisPoint
s.Start = nn.Name
prevPlace = nn.Name