Hi everyone!
I have set up a GH server with PT enabled, following the instructions in the GTFS docs chapter: graphhopper/reader-gtfs/README.md at 9.x · graphhopper/graphhopper · GitHub
The server works and routes well, however I’m having an issue sending routing HTTP request to this particular instance: the route that GH returns is a foot-only route.
My HTTP request is the following (from a bash script):
url="http://localhost:8989/route"
requests=(
'{"points":[[13.379978032054794, 52.51848663351106],[13.360877143414342,52.494636420493975]],"profile":"foot","locale":"en","instructions":true}'
)
for i in "${!requests[@]}"; do
data="${requests[$i]}"
curl -X POST -H "Content-Type: application/json" -d "$data" "$url" \
| jq '.' > "route_out/route_output_pt_$i.json"
done
It seems that I am sending a request to an instance of http://localhost:8989/ instead of http://localhost:8989/maps/pt/. I’ve tried different ways of writing url=
to access the latter, but to no avail. I’ve also tried changing profile to “pt” in "request"=
field, but I would get an error that this profile is not defined (which is true, it’s not in config-example-pt.yml).
So far I could not find anything in docs/examples to help me out, so any advice here would be very much appreciated
The branch I’m on is 9.x
Thanks,
Max
however I’m have an issue sending routing HTTP request to this particular instance
Did you try "profile": "pt"
in the request too?
Hi @karussell,
Yes, I did try "profile": "pt"
, but I got an error message saying “pt” is not defined as a profile (I can post an error message in a bit). This makes sense, as config-example-pt.yml
has only “foot” profile defined (which, I guess, also makes sense as it seems the example is meant to show a combination of walking and using public transport)
The error message that I’m getting when I set "profile":"pt"
is the following:
{
"message": "The requested profile 'pt' does not exist.\nAvailable profiles: [foot]",
"hints": [
{
"message": "The requested profile 'pt' does not exist.\nAvailable profiles: [foot]",
"details": "java.lang.IllegalArgumentException"
}
]
}
Sorry, it seems the POST method is not yet implemented for profile=pt
. You’ll have to use the GET request towards /route.
See PtRouteResource and PtRedirectFilter.
1 Like
Thanks @karussell!
I’ll test GET request today and post here if it worked for me and if it solves the issue
That solved my issue!
For the reference, my current HTTP request looks like this (bash script):
requests=(
"52.5160,13.3777 52.5200,13.4050"
)
# Loop through each set of points
for request in "${requests[@]}"; do
# Extract start and end coordinates
start=$(echo $request | awk '{print $1}')
end=$(echo $request | awk '{print $2}')
# Send the request and save the output in a JSON file
curl -X GET "http://localhost:8989/route?point=$start&point=$end&profile=pt&locale=en&pt.earliest_departure_time=2024-06-11T15:19:00Z" \
| jq '.' > "route_out/route_${start}_${end}.json"
echo "Saved route from $start to $end"
done
Thanks!
1 Like