Allow start point to be within 500m of bounding box of its nearest neighbour
This commit is contained in:
parent
617b12ff64
commit
af15ee6707
3 changed files with 59 additions and 1 deletions
|
@ -29,6 +29,16 @@ func (b *NamedBoundary) Bounds() *rtreego.Rect {
|
|||
return r
|
||||
}
|
||||
|
||||
func (b *NamedBoundary) NearEnough(p rtreego.Point, margin float64) bool {
|
||||
if len(p) != 2 {
|
||||
panic("Expected a 2-dimensional point")
|
||||
}
|
||||
return p[0] >= b.Xmin-margin &&
|
||||
p[0] <= b.Xmax+margin &&
|
||||
p[1] >= b.Ymin-margin &&
|
||||
p[1] <= b.Ymax+margin
|
||||
}
|
||||
|
||||
func (b *NamedBoundary) Contains(p rtreego.Point) bool {
|
||||
if len(p) != 2 {
|
||||
panic("Expected a 2-dimensional point")
|
||||
|
|
|
@ -125,7 +125,7 @@ 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) {
|
||||
if !nn.NearEnough(thisPoint, 500.0) {
|
||||
return nil, fmt.Errorf("start point out of range")
|
||||
}
|
||||
start = thisPoint
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue