mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 07:50:31 +00:00
Merge pull request #30 from brendan-ch/feat/orientation-data
feat/orientation-data
This commit is contained in:
@@ -57,6 +57,7 @@ type Shuttle {
|
||||
routeId: ID!
|
||||
etas: [ETA!]
|
||||
eta(forStopId: ID): ETA
|
||||
orientationInDegrees: Float!
|
||||
}
|
||||
|
||||
# Queries
|
||||
|
||||
@@ -33,6 +33,7 @@ export interface IShuttle extends IEntityWithId, IEntityWithOptionalTimestamp {
|
||||
name: string;
|
||||
routeId: string;
|
||||
systemId: string;
|
||||
orientationInDegrees: number;
|
||||
}
|
||||
|
||||
export interface IEta extends IEntityWithOptionalTimestamp {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
@@ -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
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user