Gladly, thank you.
I am using texas-latest.osm.pbf from Geofabrik Download Server
Code
I’ll have to redact specific coordinates:
import pandas as pd
import openrouteservice
from openrouteservice import convert
import json
df = pd.read_sql_query(some-sql-code-here)
# df is 384 x 21, with a 'coords' column formatted as long,lat
# at this point, I was testing if the instance works
head = df['Coords'].head().values.tolist()
head = list(map(eval, head))
# head is a list of 5 (long, lat) tuples, including A,B,C from my cURL above
client = openrouteservice.Client(base_url='localhost:8080/ors')
matrix = client.distance_matrix(
locations=head,
profile='driving-car',
metrics=['distance', 'duration'],
validate=True,
)
This is where I got the matrix endpoint error. Some of these locations may be more than 10000 meters away, but I dont think the code even got so far as to facing that error.
Directions endpoint
I also attempted the same as the directions endpoint url above:
dcoord = ((start),(end))
routes = client.directions(dcoord)
This gave me the directions endpoint error. The two locations are within the 10000 meter limit in my config.
Error text
I need the matrix endpoint for my use case, so here’s the full error
---------------------------------------------------------------------------
InvalidSchema Traceback (most recent call last)
<ipython-input-77-2244bc118b9d> in <module>
----> 1 matrix = client.distance_matrix(
2 locations=head,
3 profile='driving-car',
4 metrics=['distance', 'duration'],
5 validate=True,
~/opt/anaconda3/lib/python3.8/site-packages/openrouteservice/client.py in wrapper(*args, **kwargs)
297 def wrapper(*args, **kwargs):
298 args[0]._extra_params = kwargs.pop("extra_params", None)
--> 299 result = func(*args, **kwargs)
300 try:
301 del args[0]._extra_params
~/opt/anaconda3/lib/python3.8/site-packages/openrouteservice/distance_matrix.py in distance_matrix(client, locations, profile, sources, destinations, metrics, resolve_locations, units, optimized, validate, dry_run)
114 params["optimized"] = optimized
115
--> 116 return client.request("/v2/matrix/" + profile + '/json', {}, post_json=params, dry_run=dry_run)
~/opt/anaconda3/lib/python3.8/site-packages/openrouteservice/client.py in request(self, url, get_params, first_request_time, retry_counter, requests_kwargs, post_json, dry_run)
184
185 try:
--> 186 response = requests_method(self._base_url + authed_url,
187 **final_requests_kwargs)
188 self._req = response.request
~/opt/anaconda3/lib/python3.8/site-packages/requests/sessions.py in post(self, url, data, json, **kwargs)
579 """
580
--> 581 return self.request('POST', url, data=data, json=json, **kwargs)
582
583 def put(self, url, data=None, **kwargs):
~/opt/anaconda3/lib/python3.8/site-packages/requests/sessions.py in request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json)
531 }
532 send_kwargs.update(settings)
--> 533 resp = self.send(prep, **send_kwargs)
534
535 return resp
~/opt/anaconda3/lib/python3.8/site-packages/requests/sessions.py in send(self, request, **kwargs)
638
639 # Get the appropriate adapter to use
--> 640 adapter = self.get_adapter(url=request.url)
641
642 # Start time (approximately) of the request
~/opt/anaconda3/lib/python3.8/site-packages/requests/sessions.py in get_adapter(self, url)
729
730 # Nothing matches :-/
--> 731 raise InvalidSchema("No connection adapters were found for '%s'" % url)
732
733 def close(self):
InvalidSchema: No connection adapters were found for 'localhost:8080/ors/v2/matrix/driving-car/json?'