Skip to content

Add geocoding to the hc client - #1267

Merged
karussell merged 5 commits into
graphhopper:masterfrom
boldtrn:issue_1221
Jan 22, 2018
Merged

karussell merged 5 commits into
graphhopper:masterfrom
boldtrn:issue_1221

Conversation

@boldtrn

@boldtrn boldtrn commented Jan 15, 2018

Copy link
Copy Markdown
Member

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.

url += "&q=" + request.getQuery();
if (!Double.isNaN(request.getLat()))
url += "&point=" + request.getLat() + "," + request.getLon();
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, good idea!


public double getLon() {
return lon;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if important: we could reuse the GHPoint class here too

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, sure, I can do this. Not sure if it's a big benefit. Should I change it?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it necessary for serialization?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, we only serialize the response from the server.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't changed that so far, let me know if I should

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, yes, please change it to use GHPoint

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This way we can just check against null instead of the NaN checks

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or just point.isValid

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, I updated the code :)

*/
public class GraphHopperGeocodingIT {

public static final String KEY = "614b8305-b4db-48c9-bf4a-40de90919939";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should avoid duplicating this info and reuse GraphHopperWebIT.KEY

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I missed that 👍

@karussell

karussell commented Jan 16, 2018 •

Copy link
Copy Markdown
Member

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)?

@boldtrn

boldtrn commented Jan 17, 2018

Copy link
Copy Markdown
Member Author

I updated this PR also adding some more documentation to make it easier for users to use methods that are publicly available.

@karussell

Copy link
Copy Markdown
Member

Thanks!

@karussell
karussell merged commit 95b90c0 into graphhopper:master Jan 22, 2018
@karussell karussell added this to the 0.10 milestone Jan 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Geocoding to HC Client

2 participants