Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
46dc737
feat: Implement Persistence for User Problem Reports
AhmedAlian7 Feb 3, 2026
8a6ed75
chore: Trigger CI
AhmedAlian7 Feb 18, 2026
7e78baf
fix: update SituationIDs in BuildTripStatus to use GetSituationIDsFor…
Ahmedhossamdev Jan 16, 2026
5072ff6
refactor: Add situations to reference
Ahmedhossamdev Jan 16, 2026
2ba1425
feat: improve trip status calculations with real-time stop delays + r…
Ahmedhossamdev Jan 24, 2026
e4314a8
fix: update the last location update time only when the vehicle posit…
Ahmedhossamdev Jan 27, 2026
de285b8
refactor: remove unused functions
Ahmedhossamdev Feb 8, 2026
ac24b1d
feat: add service date
Ahmedhossamdev Feb 13, 2026
13b8973
refactor: simplify service date handling
Ahmedhossamdev Feb 13, 2026
4ed433c
fix: update go-gtfs dependency to v1.1.1
Ahmedhossamdev Feb 13, 2026
5b3798a
feat: enhance vehicle status handling and add position projection ont…
Ahmedhossamdev Feb 13, 2026
9d220d4
feat: implement StaleDetector for vehicle timestamp validation
Ahmedhossamdev Feb 13, 2026
bb582e3
feat: improve trip status calculation with block-level position and e…
Ahmedhossamdev Feb 13, 2026
9dfe4bb
refactor: streamline service date handling and optimize route ID retr…
Ahmedhossamdev Feb 13, 2026
2b59755
feat: improve trip status calculation with improved vehicle position …
Ahmedhossamdev Feb 14, 2026
5002188
feat: implement vehicle position service with scheduled position calc…
Ahmedhossamdev Feb 14, 2026
15f5c87
refactor: remove deprecated schedule deviation calculation methods (m…
Ahmedhossamdev Feb 14, 2026
49e51cb
refactor: remove realtime service implementation
Ahmedhossamdev Feb 16, 2026
5eb996a
feat: add CalculateSecondsSinceServiceDate function to compute second…
Ahmedhossamdev Feb 16, 2026
0b0cce2
refactor: clean up GetVehicleStatusAndPhase and relocate getCurrentVe…
Ahmedhossamdev Feb 17, 2026
7154723
feat: implement GetScheduleDeviation and GetStopDelaysFromTripUpdates…
Ahmedhossamdev Feb 17, 2026
ec57ce9
refactor: update BuildVehicleStatus to determine predicted and schedu…
Ahmedhossamdev Feb 17, 2026
c72b447
refactor: rewrite BuildTripStatus to use GTFS-RT trip updates directly
Ahmedhossamdev Feb 17, 2026
d12c181
feat: improve trip status calculations with real-time stop delays + r…
Ahmedhossamdev Jan 24, 2026
f079af6
feat: enhance vehicle status handling and add position projection ont…
Ahmedhossamdev Feb 13, 2026
cfe46d9
feat: improve trip status calculation with block-level position and e…
Ahmedhossamdev Feb 13, 2026
765f6b7
feat: implement vehicle position service with scheduled position calc…
Ahmedhossamdev Feb 14, 2026
605f9e4
refactor: remove realtime service implementation
Ahmedhossamdev Feb 16, 2026
b5d4b77
refactor: rewrite BuildTripStatus to use GTFS-RT trip updates directly
Ahmedhossamdev Feb 17, 2026
9854c6c
refactor: remove unused trip update handling functions and streamline…
Ahmedhossamdev Feb 20, 2026
a439fa8
feat: only adjust next stop logic when the vehicle status is in stopp…
Ahmedhossamdev Feb 20, 2026
6429903
fix: update schedule deviation calculation to use active trip ID rath…
Ahmedhossamdev Feb 20, 2026
acea2a1
fix: update vehicle ID assignment to use combined agency ID and impro…
Ahmedhossamdev Feb 20, 2026
2eb3cc7
docs: update comments for GetVehicleStatusAndPhase function to clarif…
Ahmedhossamdev Feb 20, 2026
25b5d97
refactor: rmove the code logic to vehicles_helper file
Ahmedhossamdev Feb 20, 2026
c7ef29e
feat: implement StaleDetector to manage vehicle data freshness and up…
Ahmedhossamdev Feb 20, 2026
ec6da1d
fix: simplify vehicle ID assignment and improve stop distance calcula…
Ahmedhossamdev Feb 20, 2026
bd035e3
fix: correct vehicle ID assertion in TestBuildTripStatus_VehicleIDFormat
Ahmedhossamdev Feb 20, 2026
46427d9
feat: add timestamp to MockAddVehicle for vehicle tracking
Ahmedhossamdev Feb 20, 2026
bd2ed35
fix: update vehicle phase logic to reflect trip status accurately
Ahmedhossamdev Feb 20, 2026
fe06283
feat: add functions to convert GTFS stop-time values from nanoseconds…
Ahmedhossamdev Feb 22, 2026
19c6a6c
fix: update NanosToSeconds function comment for clarity on GTFS stop-…
Ahmedhossamdev Feb 22, 2026
38ee862
feat: Add MockAddTripUpdate function for managing real-time trip updates
Ahmedhossamdev Feb 22, 2026
5d8fb3a
refactor: extract shapeRowsToPoints function for converting shape row…
Ahmedhossamdev Feb 22, 2026
365776b
fix: update GetVehicleStatusAndPhase to align with Java behavior and …
Ahmedhossamdev Feb 22, 2026
94696a2
test: add unit tests for GetVehicleStatusAndPhase and StaleDetector f…
Ahmedhossamdev Feb 22, 2026
38ba04c
refactor: use the shalpeRowsToPoints directly
Ahmedhossamdev Feb 22, 2026
e8da79f
fix: update time conversion in transformBlockToEntry to use NanosToSe…
Ahmedhossamdev Feb 22, 2026
8a35498
fix: update arrival and departure time conversion to use NanosToSecon…
Ahmedhossamdev Feb 22, 2026
074af8f
fix: update parameter parsing in TestParseTripIdDetailsParams_Unit to…
Ahmedhossamdev Feb 22, 2026
476d088
refactor: rename TripDetailsParams to TripParams and update parsing f…
Ahmedhossamdev Feb 22, 2026
8f40e13
fix: update occupancy capacity handling and time conversions in Build…
Ahmedhossamdev Feb 22, 2026
8db5f2b
feat: add functions to find closest and next stops by time with delay…
Ahmedhossamdev Feb 22, 2026
de26a4a
refactor: simplify shape points creation in buildScheduleForTrip func…
Ahmedhossamdev Feb 22, 2026
bf59030
fix: update GetScheduleDeviation to return a boolean indicating that …
Ahmedhossamdev Feb 22, 2026
9bec5f3
refactor: update parseTripParams function comment for clarity
Ahmedhossamdev Feb 22, 2026
c0f09c8
test: Add tests for GetScheduleDeviation and GetStopDelaysFromTripUpd…
Ahmedhossamdev Feb 22, 2026
5cf569a
refactor: remove TripForVehicleParams and related parsing logic
Ahmedhossamdev Feb 22, 2026
4bf8733
refactor: update parseTripForVehicleParams calls to use parseTripParams
Ahmedhossamdev Feb 22, 2026
c06cc27
Merge origin/main into verifiy-trip-status to resolve trip_details_ha…
Ahmedhossamdev Feb 22, 2026
cf488e0
refactor: update vehicle status logic to correctly set Predicted and …
Ahmedhossamdev Feb 23, 2026
26560d1
refactor: add logging for BuildTripStatus if it return error it shoul…
Ahmedhossamdev Feb 23, 2026
3fcefa3
refactor: MockAddVehicle and MockAddVehicleWithOptions to update tri…
Ahmedhossamdev Feb 23, 2026
0ae1780
refactor: Include all stops that have a real-time update, even if the…
Ahmedhossamdev Feb 23, 2026
91db073
refactor: Treat nil timestamp as not-stale when the vehicle has other…
Ahmedhossamdev Feb 23, 2026
cdf9f36
refactor: Update stale detection tests for vehicles with nil timestam…
Ahmedhossamdev Feb 23, 2026
d1afb93
refactor: Update occupancy capacity handling and refine GPS position …
Ahmedhossamdev Feb 23, 2026
4df058a
refactor: Add tests for finding closest and next stops by sequence wi…
Ahmedhossamdev Feb 23, 2026
eea4029
refactor: Remove unused projectPositionOntoRoute function from vehicl…
Ahmedhossamdev Feb 23, 2026
17227ad
refactor: Update stop delay tests to include stops with zero delays
Ahmedhossamdev Feb 23, 2026
83d66f1
refactor: Replace createTestApi with direct RestAPI instantiation in …
Ahmedhossamdev Feb 23, 2026
8228121
refactor: Correct return value for GetScheduleDeviation when no delay…
Ahmedhossamdev Feb 23, 2026
115f7bf
refactor: Update BuildVehicleStatus to accept currentTime param and a…
Ahmedhossamdev Feb 23, 2026
5720fba
refactor: Add check for valid BlockID in calculateBlockTripSequence f…
Ahmedhossamdev Feb 23, 2026
568da32
refactor: Set status to nil on error
Ahmedhossamdev Feb 23, 2026
c4efbd6
refactor: Optimize findStopsByScheduleDeviation to use index for clos…
Ahmedhossamdev Feb 23, 2026
3dc38cf
refactor: Update TripID in TripDetails to use combined ID format
Ahmedhossamdev Feb 23, 2026
083bfaf
refactor: Simplify StaleDetector WithThreshold method to return a new…
Ahmedhossamdev Feb 23, 2026
ce1d932
refactor: Update vehicle status comments to clarify GTFS-RT schedule …
Ahmedhossamdev Feb 23, 2026
0e2051d
refactor: Implement MockResetRealTimeData method to clear mock data f…
Ahmedhossamdev Feb 23, 2026
2d43f61
refactor: Remove cleanup comment from MockResetRealTimeData method
Ahmedhossamdev Feb 23, 2026
a569c1e
refactor: Add tests for bearing conversion in BuildVehicleStatus
Ahmedhossamdev Feb 23, 2026
d3edc01
refactor: Improve logging in fillStopsFromSchedule and remove unused …
Ahmedhossamdev Feb 23, 2026
fc58af1
refactor: Add cleanup for MockResetRealTimeData in test setup
Ahmedhossamdev Feb 23, 2026
1354bd8
refactor: Ensure MockResetRealTimeData is called in all schedule devi…
Ahmedhossamdev Feb 23, 2026
e7d421e
refactor: Add tests for BuildTripStatus functionality and vehicle pos…
Ahmedhossamdev Feb 23, 2026
7dcb918
refactor: Update BuildTripSchedule call to use location and streamlin…
Ahmedhossamdev Feb 23, 2026
89bd5cf
refactor: Add tests for calculateOffsetForStop and findNextStopAfter …
Ahmedhossamdev Feb 23, 2026
8308261
refactor: Add logging for error handling in BuildTripStatus and relat…
Ahmedhossamdev Feb 23, 2026
d0d93b3
Merge remote-tracking branch 'origin/main' into verify-trip-status
Ahmedhossamdev Feb 23, 2026
cb99dc6
docs: Update comment for shapeRowsToPoints to clarify distance comput…
Ahmedhossamdev Feb 25, 2026
33f594d
refactor: Add mutex locking to MockAddVehicle and MockAddVehicleWithO…
Ahmedhossamdev Feb 25, 2026
24326db
refactor: Enhance error handling in tripDetailsHandler with logging f…
Ahmedhossamdev Feb 25, 2026
719fd35
docs: add comments in trip_updates_helper and vehicles_helper for cla…
Ahmedhossamdev Feb 25, 2026
ee5ee9d
refactor: Update BuildTripStatus to use activeTripRawID and improve l…
Ahmedhossamdev Feb 25, 2026
78fa2e3
refactor: Update vehicle ID assertion in TestBuildTripStatus and simp…
Ahmedhossamdev Feb 25, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,10 @@ dateStr, parsedTime, fieldErrors, ok := utils.ParseTimeParameter(timeParam, loca
### Vehicle Status (`internal/restapi/vehicles_helper.go`)

```go
// Convert GTFS-RT status to OneBusAway format
// Convert GTFS-RT schedule relationship to OneBusAway status and phase
status, phase := GetVehicleStatusAndPhase(vehicle)
// Returns: ("IN_TRANSIT_TO", "in_progress"), ("STOPPED_AT", "stopped"), etc.
// Returns: ("SCHEDULED", "in_progress"), ("CANCELED", ""), ("ADDED", "in_progress"), ("DUPLICATED", "in_progress")
// For nil vehicle: ("default", "scheduled")
```

## Database Management
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module maglev.onebusaway.org
go 1.24.2

require (
github.com/OneBusAway/go-gtfs v1.1.0
github.com/OneBusAway/go-gtfs v1.1.1
github.com/davecgh/go-spew v1.1.1
github.com/google/uuid v1.6.0
github.com/klauspost/compress v1.18.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ cel.dev/expr v0.24.0/go.mod h1:hLPLo1W4QUmuYdA72RBX06QTs6MXw941piREPl3Yfiw=
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/OneBusAway/go-gtfs v1.1.0 h1:oeiuHObV5tkFB8NFwb0TDvnAe1g/o3XGgKUZvgtMs5E=
github.com/OneBusAway/go-gtfs v1.1.0/go.mod h1:MJqNyFOJs+iE1R6uerTyfBY6g3/sxvTvVdRhDeN1bu8=
github.com/OneBusAway/go-gtfs v1.1.1 h1:JWl0ndXHBED6PAh8v3w0UgSDYWBg2OmHvAJb5RXX3Ss=
github.com/OneBusAway/go-gtfs v1.1.1/go.mod h1:MJqNyFOJs+iE1R6uerTyfBY6g3/sxvTvVdRhDeN1bu8=
github.com/antlr4-go/antlr/v4 v4.13.1 h1:SqQKkuVZ+zWkMMNkjy5FZe5mr5WURWnlpmOuzYWrPrQ=
github.com/antlr4-go/antlr/v4 v4.13.1/go.mod h1:GKmUxMtwp6ZgGwZSva4eWPC5mS6vUAmOABFgjdkM7Nw=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
Expand Down
13 changes: 6 additions & 7 deletions gtfsdb/query.sql
Original file line number Diff line number Diff line change
Expand Up @@ -629,16 +629,16 @@ ORDER BY
s.shape_pt_sequence ASC;

-- name: GetStopsWithShapeContextByIDs :many
SELECT
st.stop_id,
t.shape_id,
s.lat,
s.lon,
SELECT
st.stop_id,
t.shape_id,
s.lat,
s.lon,
st.shape_dist_traveled
FROM stop_times st
JOIN trips t ON st.trip_id = t.id
JOIN stops s ON st.stop_id = s.id
WHERE st.stop_id IN (sqlc.slice('stop_ids'));
WHERE st.stop_id IN (sqlc.slice('stop_ids'));

-- name: GetTripsByBlockIDOrdered :many
SELECT
Expand Down Expand Up @@ -984,7 +984,6 @@ WHERE t.block_id IN (sqlc.slice('block_ids'))
AND t.service_id IN (sqlc.slice('service_ids'))
GROUP BY t.id
ORDER BY t.block_id, MIN(st.departure_time), t.id;

-- Problem Report Queries

-- name: CreateProblemReportTrip :exec
Expand Down
10 changes: 5 additions & 5 deletions gtfsdb/query.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

83 changes: 81 additions & 2 deletions internal/gtfs/gtfs_manager_mock.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package gtfs

import (
"time"

"github.com/OneBusAway/go-gtfs"
)

Expand Down Expand Up @@ -29,13 +31,18 @@ func (m *Manager) MockAddRoute(id, agencyID, name string) {
})
}
func (m *Manager) MockAddVehicle(vehicleID, tripID, routeID string) {
m.realTimeMutex.Lock()
defer m.realTimeMutex.Unlock()

for _, v := range m.realTimeVehicles {
if v.ID.ID == vehicleID {
return
}
}
now := time.Now()
m.realTimeVehicles = append(m.realTimeVehicles, gtfs.Vehicle{
ID: &gtfs.VehicleID{ID: vehicleID},
ID: &gtfs.VehicleID{ID: vehicleID},
Timestamp: &now,
Trip: &gtfs.Trip{
ID: gtfs.TripID{
ID: tripID,
Expand All @@ -44,7 +51,51 @@ func (m *Manager) MockAddVehicle(vehicleID, tripID, routeID string) {
},
})

m.realTimeVehicleLookupByVehicle[vehicleID] = len(m.realTimeVehicles) - 1
idx := len(m.realTimeVehicles) - 1
m.realTimeVehicleLookupByVehicle[vehicleID] = idx
if tripID != "" {
m.realTimeVehicleLookupByTrip[tripID] = idx
}
}

type MockVehicleOptions struct {
Position *gtfs.Position
CurrentStopSequence *uint32
StopID *string
CurrentStatus *gtfs.CurrentStatus
}

func (m *Manager) MockAddVehicleWithOptions(vehicleID, tripID, routeID string, opts MockVehicleOptions) {
m.realTimeMutex.Lock()
defer m.realTimeMutex.Unlock()

for _, v := range m.realTimeVehicles {
if v.ID.ID == vehicleID {
return
}
}
now := time.Now()
v := gtfs.Vehicle{
ID: &gtfs.VehicleID{ID: vehicleID},
Timestamp: &now,
Trip: &gtfs.Trip{
ID: gtfs.TripID{
ID: tripID,
RouteID: routeID,
},
},
Position: opts.Position,
CurrentStopSequence: opts.CurrentStopSequence,
StopID: opts.StopID,
CurrentStatus: opts.CurrentStatus,
}
m.realTimeVehicles = append(m.realTimeVehicles, v)

idx := len(m.realTimeVehicles) - 1
m.realTimeVehicleLookupByVehicle[vehicleID] = idx
if tripID != "" {
m.realTimeVehicleLookupByTrip[tripID] = idx
}
}

func (m *Manager) MockAddTrip(tripID, agencyID, routeID string) {
Expand All @@ -58,3 +109,31 @@ func (m *Manager) MockAddTrip(tripID, agencyID, routeID string) {
Route: &gtfs.Route{Id: routeID},
})
}

func (m *Manager) MockAddTripUpdate(tripID string, delay *time.Duration, stopTimeUpdates []gtfs.StopTimeUpdate) {
m.realTimeMutex.Lock()
defer m.realTimeMutex.Unlock()

trip := gtfs.Trip{
ID: gtfs.TripID{ID: tripID},
Delay: delay,
StopTimeUpdates: stopTimeUpdates,
}
m.realTimeTrips = append(m.realTimeTrips, trip)
if m.realTimeTripLookup == nil {
m.realTimeTripLookup = make(map[string]int)
}
m.realTimeTripLookup[tripID] = len(m.realTimeTrips) - 1
}

// MockResetRealTimeData clears all mock real-time vehicles and trip updates.
func (m *Manager) MockResetRealTimeData() {
m.realTimeMutex.Lock()
defer m.realTimeMutex.Unlock()

m.realTimeVehicles = nil
m.realTimeVehicleLookupByVehicle = make(map[string]int)
m.realTimeVehicleLookupByTrip = make(map[string]int)
m.realTimeTrips = nil
m.realTimeTripLookup = make(map[string]int)
}
5 changes: 1 addition & 4 deletions internal/restapi/block_distance_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,7 @@ func (api *RestAPI) getBlockDistanceToStop(ctx context.Context, targetTripID, ta
shapeRows, _ := api.GtfsManager.GtfsDB.Queries.GetShapePointsByTripID(ctx, blockTrip.ID)
totalDist := 0.0
if len(shapeRows) > 1 {
shapePoints := make([]gtfs.ShapePoint, len(shapeRows))
for i, sp := range shapeRows {
shapePoints[i] = gtfs.ShapePoint{Latitude: sp.Lat, Longitude: sp.Lon}
}
shapePoints := shapeRowsToPoints(shapeRows)
totalDist = preCalculateCumulativeDistances(shapePoints)[len(shapePoints)-1]
}

Expand Down
4 changes: 2 additions & 2 deletions internal/restapi/block_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ func transformBlockToEntry(block []gtfsdb.GetBlockDetailsRow, blockID, agencyID
BlockSequence: int(stop.StopSequence - 1),
DistanceAlongBlock: blockDistance,
StopTime: models.StopTime{
ArrivalTime: int(stop.ArrivalTime / 1e9),
DepartureTime: int(stop.DepartureTime / 1e9),
ArrivalTime: int(utils.NanosToSeconds(stop.ArrivalTime)),
DepartureTime: int(utils.NanosToSeconds(stop.DepartureTime)),
DropOffType: int(stop.DropOffType.Int64),
PickupType: int(stop.PickupType.Int64),
StopID: utils.FormCombinedID(agencyID, stop.StopID),
Expand Down
4 changes: 2 additions & 2 deletions internal/restapi/schedule_for_route_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ func (api *RestAPI) scheduleForRouteHandler(w http.ResponseWriter, r *http.Reque
}
stopTimesList := make([]models.RouteStopTime, 0, len(stopTimes))
for _, st := range stopTimes {
arrivalSec := int(st.ArrivalTime / 1e9)
departureSec := int(st.DepartureTime / 1e9)
arrivalSec := int(utils.NanosToSeconds(st.ArrivalTime))
departureSec := int(utils.NanosToSeconds(st.DepartureTime))
stopTimesList = append(stopTimesList, models.RouteStopTime{
ArrivalEnabled: true,
ArrivalTime: arrivalSec,
Expand Down
22 changes: 14 additions & 8 deletions internal/restapi/shape_distance_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,20 @@ import (
"context"

"github.com/OneBusAway/go-gtfs"
"maglev.onebusaway.org/gtfsdb"
)

// shapeRowsToPoints converts database shape rows to gtfs.ShapePoint slice.
// ShapeDistTraveled is intentionally dropped; cumulative distances are recomputed
// from scratch via preCalculateCumulativeDistances to ensure consistency.
func shapeRowsToPoints(rows []gtfsdb.Shape) []gtfs.ShapePoint {
pts := make([]gtfs.ShapePoint, len(rows))
for i, sp := range rows {
pts[i] = gtfs.ShapePoint{Latitude: sp.Lat, Longitude: sp.Lon}
}
return pts
}

// IMPORTANT: Caller must hold manager.RLock() before calling this method.
func (api *RestAPI) getStopDistanceAlongShape(ctx context.Context, tripID, stopID string) float64 {
stopTimes, err := api.GtfsManager.GtfsDB.Queries.GetStopTimesForTrip(ctx, tripID)
Expand All @@ -27,10 +39,7 @@ func (api *RestAPI) getStopDistanceAlongShape(ctx context.Context, tripID, stopI
return 0
}

shapePoints := make([]gtfs.ShapePoint, len(shapeRows))
for i, sp := range shapeRows {
shapePoints[i] = gtfs.ShapePoint{Latitude: sp.Lat, Longitude: sp.Lon}
}
shapePoints := shapeRowsToPoints(shapeRows)

return getDistanceAlongShape(stop.Lat, stop.Lon, shapePoints)
}
Expand All @@ -46,10 +55,7 @@ func (api *RestAPI) getVehicleDistanceAlongShapeContextual(ctx context.Context,
return 0
}

shapePoints := make([]gtfs.ShapePoint, len(shapeRows))
for i, sp := range shapeRows {
shapePoints[i] = gtfs.ShapePoint{Latitude: sp.Lat, Longitude: sp.Lon}
}
shapePoints := shapeRowsToPoints(shapeRows)

lat := float64(*vehicle.Position.Latitude)
lon := float64(*vehicle.Position.Longitude)
Expand Down
Loading
Loading