diff options
Diffstat (limited to 'web/views.go')
| -rw-r--r-- | web/views.go | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/web/views.go b/web/views.go index 551a74f..b728de8 100644 --- a/web/views.go +++ b/web/views.go @@ -21,6 +21,7 @@ type RideView struct { type RideDetailView struct { RideView Route GeoJSONFeatureCollection + Passes []RideMapPass HasRoute bool Profile RideProfile RouteError string @@ -28,6 +29,13 @@ type RideDetailView struct { Notice string } +type RideMapPass struct { + Name string `json:"name"` + ElevationM int `json:"elevationM"` + Latitude float64 `json:"latitude"` + Longitude float64 `json:"longitude"` +} + type RideProfile struct { Points []RideProfilePoint `json:"points"` Climbs []RideProfileClimb `json:"climbs"` @@ -228,6 +236,7 @@ func buildRideDetailView(item rides.Ride, parsed ride.Ride, passes []mountain_pa profile := buildRideProfile(parsed, passes, officialClimbs, matchPolicy) return RideDetailView{ RideView: buildRideView(item), + Passes: buildRideMapPasses(passes), Route: GeoJSONFeatureCollection{ Type: "FeatureCollection", Features: []GeoJSONFeature{{ @@ -243,6 +252,22 @@ func buildRideDetailView(item rides.Ride, parsed ride.Ride, passes []mountain_pa } } +func buildRideMapPasses(passes []mountain_pass.MountainPass) []RideMapPass { + mapPasses := make([]RideMapPass, 0, len(passes)) + for _, mountainPass := range passes { + if mountainPass.Coord == nil { + continue + } + mapPasses = append(mapPasses, RideMapPass{ + Name: mountainPass.Name, + ElevationM: mountainPass.Elevation, + Latitude: mountainPass.Coord.Lat, + Longitude: mountainPass.Coord.Lon, + }) + } + return mapPasses +} + func buildRideProfile(parsed ride.Ride, passes []mountain_pass.MountainPass, officialClimbs []official_climb.OfficialClimb, matchPolicy official_climb.MatchPolicy) RideProfile { profile := RideProfile{ Points: make([]RideProfilePoint, parsed.Len()), |