Back to data catalog

Geocoding API

Geocoding and reverse-geocoding based on OpenStreetMap®-data

More info

Data sources

The API is exclusively fetching data from https://photon.komoot.io. The service is based on OpenStreetMap® data, which is licensed under the Open Data Commons Open Database License (ODbL), by the OpenStreetMap Foundation (OSMF).

Processing

The data obtained from https://photon.komoot.io is presented as is, without any further processing or modification.

Examples

Example 1

Retrieving the coordinates of Berlin.

1import io.openepi.geocoding.api.GeocodingApi;
2import io.openepi.geocoding.model.FeatureCollection;
3import io.openepi.common.ApiException;
4
5public class Main {
6    public static void main(String[] args) {
7        GeocodingApi api = new GeocodingApi();
8        try {
9            FeatureCollection response = api.geocodingGet("Berlin");
10
11            // Prints the coordinates of the first result
12            System.out.println(response.getFeatures().get(0).getGeometry().getPoint().getCoordinates());
13        } catch (ApiException e) {
14            System.err.println("Exception when calling GeocodingApi#geocodingGet");
15            e.printStackTrace();
16        }
17    }
18}

Example 2

Retrieving a location near the given coordinate.

1import io.openepi.geocoding.api.GeocodingApi;
2import io.openepi.geocoding.model.FeatureCollection;
3import io.openepi.common.ApiException;
4import java.math.BigDecimal;
5
6public class Main {
7    public static void main(String[] args) {
8        GeocodingApi api = new GeocodingApi();
9        try {
10            BigDecimal lat = new BigDecimal("52.5200");
11            BigDecimal lon = new BigDecimal("13.4050");
12            FeatureCollection response = api.reverseGeocodingReverseGet(lat, lon, null, null);
13
14            // Prints the name of the first result
15            System.out.println(response.getFeatures().get(0).getProperties().getName());
16        } catch (ApiException e) {
17            System.err.println("Exception when calling GeocodingApi#reverseGeocodingReverseGet");
18            e.printStackTrace();
19        }
20    }
21}