diff --git a/src/app/hirebike/hirebike.page.html b/src/app/hirebike/hirebike.page.html index ee3bafd27c04bebb92417550606b6a9fb7de854b..322c1f35750bf4b201940de419a760441f490abb 100644 --- a/src/app/hirebike/hirebike.page.html +++ b/src/app/hirebike/hirebike.page.html @@ -26,7 +26,8 @@ </ion-card-content> </ion-card> <div #mapElement style="width: 100%; height: 100%" id="mapContainer" *ngIf="isBikeReserved"></div> - <ion-fab *ngIf="isBikeReserved" class="get-position" vertical="bottom" horizontal="end" (click)="getCurrentPosition()" slot="fixed"> + <ion-fab *ngIf="isBikeReserved" class="get-position" vertical="bottom" horizontal="end" (click)="getCurrentPosition()" + slot="fixed"> <ion-fab-button> <ion-icon name="locate"></ion-icon> </ion-fab-button> @@ -35,12 +36,11 @@ <ion-footer> <div class="bike-details-container" *ngIf="isBikeReserved"> <div class="inner"> - <div class="button-container"> - + <div class="button-container" *ngIf="isTripStarted"> <ion-grid *ngIf="isBikeHired" class="directions"> - <ion-item class="waypoint-wrapper"> + <div class="waypoint-wrapper"> <span [innerHTML]="wayPointsInfo"></span> - </ion-item> + </div> <ion-list class="my-ion-list"> <ion-item *ngFor="let maneuver of maneuverList"> <li><span [className]="'arrow '+ maneuver.action"></span><span [innerHTML]="maneuver.instruction"></span> @@ -62,19 +62,34 @@ </ion-row> </ion-grid> <ion-grid> - <ion-row *ngIf="!isBikeHired"> - <ion-col> - <ion-button size="medium" expand="block" (click)="startTrip()">Start Trip</ion-button> - </ion-col> - </ion-row> - - <ion-row *ngIf="isBikeHired"> + <ion-row> <ion-col> <ion-button size="medium" expand="block" (click)="CancelTrip()">End Trip</ion-button> </ion-col> </ion-row> </ion-grid> </div> + <div id="route-selection-container" *ngIf="!isTripStarted"> + <div class="route-selection-header" *ngIf="gotRouteOptions"> + <div class="waypoint-wrapper"> + <div [innerHTML]="wayPointsInfo"></div> + <div> Select Route:</div> + </div> + </div> + <div class="routes-list-wrapper"> + <div class="routes-list-inner"> + <div class="route-option-wrapper" *ngFor="let route of routeList | keyvalue; let i = index"> + <div class="route-option-inner" (click)="selectRoute(route.value.route, i)"> + <div class="route-heading">{{getRouteType(route.value.mode)}}:</div> + <div class="route-summary">{{route.value.summary}}</div> + <div class="route-prediction"></div> + </div> + </div> + </div> + </div> + <ion-button *ngIf="!isRouteSelected && !gotRouteOptions" [disabled]="!isDestinationSelected" size="medium" expand="block" (click)="getRouteOptions()">Get Routes</ion-button> + <ion-button *ngIf="isRouteSelected" size="medium" expand="block" (click)="startTrip2()">Start Trip</ion-button> + </div> </div> </div> </ion-footer> \ No newline at end of file diff --git a/src/app/hirebike/hirebike.page.scss b/src/app/hirebike/hirebike.page.scss index eeedfd73c3271b2ce0619428b77bd09b043d9427..293a80644e2b829643e0f6f29bc1e30f378b63c6 100644 --- a/src/app/hirebike/hirebike.page.scss +++ b/src/app/hirebike/hirebike.page.scss @@ -5,7 +5,28 @@ } .waypoint-wrapper{ - font-weight: 700; + padding: 8px; + font-weight: 500; + border-bottom: 1px solid #ddd; + background-color: #34a080; + text-align: center; + color: #fff; +} + +.routes-list-wrapper{ + font-size: 14px; + color: #444444; + + .route-option-wrapper{ + padding: 8px; + border-bottom: 1px solid #ddd; + font-size: 14px; + + .route-heading{ + font-weight: 500; + margin-bottom: 5px; + } + } } .directions li span.arrow { diff --git a/src/app/hirebike/hirebike.page.ts b/src/app/hirebike/hirebike.page.ts index 0b8f626f6d1099528efe89aaf5c12dfba0369a40..1d74d154eb32d2ab822b7f486de068e446454bb3 100644 --- a/src/app/hirebike/hirebike.page.ts +++ b/src/app/hirebike/hirebike.page.ts @@ -32,7 +32,7 @@ export class HirebikePage implements OnInit { currentRoute: any; routeSummary: any; - wayPointsInfo:any; + wayPointsInfo: any; startRideSubject: Subject<any> = new Subject(); gotReservedBikeSubject: Subject<any> = new Subject(); @@ -55,6 +55,7 @@ export class HirebikePage implements OnInit { public rideStarted = false; + isTripStarted = false; constructor(private geolocation: Geolocation, public restService: RestService, @@ -66,14 +67,14 @@ export class HirebikePage implements OnInit { public locationService: LocationService, public loadingService: LoadingService, public feedbackService: FeedbackService) { - + this.platform = new H.service.Platform({ 'apikey': 'tiVTgBnPbgV1spie5U2MSy-obhD9r2sGiOCbBzFY2_k' }); } ngOnInit() { - + } ngAfterViewInit() { @@ -111,7 +112,7 @@ export class HirebikePage implements OnInit { this.currentRoute = receiveddata; let content = ''; content += 'Total distance: ' + receiveddata.summary.distance + 'm. '; - content += 'Travel Time: ' + Math.floor(receiveddata.summary.travelTime / 60) + ' minutes ' + (receiveddata.summary.travelTime % 60) + ' seconds.' + ' (in current traffic)'; + content += 'Travel Time: ' + Math.floor(receiveddata.summary.travelTime / 60) + ' min'; this.routeSummary = content; this.showRouteInfoPanel(receiveddata); let waypointLabels = []; @@ -206,6 +207,133 @@ export class HirebikePage implements OnInit { }); } + gotRouteOptions = false; + + getRouteOptions() { + var waypoint0 = this.bikePosition.lat + ',' + this.bikePosition.lng; + var waypoint1 = this.destinationPosition.lat + ',' + this.destinationPosition.lng; + this.loadingService.showLoader(); + this.storage.get('token').then((token) => { + let url = 'http://193.196.52.237:8081/routing?startlng='+ this.bikePosition.lng + '&startlat=' + this.bikePosition.lat + '&destinationlng='+ this.destinationPosition.lng + '&destinationlat=' + this.destinationPosition.lat; + const headers = new HttpHeaders().set("Authorization", "Bearer " + token); + let bikeApi = this.httpClient.get(url, { headers }); + bikeApi.subscribe((resp) => { + console.log('my data: ', resp); + this.loadingService.hideLoader(); + this.isBikeHired = true; + this.displayRouteOptions(resp); + this.gotRouteOptions = true; + }, (error) => { + console.log(error); + this.loadingService.hideLoader(); + }); + }); + + // let resp = { + // "data": { + // "routes": [ + // { + // "route": "{\"response\":{\"metaInfo\":{\"timestamp\":\"2019-12-10T22:17:31Z\",\"mapVersion\":\"8.30.103.151\",\"moduleVersion\":\"7.2.201949-5928\",\"interfaceVersion\":\"2.6.74\",\"availableMapVersion\":[\"8.30.103.151\"]},\"route\":[{\"waypoint\":[{\"linkId\":\"+1188640340\",\"mappedPosition\":{\"latitude\":48.7704613,\"longitude\":9.1575942},\"originalPosition\":{\"latitude\":48.770685,\"longitude\":9.157448},\"type\":\"stopOver\",\"spot\":0.1666667,\"sideOfStreet\":\"left\",\"mappedRoadName\":\"Rotebühlstraße\",\"label\":\"Rotebühlstraße - L1015\",\"shapeIndex\":0,\"source\":\"user\"},{\"linkId\":\"-1189087529\",\"mappedPosition\":{\"latitude\":48.7857878,\"longitude\":9.2159522},\"originalPosition\":{\"latitude\":48.786034,\"longitude\":9.2158129},\"type\":\"stopOver\",\"spot\":0.41,\"sideOfStreet\":\"right\",\"mappedRoadName\":\"Talstraße\",\"label\":\"Talstraße - L1014\",\"shapeIndex\":94,\"source\":\"user\"}],\"mode\":{\"type\":\"fastest\",\"transportModes\":[\"bicycle\"],\"trafficMode\":\"disabled\",\"feature\":[]},\"shape\":[\"48.7704613,9.1575942,337.0\",\"48.7715851,9.1540272,335.0\",\"48.7712073,9.1605806,329.0\",\"48.7717223,9.1625118,325.0\",\"48.7719047,9.163295,324.0\",\"48.7721622,9.1641963,323.0\",\"48.7725377,9.1656125,322.0\",\"48.7727737,9.1663849,321.0\",\"48.7730205,9.1672969,319.0\",\"48.7730205,9.1674793,318.0\",\"48.7730956,9.1678011,317.0\",\"48.7735248,9.1691315,314.0\",\"48.7735462,9.1692603,313.0\",\"48.7737072,9.1698503,312.0\",\"48.7738574,9.1702366,312.0\",\"48.7739646,9.1704512,312.0\",\"48.7742114,9.1707838,311.0\",\"48.7747371,9.1713846,310.0\",\"48.7749624,9.1715884,310.0\",\"48.775295,9.1719317,310.0\",\"48.7762928,9.1730046,309.0\",\"48.7772691,9.1741741,306.0\",\"48.7784064,9.175483,304.0\",\"48.7795544,9.1766739,301.0\",\"48.7797582,9.1768348,300.0\",\"48.7800801,9.176985,300.0\",\"48.7803805,9.1770923,300.0\",\"48.7805414,9.1771245,300.0\",\"48.7810457,9.177146,298.0\",\"48.7822258,9.1772747,297.0\",\"48.782419,9.1773069,296.0\",\"48.7827516,9.1774356,295.0\",\"48.7869983,9.1746073,295.0\",\"48.7832236,9.1778433,295.0\",\"48.7838459,9.1786051,294.0\",\"48.7840712,9.1789269,294.0\",\"48.7838566,9.1793454,293.0\",\"48.783489,9.180268,292.0\",\"48.7828696,9.1816843,291.0\",\"48.7826765,9.18221,291.0\",\"48.7824082,9.1831219,290.0\",\"48.7820113,9.1845703,289.0\",\"48.7818289,9.1851497,290.0\",\"48.7814856,9.1861689,293.0\",\"48.7814319,9.1863942,294.0\",\"48.7812924,9.1868341,294.0\",\"48.7814426,9.1869199,294.0\",\"48.7821937,9.1874456,293.0\",\"48.782537,9.1877246,292.0\",\"48.7829447,9.1879928,291.0\",\"48.7835558,9.1881752,291.0\",\"48.7838352,9.1886044,290.0\",\"48.7842751,9.1888833,290.0\",\"48.7853587,9.1896343,288.0\",\"48.7857449,9.1898811,288.0\",\"48.7858951,9.1899133,288.0\",\"48.7859917,9.1899133,288.0\",\"48.7860024,9.1900098,288.0\",\"48.7860453,9.19016,287.0\",\"48.7862921,9.1904819,287.0\",\"48.7865818,9.1910291,287.0\",\"48.7878478,9.1932714,285.0\",\"48.7881052,9.1936684,285.0\",\"48.7894249,9.1958678,284.0\",\"48.7893927,9.1963291,284.0\",\"48.7894034,9.1966617,285.0\",\"48.7893713,9.1975951,287.0\",\"48.7893069,9.1987109,291.0\",\"48.789221,9.2007816,298.0\",\"48.7891889,9.2013931,300.0\",\"48.7891352,9.2017472,301.0\",\"48.789103,9.2022085,302.0\",\"48.789103,9.2024767,303.0\",\"48.7891567,9.2027986,304.0\",\"48.7890601,9.2058671,311.0\",\"48.7890279,9.206543,312.0\",\"48.7889636,9.2070901,313.0\",\"48.7888777,9.2084849,311.0\",\"48.7888026,9.210695,303.0\",\"48.7888026,9.2115963,299.0\",\"48.788867,9.2122185,297.0\",\"48.7889314,9.2125726,296.0\",\"48.7889636,9.2130125,294.0\",\"48.7889636,9.2133021,293.0\",\"48.7889099,9.2136347,291.0\",\"48.7887168,9.2140639,289.0\",\"48.7883949,9.2144716,287.0\",\"48.7881696,9.21489,285.0\",\"48.7880409,9.2152762,284.0\",\"48.7878048,9.216274,280.0\",\"48.7876868,9.2165959,279.0\",\"48.7874615,9.2170358,277.0\",\"48.7867856,9.217937,273.0\",\"48.7861633,9.2167246,277.0\",\"48.7857878,9.2159522,282.0\"],\"leg\":[{\"start\":{\"linkId\":\"+1188640340\",\"mappedPosition\":{\"latitude\":48.7704613,\"longitude\":9.1575942},\"originalPosition\":{\"latitude\":48.770685,\"longitude\":9.157448},\"type\":\"stopOver\",\"spot\":0.1666667,\"sideOfStreet\":\"left\",\"mappedRoadName\":\"Rotebühlstraße\",\"label\":\"Rotebühlstraße - L1015\",\"shapeIndex\":0,\"source\":\"user\"},\"end\":{\"linkId\":\"-1189087529\",\"mappedPosition\":{\"latitude\":48.7857878,\"longitude\":9.2159522},\"originalPosition\":{\"latitude\":48.786034,\"longitude\":9.2158129},\"type\":\"stopOver\",\"spot\":0.41,\"sideOfStreet\":\"right\",\"mappedRoadName\":\"Talstraße\",\"label\":\"Talstraße - L1014\",\"shapeIndex\":94,\"source\":\"user\"},\"length\":6049,\"travelTime\":1633,\"maneuver\":[{\"position\":{\"latitude\":48.7704613,\"longitude\":9.1575942},\"instruction\":\"Head toward <span class=\\\"toward_street\\\">Schwabstraße</span> on <span class=\\\"street\\\">Rotebühlstraße</span> <span class=\\\"number\\\">(L1015)</span>. <span class=\\\"distance-description\\\">Go for <span class=\\\"length\\\">35 m</span>.</span>\",\"travelTime\":8,\"length\":35,\"id\":\"M1\",\"_type\":\"PrivateTransportManeuverType\"},{\"position\":{\"latitude\":48.7705851,\"longitude\":9.1580272},\"instruction\":\"Continue on <span class=\\\"next-street\\\">Rotebühlstraße</span> <span class=\\\"number\\\">(L1015)</span>. <span class=\\\"distance-description\\\">Go for <span class=\\\"length\\\">2.3 km</span>.</span>\",\"travelTime\":578,\"length\":2305,\"id\":\"M2\",\"_type\":\"PrivateTransportManeuverType\"},{\"position\":{\"latitude\":48.7840712,\"longitude\":9.1789269},\"instruction\":\"Turn <span class=\\\"direction\\\">right</span> onto <span class=\\\"next-street\\\">Arnulf-Klett-Platz</span>. <span class=\\\"distance-description\\\">Go for <span class=\\\"length\\\">524 m</span>.</span>\",\"travelTime\":138,\"length\":524,\"id\":\"M3\",\"_type\":\"PrivateTransportManeuverType\"},{\"position\":{\"latitude\":48.7818289,\"longitude\":9.1851497},\"instruction\":\"Keep <span class=\\\"direction\\\">left</span> onto <span class=\\\"next-street\\\">Gebhard-Müller-Platz</span>. <span class=\\\"distance-description\\\">Go for <span class=\\\"length\\\">101 m</span>.</span>\",\"travelTime\":36,\"length\":101,\"id\":\"M4\",\"_type\":\"PrivateTransportManeuverType\"},{\"position\":{\"latitude\":48.7814319,\"longitude\":9.1863942},\"instruction\":\"Turn <span class=\\\"direction\\\">left</span> onto <span class=\\\"next-street\\\">Willy-Brandt-Straße</span>. <span class=\\\"distance-description\\\">Go for <span class=\\\"length\\\">608 m</span>.</span>\",\"travelTime\":176,\"length\":608,\"id\":\"M5\",\"_type\":\"PrivateTransportManeuverType\"},{\"position\":{\"latitude\":48.7859917,\"longitude\":9.1899133},\"instruction\":\"Turn <span class=\\\"direction\\\">right</span> onto <span class=\\\"next-street\\\">Neckarstraße</span>. <span class=\\\"distance-description\\\">Go for <span class=\\\"length\\\">583 m</span>.</span>\",\"travelTime\":155,\"length\":583,\"id\":\"M6\",\"_type\":\"PrivateTransportManeuverType\"},{\"position\":{\"latitude\":48.7894249,\"longitude\":9.1958678},\"instruction\":\"Turn <span class=\\\"direction\\\">right</span> onto <span class=\\\"next-street\\\">Hackstraße</span>. <span class=\\\"distance-description\\\">Go for <span class=\\\"length\\\">1.4 km</span>.</span>\",\"travelTime\":402,\"length\":1393,\"id\":\"M7\",\"_type\":\"PrivateTransportManeuverType\"},{\"position\":{\"latitude\":48.7883949,\"longitude\":9.2144716},\"instruction\":\"Continue on <span class=\\\"next-street\\\">Rotenbergstraße</span>. <span class=\\\"distance-description\\\">Go for <span class=\\\"length\\\">318 m</span>.</span>\",\"travelTime\":63,\"length\":318,\"id\":\"M8\",\"_type\":\"PrivateTransportManeuverType\"},{\"position\":{\"latitude\":48.7867856,\"longitude\":9.217937},\"instruction\":\"Turn <span class=\\\"direction\\\">right</span> onto <span class=\\\"next-street\\\">Talstraße</span> <span class=\\\"number\\\">(L1014)</span>. <span class=\\\"distance-description\\\">Go for <span class=\\\"length\\\">182 m</span>.</span>\",\"travelTime\":77,\"length\":182,\"id\":\"M9\",\"_type\":\"PrivateTransportManeuverType\"},{\"position\":{\"latitude\":48.7857878,\"longitude\":9.2159522},\"instruction\":\"Arrive at <span class=\\\"street\\\">Talstraße</span> <span class=\\\"number\\\">(L1014)</span>. Your destination is on the right.\",\"travelTime\":0,\"length\":0,\"id\":\"M10\",\"_type\":\"PrivateTransportManeuverType\"}]}],\"summary\":{\"distance\":6049,\"baseTime\":1633,\"flags\":[\"builtUpArea\"],\"text\":\"The trip takes <span class=\\\"length\\\">6.0 km</span> and <span class=\\\"time\\\">27 mins</span>.\",\"travelTime\":1633,\"_type\":\"RouteSummaryType\"}}],\"language\":\"en-us\"}}", + // "mode": "NORMAL" + // }, + // { + // "route": "{\"response\":{\"metaInfo\":{\"timestamp\":\"2019-12-10T22:17:30Z\",\"mapVersion\":\"8.30.103.151\",\"moduleVersion\":\"7.2.201949-5928\",\"interfaceVersion\":\"2.6.74\",\"availableMapVersion\":[\"8.30.103.151\"]},\"route\":[{\"waypoint\":[{\"linkId\":\"+1188640340\",\"mappedPosition\":{\"latitude\":48.7704613,\"longitude\":9.1575942},\"originalPosition\":{\"latitude\":48.770685,\"longitude\":9.157448},\"type\":\"stopOver\",\"spot\":0.1666667,\"sideOfStreet\":\"left\",\"mappedRoadName\":\"Rotebühlstraße\",\"label\":\"Rotebühlstraße - L1015\",\"shapeIndex\":0,\"source\":\"user\"},{\"linkId\":\"-1189087529\",\"mappedPosition\":{\"latitude\":48.7857878,\"longitude\":9.2159522},\"originalPosition\":{\"latitude\":48.786034,\"longitude\":9.2158129},\"type\":\"stopOver\",\"spot\":0.41,\"sideOfStreet\":\"right\",\"mappedRoadName\":\"Talstraße\",\"label\":\"Talstraße - L1014\",\"shapeIndex\":94,\"source\":\"user\"}],\"mode\":{\"type\":\"fastest\",\"transportModes\":[\"bicycle\"],\"trafficMode\":\"disabled\",\"feature\":[]},\"shape\":[\"48.7704613,9.1575942,337.0\",\"48.7725851,9.1560272,335.0\",\"48.7712073,9.1605806,329.0\",\"48.7717223,9.1625118,325.0\",\"48.7719047,9.163295,324.0\",\"48.7721622,9.1641963,323.0\",\"48.7725377,9.1656125,322.0\",\"48.7727737,9.1663849,321.0\",\"48.7730205,9.1672969,319.0\",\"48.7730205,9.1674793,318.0\",\"48.7730956,9.1678011,317.0\",\"48.7735248,9.1691315,314.0\",\"48.7735462,9.1692603,313.0\",\"48.7737072,9.1698503,312.0\",\"48.7738574,9.1702366,312.0\",\"48.7739646,9.1704512,312.0\",\"48.7742114,9.1707838,311.0\",\"48.7747371,9.1713846,310.0\",\"48.7749624,9.1715884,310.0\",\"48.775295,9.1719317,310.0\",\"48.7762928,9.1730046,309.0\",\"48.7772691,9.1741741,306.0\",\"48.7784064,9.175483,304.0\",\"48.7795544,9.1766739,301.0\",\"48.7797582,9.1768348,300.0\",\"48.7800801,9.176985,300.0\",\"48.7803805,9.1770923,300.0\",\"48.7805414,9.1771245,300.0\",\"48.7810457,9.177146,298.0\",\"48.7822258,9.1772747,297.0\",\"48.782419,9.1773069,296.0\",\"48.7827516,9.1774356,295.0\",\"48.7859983,9.1756073,295.0\",\"48.7832236,9.1778433,295.0\",\"48.7838459,9.1786051,294.0\",\"48.7840712,9.1789269,294.0\",\"48.7838566,9.1793454,293.0\",\"48.7834489,9.180268,292.0\",\"48.7828696,9.1816843,291.0\",\"48.7826765,9.18221,291.0\",\"48.7824082,9.1831219,290.0\",\"48.7820113,9.1845703,289.0\",\"48.7818289,9.1851497,290.0\",\"48.7814856,9.1861689,293.0\",\"48.7814319,9.1863942,294.0\",\"48.7812924,9.1868341,294.0\",\"48.7814426,9.1869199,294.0\",\"48.7821937,9.1874456,293.0\",\"48.782537,9.1877246,292.0\",\"48.7829447,9.1879928,291.0\",\"48.7862558,9.1881752,291.0\",\"48.7838352,9.1886044,290.0\",\"48.7842751,9.1888833,290.0\",\"48.7853587,9.1896343,288.0\",\"48.7857449,9.1898811,288.0\",\"48.7858951,9.1899133,288.0\",\"48.7859917,9.1899133,288.0\",\"48.7860024,9.1900098,288.0\",\"48.7860453,9.19016,287.0\",\"48.7862921,9.1904819,287.0\",\"48.7865818,9.1910291,287.0\",\"48.7878478,9.1932714,285.0\",\"48.7881052,9.1936684,285.0\",\"48.7894249,9.1958678,284.0\",\"48.7893927,9.1963291,284.0\",\"48.7894034,9.1966617,285.0\",\"48.7893713,9.1975951,287.0\",\"48.7893069,9.1987109,291.0\",\"48.789221,9.2007816,298.0\",\"48.7891889,9.2013931,300.0\",\"48.7891352,9.2017472,301.0\",\"48.789103,9.2022085,302.0\",\"48.789103,9.2024767,303.0\",\"48.7891567,9.2027986,304.0\",\"48.7890601,9.2058671,311.0\",\"48.7890279,9.206543,312.0\",\"48.7889636,9.2070901,313.0\",\"48.7888777,9.2084849,311.0\",\"48.7888026,9.210695,303.0\",\"48.7888026,9.2115963,299.0\",\"48.788867,9.2122185,297.0\",\"48.7889314,9.2125726,296.0\",\"48.7889636,9.2130125,294.0\",\"48.7889636,9.2133021,293.0\",\"48.7889099,9.2136347,291.0\",\"48.7887168,9.2140639,289.0\",\"48.7883949,9.2144716,287.0\",\"48.7881696,9.21489,285.0\",\"48.7880409,9.2152762,284.0\",\"48.7878048,9.216274,280.0\",\"48.7876868,9.2165959,279.0\",\"48.7874615,9.2170358,277.0\",\"48.7867856,9.217937,273.0\",\"48.7861633,9.2167246,277.0\",\"48.7857878,9.2159522,282.0\"],\"leg\":[{\"start\":{\"linkId\":\"+1188640340\",\"mappedPosition\":{\"latitude\":48.7704613,\"longitude\":9.1575942},\"originalPosition\":{\"latitude\":48.770685,\"longitude\":9.157448},\"type\":\"stopOver\",\"spot\":0.1666667,\"sideOfStreet\":\"left\",\"mappedRoadName\":\"Rotebühlstraße\",\"label\":\"Rotebühlstraße - L1015\",\"shapeIndex\":0,\"source\":\"user\"},\"end\":{\"linkId\":\"-1189087529\",\"mappedPosition\":{\"latitude\":48.7857878,\"longitude\":9.2159522},\"originalPosition\":{\"latitude\":48.786034,\"longitude\":9.2158129},\"type\":\"stopOver\",\"spot\":0.41,\"sideOfStreet\":\"right\",\"mappedRoadName\":\"Talstraße\",\"label\":\"Talstraße - L1014\",\"shapeIndex\":94,\"source\":\"user\"},\"length\":6049,\"travelTime\":1633,\"maneuver\":[{\"position\":{\"latitude\":48.7704613,\"longitude\":9.1575942},\"instruction\":\"Head toward <span class=\\\"toward_street\\\">Schwabstraße</span> on <span class=\\\"street\\\">Rotebühlstraße</span> <span class=\\\"number\\\">(L1015)</span>. <span class=\\\"distance-description\\\">Go for <span class=\\\"length\\\">35 m</span>.</span>\",\"travelTime\":8,\"length\":35,\"id\":\"M1\",\"_type\":\"PrivateTransportManeuverType\"},{\"position\":{\"latitude\":48.7705851,\"longitude\":9.1580272},\"instruction\":\"Continue on <span class=\\\"next-street\\\">Rotebühlstraße</span> <span class=\\\"number\\\">(L1015)</span>. <span class=\\\"distance-description\\\">Go for <span class=\\\"length\\\">2.3 km</span>.</span>\",\"travelTime\":578,\"length\":2305,\"id\":\"M2\",\"_type\":\"PrivateTransportManeuverType\"},{\"position\":{\"latitude\":48.7840712,\"longitude\":9.1789269},\"instruction\":\"Turn <span class=\\\"direction\\\">right</span> onto <span class=\\\"next-street\\\">Arnulf-Klett-Platz</span>. <span class=\\\"distance-description\\\">Go for <span class=\\\"length\\\">524 m</span>.</span>\",\"travelTime\":138,\"length\":524,\"id\":\"M3\",\"_type\":\"PrivateTransportManeuverType\"},{\"position\":{\"latitude\":48.7818289,\"longitude\":9.1851497},\"instruction\":\"Keep <span class=\\\"direction\\\">left</span> onto <span class=\\\"next-street\\\">Gebhard-Müller-Platz</span>. <span class=\\\"distance-description\\\">Go for <span class=\\\"length\\\">101 m</span>.</span>\",\"travelTime\":36,\"length\":101,\"id\":\"M4\",\"_type\":\"PrivateTransportManeuverType\"},{\"position\":{\"latitude\":48.7814319,\"longitude\":9.1863942},\"instruction\":\"Turn <span class=\\\"direction\\\">left</span> onto <span class=\\\"next-street\\\">Willy-Brandt-Straße</span>. <span class=\\\"distance-description\\\">Go for <span class=\\\"length\\\">608 m</span>.</span>\",\"travelTime\":176,\"length\":608,\"id\":\"M5\",\"_type\":\"PrivateTransportManeuverType\"},{\"position\":{\"latitude\":48.7859917,\"longitude\":9.1899133},\"instruction\":\"Turn <span class=\\\"direction\\\">right</span> onto <span class=\\\"next-street\\\">Neckarstraße</span>. <span class=\\\"distance-description\\\">Go for <span class=\\\"length\\\">583 m</span>.</span>\",\"travelTime\":155,\"length\":583,\"id\":\"M6\",\"_type\":\"PrivateTransportManeuverType\"},{\"position\":{\"latitude\":48.7894249,\"longitude\":9.1958678},\"instruction\":\"Turn <span class=\\\"direction\\\">right</span> onto <span class=\\\"next-street\\\">Hackstraße</span>. <span class=\\\"distance-description\\\">Go for <span class=\\\"length\\\">1.4 km</span>.</span>\",\"travelTime\":402,\"length\":1393,\"id\":\"M7\",\"_type\":\"PrivateTransportManeuverType\"},{\"position\":{\"latitude\":48.7883949,\"longitude\":9.2144716},\"instruction\":\"Continue on <span class=\\\"next-street\\\">Rotenbergstraße</span>. <span class=\\\"distance-description\\\">Go for <span class=\\\"length\\\">318 m</span>.</span>\",\"travelTime\":63,\"length\":318,\"id\":\"M8\",\"_type\":\"PrivateTransportManeuverType\"},{\"position\":{\"latitude\":48.7867856,\"longitude\":9.217937},\"instruction\":\"Turn <span class=\\\"direction\\\">right</span> onto <span class=\\\"next-street\\\">Talstraße</span> <span class=\\\"number\\\">(L1014)</span>. <span class=\\\"distance-description\\\">Go for <span class=\\\"length\\\">182 m</span>.</span>\",\"travelTime\":77,\"length\":182,\"id\":\"M9\",\"_type\":\"PrivateTransportManeuverType\"},{\"position\":{\"latitude\":48.7857878,\"longitude\":9.2159522},\"instruction\":\"Arrive at <span class=\\\"street\\\">Talstraße</span> <span class=\\\"number\\\">(L1014)</span>. Your destination is on the right.\",\"travelTime\":0,\"length\":0,\"id\":\"M10\",\"_type\":\"PrivateTransportManeuverType\"}]}],\"summary\":{\"distance\":6049,\"baseTime\":1633,\"flags\":[\"builtUpArea\"],\"text\":\"The trip takes <span class=\\\"length\\\">6.0 km</span> and <span class=\\\"time\\\">27 mins</span>.\",\"travelTime\":1633,\"_type\":\"RouteSummaryType\"}}],\"language\":\"en-us\"}}", + // "mode": "ACCIDENTS" + // }, + // { + // "route": "{\"response\":{\"metaInfo\":{\"timestamp\":\"2019-12-10T22:17:30Z\",\"mapVersion\":\"8.30.103.151\",\"moduleVersion\":\"7.2.201949-5928\",\"interfaceVersion\":\"2.6.74\",\"availableMapVersion\":[\"8.30.103.151\"]},\"route\":[{\"waypoint\":[{\"linkId\":\"+1188640340\",\"mappedPosition\":{\"latitude\":48.7704613,\"longitude\":9.1575942},\"originalPosition\":{\"latitude\":48.770685,\"longitude\":9.157448},\"type\":\"stopOver\",\"spot\":0.1666667,\"sideOfStreet\":\"left\",\"mappedRoadName\":\"Rotebühlstraße\",\"label\":\"Rotebühlstraße - L1015\",\"shapeIndex\":0,\"source\":\"user\"},{\"linkId\":\"-1189087529\",\"mappedPosition\":{\"latitude\":48.7857878,\"longitude\":9.2159522},\"originalPosition\":{\"latitude\":48.786034,\"longitude\":9.2158129},\"type\":\"stopOver\",\"spot\":0.41,\"sideOfStreet\":\"right\",\"mappedRoadName\":\"Talstraße\",\"label\":\"Talstraße - L1014\",\"shapeIndex\":94,\"source\":\"user\"}],\"mode\":{\"type\":\"fastest\",\"transportModes\":[\"bicycle\"],\"trafficMode\":\"disabled\",\"feature\":[]},\"shape\":[\"48.7704613,9.1575942,337.0\",\"48.7735851,9.1570272,335.0\",\"48.7712073,9.1605806,329.0\",\"48.7717223,9.1625118,325.0\",\"48.7719047,9.163295,324.0\",\"48.7721622,9.1641963,323.0\",\"48.7725377,9.1656125,322.0\",\"48.7727737,9.1663849,321.0\",\"48.7730205,9.1672969,319.0\",\"48.7730205,9.1674793,318.0\",\"48.7730956,9.1678011,317.0\",\"48.7735248,9.1691315,314.0\",\"48.7735462,9.1692603,313.0\",\"48.7737072,9.1698503,312.0\",\"48.7738574,9.1702366,312.0\",\"48.7739646,9.1704512,312.0\",\"48.7742114,9.1707838,311.0\",\"48.7747371,9.1713846,310.0\",\"48.7749624,9.1715884,310.0\",\"48.775295,9.1719317,310.0\",\"48.7762928,9.1730046,309.0\",\"48.7772691,9.1741741,306.0\",\"48.7784064,9.175483,304.0\",\"48.7795544,9.1766739,301.0\",\"48.7797582,9.1768348,300.0\",\"48.7800801,9.176985,300.0\",\"48.7803805,9.1770923,300.0\",\"48.7805414,9.1771245,300.0\",\"48.7810457,9.177146,298.0\",\"48.7822258,9.1772747,297.0\",\"48.782419,9.1773069,296.0\",\"48.7827516,9.1774356,295.0\",\"48.7849983,9.1766073,295.0\",\"48.7832236,9.1778433,295.0\",\"48.7838459,9.1786051,294.0\",\"48.7840712,9.1789269,294.0\",\"48.7838566,9.1793454,293.0\",\"48.7834489,9.180268,292.0\",\"48.7828696,9.1816843,291.0\",\"48.7826765,9.18221,291.0\",\"48.7824082,9.1831219,290.0\",\"48.7820113,9.1845703,289.0\",\"48.7818289,9.1851497,290.0\",\"48.7814856,9.1861689,293.0\",\"48.7814319,9.1863942,294.0\",\"48.7812924,9.1868341,294.0\",\"48.7814426,9.1869199,294.0\",\"48.7821937,9.1874456,293.0\",\"48.782537,9.1877246,292.0\",\"48.7829447,9.1879928,291.0\",\"48.7872558,9.1881752,291.0\",\"48.7838352,9.1886044,290.0\",\"48.7842751,9.1888833,290.0\",\"48.7853587,9.1896343,288.0\",\"48.7857449,9.1898811,288.0\",\"48.7858951,9.1899133,288.0\",\"48.7859917,9.1899133,288.0\",\"48.7860024,9.1900098,288.0\",\"48.7860453,9.19016,287.0\",\"48.7862921,9.1904819,287.0\",\"48.7865818,9.1910291,287.0\",\"48.7878478,9.1932714,285.0\",\"48.7881052,9.1936684,285.0\",\"48.7894249,9.1958678,284.0\",\"48.7893927,9.1963291,284.0\",\"48.7894034,9.1966617,285.0\",\"48.7893713,9.1975951,287.0\",\"48.7893069,9.1987109,291.0\",\"48.789221,9.2007816,298.0\",\"48.7891889,9.2013931,300.0\",\"48.7891352,9.2017472,301.0\",\"48.789103,9.2022085,302.0\",\"48.789103,9.2024767,303.0\",\"48.7891567,9.2027986,304.0\",\"48.7890601,9.2058671,311.0\",\"48.7890279,9.206543,312.0\",\"48.7889636,9.2070901,313.0\",\"48.7888777,9.2084849,311.0\",\"48.7888026,9.210695,303.0\",\"48.7888026,9.2115963,299.0\",\"48.788867,9.2122185,297.0\",\"48.7889314,9.2125726,296.0\",\"48.7889636,9.2130125,294.0\",\"48.7889636,9.2133021,293.0\",\"48.7889099,9.2136347,291.0\",\"48.7887168,9.2140639,289.0\",\"48.7883949,9.2144716,287.0\",\"48.7881696,9.21489,285.0\",\"48.7880409,9.2152762,284.0\",\"48.7878048,9.216274,280.0\",\"48.7876868,9.2165959,279.0\",\"48.7874615,9.2170358,277.0\",\"48.7867856,9.217937,273.0\",\"48.7861633,9.2167246,277.0\",\"48.7857878,9.2159522,282.0\"],\"leg\":[{\"start\":{\"linkId\":\"+1188640340\",\"mappedPosition\":{\"latitude\":48.7704613,\"longitude\":9.1575942},\"originalPosition\":{\"latitude\":48.770685,\"longitude\":9.157448},\"type\":\"stopOver\",\"spot\":0.1666667,\"sideOfStreet\":\"left\",\"mappedRoadName\":\"Rotebühlstraße\",\"label\":\"Rotebühlstraße - L1015\",\"shapeIndex\":0,\"source\":\"user\"},\"end\":{\"linkId\":\"-1189087529\",\"mappedPosition\":{\"latitude\":48.7857878,\"longitude\":9.2159522},\"originalPosition\":{\"latitude\":48.786034,\"longitude\":9.2158129},\"type\":\"stopOver\",\"spot\":0.41,\"sideOfStreet\":\"right\",\"mappedRoadName\":\"Talstraße\",\"label\":\"Talstraße - L1014\",\"shapeIndex\":94,\"source\":\"user\"},\"length\":6049,\"travelTime\":1633,\"maneuver\":[{\"position\":{\"latitude\":48.7704613,\"longitude\":9.1575942},\"instruction\":\"Head toward <span class=\\\"toward_street\\\">Schwabstraße</span> on <span class=\\\"street\\\">Rotebühlstraße</span> <span class=\\\"number\\\">(L1015)</span>. <span class=\\\"distance-description\\\">Go for <span class=\\\"length\\\">35 m</span>.</span>\",\"travelTime\":8,\"length\":35,\"id\":\"M1\",\"_type\":\"PrivateTransportManeuverType\"},{\"position\":{\"latitude\":48.7705851,\"longitude\":9.1580272},\"instruction\":\"Continue on <span class=\\\"next-street\\\">Rotebühlstraße</span> <span class=\\\"number\\\">(L1015)</span>. <span class=\\\"distance-description\\\">Go for <span class=\\\"length\\\">2.3 km</span>.</span>\",\"travelTime\":578,\"length\":2305,\"id\":\"M2\",\"_type\":\"PrivateTransportManeuverType\"},{\"position\":{\"latitude\":48.7840712,\"longitude\":9.1789269},\"instruction\":\"Turn <span class=\\\"direction\\\">right</span> onto <span class=\\\"next-street\\\">Arnulf-Klett-Platz</span>. <span class=\\\"distance-description\\\">Go for <span class=\\\"length\\\">524 m</span>.</span>\",\"travelTime\":138,\"length\":524,\"id\":\"M3\",\"_type\":\"PrivateTransportManeuverType\"},{\"position\":{\"latitude\":48.7818289,\"longitude\":9.1851497},\"instruction\":\"Keep <span class=\\\"direction\\\">left</span> onto <span class=\\\"next-street\\\">Gebhard-Müller-Platz</span>. <span class=\\\"distance-description\\\">Go for <span class=\\\"length\\\">101 m</span>.</span>\",\"travelTime\":36,\"length\":101,\"id\":\"M4\",\"_type\":\"PrivateTransportManeuverType\"},{\"position\":{\"latitude\":48.7814319,\"longitude\":9.1863942},\"instruction\":\"Turn <span class=\\\"direction\\\">left</span> onto <span class=\\\"next-street\\\">Willy-Brandt-Straße</span>. <span class=\\\"distance-description\\\">Go for <span class=\\\"length\\\">608 m</span>.</span>\",\"travelTime\":176,\"length\":608,\"id\":\"M5\",\"_type\":\"PrivateTransportManeuverType\"},{\"position\":{\"latitude\":48.7859917,\"longitude\":9.1899133},\"instruction\":\"Turn <span class=\\\"direction\\\">right</span> onto <span class=\\\"next-street\\\">Neckarstraße</span>. <span class=\\\"distance-description\\\">Go for <span class=\\\"length\\\">583 m</span>.</span>\",\"travelTime\":155,\"length\":583,\"id\":\"M6\",\"_type\":\"PrivateTransportManeuverType\"},{\"position\":{\"latitude\":48.7894249,\"longitude\":9.1958678},\"instruction\":\"Turn <span class=\\\"direction\\\">right</span> onto <span class=\\\"next-street\\\">Hackstraße</span>. <span class=\\\"distance-description\\\">Go for <span class=\\\"length\\\">1.4 km</span>.</span>\",\"travelTime\":402,\"length\":1393,\"id\":\"M7\",\"_type\":\"PrivateTransportManeuverType\"},{\"position\":{\"latitude\":48.7883949,\"longitude\":9.2144716},\"instruction\":\"Continue on <span class=\\\"next-street\\\">Rotenbergstraße</span>. <span class=\\\"distance-description\\\">Go for <span class=\\\"length\\\">318 m</span>.</span>\",\"travelTime\":63,\"length\":318,\"id\":\"M8\",\"_type\":\"PrivateTransportManeuverType\"},{\"position\":{\"latitude\":48.7867856,\"longitude\":9.217937},\"instruction\":\"Turn <span class=\\\"direction\\\">right</span> onto <span class=\\\"next-street\\\">Talstraße</span> <span class=\\\"number\\\">(L1014)</span>. <span class=\\\"distance-description\\\">Go for <span class=\\\"length\\\">182 m</span>.</span>\",\"travelTime\":77,\"length\":182,\"id\":\"M9\",\"_type\":\"PrivateTransportManeuverType\"},{\"position\":{\"latitude\":48.7857878,\"longitude\":9.2159522},\"instruction\":\"Arrive at <span class=\\\"street\\\">Talstraße</span> <span class=\\\"number\\\">(L1014)</span>. Your destination is on the right.\",\"travelTime\":0,\"length\":0,\"id\":\"M10\",\"_type\":\"PrivateTransportManeuverType\"}]}],\"summary\":{\"distance\":6049,\"baseTime\":1633,\"flags\":[\"builtUpArea\"],\"text\":\"The trip takes <span class=\\\"length\\\">6.0 km</span> and <span class=\\\"time\\\">27 mins</span>.\",\"travelTime\":1633,\"_type\":\"RouteSummaryType\"}}],\"language\":\"en-us\"}}", + // "mode": "AIR_POLLUTION" + // }, + // { + // "route": "{\"response\":{\"metaInfo\":{\"timestamp\":\"2019-12-10T22:17:31Z\",\"mapVersion\":\"8.30.103.151\",\"moduleVersion\":\"7.2.201949-5928\",\"interfaceVersion\":\"2.6.74\",\"availableMapVersion\":[\"8.30.103.151\"]},\"route\":[{\"waypoint\":[{\"linkId\":\"+1188640340\",\"mappedPosition\":{\"latitude\":48.7704613,\"longitude\":9.1575942},\"originalPosition\":{\"latitude\":48.770685,\"longitude\":9.157448},\"type\":\"stopOver\",\"spot\":0.1666667,\"sideOfStreet\":\"left\",\"mappedRoadName\":\"Rotebühlstraße\",\"label\":\"Rotebühlstraße - L1015\",\"shapeIndex\":0,\"source\":\"user\"},{\"linkId\":\"-1189087529\",\"mappedPosition\":{\"latitude\":48.7857878,\"longitude\":9.2159522},\"originalPosition\":{\"latitude\":48.786034,\"longitude\":9.2158129},\"type\":\"stopOver\",\"spot\":0.41,\"sideOfStreet\":\"right\",\"mappedRoadName\":\"Talstraße\",\"label\":\"Talstraße - L1014\",\"shapeIndex\":94,\"source\":\"user\"}],\"mode\":{\"type\":\"fastest\",\"transportModes\":[\"bicycle\"],\"trafficMode\":\"disabled\",\"feature\":[]},\"shape\":[\"48.7704613,9.1575942,337.0\",\"48.7745851,9.1580272,335.0\",\"48.7712073,9.1605806,329.0\",\"48.7717223,9.1625118,325.0\",\"48.7719047,9.163295,324.0\",\"48.7721622,9.1641963,323.0\",\"48.7725377,9.1656125,322.0\",\"48.7727737,9.1663849,321.0\",\"48.7730205,9.1672969,319.0\",\"48.7730205,9.1674793,318.0\",\"48.7730956,9.1678011,317.0\",\"48.7735248,9.1691315,314.0\",\"48.7735462,9.1692603,313.0\",\"48.7737072,9.1698503,312.0\",\"48.7738574,9.1702366,312.0\",\"48.7739646,9.1704512,312.0\",\"48.7742114,9.1707838,311.0\",\"48.7747371,9.1713846,310.0\",\"48.7749624,9.1715884,310.0\",\"48.775295,9.1719317,310.0\",\"48.7762928,9.1730046,309.0\",\"48.7772691,9.1741741,306.0\",\"48.7784064,9.175483,304.0\",\"48.7795544,9.1766739,301.0\",\"48.7797582,9.1768348,300.0\",\"48.7800801,9.176985,300.0\",\"48.7803805,9.1770923,300.0\",\"48.7805414,9.1771245,300.0\",\"48.7810457,9.177146,298.0\",\"48.7822258,9.1772747,297.0\",\"48.782419,9.1773069,296.0\",\"48.7827516,9.1774356,295.0\",\"48.7839983,9.1776073,295.0\",\"48.7832236,9.1778433,295.0\",\"48.7838459,9.1786051,294.0\",\"48.7840712,9.1789269,294.0\",\"48.7838566,9.1793454,293.0\",\"48.7834489,9.180268,292.0\",\"48.7828696,9.1816843,291.0\",\"48.7826765,9.18221,291.0\",\"48.7824082,9.1831219,290.0\",\"48.7820113,9.1845703,289.0\",\"48.7818289,9.1851497,290.0\",\"48.7814856,9.1861689,293.0\",\"48.7814319,9.1863942,294.0\",\"48.7812924,9.1868341,294.0\",\"48.7814426,9.1869199,294.0\",\"48.7821937,9.1874456,293.0\",\"48.782537,9.1877246,292.0\",\"48.7829447,9.1879928,291.0\",\"48.7882558,9.1881752,291.0\",\"48.7838352,9.1886044,290.0\",\"48.7842751,9.1888833,290.0\",\"48.7853587,9.1896343,288.0\",\"48.7857449,9.1898811,288.0\",\"48.7858951,9.1899133,288.0\",\"48.7859917,9.1899133,288.0\",\"48.7860024,9.1900098,288.0\",\"48.7860453,9.19016,287.0\",\"48.7862921,9.1904819,287.0\",\"48.7865818,9.1910291,287.0\",\"48.7878478,9.1932714,285.0\",\"48.7881052,9.1936684,285.0\",\"48.7894249,9.1958678,284.0\",\"48.7893927,9.1963291,284.0\",\"48.7894034,9.1966617,285.0\",\"48.7893713,9.1975951,287.0\",\"48.7893069,9.1987109,291.0\",\"48.789221,9.2007816,298.0\",\"48.7891889,9.2013931,300.0\",\"48.7891352,9.2017472,301.0\",\"48.789103,9.2022085,302.0\",\"48.789103,9.2024767,303.0\",\"48.7891567,9.2027986,304.0\",\"48.7890601,9.2058671,311.0\",\"48.7890279,9.206543,312.0\",\"48.7889636,9.2070901,313.0\",\"48.7888777,9.2084849,311.0\",\"48.7888026,9.210695,303.0\",\"48.7888026,9.2115963,299.0\",\"48.788867,9.2122185,297.0\",\"48.7889314,9.2125726,296.0\",\"48.7889636,9.2130125,294.0\",\"48.7889636,9.2133021,293.0\",\"48.7889099,9.2136347,291.0\",\"48.7887168,9.2140639,289.0\",\"48.7883949,9.2144716,287.0\",\"48.7881696,9.21489,285.0\",\"48.7880409,9.2152762,284.0\",\"48.7878048,9.216274,280.0\",\"48.7876868,9.2165959,279.0\",\"48.7874615,9.2170358,277.0\",\"48.7867856,9.217937,273.0\",\"48.7861633,9.2167246,277.0\",\"48.7857878,9.2159522,282.0\"],\"leg\":[{\"start\":{\"linkId\":\"+1188640340\",\"mappedPosition\":{\"latitude\":48.7704613,\"longitude\":9.1575942},\"originalPosition\":{\"latitude\":48.770685,\"longitude\":9.157448},\"type\":\"stopOver\",\"spot\":0.1666667,\"sideOfStreet\":\"left\",\"mappedRoadName\":\"Rotebühlstraße\",\"label\":\"Rotebühlstraße - L1015\",\"shapeIndex\":0,\"source\":\"user\"},\"end\":{\"linkId\":\"-1189087529\",\"mappedPosition\":{\"latitude\":48.7857878,\"longitude\":9.2159522},\"originalPosition\":{\"latitude\":48.786034,\"longitude\":9.2158129},\"type\":\"stopOver\",\"spot\":0.41,\"sideOfStreet\":\"right\",\"mappedRoadName\":\"Talstraße\",\"label\":\"Talstraße - L1014\",\"shapeIndex\":94,\"source\":\"user\"},\"length\":6049,\"travelTime\":1633,\"maneuver\":[{\"position\":{\"latitude\":48.7704613,\"longitude\":9.1575942},\"instruction\":\"Head toward <span class=\\\"toward_street\\\">Schwabstraße</span> on <span class=\\\"street\\\">Rotebühlstraße</span> <span class=\\\"number\\\">(L1015)</span>. <span class=\\\"distance-description\\\">Go for <span class=\\\"length\\\">35 m</span>.</span>\",\"travelTime\":8,\"length\":35,\"id\":\"M1\",\"_type\":\"PrivateTransportManeuverType\"},{\"position\":{\"latitude\":48.7705851,\"longitude\":9.1580272},\"instruction\":\"Continue on <span class=\\\"next-street\\\">Rotebühlstraße</span> <span class=\\\"number\\\">(L1015)</span>. <span class=\\\"distance-description\\\">Go for <span class=\\\"length\\\">2.3 km</span>.</span>\",\"travelTime\":578,\"length\":2305,\"id\":\"M2\",\"_type\":\"PrivateTransportManeuverType\"},{\"position\":{\"latitude\":48.7840712,\"longitude\":9.1789269},\"instruction\":\"Turn <span class=\\\"direction\\\">right</span> onto <span class=\\\"next-street\\\">Arnulf-Klett-Platz</span>. <span class=\\\"distance-description\\\">Go for <span class=\\\"length\\\">524 m</span>.</span>\",\"travelTime\":138,\"length\":524,\"id\":\"M3\",\"_type\":\"PrivateTransportManeuverType\"},{\"position\":{\"latitude\":48.7818289,\"longitude\":9.1851497},\"instruction\":\"Keep <span class=\\\"direction\\\">left</span> onto <span class=\\\"next-street\\\">Gebhard-Müller-Platz</span>. <span class=\\\"distance-description\\\">Go for <span class=\\\"length\\\">101 m</span>.</span>\",\"travelTime\":36,\"length\":101,\"id\":\"M4\",\"_type\":\"PrivateTransportManeuverType\"},{\"position\":{\"latitude\":48.7814319,\"longitude\":9.1863942},\"instruction\":\"Turn <span class=\\\"direction\\\">left</span> onto <span class=\\\"next-street\\\">Willy-Brandt-Straße</span>. <span class=\\\"distance-description\\\">Go for <span class=\\\"length\\\">608 m</span>.</span>\",\"travelTime\":176,\"length\":608,\"id\":\"M5\",\"_type\":\"PrivateTransportManeuverType\"},{\"position\":{\"latitude\":48.7859917,\"longitude\":9.1899133},\"instruction\":\"Turn <span class=\\\"direction\\\">right</span> onto <span class=\\\"next-street\\\">Neckarstraße</span>. <span class=\\\"distance-description\\\">Go for <span class=\\\"length\\\">583 m</span>.</span>\",\"travelTime\":155,\"length\":583,\"id\":\"M6\",\"_type\":\"PrivateTransportManeuverType\"},{\"position\":{\"latitude\":48.7894249,\"longitude\":9.1958678},\"instruction\":\"Turn <span class=\\\"direction\\\">right</span> onto <span class=\\\"next-street\\\">Hackstraße</span>. <span class=\\\"distance-description\\\">Go for <span class=\\\"length\\\">1.4 km</span>.</span>\",\"travelTime\":402,\"length\":1393,\"id\":\"M7\",\"_type\":\"PrivateTransportManeuverType\"},{\"position\":{\"latitude\":48.7883949,\"longitude\":9.2144716},\"instruction\":\"Continue on <span class=\\\"next-street\\\">Rotenbergstraße</span>. <span class=\\\"distance-description\\\">Go for <span class=\\\"length\\\">318 m</span>.</span>\",\"travelTime\":63,\"length\":318,\"id\":\"M8\",\"_type\":\"PrivateTransportManeuverType\"},{\"position\":{\"latitude\":48.7867856,\"longitude\":9.217937},\"instruction\":\"Turn <span class=\\\"direction\\\">right</span> onto <span class=\\\"next-street\\\">Talstraße</span> <span class=\\\"number\\\">(L1014)</span>. <span class=\\\"distance-description\\\">Go for <span class=\\\"length\\\">182 m</span>.</span>\",\"travelTime\":77,\"length\":182,\"id\":\"M9\",\"_type\":\"PrivateTransportManeuverType\"},{\"position\":{\"latitude\":48.7857878,\"longitude\":9.2159522},\"instruction\":\"Arrive at <span class=\\\"street\\\">Talstraße</span> <span class=\\\"number\\\">(L1014)</span>. Your destination is on the right.\",\"travelTime\":0,\"length\":0,\"id\":\"M10\",\"_type\":\"PrivateTransportManeuverType\"}]}],\"summary\":{\"distance\":6049,\"baseTime\":1633,\"flags\":[\"builtUpArea\"],\"text\":\"The trip takes <span class=\\\"length\\\">6.0 km</span> and <span class=\\\"time\\\">27 mins</span>.\",\"travelTime\":1633,\"_type\":\"RouteSummaryType\"}}],\"language\":\"en-us\"}}", + // "mode": "AIR_POLLUTION_AND_ACCIDENTS" + // } + // ], + // "predictionData": { + // "airPollutionAndAccidentsPrediction": "test", + // "airPollutionPrediction": "test", + // "accidentsPrediction": "test", + // "normalPrediction": "test", + // "overAllPrediction": "test" + // } + // } + // } + } + + displayRouteOptions(resp){ + for (let i = 0; i < resp.data.routes.length; i++) { + let routeResp = JSON.parse(resp.data.routes[i].route); + let route = routeResp.response.route[0]; + //console.log(route); + this.setRouteOptions(route, i, resp.data.routes[i].mode); + this.drawRouteLine(route, i); + } + + let firstRoute = JSON.parse(resp.data.routes[0].route).response.route[0]; + console.log(firstRoute); + let waypointLabels = []; + for (let i = 0; i < firstRoute.waypoint.length; i += 1) { + waypointLabels.push(firstRoute.waypoint[i].label) + } + this.wayPointsInfo = waypointLabels.join(' - '); + } + + routeList = {}; + + setRouteOptions(route, index, mode) { + let content = ''; + content += 'Total distance: ' + route.summary.distance + 'm. '; + content += 'Travel Time: ' + Math.floor(route.summary.travelTime / 60) + ' min'; + console.log(content); + this.routeList[index] = {route:route, summary:content, mode:mode}; + } + + isRouteSelected = false; + selectedRoute = {}; + + selectRoute(route, index) { + let routeLine = this.routeLines[index]; + this.map.removeObject(routeLine); + this.drawRouteLine(route, index, 'rgba(102, 157, 246, 0.9)'); + this.isRouteSelected = true; + this.selectedRoute = route; + } + + routeLines = {}; + + drawRouteLine(route, index, color = 'rgba(96, 96, 96, 0.9)') { + let lineString = new H.geo.LineString(), + routeShape = route.shape, + polyline; + + routeShape.forEach(function (point) { + let parts = point.split(','); + lineString.pushLatLngAlt(parts[0], parts[1]); + }); + + polyline = new H.map.Polyline(lineString, { + style: { + lineWidth: 3, + strokeColor: color + } + }); + this.routeLines[index] = polyline; + // Add the polyline to the map + this.map.addObject(polyline); + } + + getRouteType(mode){ + if (mode === "NORMAL") { + return "Fastest Route"; + } else if(mode === "ACCIDENTS") { + return "Safe Route"; + } else if(mode === "AIR_POLLUTION") { + return "Green Route"; + } else { + return "Safe and Green Route"; + } + } + startTrip() { this.isBikeHired = true; this.startRideSubject.next('some value'); @@ -229,9 +357,35 @@ export class HirebikePage implements OnInit { } - startTrip1() { + startTrip2() { this.isBikeHired = true; - this.startRideSubject.next('some value'); + this.isTripStarted = true; + //this.startRideSubject.next('some value'); + this.drawFinalRouteonMap(); + this.loadingService.showLoader(); + this.storage.get('token').then((token) => { + let url = 'http://193.196.52.237:8081/rent' + '?bikeId=' + this.bikeDetails.id; + const headers = new HttpHeaders().set("Authorization", "Bearer " + token); + let bikeApi = this.httpClient.get(url, { headers }); + bikeApi.subscribe((resp) => { + console.log('my data: ', resp); + this.loadingService.hideLoader(); + this.toastService.showToast("Trip Started"); + this.isBikeHired = true; + }, (error) => { + console.log(error); + this.loadingService.hideLoader(); + this.toastService.showToast("This is ongoing Trip"); + }); + }); + + } + + drawFinalRouteonMap() { + this.map.removeObjects(this.map.getObjects()); + this.addRouteShapeToMap(this.selectedRoute); + this.addManueversToMap(this.selectedRoute); + this.mapDataService.mapDataSubject.next(this.selectedRoute); } CancelTrip() { @@ -453,14 +607,17 @@ export class HirebikePage implements OnInit { // listen for map click event this.map.addEventListener('tap', this.mapClickedEvent.bind(this)); - if(!this.locationsGroup) { + if (!this.locationsGroup) { this.locationsGroup = new H.map.Group(); } this.map.addObject(this.locationsGroup); } + + isDestinationSelected = false; + mapClickedEvent(event) { - if(this.rideStarted) { + if (this.rideStarted) { return; } //console.log(event.type, event.currentPointer.type); @@ -469,6 +626,7 @@ export class HirebikePage implements OnInit { console.log(coord.lat + ', ' + coord.lng); this.destinationPosition = { lat: coord.lat, lng: coord.lng }; + this.isDestinationSelected = true; if (this.destinationMarker) { this.destinationMarker.setGeometry({ lat: coord.lat, lng: coord.lng }) @@ -477,7 +635,7 @@ export class HirebikePage implements OnInit { // Create a marker using the previously instantiated icon: this.destinationMarker = new H.map.Marker({ lat: coord.lat, lng: coord.lng }, { icon: icon }); // Add the marker to the map: - if(!this.locationsGroup) { + if (!this.locationsGroup) { this.locationsGroup = new H.map.Group(); } this.locationsGroup.addObjects([this.destinationMarker]); @@ -511,7 +669,7 @@ export class HirebikePage implements OnInit { // Create a marker using the previously instantiated icon: this.currentLocationMarker = new H.map.Marker({ lat: lat, lng: lng }, { icon: icon }); // Add the marker to the map: - if(!this.locationsGroup) { + if (!this.locationsGroup) { this.locationsGroup = new H.map.Group(); } this.locationsGroup.addObjects([this.currentLocationMarker]); @@ -527,7 +685,7 @@ export class HirebikePage implements OnInit { var marker = new H.map.Marker({ lat: lat, lng: lng }, { icon: icon }); // Add the marker to the map: //this.map.addObject(marker); - if(!this.locationsGroup) { + if (!this.locationsGroup) { this.locationsGroup = new H.map.Group(); } this.locationsGroup.addObjects([marker]);