horse: use straight front type in racecourse api

This commit is contained in:
2026-10-10 13:37:12 -04:00
parent 381df5bd35
commit 3a39794312
3 changed files with 30 additions and 38 deletions
+2 -3
View File
@@ -140,8 +140,7 @@ func spansslopes(id horse.RacecourseID, evts []courseEvent, length float32) ([]h
// Start of the straight. // Start of the straight.
span = horse.RacecourseSpan{ span = horse.RacecourseSpan{
Start: evt.Distance, Start: evt.Distance,
Straight: true, Straight: int8(evt.Values[1]),
FarStraight: evt.Values[1] == 2,
} }
// Continue out of the switch. // Continue out of the switch.
} }
@@ -154,7 +153,7 @@ func spansslopes(id horse.RacecourseID, evts []courseEvent, length float32) ([]h
// Longchamp 1000 (which doesn't appear to actually be used but w/e) // Longchamp 1000 (which doesn't appear to actually be used but w/e)
// defines straights by their start positions only, so check for the // defines straights by their start positions only, so check for the
// previous event being a straight with no end. // previous event being a straight with no end.
if prev.Straight && prev.End == 0 { if prev.Straight != 0 && prev.End == 0 {
spans[len(spans)-1].End = span.Start spans[len(spans)-1].End = span.Start
} else { } else {
// Otherwise, insert a new span which is neither straight nor corner. // Otherwise, insert a new span which is neither straight nor corner.
+14 -19
View File
@@ -35,7 +35,7 @@ func TestRacecourses(t *testing.T) {
{ {
Start: 0, Start: 0,
End: 649.9000244140625, End: 649.9000244140625,
Straight: true, Straight: 1,
}, },
{ {
Start: 649.9000244140625, Start: 649.9000244140625,
@@ -44,7 +44,7 @@ func TestRacecourses(t *testing.T) {
{ {
Start: 650, Start: 650,
End: 1000, End: 1000,
Straight: true, Straight: 1,
}, },
}, },
Slopes: []horse.Slope{}, Slopes: []horse.Slope{},
@@ -66,8 +66,7 @@ func TestRacecourses(t *testing.T) {
{ {
Start: 0, Start: 0,
End: 458, End: 458,
Straight: true, Straight: 2,
FarStraight: true,
}, },
{ {
Start: 458, Start: 458,
@@ -82,7 +81,7 @@ func TestRacecourses(t *testing.T) {
{ {
Start: 958, Start: 958,
End: 1450, End: 1450,
Straight: true, Straight: 1,
}, },
{ {
Start: 1450, Start: 1450,
@@ -97,8 +96,7 @@ func TestRacecourses(t *testing.T) {
{ {
Start: 1850, Start: 1850,
End: 2300, End: 2300,
Straight: true, Straight: 2,
FarStraight: true,
}, },
{ {
Start: 2300, Start: 2300,
@@ -113,7 +111,7 @@ func TestRacecourses(t *testing.T) {
{ {
Start: 2797, Start: 2797,
End: 3200, End: 3200,
Straight: true, Straight: 1,
}, },
}, },
Slopes: []horse.Slope{ Slopes: []horse.Slope{
@@ -166,7 +164,7 @@ func TestRacecourses(t *testing.T) {
{ {
Start: 0, Start: 0,
End: 500, End: 500,
Straight: true, Straight: 1,
}, },
{ {
Start: 500, Start: 500,
@@ -181,8 +179,7 @@ func TestRacecourses(t *testing.T) {
{ {
Start: 800, Start: 800,
End: 1300, End: 1300,
Straight: true, Straight: 2,
FarStraight: true,
}, },
{ {
Start: 1300, Start: 1300,
@@ -197,7 +194,7 @@ func TestRacecourses(t *testing.T) {
{ {
Start: 1614, Start: 1614,
End: 2000, End: 2000,
Straight: true, Straight: 1,
}, },
}, },
Slopes: []horse.Slope{}, Slopes: []horse.Slope{},
@@ -219,8 +216,7 @@ func TestRacecourses(t *testing.T) {
{ {
Start: 0, Start: 0,
End: 798, End: 798,
Straight: true, Straight: 2,
FarStraight: true,
}, },
{ {
Start: 798, Start: 798,
@@ -239,7 +235,7 @@ func TestRacecourses(t *testing.T) {
{ {
Start: 1600, Start: 1600,
End: 2400, End: 2400,
Straight: true, Straight: 1,
}, },
}, },
Slopes: []horse.Slope{}, Slopes: []horse.Slope{},
@@ -265,7 +261,7 @@ func TestRacecourses(t *testing.T) {
{ {
Start: 100, Start: 100,
End: 500, End: 500,
Straight: true, Straight: 1,
}, },
{ {
Start: 500, Start: 500,
@@ -280,8 +276,7 @@ func TestRacecourses(t *testing.T) {
{ {
Start: 900, Start: 900,
End: 1300, End: 1300,
Straight: true, Straight: 2,
FarStraight: true,
}, },
{ {
Start: 1300, Start: 1300,
@@ -296,7 +291,7 @@ func TestRacecourses(t *testing.T) {
{ {
Start: 1700, Start: 1700,
End: 2000, End: 2000,
Straight: true, Straight: 1,
}, },
}, },
Slopes: []horse.Slope{ Slopes: []horse.Slope{
+3 -5
View File
@@ -46,11 +46,9 @@ type RacecourseSpan struct {
Start float32 `json:"start"` Start float32 `json:"start"`
// End is the distance in meters along the track at which the span ends. // End is the distance in meters along the track at which the span ends.
End float32 `json:"end"` End float32 `json:"end"`
// Straight is whether the span is formally a straight. // Straight is the straight type if the span is formally a straight.
Straight bool `json:"straight,omitzero"` // 1 indicates the front stretch and 2 the backstretch.
// FarStraight is whether the span is the backstretch. Straight int8 `json:"straight,omitzero"`
// If true, then Straight is also true.
FarStraight bool `json:"far_straight,omitzero"`
// Corner is the corner number of the span, or zero if not a corner. // Corner is the corner number of the span, or zero if not a corner.
Corner int8 `json:"corner,omitzero"` Corner int8 `json:"corner,omitzero"`
} }