Replies: 3 comments 8 replies
-
I removed format = osrm and now it gives me error code = 134, failed to parse shape, I am passing long, lat and time in shape |
Beta Was this translation helpful? Give feedback.
2 replies
-
We need an actual request, not the code to generate the request. Smth which we can curl. |
Beta Was this translation helpful? Give feedback.
5 replies
-
I was able to make the code running for meili but seems the map matching is not working. I am sharing the images before (all pink dots)and after map matching for andorra. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
here is my full code -
import os
import pandas as pd
import numpy as np
import requests
import json
from tqdm.notebook import tqdm
Specify the file path to your CSV file
file_path = "Porto City.csv"
Specify the columns you want to read (latitude, longitude, and time)
columns_to_read = ["latitude", "longitude", "pdatetime"]
Read the CSV file into a DataFrame, reading only the specified columns
df_trip = pd.read_csv(file_path, usecols=columns_to_read)
Display the DataFrame to verify the data
print(df_trip)
Getting our Pandas DataFrame into a JSON
We need that because that is a Meili's request requirement
meili_coordinates = df_trip.to_json(orient='records')
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://localhost:8002/trace_route"
Providing headers to the request
headers = {'Content-type': 'application/json'}
We need to send our JSON as a string
data = str(meili_request_body)
Sending a request
r = requests.post(url, data=data, headers=headers)
if r.status_code == 200:
print(r.status_code)
#print(r.text)
this r.status_code returns 400. what is this error ? AlSO, i have created a custom_files folder in c and linked it with my valhalla docker image. valhalls is running on port 8002. custom_files folder contains map of portugal city from geofabrik download server as i am passing coordinates of porto city. what am i doing wrong ? I am new to valhalla. Any urgent help would be appreciated.
Beta Was this translation helpful? Give feedback.
All reactions