Merge pull request #30 from brendan-ch/feat/orientation-data

feat/orientation-data
This commit is contained in:
2025-03-17 13:30:32 -07:00
committed by GitHub
6 changed files with 43 additions and 6 deletions

View File

@@ -57,6 +57,7 @@ type Shuttle {
routeId: ID!
etas: [ETA!]
eta(forStopId: ID): ETA
orientationInDegrees: Float!
}
# Queries

View File

@@ -33,6 +33,7 @@ export interface IShuttle extends IEntityWithId, IEntityWithOptionalTimestamp {
name: string;
routeId: string;
systemId: string;
orientationInDegrees: number;
}
export interface IEta extends IEntityWithOptionalTimestamp {

View File

@@ -225,7 +225,8 @@ export class ApiBasedRepositoryLoader implements RepositoryLoader {
},
routeId: jsonBus.routeId,
systemId: systemId,
id: `${jsonBus.busId}`
id: `${jsonBus.busId}`,
orientationInDegrees: parseFloat(jsonBus.calculatedCourse)
}
await this.repository.addOrUpdateShuttle(constructedShuttle);

View File

@@ -4416,6 +4416,7 @@ const shuttles: IShuttle[] = [
},
routeId: routes[0].id,
systemId: systems[0].id,
orientationInDegrees: 45.91,
},
{
name: "24",
@@ -4426,6 +4427,7 @@ const shuttles: IShuttle[] = [
},
routeId: routes[0].id,
systemId: systems[0].id,
orientationInDegrees: 90.24,
}
];

View File

@@ -10,12 +10,14 @@ export const RouteResolvers: Resolvers<ServerContext> = {
coordinates,
name,
id,
orientationInDegrees
}) => ({
coordinates: coordinates as Coordinates,
name,
route: parent,
routeId: parent.id,
id,
orientationInDegrees
}));
},
orderedStop: async (parent, args, contextValue, info) => {
@@ -33,4 +35,4 @@ export const RouteResolvers: Resolvers<ServerContext> = {
}
},
},
}
}

View File

@@ -13,9 +13,39 @@ export function generateMockSystems(): ISystem[] {
export function generateMockShuttles(): IShuttle[] {
return [
{ id: "sh1", name: "Shuttle A", routeId: "r1", systemId: "sys1", coordinates: { latitude: 10, longitude: 20 } },
{ id: "sh2", name: "Shuttle B", routeId: "r2", systemId: "sys2", coordinates: { latitude: 15, longitude: 25 } },
{ id: "sh3", name: "Shuttle C", routeId: "r3", systemId: "sys3", coordinates: { latitude: 30, longitude: 40 } },
{
id: "sh1",
name: "Shuttle A",
routeId: "r1",
systemId: "sys1",
coordinates: {
latitude: 10,
longitude: 20
},
orientationInDegrees: 25.163
},
{
id: "sh2",
name: "Shuttle B",
routeId: "r2",
systemId: "sys2",
coordinates: {
latitude: 15,
longitude: 25
},
orientationInDegrees: 50.912
},
{
id: "sh3",
name: "Shuttle C",
routeId: "r3",
systemId: "sys3",
coordinates: {
latitude: 30,
longitude: 40
},
orientationInDegrees: 321.019
},
];
}
@@ -50,4 +80,4 @@ export function generateMockEtas(): IEta[] {
{ shuttleId: "sh1", stopId: "st2", secondsRemaining: 180 },
{ shuttleId: "sh2", stopId: "st3", secondsRemaining: 240 },
];
}
}