Routes API implemented for travel time
This commit is contained in:
parent
5349088ba0
commit
ce9956ea52
7 changed files with 5632 additions and 1 deletions
32
code/json/routing_distancematrix.json
Normal file
32
code/json/routing_distancematrix.json
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
{
|
||||
"destination_addresses" :
|
||||
[
|
||||
"11 Canal Reach, London N1C 4DB, UK"
|
||||
],
|
||||
"origin_addresses" :
|
||||
[
|
||||
"1 Carville St, Finsbury Park, London N4 3PE, UK"
|
||||
],
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"elements" :
|
||||
[
|
||||
{
|
||||
"distance" :
|
||||
{
|
||||
"text" : "5.4 km",
|
||||
"value" : 5411
|
||||
},
|
||||
"duration" :
|
||||
{
|
||||
"text" : "27 mins",
|
||||
"value" : 1607
|
||||
},
|
||||
"status" : "OK"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"status" : "OK"
|
||||
}
|
||||
70
code/json/routing_routeapi.json
Normal file
70
code/json/routing_routeapi.json
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
{
|
||||
"routes": [
|
||||
{
|
||||
"legs": [
|
||||
{
|
||||
"stepsOverview": {
|
||||
"multiModalSegments": [
|
||||
{
|
||||
"stepStartIndex": 0,
|
||||
"stepEndIndex": 2,
|
||||
"navigationInstruction": {
|
||||
"instructions": "Walk to Finsbury Park"
|
||||
},
|
||||
"travelMode": "WALK"
|
||||
},
|
||||
{
|
||||
"stepStartIndex": 3,
|
||||
"stepEndIndex": 3,
|
||||
"navigationInstruction": {
|
||||
"instructions": "Subway towards Brixton"
|
||||
},
|
||||
"travelMode": "TRANSIT"
|
||||
},
|
||||
{
|
||||
"stepStartIndex": 4,
|
||||
"stepEndIndex": 4,
|
||||
"navigationInstruction": {
|
||||
"instructions": "Walk to Euston"
|
||||
},
|
||||
"travelMode": "WALK"
|
||||
},
|
||||
{
|
||||
"stepStartIndex": 5,
|
||||
"stepEndIndex": 5,
|
||||
"navigationInstruction": {
|
||||
"instructions": "Subway towards Morden via Bank"
|
||||
},
|
||||
"travelMode": "TRANSIT"
|
||||
},
|
||||
{
|
||||
"stepStartIndex": 6,
|
||||
"stepEndIndex": 6,
|
||||
"navigationInstruction": {
|
||||
"instructions": "Walk to Bank Station"
|
||||
},
|
||||
"travelMode": "WALK"
|
||||
},
|
||||
{
|
||||
"stepStartIndex": 7,
|
||||
"stepEndIndex": 7,
|
||||
"navigationInstruction": {
|
||||
"instructions": "Light rail towards Woolwich Arsenal"
|
||||
},
|
||||
"travelMode": "TRANSIT"
|
||||
},
|
||||
{
|
||||
"stepStartIndex": 8,
|
||||
"stepEndIndex": 9,
|
||||
"travelMode": "WALK"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"distanceMeters": 22438,
|
||||
"duration": "3463s",
|
||||
"staticDuration": "3463s"
|
||||
}
|
||||
]
|
||||
}
|
||||
752
code/json/routing_routeapi_full.json
Normal file
752
code/json/routing_routeapi_full.json
Normal file
|
|
@ -0,0 +1,752 @@
|
|||
{
|
||||
"routes": [
|
||||
{
|
||||
"legs": [
|
||||
{
|
||||
"distanceMeters": 22438,
|
||||
"duration": "3462s",
|
||||
"staticDuration": "3462s",
|
||||
"polyline": {
|
||||
"encodedPolyline": "q_vyHfrTIFMHQK}AwDw@gDONK_@cB_E?MzBiI@UbIt@rCRpFj@pATpJdCzAM|Ac@nCcAdF_AhEm@dFqAfFeBlFsBtAg@pFuA~KiD`Cm@|Es@jDQzH?bCLtCp@pA`@pAh@dBbA|AfAjAbArBfClLvOfBnCzB`EbCvFjCbHbC|G|Jd]xAhGfCnLrCvZ`@lCPr@xIvYsAvAYn@S~Cl@Td@j@x@vBzCfKDCN{@D}@CgA[{Dc@iDyMuc@a@oBQqAsCwZqDc~AAaCT_BXsBdUauAjBoKf@cBVg@l@m@xDgBrAe@`AO|GMrEc@`Eg@~@FtHfAvBd@~L~EfNbE^?fAk@dDuBrGiF^bBoAc@AK`E{C^o@VuAn@sFfAsKv@uIl@aM^_FJsBN_HG_GCkAMuASeAw@_CcAsDUaB_@kGa@yEQ}EWaEc@eOYuNWgFi@kZ]{NIcLk@y_@CgFS{MH_EKgFUaDF}GRwG`@}Ht@iId@cEfBiKTaBTs@pBiIzA_Fz@mC|AyFrAwG`AkGD}@?kAQ_F@eARiBh@kDPuBr@uMPiBPw@FsADwEAoECYAsGa@wLOwEiAsM]aB]eAcA}Bm@oB_@_CaCaUg@gDa@uB_@kA[o@iAcBq@o@}BcBq@a@q@WeF_Am@Y{@aAo@{@o@kAu@qB_@yAEaADiAL{@Vi@r@cApByB|@{@bAe@`EwAv@MjEsB^MhAo@|Bw@hD}@d@WxKiIp@_Al@qAXiATaCV}CVwAd@yArEsKzAoErAgFpBuI|@uELeAJuBd@_ENoBTiELmE@mEIoGi@qZSiFCiDHuFE{AG_AY_Bg@aBe@kAqCoFWw@OiACmARgDCqAOoAWyAGeAHoKF_BL{@fAqEMMpA}BGCS`Ac@bB][I@EGBuBIO?K"
|
||||
},
|
||||
"startLocation": {
|
||||
"latLng": {
|
||||
"latitude": 51.5636071,
|
||||
"longitude": -0.110597
|
||||
}
|
||||
},
|
||||
"endLocation": {
|
||||
"latLng": {
|
||||
"latitude": 51.503823499999996,
|
||||
"longitude": 0.0490617
|
||||
}
|
||||
},
|
||||
"steps": [
|
||||
{
|
||||
"distanceMeters": 6,
|
||||
"staticDuration": "5s",
|
||||
"polyline": {
|
||||
"encodedPolyline": "q_vyHfrTIF"
|
||||
},
|
||||
"startLocation": {
|
||||
"latLng": {
|
||||
"latitude": 51.5636071,
|
||||
"longitude": -0.110597
|
||||
}
|
||||
},
|
||||
"endLocation": {
|
||||
"latLng": {
|
||||
"latitude": 51.563659300000005,
|
||||
"longitude": -0.1106426
|
||||
}
|
||||
},
|
||||
"navigationInstruction": {
|
||||
"maneuver": "DEPART",
|
||||
"instructions": "Head northwest on Pooles Park"
|
||||
},
|
||||
"localizedValues": {
|
||||
"distance": {
|
||||
"text": "6 m"
|
||||
},
|
||||
"staticDuration": {
|
||||
"text": "1 min"
|
||||
}
|
||||
},
|
||||
"travelMode": "WALK"
|
||||
},
|
||||
{
|
||||
"distanceMeters": 158,
|
||||
"staticDuration": "133s",
|
||||
"polyline": {
|
||||
"encodedPolyline": "{_vyHnrTMHQK}AwDw@gD"
|
||||
},
|
||||
"startLocation": {
|
||||
"latLng": {
|
||||
"latitude": 51.563659300000005,
|
||||
"longitude": -0.1106426
|
||||
}
|
||||
},
|
||||
"endLocation": {
|
||||
"latLng": {
|
||||
"latitude": 51.564572399999996,
|
||||
"longitude": -0.10886889999999999
|
||||
}
|
||||
},
|
||||
"navigationInstruction": {
|
||||
"maneuver": "TURN_SLIGHT_RIGHT",
|
||||
"instructions": "Slight right onto Biggerstaff St"
|
||||
},
|
||||
"localizedValues": {
|
||||
"distance": {
|
||||
"text": "0.2 km"
|
||||
},
|
||||
"staticDuration": {
|
||||
"text": "2 mins"
|
||||
}
|
||||
},
|
||||
"travelMode": "WALK"
|
||||
},
|
||||
{
|
||||
"distanceMeters": 19,
|
||||
"staticDuration": "18s",
|
||||
"polyline": {
|
||||
"encodedPolyline": "qevyHlgTON"
|
||||
},
|
||||
"startLocation": {
|
||||
"latLng": {
|
||||
"latitude": 51.564572399999996,
|
||||
"longitude": -0.10886889999999999
|
||||
}
|
||||
},
|
||||
"endLocation": {
|
||||
"latLng": {
|
||||
"latitude": 51.564651900000008,
|
||||
"longitude": -0.1089478
|
||||
}
|
||||
},
|
||||
"navigationInstruction": {
|
||||
"maneuver": "TURN_LEFT",
|
||||
"instructions": "Turn left onto Fonthill Rd"
|
||||
},
|
||||
"localizedValues": {
|
||||
"distance": {
|
||||
"text": "19 m"
|
||||
},
|
||||
"staticDuration": {
|
||||
"text": "1 min"
|
||||
}
|
||||
},
|
||||
"travelMode": "WALK"
|
||||
},
|
||||
{
|
||||
"distanceMeters": 102,
|
||||
"staticDuration": "85s",
|
||||
"polyline": {
|
||||
"encodedPolyline": "afvyH|gTK_@cB_E"
|
||||
},
|
||||
"startLocation": {
|
||||
"latLng": {
|
||||
"latitude": 51.564651900000008,
|
||||
"longitude": -0.1089478
|
||||
}
|
||||
},
|
||||
"endLocation": {
|
||||
"latLng": {
|
||||
"latitude": 51.5652057,
|
||||
"longitude": -0.1078344
|
||||
}
|
||||
},
|
||||
"navigationInstruction": {
|
||||
"maneuver": "TURN_RIGHT",
|
||||
"instructions": "Turn right onto Wells Terrace"
|
||||
},
|
||||
"localizedValues": {
|
||||
"distance": {
|
||||
"text": "0.1 km"
|
||||
},
|
||||
"staticDuration": {
|
||||
"text": "1 min"
|
||||
}
|
||||
},
|
||||
"travelMode": "WALK"
|
||||
},
|
||||
{
|
||||
"staticDuration": "30s",
|
||||
"polyline": {
|
||||
"encodedPolyline": "qivyHn`T"
|
||||
},
|
||||
"startLocation": {
|
||||
"latLng": {
|
||||
"latitude": 51.565208,
|
||||
"longitude": -0.107765
|
||||
}
|
||||
},
|
||||
"endLocation": {
|
||||
"latLng": {
|
||||
"latitude": 51.565208,
|
||||
"longitude": -0.107765
|
||||
}
|
||||
},
|
||||
"navigationInstruction": {
|
||||
"instructions": "Take entrance "
|
||||
},
|
||||
"localizedValues": {
|
||||
"distance": {
|
||||
"text": "1 m"
|
||||
},
|
||||
"staticDuration": {
|
||||
"text": "1 min"
|
||||
}
|
||||
},
|
||||
"travelMode": "WALK"
|
||||
},
|
||||
{
|
||||
"distanceMeters": 133,
|
||||
"staticDuration": "60s",
|
||||
"polyline": {
|
||||
"encodedPolyline": "qivyHn`TzBiI"
|
||||
},
|
||||
"startLocation": {
|
||||
"latLng": {
|
||||
"latitude": 51.565208,
|
||||
"longitude": -0.107765
|
||||
}
|
||||
},
|
||||
"endLocation": {
|
||||
"latLng": {
|
||||
"latitude": 51.56459,
|
||||
"longitude": -0.10610900000000001
|
||||
}
|
||||
},
|
||||
"localizedValues": {
|
||||
"distance": {
|
||||
"text": "0.1 km"
|
||||
},
|
||||
"staticDuration": {
|
||||
"text": "1 min"
|
||||
}
|
||||
},
|
||||
"travelMode": "WALK"
|
||||
},
|
||||
{
|
||||
"distanceMeters": 5202,
|
||||
"staticDuration": "392s",
|
||||
"polyline": {
|
||||
"encodedPolyline": "uevyHdvS@UbIt@rCRpFj@pATpJdCzAM|Ac@nCcAdF_AhEm@dFqAfFeBlFsBtAg@pFuA~KiD`Cm@|Es@jDQzH?bCLtCp@pA`@pAh@dBbA|AfAjAbArBfClLvOfBnCzB`EbCvFjCbHbC|G|Jd]xAhGfCnLrCvZ`@lCPr@xIvYsAvA"
|
||||
},
|
||||
"startLocation": {
|
||||
"latLng": {
|
||||
"latitude": 51.56459,
|
||||
"longitude": -0.10610900000000001
|
||||
}
|
||||
},
|
||||
"endLocation": {
|
||||
"latLng": {
|
||||
"latitude": 51.528693999999994,
|
||||
"longitude": -0.13204
|
||||
}
|
||||
},
|
||||
"navigationInstruction": {
|
||||
"instructions": "Subway towards Brixton"
|
||||
},
|
||||
"localizedValues": {
|
||||
"distance": {
|
||||
"text": "5.2 km"
|
||||
},
|
||||
"staticDuration": {
|
||||
"text": "7 mins"
|
||||
}
|
||||
},
|
||||
"transitDetails": {
|
||||
"stopDetails": {
|
||||
"arrivalStop": {
|
||||
"name": "Euston",
|
||||
"location": {
|
||||
"latLng": {
|
||||
"latitude": 51.528693999999994,
|
||||
"longitude": -0.13204
|
||||
}
|
||||
}
|
||||
},
|
||||
"arrivalTime": "2024-03-04T09:20:32Z",
|
||||
"departureStop": {
|
||||
"name": "Finsbury Park",
|
||||
"location": {
|
||||
"latLng": {
|
||||
"latitude": 51.56459,
|
||||
"longitude": -0.10610900000000001
|
||||
}
|
||||
}
|
||||
},
|
||||
"departureTime": "2024-03-04T09:14:00Z"
|
||||
},
|
||||
"localizedValues": {
|
||||
"arrivalTime": {
|
||||
"time": {
|
||||
"text": "9:20 AM"
|
||||
},
|
||||
"timeZone": "Europe/London"
|
||||
},
|
||||
"departureTime": {
|
||||
"time": {
|
||||
"text": "9:14 AM"
|
||||
},
|
||||
"timeZone": "Europe/London"
|
||||
}
|
||||
},
|
||||
"headsign": "Brixton",
|
||||
"headway": "120s",
|
||||
"transitLine": {
|
||||
"agencies": [
|
||||
{
|
||||
"name": "Transport for London",
|
||||
"uri": "https://tfl.gov.uk/modes/tube/"
|
||||
}
|
||||
],
|
||||
"name": "Victoria line",
|
||||
"uri": "https://tfl.gov.uk/modes/tube/",
|
||||
"color": "#00a3e0",
|
||||
"nameShort": "Victoria",
|
||||
"textColor": "#ffffff",
|
||||
"vehicle": {
|
||||
"name": {
|
||||
"text": "Subway"
|
||||
},
|
||||
"type": "SUBWAY",
|
||||
"iconUri": "//maps.gstatic.com/mapfiles/transit/iw2/6/subway2.png",
|
||||
"localIconUri": "//maps.gstatic.com/mapfiles/transit/iw2/6/uk-london-underground.png"
|
||||
}
|
||||
},
|
||||
"stopCount": 4
|
||||
},
|
||||
"travelMode": "TRANSIT"
|
||||
},
|
||||
{
|
||||
"distanceMeters": 21,
|
||||
"staticDuration": "30s",
|
||||
"polyline": {
|
||||
"encodedPolyline": "ieoyHfxXYn@"
|
||||
},
|
||||
"startLocation": {
|
||||
"latLng": {
|
||||
"latitude": 51.528693999999994,
|
||||
"longitude": -0.13204
|
||||
}
|
||||
},
|
||||
"endLocation": {
|
||||
"latLng": {
|
||||
"latitude": 51.528819999999996,
|
||||
"longitude": -0.13227500000000003
|
||||
}
|
||||
},
|
||||
"localizedValues": {
|
||||
"distance": {
|
||||
"text": "21 m"
|
||||
},
|
||||
"staticDuration": {
|
||||
"text": "1 min"
|
||||
}
|
||||
},
|
||||
"travelMode": "WALK"
|
||||
},
|
||||
{
|
||||
"distanceMeters": 5627,
|
||||
"staticDuration": "600s",
|
||||
"polyline": {
|
||||
"encodedPolyline": "cfoyHvyXS~Cl@Td@j@x@vBzCfKDCN{@D}@CgA[{Dc@iDyMuc@a@oBQqAsCwZqDc~AAaCT_BXsBdUauAjBoKf@cBVg@l@m@xDgBrAe@`AO|GMrEc@`Eg@~@FtHfAvBd@~L~EfNbE^?fAk@dDuBrGiF^bB"
|
||||
},
|
||||
"startLocation": {
|
||||
"latLng": {
|
||||
"latitude": 51.528819999999996,
|
||||
"longitude": -0.13227500000000003
|
||||
}
|
||||
},
|
||||
"endLocation": {
|
||||
"latLng": {
|
||||
"latitude": 51.511845,
|
||||
"longitude": -0.088246899999999989
|
||||
}
|
||||
},
|
||||
"navigationInstruction": {
|
||||
"instructions": "Subway towards Morden via Bank"
|
||||
},
|
||||
"localizedValues": {
|
||||
"distance": {
|
||||
"text": "5.6 km"
|
||||
},
|
||||
"staticDuration": {
|
||||
"text": "10 mins"
|
||||
}
|
||||
},
|
||||
"transitDetails": {
|
||||
"stopDetails": {
|
||||
"arrivalStop": {
|
||||
"name": "Bank Station",
|
||||
"location": {
|
||||
"latLng": {
|
||||
"latitude": 51.511845,
|
||||
"longitude": -0.088246899999999989
|
||||
}
|
||||
}
|
||||
},
|
||||
"arrivalTime": "2024-03-04T09:35:00Z",
|
||||
"departureStop": {
|
||||
"name": "Euston",
|
||||
"location": {
|
||||
"latLng": {
|
||||
"latitude": 51.528819999999996,
|
||||
"longitude": -0.13227500000000003
|
||||
}
|
||||
}
|
||||
},
|
||||
"departureTime": "2024-03-04T09:25:00Z"
|
||||
},
|
||||
"localizedValues": {
|
||||
"arrivalTime": {
|
||||
"time": {
|
||||
"text": "9:35 AM"
|
||||
},
|
||||
"timeZone": "Europe/London"
|
||||
},
|
||||
"departureTime": {
|
||||
"time": {
|
||||
"text": "9:25 AM"
|
||||
},
|
||||
"timeZone": "Europe/London"
|
||||
}
|
||||
},
|
||||
"headsign": "Morden via Bank",
|
||||
"headway": "180s",
|
||||
"transitLine": {
|
||||
"agencies": [
|
||||
{
|
||||
"name": "Transport for London",
|
||||
"uri": "https://tfl.gov.uk/modes/tube/"
|
||||
}
|
||||
],
|
||||
"name": "Northern Line",
|
||||
"uri": "https://tfl.gov.uk/modes/tube/",
|
||||
"color": "#000000",
|
||||
"nameShort": "Northern",
|
||||
"textColor": "#ffffff",
|
||||
"vehicle": {
|
||||
"name": {
|
||||
"text": "Subway"
|
||||
},
|
||||
"type": "SUBWAY",
|
||||
"iconUri": "//maps.gstatic.com/mapfiles/transit/iw2/6/subway2.png",
|
||||
"localIconUri": "//maps.gstatic.com/mapfiles/transit/iw2/6/uk-london-underground.png"
|
||||
}
|
||||
},
|
||||
"stopCount": 6
|
||||
},
|
||||
"travelMode": "TRANSIT"
|
||||
},
|
||||
{
|
||||
"distanceMeters": 45,
|
||||
"staticDuration": "60s",
|
||||
"polyline": {
|
||||
"encodedPolyline": "_|kyHpfPoAc@"
|
||||
},
|
||||
"startLocation": {
|
||||
"latLng": {
|
||||
"latitude": 51.511845,
|
||||
"longitude": -0.088246899999999989
|
||||
}
|
||||
},
|
||||
"endLocation": {
|
||||
"latLng": {
|
||||
"latitude": 51.512236699999995,
|
||||
"longitude": -0.0880733
|
||||
}
|
||||
},
|
||||
"localizedValues": {
|
||||
"distance": {
|
||||
"text": "45 m"
|
||||
},
|
||||
"staticDuration": {
|
||||
"text": "1 min"
|
||||
}
|
||||
},
|
||||
"travelMode": "WALK"
|
||||
},
|
||||
{
|
||||
"distanceMeters": 10907,
|
||||
"staticDuration": "1320s",
|
||||
"polyline": {
|
||||
"encodedPolyline": "o~kyHlePAK`E{C^o@VuAn@sFfAsKv@uIl@aM^_FJsBN_HG_GCkAMuASeAw@_CcAsDUaB_@kGa@yEQ}EWaEc@eOYuNWgFi@kZ]{NIcLk@y_@CgFS{MH_EKgFUaDF}GRwG`@}Ht@iId@cEfBiKTaBTs@pBiIzA_Fz@mC|AyFrAwG`AkGD}@?kAQ_F@eARiBh@kDPuBr@uMPiBPw@FsADwEAoECYAsGa@wLOwEiAsM]aB]eAcA}Bm@oB_@_CaCaUg@gDa@uB_@kA[o@iAcBq@o@}BcBq@a@q@WeF_Am@Y{@aAo@{@o@kAu@qB_@yAEaADiAL{@Vi@r@cApByB|@{@bAe@`EwAv@MjEsB^MhAo@|Bw@hD}@d@WxKiIp@_Al@qAXiATaCV}CVwAd@yArEsKzAoErAgFpBuI|@uELeAJuBd@_ENoBTiELmE@mEIoGi@qZSiFCiDHuFE{AG_AY_Bg@aBe@kAqCoFWw@OiACmARgDCqAOoAWyAGeAHoKF_BL{@fAqEMM"
|
||||
},
|
||||
"startLocation": {
|
||||
"latLng": {
|
||||
"latitude": 51.512236699999995,
|
||||
"longitude": -0.0880733
|
||||
}
|
||||
},
|
||||
"endLocation": {
|
||||
"latLng": {
|
||||
"latitude": 51.503653,
|
||||
"longitude": 0.0483353
|
||||
}
|
||||
},
|
||||
"navigationInstruction": {
|
||||
"instructions": "Light rail towards Woolwich Arsenal"
|
||||
},
|
||||
"localizedValues": {
|
||||
"distance": {
|
||||
"text": "10.9 km"
|
||||
},
|
||||
"staticDuration": {
|
||||
"text": "22 mins"
|
||||
}
|
||||
},
|
||||
"transitDetails": {
|
||||
"stopDetails": {
|
||||
"arrivalStop": {
|
||||
"name": "London City Airport",
|
||||
"location": {
|
||||
"latLng": {
|
||||
"latitude": 51.503653,
|
||||
"longitude": 0.0483353
|
||||
}
|
||||
}
|
||||
},
|
||||
"arrivalTime": "2024-03-04T10:03:00Z",
|
||||
"departureStop": {
|
||||
"name": "Bank Station",
|
||||
"location": {
|
||||
"latLng": {
|
||||
"latitude": 51.512236699999995,
|
||||
"longitude": -0.0880733
|
||||
}
|
||||
}
|
||||
},
|
||||
"departureTime": "2024-03-04T09:41:00Z"
|
||||
},
|
||||
"localizedValues": {
|
||||
"arrivalTime": {
|
||||
"time": {
|
||||
"text": "10:03 AM"
|
||||
},
|
||||
"timeZone": "Europe/London"
|
||||
},
|
||||
"departureTime": {
|
||||
"time": {
|
||||
"text": "9:41 AM"
|
||||
},
|
||||
"timeZone": "Europe/London"
|
||||
}
|
||||
},
|
||||
"headsign": "Woolwich Arsenal",
|
||||
"transitLine": {
|
||||
"agencies": [
|
||||
{
|
||||
"name": "Transport for London",
|
||||
"uri": "https://tfl.gov.uk/modes/tube/"
|
||||
}
|
||||
],
|
||||
"uri": "https://tfl.gov.uk/modes/dlr/",
|
||||
"color": "#00afad",
|
||||
"nameShort": "DLR",
|
||||
"textColor": "#ffffff",
|
||||
"vehicle": {
|
||||
"name": {
|
||||
"text": "Light rail"
|
||||
},
|
||||
"type": "TRAM",
|
||||
"iconUri": "//maps.gstatic.com/mapfiles/transit/iw2/6/tram2.png",
|
||||
"localIconUri": "//maps.gstatic.com/mapfiles/transit/iw2/6/uk-london-dlr.png"
|
||||
}
|
||||
},
|
||||
"stopCount": 11
|
||||
},
|
||||
"travelMode": "TRANSIT"
|
||||
},
|
||||
{
|
||||
"distanceMeters": 63,
|
||||
"staticDuration": "64s",
|
||||
"polyline": {
|
||||
"encodedPolyline": "yhjyHcmHpA}B"
|
||||
},
|
||||
"startLocation": {
|
||||
"latLng": {
|
||||
"latitude": 51.503653,
|
||||
"longitude": 0.0483353
|
||||
}
|
||||
},
|
||||
"endLocation": {
|
||||
"latLng": {
|
||||
"latitude": 51.5032434,
|
||||
"longitude": 0.048965499999999995
|
||||
}
|
||||
},
|
||||
"navigationInstruction": {
|
||||
"instructions": "Take exit "
|
||||
},
|
||||
"localizedValues": {
|
||||
"distance": {
|
||||
"text": "63 m"
|
||||
},
|
||||
"staticDuration": {
|
||||
"text": "1 min"
|
||||
}
|
||||
},
|
||||
"travelMode": "WALK"
|
||||
},
|
||||
{
|
||||
"distanceMeters": 70,
|
||||
"staticDuration": "54s",
|
||||
"polyline": {
|
||||
"encodedPolyline": "ofjyHeqHS`Ac@bB"
|
||||
},
|
||||
"startLocation": {
|
||||
"latLng": {
|
||||
"latitude": 51.5032794,
|
||||
"longitude": 0.0489907
|
||||
}
|
||||
},
|
||||
"endLocation": {
|
||||
"latLng": {
|
||||
"latitude": 51.503564399999995,
|
||||
"longitude": 0.0481594
|
||||
}
|
||||
},
|
||||
"navigationInstruction": {
|
||||
"maneuver": "DEPART",
|
||||
"instructions": "Head northwest on Hartmann Rd"
|
||||
},
|
||||
"localizedValues": {
|
||||
"distance": {
|
||||
"text": "70 m"
|
||||
},
|
||||
"staticDuration": {
|
||||
"text": "1 min"
|
||||
}
|
||||
},
|
||||
"travelMode": "WALK"
|
||||
},
|
||||
{
|
||||
"distanceMeters": 85,
|
||||
"staticDuration": "73s",
|
||||
"polyline": {
|
||||
"encodedPolyline": "ghjyH_lH][I@EGBuBIO?K"
|
||||
},
|
||||
"startLocation": {
|
||||
"latLng": {
|
||||
"latitude": 51.503564399999995,
|
||||
"longitude": 0.0481594
|
||||
}
|
||||
},
|
||||
"endLocation": {
|
||||
"latLng": {
|
||||
"latitude": 51.503823499999996,
|
||||
"longitude": 0.0490617
|
||||
}
|
||||
},
|
||||
"navigationInstruction": {
|
||||
"maneuver": "TURN_RIGHT",
|
||||
"instructions": "Turn right\nPartial restricted usage road"
|
||||
},
|
||||
"localizedValues": {
|
||||
"distance": {
|
||||
"text": "85 m"
|
||||
},
|
||||
"staticDuration": {
|
||||
"text": "1 min"
|
||||
}
|
||||
},
|
||||
"travelMode": "WALK"
|
||||
}
|
||||
],
|
||||
"localizedValues": {
|
||||
"distance": {
|
||||
"text": "22.4 km"
|
||||
},
|
||||
"duration": {
|
||||
"text": "58 mins"
|
||||
},
|
||||
"staticDuration": {
|
||||
"text": "58 mins"
|
||||
}
|
||||
},
|
||||
"stepsOverview": {
|
||||
"multiModalSegments": [
|
||||
{
|
||||
"stepStartIndex": 0,
|
||||
"stepEndIndex": 5,
|
||||
"navigationInstruction": {
|
||||
"instructions": "Walk to Finsbury Park"
|
||||
},
|
||||
"travelMode": "WALK"
|
||||
},
|
||||
{
|
||||
"stepStartIndex": 6,
|
||||
"stepEndIndex": 6,
|
||||
"navigationInstruction": {
|
||||
"instructions": "Subway towards Brixton"
|
||||
},
|
||||
"travelMode": "TRANSIT"
|
||||
},
|
||||
{
|
||||
"stepStartIndex": 7,
|
||||
"stepEndIndex": 7,
|
||||
"navigationInstruction": {
|
||||
"instructions": "Walk to Euston"
|
||||
},
|
||||
"travelMode": "WALK"
|
||||
},
|
||||
{
|
||||
"stepStartIndex": 8,
|
||||
"stepEndIndex": 8,
|
||||
"navigationInstruction": {
|
||||
"instructions": "Subway towards Morden via Bank"
|
||||
},
|
||||
"travelMode": "TRANSIT"
|
||||
},
|
||||
{
|
||||
"stepStartIndex": 9,
|
||||
"stepEndIndex": 9,
|
||||
"navigationInstruction": {
|
||||
"instructions": "Walk to Bank Station"
|
||||
},
|
||||
"travelMode": "WALK"
|
||||
},
|
||||
{
|
||||
"stepStartIndex": 10,
|
||||
"stepEndIndex": 10,
|
||||
"navigationInstruction": {
|
||||
"instructions": "Light rail towards Woolwich Arsenal"
|
||||
},
|
||||
"travelMode": "TRANSIT"
|
||||
},
|
||||
{
|
||||
"stepStartIndex": 11,
|
||||
"stepEndIndex": 13,
|
||||
"travelMode": "WALK"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"distanceMeters": 22438,
|
||||
"duration": "3463s",
|
||||
"staticDuration": "3463s",
|
||||
"polyline": {
|
||||
"encodedPolyline": "q_vyHfrTIFMHQK}AwDw@gDONK_@cB_E?MzBiI@UbIt@rCRpFj@pATpJdCzAM|Ac@nCcAdF_AhEm@dFqAfFeBlFsBtAg@pFuA~KiD`Cm@|Es@jDQzH?bCLtCp@pA`@pAh@dBbA|AfAjAbArBfClLvOfBnCzB`EbCvFjCbHbC|G|Jd]xAhGfCnLrCvZ`@lCPr@xIvYsAvAYn@S~Cl@Td@j@x@vBzCfKDCN{@D}@CgA[{Dc@iDyMuc@a@oBQqAsCwZqDc~AAaCT_BXsBdUauAjBoKf@cBVg@l@m@xDgBrAe@`AO|GMrEc@`Eg@~@FtHfAvBd@~L~EfNbE^?fAk@dDuBrGiF^bBoAc@AK`E{C^o@VuAn@sFfAsKv@uIl@aM^_FJsBN_HG_GCkAMuASeAw@_CcAsDUaB_@kGa@yEQ}EWaEc@eOYuNWgFi@kZ]{NIcLk@y_@CgFS{MH_EKgFUaDF}GRwG`@}Ht@iId@cEfBiKTaBTs@pBiIzA_Fz@mC|AyFrAwG`AkGD}@?kAQ_F@eARiBh@kDPuBr@uMPiBPw@FsADwEAoECYAsGa@wLOwEiAsM]aB]eAcA}Bm@oB_@_CaCaUg@gDa@uB_@kA[o@iAcBq@o@}BcBq@a@q@WeF_Am@Y{@aAo@{@o@kAu@qB_@yAEaADiAL{@Vi@r@cApByB|@{@bAe@`EwAv@MjEsB^MhAo@|Bw@hD}@d@WxKiIp@_Al@qAXiATaCV}CVwAd@yArEsKzAoErAgFpBuI|@uELeAJuBd@_ENoBTiELmE@mEIoGi@qZSiFCiDHuFE{AG_AY_Bg@aBe@kAqCoFWw@OiACmARgDCqAOoAWyAGeAHoKF_BL{@fAqEMMpA}BGCS`Ac@bB][I@EGBuBIO?K"
|
||||
},
|
||||
"viewport": {
|
||||
"low": {
|
||||
"latitude": 51.502068799999996,
|
||||
"longitude": -0.1359722
|
||||
},
|
||||
"high": {
|
||||
"latitude": 51.565208,
|
||||
"longitude": 0.0490617
|
||||
}
|
||||
},
|
||||
"travelAdvisory": {
|
||||
"transitFare": {
|
||||
"currencyCode": "GBP",
|
||||
"units": "3",
|
||||
"nanos": 700000000
|
||||
}
|
||||
},
|
||||
"localizedValues": {
|
||||
"distance": {
|
||||
"text": "22.4 km"
|
||||
},
|
||||
"duration": {
|
||||
"text": "58 mins"
|
||||
},
|
||||
"staticDuration": {
|
||||
"text": "58 mins"
|
||||
},
|
||||
"transitFare": {
|
||||
"text": "£3.70"
|
||||
}
|
||||
},
|
||||
"routeLabels": [
|
||||
"DEFAULT_ROUTE"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
4706
code/json/routing_routeapi_with_alternative.json
Normal file
4706
code/json/routing_routeapi_with_alternative.json
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -18,3 +18,6 @@ print(r.status_code)
|
|||
|
||||
print(r.json())
|
||||
|
||||
with open('code/json/routing_distancematrix.json', 'w') as f:
|
||||
f.write(r.text)
|
||||
|
||||
60
code/routing_routing.py
Normal file
60
code/routing_routing.py
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
import requests
|
||||
from utils import nextMonday
|
||||
|
||||
API_KEY = 'AIzaSyBoBHzeQFgR7O-NlNsuHXQcC1B7ccEHpl8'
|
||||
url = "https://routes.googleapis.com/directions/v2:computeRoutes"
|
||||
|
||||
|
||||
def travel_time(origin_lat:float, origin_lon:float, dest_lat:float, dest_lon:float):
|
||||
monday9am = nextMonday()
|
||||
|
||||
header = {
|
||||
"X-Goog-Api-Key": API_KEY,
|
||||
"Content-Type": "application/json",
|
||||
"X-Goog-FieldMask": "routes.distanceMeters,routes.duration,routes.staticDuration,routes.legs.stepsOverview",
|
||||
}
|
||||
|
||||
body = {
|
||||
"origin":{
|
||||
"location":{
|
||||
"latLng":{
|
||||
"latitude": origin_lat,
|
||||
"longitude": origin_lon
|
||||
}
|
||||
}
|
||||
},
|
||||
"destination":{
|
||||
"location":{
|
||||
"latLng":{
|
||||
"latitude": dest_lat,
|
||||
"longitude": dest_lon
|
||||
}
|
||||
}
|
||||
},
|
||||
"travelMode": "TRANSIT",
|
||||
# "2023-10-15T15:01:23.045123456Z"
|
||||
"departureTime": monday9am.strftime("%Y-%m-%dT%H:%M:%S.%fZ"),
|
||||
"computeAlternativeRoutes": False,
|
||||
# "routeModifiers": {
|
||||
# "avoidTolls": false,
|
||||
# "avoidHighways": false,
|
||||
# "avoidFerries": false
|
||||
# },
|
||||
"languageCode": "en-US",
|
||||
"units": "METRIC"
|
||||
}
|
||||
|
||||
r = requests.post(url, json=body, headers=header)
|
||||
if r.status_code == 200:
|
||||
return r.json()
|
||||
|
||||
raise Exception(r.json())
|
||||
|
||||
if __name__ == "__main__":
|
||||
origin = 51.5635664310333, -0.1107173751570373 # home
|
||||
dest = 51.50475678313417, 0.04915321000190009 # london city airport
|
||||
d = travel_time(origin[0], origin[1], dest[0], dest[1])
|
||||
import json
|
||||
with open('code/json/routing_routeapi2.json', 'w') as f:
|
||||
json.dump(d, f)
|
||||
|
||||
|
|
@ -1,9 +1,17 @@
|
|||
from datetime import datetime, timedelta, timezone
|
||||
|
||||
def nextMonday():
|
||||
"""
|
||||
I think this function doesnt work when the day is monday itself.
|
||||
|
||||
Returns:
|
||||
_type_: _description_
|
||||
"""
|
||||
now = datetime.now(timezone.utc)
|
||||
days_until_monday = (0 - now.weekday() + 7) % 7
|
||||
monday = now + timedelta(days=days_until_monday)
|
||||
monday_9am = monday.replace(hour=9, minute=0, second=0, microsecond=0, tzinfo=timezone.utc)
|
||||
return monday_9am
|
||||
|
||||
print(nextMonday())
|
||||
if __name__ == '__main__':
|
||||
print(nextMonday())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue