@@ -119,7 +119,7 @@ constantSpeedConsumptionInkWhPerHundredkm="50,8.2:130,21.3"
119
119
120
120
121
121
# Get boundaries for the electric vehicle's reachable range.
122
- routeRangeResponse = await (await session.get(" https://atlas.microsoft.com/route/range/json?subscription-key={Your-Azure-Maps-Subscription-key }&api-version=1.0&query={}&travelMode={}&vehicleEngineType={}¤tChargeInkWh={}&maxChargeInkWh={}&timeBudgetInSec={}&routeType={}&constantSpeedConsumptionInkWhPerHundredkm={}"
122
+ routeRangeResponse = await (await session.get(" https://atlas.microsoft.com/route/range/json?subscription-key={} &api-version=1.0&query={} &travelMode={} &vehicleEngineType={} ¤tChargeInkWh={} &maxChargeInkWh={} &timeBudgetInSec={} &routeType={} &constantSpeedConsumptionInkWhPerHundredkm={} "
123
123
.format(subscriptionKey,str (currentLocation[0 ])+ " ," + str (currentLocation[1 ]),travelMode, vehicleEngineType, currentChargeInkWh, maxChargeInkWh, timeBudgetInSec, routeType, constantSpeedConsumptionInkWhPerHundredkm))).json()
124
124
125
125
polyBounds = routeRangeResponse[" reachableRange" ][" boundary" ]
@@ -153,7 +153,7 @@ To search for electric vehicle charging stations within the reachable range, run
153
153
154
154
``` python
155
155
# Search for electric vehicle stations within reachable range.
156
- searchPolyResponse = await (await session.post(url = " https://atlas.microsoft.com/search/geometry/json?subscription-key={Your-Azure-Maps-Subscription-key }&api-version=1.0&query=electric vehicle station&idxSet=POI&limit=50" .format(subscriptionKey), json = boundsData)).json()
156
+ searchPolyResponse = await (await session.post(url = " https://atlas.microsoft.com/search/geometry/json?subscription-key={} &api-version=1.0&query=electric vehicle station&idxSet=POI&limit=50" .format(subscriptionKey), json = boundsData)).json()
157
157
158
158
reachableLocations = []
159
159
for loc in range (len (searchPolyResponse[" results" ])):
@@ -186,9 +186,9 @@ rangeData = {
186
186
}
187
187
188
188
# Upload the range data to Azure Maps Data service.
189
- uploadRangeResponse = await session.post(" https://us.atlas.microsoft.com/mapData?subscription-key={Your-Azure-Maps-Subscription-key }&api-version=2.0&dataFormat=geojson" .format(subscriptionKey), json = rangeData)
189
+ uploadRangeResponse = await session.post(" https://us.atlas.microsoft.com/mapData?subscription-key={} &api-version=2.0&dataFormat=geojson" .format(subscriptionKey), json = rangeData)
190
190
191
- rangeUdidRequest = uploadRangeResponse.headers[" Location" ]+ " &subscription-key={Your-Azure-Maps-Subscription-key }" .format(subscriptionKey)
191
+ rangeUdidRequest = uploadRangeResponse.headers[" Location" ]+ " &subscription-key={} " .format(subscriptionKey)
192
192
193
193
while True :
194
194
getRangeUdid = await (await session.get(rangeUdidRequest)).json()
@@ -215,9 +215,9 @@ poiData = {
215
215
}
216
216
217
217
# Upload the electric vehicle charging station data to Azure Maps Data service.
218
- uploadPOIsResponse = await session.post(" https://us.atlas.microsoft.com/mapData?subscription-key={Your-Azure-Maps-Subscription-key }&api-version=2.0&dataFormat=geojson" .format(subscriptionKey), json = poiData)
218
+ uploadPOIsResponse = await session.post(" https://us.atlas.microsoft.com/mapData?subscription-key={} &api-version=2.0&dataFormat=geojson" .format(subscriptionKey), json = poiData)
219
219
220
- poiUdidRequest = uploadPOIsResponse.headers[" Location" ]+ " &subscription-key={Your-Azure-Maps-Subscription-key }" .format(subscriptionKey)
220
+ poiUdidRequest = uploadPOIsResponse.headers[" Location" ]+ " &subscription-key={} " .format(subscriptionKey)
221
221
222
222
while True :
223
223
getPoiUdid = await (await session.get(poiUdidRequest)).json()
@@ -260,7 +260,7 @@ pins = "custom|an15 53||udid-{}||https://raw.githubusercontent.com/Azure-Samples
260
260
encodedPins = urllib.parse.quote(pins, safe = ' ' )
261
261
262
262
# Render the range and electric vehicle charging points on the map.
263
- staticMapResponse = await session.get(" https://atlas.microsoft.com/map/static/png?api-version=1.0&subscription-key={Your-Azure-Maps-Subscription-key }&pins={}&path={}&bbox={}&zoom=12" .format(subscriptionKey,encodedPins,path,str (minLon)+ " , " + str (minLat)+ " , " + str (maxLon)+ " , " + str (maxLat)))
263
+ staticMapResponse = await session.get(" https://atlas.microsoft.com/map/static/png?api-version=1.0&subscription-key={} &pins={} &path={} &bbox={} &zoom=12" .format(subscriptionKey,encodedPins,path,str (minLon)+ " , " + str (minLat)+ " , " + str (maxLon)+ " , " + str (maxLat)))
264
264
265
265
poiRangeMap = await staticMapResponse.content.read()
266
266
@@ -290,7 +290,7 @@ locationData = {
290
290
}
291
291
292
292
# Get the travel time and distance to each specified charging station.
293
- searchPolyRes = await (await session.post(url = " https://atlas.microsoft.com/route/matrix/json?subscription-key={Your-Azure-Maps-Subscription-key }&api-version=1.0&routeType=shortest&waitForResults=true" .format(subscriptionKey), json = locationData)).json()
293
+ searchPolyRes = await (await session.post(url = " https://atlas.microsoft.com/route/matrix/json?subscription-key={} &api-version=1.0&routeType=shortest&waitForResults=true" .format(subscriptionKey), json = locationData)).json()
294
294
295
295
distances = []
296
296
for dist in range (len (reachableLocations)):
@@ -310,7 +310,7 @@ To get the route to the charging station and to parse the response to create a g
310
310
311
311
``` python
312
312
# Get the route from the electric vehicle's current location to the closest charging station.
313
- routeResponse = await (await session.get(" https://atlas.microsoft.com/route/directions/json?subscription-key={Your-Azure-Maps-Subscription-key }&api-version=1.0&query={}:{}" .format(subscriptionKey, str (currentLocation[0 ])+ " ," + str (currentLocation[1 ]), closestChargeLoc))).json()
313
+ routeResponse = await (await session.get(" https://atlas.microsoft.com/route/directions/json?subscription-key={} &api-version=1.0&query={} :{} " .format(subscriptionKey, str (currentLocation[0 ])+ " ," + str (currentLocation[1 ]), closestChargeLoc))).json()
314
314
315
315
route = []
316
316
for loc in range (len (routeResponse[" routes" ][0 ][" legs" ][0 ][" points" ])):
@@ -332,9 +332,9 @@ To get an image for the rendered route on the map, run the following script:
332
332
333
333
``` python
334
334
# Upload the route data to Azure Maps Data service .
335
- routeUploadRequest = await session.post(" https://atlas.microsoft.com/mapData?subscription-key={Your-Azure-Maps-Subscription-key }&api-version=2.0&dataFormat=geojson" .format(subscriptionKey), json = routeData)
335
+ routeUploadRequest = await session.post(" https://atlas.microsoft.com/mapData?subscription-key={} &api-version=2.0&dataFormat=geojson" .format(subscriptionKey), json = routeData)
336
336
337
- udidRequestURI = routeUploadRequest.headers[" Location" ]+ " &subscription-key={Your-Azure-Maps-Subscription-key }" .format(subscriptionKey)
337
+ udidRequestURI = routeUploadRequest.headers[" Location" ]+ " &subscription-key={} " .format(subscriptionKey)
338
338
339
339
while True :
340
340
udidRequest = await (await session.get(udidRequestURI)).json()
@@ -367,7 +367,7 @@ minLat -= latBuffer
367
367
maxLat += latBuffer
368
368
369
369
# Render the route on the map.
370
- staticMapResponse = await session.get(" https://atlas.microsoft.com/map/static/png?api-version=1.0&subscription-key={Your-Azure-Maps-Subscription-key }&&path={}&pins={}&bbox={}&zoom=16" .format(subscriptionKey,path,pins,str (minLon)+ " , " + str (minLat)+ " , " + str (maxLon)+ " , " + str (maxLat)))
370
+ staticMapResponse = await session.get(" https://atlas.microsoft.com/map/static/png?api-version=1.0&subscription-key={} &&path={} &pins={} &bbox={} &zoom=16" .format(subscriptionKey,path,pins,str (minLon)+ " , " + str (minLat)+ " , " + str (maxLon)+ " , " + str (maxLat)))
371
371
372
372
staticMapImage = await staticMapResponse.content.read()
373
373
0 commit comments