Add type to points of interest.

This commit is contained in:
Ray Miller 2020-04-20 12:14:24 +01:00
parent 2f9e0e66e3
commit a51a3634bd
4 changed files with 7 additions and 4 deletions

View file

@ -25,6 +25,7 @@ func main() {
func(r *openname.Record) error { func(r *openname.Record) error {
b := placenames.NamedBoundary{ b := placenames.NamedBoundary{
Name: r.Name, Name: r.Name,
Type: r.LocalType,
Xmin: r.MbrXMin, Xmin: r.MbrXMin,
Ymin: r.MbrYMin, Ymin: r.MbrYMin,
Xmax: r.MbrXMax, Xmax: r.MbrXMax,

BIN
pkg/placenames/placenames.bin (Stored with Git LFS)

Binary file not shown.

View file

@ -13,6 +13,7 @@ import (
type NamedBoundary struct { type NamedBoundary struct {
Name string Name string
Type string
Xmin float64 Xmin float64
Ymin float64 Ymin float64
Xmax float64 Xmax float64

View file

@ -42,6 +42,7 @@ func distance(p1, p2 rtreego.Point) float64 {
type POI struct { type POI struct {
Name string Name string
Type string
Distance float64 Distance float64
} }
@ -94,7 +95,7 @@ func (gs *GPXSummarizer) SummarizeTrack(r io.Reader) (*TrackSummary, error) {
prevPlacePoint = thisPoint prevPlacePoint = thisPoint
prevPoint = thisPoint prevPoint = thisPoint
prevHeight = thisHeight prevHeight = thisHeight
s.PointsOfInterest = append(s.PointsOfInterest, POI{nn.Name, 0.0}) s.PointsOfInterest = append(s.PointsOfInterest, POI{Name: nn.Name, Type: nn.Type, Distance: 0.0})
init = false init = false
continue continue
} }
@ -103,7 +104,7 @@ func (gs *GPXSummarizer) SummarizeTrack(r io.Reader) (*TrackSummary, error) {
s.Ascent += ascent s.Ascent += ascent
} }
if nn.Contains(thisPoint) && nn.Name != prevPlace && distance(thisPoint, prevPlacePoint) > 0.2 { if nn.Contains(thisPoint) && nn.Name != prevPlace && distance(thisPoint, prevPlacePoint) > 0.2 {
s.PointsOfInterest = append(s.PointsOfInterest, POI{nn.Name, s.Distance}) s.PointsOfInterest = append(s.PointsOfInterest, POI{Name: nn.Name, Type: nn.Type, Distance: s.Distance})
prevPlace = nn.Name prevPlace = nn.Name
prevPlacePoint = thisPoint prevPlacePoint = thisPoint
} }