From d9d11e1b31213b7e552462fb416e0038e9cfdfbc Mon Sep 17 00:00:00 2001 From: Brendan Chen Date: Mon, 17 Mar 2025 13:15:07 -0700 Subject: [PATCH 1/6] update entities and schema to include orientation in degrees --- schema.graphqls | 1 + src/entities/entities.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/schema.graphqls b/schema.graphqls index c5a6726..007dfd8 100644 --- a/schema.graphqls +++ b/schema.graphqls @@ -47,6 +47,7 @@ type ETA { shuttle: Shuttle shuttleId: ID! secondsRemaining: Float! + orientationInDegrees: Float! } type Shuttle { diff --git a/src/entities/entities.ts b/src/entities/entities.ts index 3579c5d..2766595 100644 --- a/src/entities/entities.ts +++ b/src/entities/entities.ts @@ -33,6 +33,7 @@ export interface IShuttle extends IEntityWithId, IEntityWithOptionalTimestamp { name: string; routeId: string; systemId: string; + orientationInDegrees: number; } export interface IEta extends IEntityWithOptionalTimestamp { From c0b7d99e8e509ca5583e6c548c591c7087da5cc3 Mon Sep 17 00:00:00 2001 From: Brendan Chen Date: Mon, 17 Mar 2025 13:18:34 -0700 Subject: [PATCH 2/6] add orientation data for mock shuttles function --- test/testHelpers/mockDataGenerators.ts | 38 +++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/test/testHelpers/mockDataGenerators.ts b/test/testHelpers/mockDataGenerators.ts index e284c93..07d14bf 100644 --- a/test/testHelpers/mockDataGenerators.ts +++ b/test/testHelpers/mockDataGenerators.ts @@ -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 }, ]; -} \ No newline at end of file +} From 919832e86f2c534d1723571c105a15d743dcd055 Mon Sep 17 00:00:00 2001 From: Brendan Chen Date: Mon, 17 Mar 2025 13:23:53 -0700 Subject: [PATCH 3/6] move orientation to shuttle instead of eta (whoops) --- schema.graphqls | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schema.graphqls b/schema.graphqls index 007dfd8..f874943 100644 --- a/schema.graphqls +++ b/schema.graphqls @@ -47,7 +47,6 @@ type ETA { shuttle: Shuttle shuttleId: ID! secondsRemaining: Float! - orientationInDegrees: Float! } type Shuttle { @@ -58,6 +57,7 @@ type Shuttle { routeId: ID! etas: [ETA!] eta(forStopId: ID): ETA + orientationInDegrees: Float! } # Queries From 024a7dd30c855b2f848ae8d1b62cc2065660fb31 Mon Sep 17 00:00:00 2001 From: Brendan Chen Date: Mon, 17 Mar 2025 13:24:08 -0700 Subject: [PATCH 4/6] add orientation to loadTestData --- src/loaders/loadTestData.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/loaders/loadTestData.ts b/src/loaders/loadTestData.ts index 833a660..543a06c 100644 --- a/src/loaders/loadTestData.ts +++ b/src/loaders/loadTestData.ts @@ -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, } ]; From 891bf522ba335513e500dcc14cd9b35fed11c396 Mon Sep 17 00:00:00 2001 From: Brendan Chen Date: Mon, 17 Mar 2025 13:25:37 -0700 Subject: [PATCH 5/6] add orientation data to route resolver --- src/resolvers/RouteResolvers.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/resolvers/RouteResolvers.ts b/src/resolvers/RouteResolvers.ts index 0c71cfd..d5a5810 100644 --- a/src/resolvers/RouteResolvers.ts +++ b/src/resolvers/RouteResolvers.ts @@ -10,12 +10,14 @@ export const RouteResolvers: Resolvers = { 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 = { } }, }, -} \ No newline at end of file +} From 889e3029121563c307ee15f2a0769cceca8aaa26 Mon Sep 17 00:00:00 2001 From: Brendan Chen Date: Mon, 17 Mar 2025 13:25:46 -0700 Subject: [PATCH 6/6] add orientation data to api based loader --- src/loaders/ApiBasedRepositoryLoader.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/loaders/ApiBasedRepositoryLoader.ts b/src/loaders/ApiBasedRepositoryLoader.ts index 5bfe37d..50003db 100644 --- a/src/loaders/ApiBasedRepositoryLoader.ts +++ b/src/loaders/ApiBasedRepositoryLoader.ts @@ -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);