def getRouteFromAPI(input): lat = round(float(input[0]), 9) long = round(float(input[1]), 9) length = input[2] seed = input[3] imageName = input[4] type = input[5] baseURL = "http://*****:*****@2x?access_token=pk.eyJ1IjoiZ2FveXVzaGkwMDEiLCJhIjoiY2tubGM0cmV1MGY5aTJucGVtMHAwZGtpNyJ9.xApcEalgtGPF4fQc4to1DA" res = requests.get(requestUrl) if res.status_code != 200: return with staticfiles_storage.open( os.path.join(django_settings.STATIC_ROOT, imageName), 'wb') as out_file: out_file.write(res.content) del res return instructionsList, realDistance, time, imageName, risk, encodedCoordinatesList, polyline
def surface(self, features, mapid="mapbox.mapbox-terrain-v1", layer="contour", fields=["ele"], geojson=True, polyline=False, interpolate=None, zoom=None): warnings.warn( "The surface module will be removed in the next version. " "It has no replacement.", MapboxDeprecationWarning) params = { 'layer': layer, 'fields': ','.join(fields), 'geojson': 'true' if geojson else 'false', } if interpolate is not None: params['interpolate'] = 'true' if interpolate else 'false', if zoom is not None: params['zoom'] = zoom if polyline: params['encoded_polyline'] = encode_polyline(features) else: params['points'] = encode_waypoints(features, precision=6, min_limit=1, max_limit=300) uri = URITemplate(self.baseuri + '/{mapid}.json').expand(mapid=mapid) res = self.session.get(uri, params=params) self.handle_http_error(res) def geojson(): return res.json()['results'] res.geojson = geojson return res
def surface(self, features, mapid="mapbox.mapbox-terrain-v1", layer="contour", fields=["ele"], geojson=True, polyline=False, interpolate=None, zoom=None): params = { 'layer': layer, 'fields': ','.join(fields), 'geojson': 'true' if geojson else 'false', } if interpolate is not None: params['interpolate'] = 'true' if interpolate else 'false', if zoom is not None: params['zoom'] = zoom if polyline: params['encoded_polyline'] = encode_polyline(features) else: params['points'] = encode_waypoints( features, precision=6, min_limit=1, max_limit=300) uri = URITemplate(self.baseuri + '/{mapid}.json').expand(mapid=mapid) res = self.session.get(uri, params=params) self.handle_http_error(res) def geojson(): return res.json()['results'] res.geojson = geojson return res
def test_encode_polyline(): expected = "wp_~EvdatO{xiAfupD" assert expected == encode_polyline(gj_point_features) assert expected == encode_polyline(gj_multipoint_features) assert expected == encode_polyline(gj_line_features)
def test_encode_polyline(): expected = "vdatOwp_~EhupD{xiA" assert expected == encode_polyline(gj_point_features) assert expected == encode_polyline(gj_multipoint_features) assert expected == encode_polyline(gj_line_features)