osrm.service:

Create a string for the parameters and provide instead
Create a class member for the request parameters
This commit is contained in:
Janis Meister
2022-02-09 09:54:33 +01:00
parent 91ea1e4823
commit ad9125b857
3 changed files with 11 additions and 4 deletions

View File

@@ -0,0 +1,6 @@
export interface osrmRequest{
longFrom: number;
latFrom: number;
longTo: number;
latTo: number;
}

View File

@@ -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);
/*

View File

@@ -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<Osrm> {
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<Osrm>("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<Osrm> {
console.log(url + this.reqParam);
return this.http.get<Osrm>(url + this.reqParam);
}
}