-
Notifications
You must be signed in to change notification settings - Fork 658
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
meili_request #3188
Comments
There is a ton of code here but from the beginning of this issue it sounded more like the code isnt the problem but rather that you dont get a response from the map matching service? If this is the case please tell us how you are running the service. It sounded like you were saying its running in a VM, is the VM a docker container? Please elaborate on how the service is running, can you hit the service in a web browser just to be sure its answering requests, after that we can move on to what you want to do in code. |
I'm almost sure the server is working because I tested it before, I run the Valhalla server in ubuntu VMbox. |
if you know for sure its working then the above statement doesnt make sense to me. here's a python example of hitting the server: here |
now,i have a new error: "code":"NoSegment","message":"One of the supplied input coordinates could not snap to street segment." |
this means that we cant find any roads near your input location. this could either be:
|
i have already snapped all thae points with help folium and can see all of them of the map |
id,lat,lon,time |
show me your valhalla formatted request, if that looks good then it must be that you dont have the data loaded |
data = d3.to_json(orient='records') |
yeah can you please add print(json.dumps(data)) and paste the result here |
"{"shape":[{"lat":50.8376,"lon":7.0947,"time":"2021-03-01T08:20:12.000Z"},{"lat":50.841238,"lon":7.095817,"time":"2021-03-01T08:20:27.000Z"},{"lat":50.84239,"lon":7.096191,"time":"2021-03-01T08:20:32.000Z"},{"lat":50.845809,"lon":7.09728,"time":"2021-03-01T08:20:47.000Z"},{"lat":50.851806,"lon":7.097788,"time":"2021-03-01T08:21:12.000Z"},{"lat":50.856086,"lon":7.09729,"time":"2021-03-01T08:21:37.000Z"},{"lat":50.857532,"lon":7.096971,"time":"2021-03-01T08:21:47.000Z"},{"lat":50.858139,"lon":7.096886,"time":"2021-03-01T08:21:52.000Z"},{"lat":50.858644,"lon":7.096808,"time":"2021-03-01T08:21:57.000Z"},{"lat":50.859432,"lon":7.096692,"time":"2021-03-01T08:22:02.000Z"}],"search_radius": 130, "shape_match":"map_snap", "costing":"auto", "format":"osrm"}" |
I have no idea what will happen with those timestamps. The api takes epoch times for per location timestamps |
if times does not necessary,for map matching,can it remove from df? |
thats right, its required you can remove it. it helps to make the match better but it is optional |
i have yet same problem: "{"shape":[{"lat":50.8376,"lon":7.0947},{"lat":50.841238,"lon":7.095817},{"lat":50.84239,"lon":7.096191},{"lat":50.845809,"lon":7.09728},{"lat":50.851806,"lon":7.097788},{"lat":50.856086,"lon":7.09729},{"lat":50.857532,"lon":7.096971},{"lat":50.858139,"lon":7.096886},{"lat":50.858644,"lon":7.096808},{"lat":50.859432,"lon":7.096692}],"search_radius": 130, "shape_match":"map_snap", "costing":"auto", "format":"osrm"}" |
ok great can you confirm that you have actually loaded tile data in the service? your config file should have either tile_dir or tile_extract set to a path that contains a directory of tiles or a tar file extract respectively. |
i have 2 folder in path Scripts folder, one ist conf folder in wich i have only valhalla.json and another folder name is valhalla-tiles. |
before going any further: can you pls make this fully reproducible, so we're not poking around in the dark:
Also make sure you format your answer properly pls, esp for code use 3 backticks: https://guides.github.com/features/mastering-markdown/ |
thank you for your Help, the problem was my commands to create the valhalla tiles and now i have a correct response. |
I tried to send a request with meili, the Valhalla server also runs virtually in the vmbox at the same time, but I do not receive a response. any help is really appreciated. Thanks.
import pandas as pd
import requests
import json
waypoints=pd.read_csv('waypoints.csv',names=["TripID","WaypointSequence","CaptureDate","Latitude","Longitude","SegmentID","ZoneName","FRC","DeviceId","RawSpeed","RawSpeedMetric"])
#ds=waypoints.groupby('TripID').count()
ds=waypoints.groupby('TripID')
df_sampel = ds.get_group('3dba9f6bd6cc725263cf5b4dbb84d9f3')
pd.to_datetime(df_sampel['CaptureDate'])
df_sampel=df_sampel[['Longitude','Latitude','CaptureDate']]
df_sampel.columns=['lon','lat','time']
df_sampel_sortet=df_sampel.sort_values('time',axis=0)
data = df_sampel_sortet.to_json(orient='records')
#meili_coordinates = df_trip.to_json(orient='records')
meili_coordinates =data
Providing needed data for the body of Meili's request
meili_head = '{"shape":'
Those are parameters that you can change according to the Meili's documentation
meili_tail = ""","search_radius": 150, "shape_match":"map_snap", "costing":"auto", "format":"osrm"}"""
Combining all the string into a single request
meili_request_body = meili_head + meili_coordinates + meili_tail
The URL of our local Valhalla server
"trace_route" means that we're sening a request to Meili
url = "http://0.0.0.0:8002/trace_route"
Providing headers to the request
headers = {'Content-type': 'application/json'}
We need to send our JSON as a string
meili_request_body=json.loads(meili_request_body)
data = json.dumps(meili_request_body)
try:
# Sending a request
#print(data)
#print(url)
#print(headers)
r = requests.post(url,data=data,headers=headers)
#print(r.text)
except requests.Timeout as e:
print("OOPS!! Timeout Error")
print(str(e))
renewIPadress()
#continue
except requests.ConnectionError as e:
print("OOPS!! Connection Error. Make sure you are connected to Internet. Technical Details given below.\n")
print(str(e))
renewIPadress()
#continue
except requests.RequestException as e:
print("OOPS!! General Error")
print(str(e))
renewIPadress()
#continue
except KeyboardInterrupt:
print("Someone closed the program")
Checking if the response from Meili was correct
if r.status_code == 200:
# Parsing the JSON response
response_text = json.loads(r.text)
Processing through our dataframe
for i, row in df_trip_optimized.iterrows():
# Parsing a 'location' data that we got from Meili
# to get 2 columns of optimized longitude and latitude
df_trip_optimized.at[i, 'lon_optimized'] = df_trip_optimized.at[i,'location'][0]
df_trip_optimized.at[i, 'lat_optimized'] = df_trip_optimized.at[i,'location'][1]
# When either longitude or latitude that we got from Meili equals to 0
# we assume that Meili couldn't find any roads with given parameters
# therefore it's safe to save our previous longitude and latitude
if df_trip_optimized.at[i, 'lon_optimized'] == 0.0:
df_trip_optimized.at[i, 'lon_optimized'] = df_trip_optimized.at[i,'lon']
df_trip_optimized.at[i, 'lat_optimized'] = df_trip_optimized.at[i,'lat']
Done processing, can just drop the location column
df_trip_optimized = df_trip_optimized.drop(['location'], 1)
The text was updated successfully, but these errors were encountered: