From ad9125b8570dd7a575e2971e9f2e1fa90f079221 Mon Sep 17 00:00:00 2001 From: Janis Meister Date: Wed, 9 Feb 2022 09:54:33 +0100 Subject: [PATCH] osrm.service: Create a string for the parameters and provide instead Create a class member for the request parameters --- src/app/interfaces/osrmRequest.ts | 6 ++++++ src/app/search/search.component.ts | 2 +- src/app/services/osrm.service.ts | 7 ++++--- 3 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 src/app/interfaces/osrmRequest.ts diff --git a/src/app/interfaces/osrmRequest.ts b/src/app/interfaces/osrmRequest.ts new file mode 100644 index 0000000..3995bcd --- /dev/null +++ b/src/app/interfaces/osrmRequest.ts @@ -0,0 +1,6 @@ +export interface osrmRequest{ + longFrom: number; + latFrom: number; + longTo: number; + latTo: number; +} diff --git a/src/app/search/search.component.ts b/src/app/search/search.component.ts index d0bd172..42e6878 100644 --- a/src/app/search/search.component.ts +++ b/src/app/search/search.component.ts @@ -115,7 +115,7 @@ export class SearchComponent { } getRoute(): void{ - this.osrmService.sendQueryRequest(this.longFrom, this.latFrom, this.longTo, this.latTo) + this.osrmService.sendQueryRequest("https://routing.openstreetmap.de/routed-bike/route/v1/driving/" + this.longFrom + "," + this.latFrom + ";" + this.longTo + "," + this.latTo) .subscribe((response: Osrm) => { this.emitter.emit(response); /* diff --git a/src/app/services/osrm.service.ts b/src/app/services/osrm.service.ts index e6ce148..7d5acac 100644 --- a/src/app/services/osrm.service.ts +++ b/src/app/services/osrm.service.ts @@ -11,14 +11,15 @@ import { Osrm } from '../interfaces/osrm'; }) export class OsrmService{ + reqParam: string = "?overview=full&alternatives=false&steps=true&geometries=geojson"; constructor(private http: HttpClient) { } /** * sends a query request to Osrm and gets response (http://project-osrm.org/docs/v5.24.0/api/?language=cURL#table-service) */ - sendQueryRequest(longFrom: number, latFrom: number, longTo: number, latTo: number): Observable { - console.log("https://routing.openstreetmap.de/routed-bike/route/v1/driving/" + longFrom + "," + latFrom + ";" + longTo + "," + latTo + "?overview=full&alternatives=false&steps=true&geometries=geojson") - return this.http.get("https://routing.openstreetmap.de/routed-bike/route/v1/driving/" + longFrom + "," + latFrom + ";" + longTo + "," + latTo + "?overview=full&alternatives=false&steps=true&geometries=geojson"); + sendQueryRequest(url: string): Observable { + console.log(url + this.reqParam); + return this.http.get(url + this.reqParam); } }