Repository navigation
Add geocoding to the hc client - #1267
Conversation
| url += "&q=" + request.getQuery(); | ||
| if (!Double.isNaN(request.getLat())) | ||
| url += "&point=" + request.getLat() + "," + request.getLon(); | ||
| } |
There was a problem hiding this comment.
I would help here the user a bit: if reverse than throw an exception if the lat or lon is invalid. And if non-reverse throw exc if query is empty. Also adding the point can be moved outside of the if+else IMO to have just one line
|
|
||
| public double getLon() { | ||
| return lon; | ||
| } |
There was a problem hiding this comment.
Not sure if important: we could reuse the GHPoint class here too
There was a problem hiding this comment.
Ok, sure, I can do this. Not sure if it's a big benefit. Should I change it?
There was a problem hiding this comment.
Is it necessary for serialization?
There was a problem hiding this comment.
No, we only serialize the response from the server.
There was a problem hiding this comment.
I haven't changed that so far, let me know if I should
There was a problem hiding this comment.
Ok, yes, please change it to use GHPoint
There was a problem hiding this comment.
This way we can just check against null instead of the NaN checks
There was a problem hiding this comment.
Good idea, I updated the code :)
| */ | ||
| public class GraphHopperGeocodingIT { | ||
|
|
||
| public static final String KEY = "614b8305-b4db-48c9-bf4a-40de90919939"; |
There was a problem hiding this comment.
We should avoid duplicating this info and reuse GraphHopperWebIT.KEY
|
Also this name would need a change https://github.com/graphhopper/graphhopper/blob/master/client-hc/pom.xml#L28 maybe remove the 2nd sentence completely (would be also more align with the other modules)? |
|
I updated this PR also adding some more documentation to make it easier for users to use methods that are publicly available. |
|
Thanks! |
This PR fixes #1221.
I reused the model classes that we created in the geocoding converter to easily convert json received via the API to Java objects. Probably the effort of hosting them in an independent repository and add a dependency from gh and the geocoding converter is not worth it. Also I changed one or two small details like the name of the classes and removed a constructor that used AbstractAddress, which we don't need here.