Java SDK for the GeoCode Routing API
The GeoCode Routing API SDK for Java enables Java developers to easily work with the GeoCode Routing API in Java.
Installation
Maven
In order to use the GeoCode Routing API SDK for Java in your project, please include the following Maven Central Repository dependency in your pom.xml
.
<dependency>
<groupId>zone.stefan.dev</groupId>
<artifactId>geocode</artifactId>
<version>1.0.1</version>
</dependency>
From Git
The Java SDK for the GeoCode Routing API can be installed via Git. Run this command from your terminal.
git clone https://github.com/stefanzone/geocode-sdk-for-java.git
Download as ZIP archive
Download the latest version from here.
Usage
Note: The GeoCode Routing API SDK for Java requires OpenJDK version 11.
Parse the GeoCodeEndpoint for Address MetaData.
final GeoCodeEndpoint geoCodeEndpoint = GeoCode.getAddress(
"Lothstraße 34"
);
// Information about the address.
System.out.println("Street: " + geoCodeEndpoint.getAddress().getStreet());
System.out.println("House Number: " + geoCodeEndpoint.getAddress().getNumber());
System.out.println("City: " + geoCodeEndpoint.getAddress().getCity());
System.out.println("State: " + geoCodeEndpoint.getAddress().getState());
System.out.println("Post Code " + geoCodeEndpoint.getAddress().getPostCode());
System.out.println("Country: " + geoCodeEndpoint.getAddress().getCountry());
System.out.println("Country Code: " + geoCodeEndpoint.getAddress().getCountryCode());
System.out.println("Formatted: " + geoCodeEndpoint.getAddress().getFormatted());
// Informationen zur GeoPosition.
System.out.println("Latitude: " + geoCodeEndpoint.getPosition().getLat());
System.out.println("Longitude: " + geoCodeEndpoint.getPosition().getLon());
Parse the RoutingEndpoint for Routing MetaData.
final RoutingEndpoint routingEndpoint = GeoCode.getRoute(
"Lothstraße 34",
"Lindwurmstraße",
"transit" // Use of public transport.
);
// Information about the origin and destination address.
System.out.println("Origin Address: " + routingEndpoint.getSummary().getLocation().getOrigin());
System.out.println("Destination Address: " + routingEndpoint.getSummary().getLocation().getDestination());
// Textual summary of the route.
System.out.println("Summary: " + routingEndpoint.getSummary().getText());
// Travel time information.
System.out.println("Duration in Seconds: " + routingEndpoint.getSummary().getDuration().getSeconds());
System.out.println("Duration in Words: " + routingEndpoint.getSummary().getDuration().getText());
// Distance information.
System.out.println("Distance in Meters: " + routingEndpoint.getSummary().getDistance().getMeters());
System.out.println("Distance in Words: " + routingEndpoint.getSummary().getDistance().getText());
// All steps of the calculated route.
for (Step step : routingEndpoint.getRoute()) {
System.out.println("Instruction: " + step.getInstruction());
}
Contributing
Please see CONTRIBUTING for details.
License
© 2021 Stefan Kühnel, All Rights reserved.