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
+3 -4
View File
@@ -139,9 +139,8 @@ func spansslopes(id horse.RacecourseID, evts []courseEvent, length float32) ([]h
}
// Start of the straight.
span = horse.RacecourseSpan{
Start: evt.Distance,
Straight: true,
FarStraight: evt.Values[1] == 2,
Start: evt.Distance,
Straight: int8(evt.Values[1]),
}
// 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)
// defines straights by their start positions only, so check for the
// 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
} else {
// Otherwise, insert a new span which is neither straight nor corner.
+24 -29
View File
@@ -35,7 +35,7 @@ func TestRacecourses(t *testing.T) {
{
Start: 0,
End: 649.9000244140625,
Straight: true,
Straight: 1,
},
{
Start: 649.9000244140625,
@@ -44,7 +44,7 @@ func TestRacecourses(t *testing.T) {
{
Start: 650,
End: 1000,
Straight: true,
Straight: 1,
},
},
Slopes: []horse.Slope{},
@@ -64,10 +64,9 @@ func TestRacecourses(t *testing.T) {
LaneStart: [18]horse.TenThousandths{0, 555, 1111, 1666, 2222, 2777, 3333, 3888, 4444, 5333, 5888, 6444, 7000, 7555, 8111, 8666, 9222, 9777},
Spans: []horse.RacecourseSpan{
{
Start: 0,
End: 458,
Straight: true,
FarStraight: true,
Start: 0,
End: 458,
Straight: 2,
},
{
Start: 458,
@@ -82,7 +81,7 @@ func TestRacecourses(t *testing.T) {
{
Start: 958,
End: 1450,
Straight: true,
Straight: 1,
},
{
Start: 1450,
@@ -95,10 +94,9 @@ func TestRacecourses(t *testing.T) {
Corner: 2,
},
{
Start: 1850,
End: 2300,
Straight: true,
FarStraight: true,
Start: 1850,
End: 2300,
Straight: 2,
},
{
Start: 2300,
@@ -113,7 +111,7 @@ func TestRacecourses(t *testing.T) {
{
Start: 2797,
End: 3200,
Straight: true,
Straight: 1,
},
},
Slopes: []horse.Slope{
@@ -166,7 +164,7 @@ func TestRacecourses(t *testing.T) {
{
Start: 0,
End: 500,
Straight: true,
Straight: 1,
},
{
Start: 500,
@@ -179,10 +177,9 @@ func TestRacecourses(t *testing.T) {
Corner: 2,
},
{
Start: 800,
End: 1300,
Straight: true,
FarStraight: true,
Start: 800,
End: 1300,
Straight: 2,
},
{
Start: 1300,
@@ -197,7 +194,7 @@ func TestRacecourses(t *testing.T) {
{
Start: 1614,
End: 2000,
Straight: true,
Straight: 1,
},
},
Slopes: []horse.Slope{},
@@ -217,10 +214,9 @@ func TestRacecourses(t *testing.T) {
LaneStart: [18]horse.TenThousandths{0, 555, 1111, 1666, 2222, 2777, 3333, 3888, 4444, 5000, 5555, 6111, 6666, 7222, 8811, 9366, 9922, 10477},
Spans: []horse.RacecourseSpan{
{
Start: 0,
End: 798,
Straight: true,
FarStraight: true,
Start: 0,
End: 798,
Straight: 2,
},
{
Start: 798,
@@ -239,7 +235,7 @@ func TestRacecourses(t *testing.T) {
{
Start: 1600,
End: 2400,
Straight: true,
Straight: 1,
},
},
Slopes: []horse.Slope{},
@@ -265,7 +261,7 @@ func TestRacecourses(t *testing.T) {
{
Start: 100,
End: 500,
Straight: true,
Straight: 1,
},
{
Start: 500,
@@ -278,10 +274,9 @@ func TestRacecourses(t *testing.T) {
Corner: 2,
},
{
Start: 900,
End: 1300,
Straight: true,
FarStraight: true,
Start: 900,
End: 1300,
Straight: 2,
},
{
Start: 1300,
@@ -296,7 +291,7 @@ func TestRacecourses(t *testing.T) {
{
Start: 1700,
End: 2000,
Straight: true,
Straight: 1,
},
},
Slopes: []horse.Slope{
+3 -5
View File
@@ -46,11 +46,9 @@ type RacecourseSpan struct {
Start float32 `json:"start"`
// End is the distance in meters along the track at which the span ends.
End float32 `json:"end"`
// Straight is whether the span is formally a straight.
Straight bool `json:"straight,omitzero"`
// FarStraight is whether the span is the backstretch.
// If true, then Straight is also true.
FarStraight bool `json:"far_straight,omitzero"`
// Straight is the straight type if the span is formally a straight.
// 1 indicates the front stretch and 2 the backstretch.
Straight int8 `json:"straight,omitzero"`
// Corner is the corner number of the span, or zero if not a corner.
Corner int8 `json:"corner,omitzero"`
}