diff options
Diffstat (limited to 'official_climb/model.go')
| -rw-r--r-- | official_climb/model.go | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/official_climb/model.go b/official_climb/model.go index ae66f46..beecd02 100644 --- a/official_climb/model.go +++ b/official_climb/model.go @@ -7,6 +7,7 @@ import ( "time" "github.com/jftuga/geodist" + "github.com/martinlehoux/biking_home/climb" ) const DefaultMatchRadiusM = 100.0 @@ -16,8 +17,10 @@ type OfficialClimb struct { Name string StartCoord geodist.Coord EndCoord geodist.Coord - CreatedAt time.Time - UpdatedAt time.Time + // Sample is the passage the climb was created from; matching rejects candidates outside its band. + Sample climb.SegmentSample + CreatedAt time.Time + UpdatedAt time.Time } type MatchPolicy struct { @@ -42,6 +45,9 @@ func (climb OfficialClimb) validate() error { if !validCoord(climb.StartCoord) || !validCoord(climb.EndCoord) { return fmt.Errorf("official climb coordinates are invalid") } + if climb.Sample.DistanceM <= 0 || climb.Sample.ElevationGainM <= 0 { + return fmt.Errorf("official climb sample must record a positive distance and elevation gain") + } return nil } |
