mirror of
https://github.com/DerTyp7/street-map-typescript.git
synced 2025-10-28 20:32:11 +01:00
osrm.service:
Create a string for the parameters and provide instead Create a class member for the request parameters
This commit is contained in:
6
src/app/interfaces/osrmRequest.ts
Normal file
6
src/app/interfaces/osrmRequest.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
export interface osrmRequest{
|
||||
longFrom: number;
|
||||
latFrom: number;
|
||||
longTo: number;
|
||||
latTo: number;
|
||||
}
|
||||
@@ -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);
|
||||
/*
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user