Closed caido160 closed 3 years ago
It’s not the token. You have some weird coordinate system.. Is it defined in qgis? The built in map tool should transform that to wgs84 when you click in the canvas, which only works if the CRS is known to qgis.
It did happen to me too before (the plugin not transforming my coords when I click) and I'm not sure why that happens and don't have the time right now to look into it, but will fairly soon.. For me it's solved when I reload QGIS.
these are lest97 (3301) coordinates. I didn't realise it was converting until now :). But the problem is with access-token paramter that the tool is puting to get parameter. When I modified valhalla/common/client.py file and changed url construction then it worked perfectly :) I changed from this:
# Define the request
params = {'access_token': self.key}
authed_url = self._generate_auth_url(url,
params,
)
url_object = QUrl(self.base_url + authed_url)
self.url = url_object.url()
body = QJsonDocument.fromJson(json.dumps(post_json).encode())
request = QNetworkRequest(url_object)
request.setHeader(QNetworkRequest.ContentTypeHeader, 'application/json')
to this (just changed url_object - just a hack not a fix :) ):
# Define the request
params = {'access_token': self.key}
authed_url = self._generate_auth_url(url,
params,
)
url_object = QUrl(self.base_url)
self.url = url_object.url()
body = QJsonDocument.fromJson(json.dumps(post_json).encode())
request = QNetworkRequest(url_object)
request.setHeader(QNetworkRequest.ContentTypeHeader, 'application/json')
huh, really? I use the tool almost every day on localhost and it has never been a problem. And it really shouldn't be, Valhalla ignores query parameters for POST. I'll do the fix though, it's just cleaner anyways.
Can you please have a look into the (docker) logs for Valhalla? It should tell what the problem is. Because your request coordinates are definitely not right (valhalla only accepts geodesic).
I should find a way to get back the real error message for 400, didn't figure out how to do yet back then.
BTW, it also prints the coordinates it "transformed" (or not) to the GUI. Or are you using the processing algos?
I tried again and found that it will transform input point coodrinates when I open tool after I add my wms basemap (and opening my wms map sets map projection to 3301)
But if open valhalla tool before and wms after that (seting map projection after opeing tool) then it won't trasform my coordinates.
And I found out why I had problems at first. My bad :) When i copied my url to Base URL under settings I copied too much instead of http://localhost:8002 I used http://localhost:8002/route wich means in the end that path "/route" was double)
It is even in my original post: " ApiError: (400 (Error transferring http://localhost:8002/route/route?access_token= - server replied: Bad Request)) http://localhost:8002/route/route?access_token= "
aah:) yeah totally overlooked that part of the URL as well..
I experienced that as well, but it felt much more random than that (qgis crashes sooo often for me on arch linux, I thought it might just be another of those individual failures only I experience;)), so your insight proves super valuable! I could reproduce here. Must be in the initialization then, apparently I don't grab the CRS dynamically, which I should of course! Thanks for the input!
I had the same problem when first firing up the Valhalla plugin. Changed the project SRID to 3301 and then loaded a WMS background. Opened Valhalla plugin and the same url. The error was the same. Token = -.
It would still be better if that token is not hard-coded and would be optional.
@sanderpukk can you update the plugin pls and try again (version 2.2.0)? The fix was approved yesterday night.
Again, it really shouldn't be a problem with query parameters.
I installed it today minutes before posting. After reinstalling the query worked again, but it didnt on the first try.
so weird.. I really can't reproduce.
When using your own localhost valhalla the access_token parameter gives http 400 error. Is it possible to make key parameter optional for easier use?
ApiError: (400 (Error transferring http://localhost:8002/route/route?access_token= - server replied: Bad Request)) http://localhost:8002/route/route?access_token= Parameters: { "costing": "auto", "narrative": false, "id": 1, "locations": [ { "lon": 544290.101836, "lat": 6586980.218267 }, { "lon": 658140.446643, "lat": 6472558.717883 } ] } timing: 0.030 secs