diff --git a/visual-debugger/src/data-processing/Query-Batch.json b/visual-debugger/src/data-processing/Query-Batch.json index 7f50935586..c362474c9c 100644 --- a/visual-debugger/src/data-processing/Query-Batch.json +++ b/visual-debugger/src/data-processing/Query-Batch.json @@ -5,6 +5,18 @@ "from":"Aachen HBF", "to": "Aachen West", "class": "Regional" + }, + { + "index":2, + "from":"Aachen West", + "to": "Aachen HBF", + "class": "Regional" + }, + { + "index":3, + "from":"Aachen Bushof", + "to": "Aachen Schanz", + "class": "Regional" } ] } \ No newline at end of file diff --git a/visual-debugger/src/data-processing/parsing-types/planParsingTypes.ts b/visual-debugger/src/data-processing/parsing-types/planParsingTypes.ts new file mode 100644 index 0000000000..45b658d95f --- /dev/null +++ b/visual-debugger/src/data-processing/parsing-types/planParsingTypes.ts @@ -0,0 +1,66 @@ +/** + * Plan type used for parsing plan responses + */ +export interface Plan{ + requestParameters:string; + debugOutput: number[]; + from:Place; + to: Place; + direct: Itinerary[]; + itineraries: Itinerary[]; + previousPageCursor: string; + nextPageCursor: string; +} + +/** + * Place type used for parsing plan responses + */ +export interface Place{ + name:string; + stopId:string; + lat:number; + lon:number; + level: number; + arrival: string; + departure:string; + scheduledArrival: string; + scheduledDeparture: string; + scheduledTrack:string; + track:string; + vertexType:string; +} + +/** + * Itinerary type used for parsing plan responses + */ +export interface Itinerary { + duration:number; + startTime:string; + endTime:string; + transfers:number; + legs:Leg[]; +} + +/** + * Leg type used for parsing plan responses + */ +export interface Leg { + mode:string; + from:Place; + to:Place; + duration:number; + startTime:string; + endTime:string; + scheduledStartTime:string; + scheduledEndTime:string; + realTime:boolean; + legGeometry:EncodedPolyline; +} + +/** + * EncodedPolyline type used for parsing plan responses + */ +export interface EncodedPolyline { + points:string; + length:number; +} \ No newline at end of file diff --git a/visual-debugger/src/data-processing/parsing-types/queryInterpolationTypes.ts b/visual-debugger/src/data-processing/parsing-types/queryInterpolationTypes.ts new file mode 100644 index 0000000000..90cfcef383 --- /dev/null +++ b/visual-debugger/src/data-processing/parsing-types/queryInterpolationTypes.ts @@ -0,0 +1,44 @@ +/** + * location type used for storing stop information + */ +export interface Location { + type: string; + tokens: number[][]; + name: string; + id: string; + lat: number; + lon: number; + level: number; + zip: string; + areas: Area[]; + score: number; +} + +/** + * area type used for storing information about the area of a stop + */ +export interface Area { + name: string; + adminLevel: number; + matched: boolean; + default: boolean; +} + +/** + * Query type used for storing information about a single query + */ +export interface Query { + index: number; + from:string; + fromStopID:string; + to: string; + toStopID: string; + class:string; +} + +/** + * Type used for storing all queries in a Batch + */ +export interface Batch { + queries: Query[]; +} \ No newline at end of file diff --git a/visual-debugger/src/data-processing/planParsing.ts b/visual-debugger/src/data-processing/planParsing.ts new file mode 100644 index 0000000000..25506b85ae --- /dev/null +++ b/visual-debugger/src/data-processing/planParsing.ts @@ -0,0 +1,56 @@ +import {interpolatedQueryStore, computedPlanStore, currentPlanStore} from "../sveltestore.ts"; +import type {Query} from "./parsing-types/queryInterpolationTypes.ts"; +import type {Plan} from "./parsing-types/planParsingTypes.ts" +import axios from "axios"; + +/** + * Base URL of the MOTIS API + */ +const motisApiUrlBase = 'http://localhost:8080/api/v1/' + +/** + * data of the interpolated queries + */ +let queries: Query[] + +/** + * Interaction function that is accessed by the frontend to get the plan for all queries + */ +export async function computePlan(){ + //get read file content from storage + interpolatedQueryStore.subscribe(file_data => { + queries = file_data; + }) + + // if store is empty abort data processing + if(queries == undefined){return} + + let plans: Plan[] = []; + let index =0; + + // compute the plan for each query + for(const query of queries){ + plans[index] = await computePlanForQuery(query) + index++; + } + + // put computed plans into storage and set first plan as active + computedPlanStore.set(plans) + currentPlanStore.set(plans[0]) +} + +/** + * Calls the MOTIS API for a specific query and returns the plan for it + * @param query the query to get the plan for + */ +export async function computePlanForQuery(query:Query){ + const response = await axios + .get( + //configuration for api call parameters + `${motisApiUrlBase}plan/?fromPlace=${query.fromStopID}&toPlace=${query.toStopID}` + ) + let plan: Plan = response.data + return plan +} + + diff --git a/visual-debugger/src/data-processing/query-build.ts b/visual-debugger/src/data-processing/queryBuild.ts similarity index 64% rename from visual-debugger/src/data-processing/query-build.ts rename to visual-debugger/src/data-processing/queryBuild.ts index d3e1ddf181..c48f08a1f9 100644 --- a/visual-debugger/src/data-processing/query-build.ts +++ b/visual-debugger/src/data-processing/queryBuild.ts @@ -1,5 +1,6 @@ import axios from "axios"; import {queryJsonStringStore, interpolatedQueryStore} from "../sveltestore"; +import type { Location, Batch } from "./parsing-types/queryInterpolationTypes.ts" /** * Base URL of the MOTIS API @@ -11,66 +12,20 @@ const motisApiUrlBase = 'http://localhost:8080/api/v1/' */ let queryFileContent: string -/** - * location type used for storing stop information - */ -export interface Location { - type: string; - tokens: number[][]; - name: string; - id: string; - lat: number; - lon: number; - level: number; - zip: string; - areas: Area[]; - score: number; -} - -/** - * area type used for storing information about the area of a stop - */ -export interface Area { - name: string; - adminLevel: number; - matched: boolean; - default: boolean; -} - -/** - * Query type used for storing information about a single query - */ -export interface Query { - index: number; - from:string; - fromStopID:string; - to: string; - toStopID: string; - class:string; -} - -/** - * Type used for storing all queries in a Batch - */ -interface Batch { - queries: Query[]; -} - /** * Reads the query batch and generates the nearest stops for the read query trips * @param query_batch path to the query batch JSON file * @return the query batch dataset with stop id's */ export async function buildQueryDataset(query_batch:string) { - // parse query batch file into readable queries let batch: Batch = JSON.parse(query_batch) let queries = batch.queries // call MOTIS API to search for the nearest stations to the start and end point of the query for (const queryTrip of queries) { - queryTrip.fromStopID = await getLocationId(queryTrip.from) - queryTrip.toStopID = await getLocationId(queryTrip.to) + queryTrip.fromStopID = await computeLocationId(queryTrip.from) + queryTrip.toStopID = await computeLocationId(queryTrip.to) } // update store with the new queries @@ -82,7 +37,7 @@ export async function buildQueryDataset(query_batch:string) { * @param locationName location the most similar stop id is needed of * @return the id of the most similar location to the input string */ -async function getLocationId (locationName:string){ +async function computeLocationId (locationName:string){ const response = await axios .get( //configuration for api call parameters @@ -95,7 +50,7 @@ async function getLocationId (locationName:string){ /** * Interaction method for printing queries to page */ -export function getQueryAttributes(){ +export function computeQueryAttributes(){ //get read file content from storage queryJsonStringStore.subscribe(file_data => { diff --git a/visual-debugger/src/demo.spec.ts b/visual-debugger/src/demo.spec.ts deleted file mode 100644 index e07cbbd725..0000000000 --- a/visual-debugger/src/demo.spec.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { describe, it, expect } from 'vitest'; - -describe('sum test', () => { - it('adds 1 + 2 to equal 3', () => { - expect(1 + 2).toBe(3); - }); -}); diff --git a/visual-debugger/src/lib/components/ui/FileUpload.svelte b/visual-debugger/src/lib/components/ui/FileUpload.svelte index 816e30dfa0..870128bb3d 100644 --- a/visual-debugger/src/lib/components/ui/FileUpload.svelte +++ b/visual-debugger/src/lib/components/ui/FileUpload.svelte @@ -1,24 +1,31 @@ - -
Selected file: {file.name}
- {/if} -Selected file: {file.name}
+ {/if} +{from} ({fromId}) -> {to} ({toId})
-StartTime:{startTime}, EndTime:{endTime}, Duration: {duration}, Number of Transfers: {transfers}
+