Package de.westnordost.osmapi.overpass
Class OverpassMapDataApi
- java.lang.Object
-
- de.westnordost.osmapi.overpass.OverpassMapDataApi
-
public class OverpassMapDataApi extends java.lang.ObjectGet map data from the overpass api. Always expects XMl output in the queries.
-
-
Constructor Summary
Constructors Constructor Description OverpassMapDataApi(de.westnordost.osmapi.OsmConnection osm)OverpassMapDataApi(de.westnordost.osmapi.OsmConnection osm, de.westnordost.osmapi.map.MapDataFactory mapDataFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description OverpassStatusgetStatus()Get info about how many queries the user may make until reaching his quotavoidkillMyQueries()Kills all the queries sent from this IP.<T> Tquery(java.lang.String query, de.westnordost.osmapi.ApiResponseReader<T> reader)Executes the given query.ElementCountqueryCount(java.lang.String query)Executes the given query to count the elements.voidqueryElements(java.lang.String query, de.westnordost.osmapi.map.handler.MapDataHandler handler)Executes the given query and expects a response that is alike a map data query on the OSM API, just returning the map data.voidqueryElementsWithGeometry(java.lang.String query, MapDataWithGeometryHandler handler)Executes the given query that has thegeommodificator.voidqueryTable(java.lang.String query, de.westnordost.osmapi.common.Handler<java.lang.String[]> handler)voidqueryTable(java.lang.String query, de.westnordost.osmapi.common.Handler<java.lang.String[]> handler, java.lang.String separator)Executes the given query that has the output mode set to CSV.
-
-
-
Method Detail
-
queryElements
public void queryElements(@NotNull java.lang.String query, @NotNull de.westnordost.osmapi.map.handler.MapDataHandler handler)Executes the given query and expects a response that is alike a map data query on the OSM API, just returning the map data. For example a query without body;.- Parameters:
query- Query string. Either Overpass QL or Overpass XML query string.handler- handler to feed the map data to- Throws:
OsmTooManyRequestsException- if the user is over his request quota. See getStatus, killMyQueriesde.westnordost.osmapi.common.errors.OsmBadUserInputException- if there is an error in the query
-
queryElementsWithGeometry
public void queryElementsWithGeometry(@NotNull java.lang.String query, @NotNull MapDataWithGeometryHandler handler)Executes the given query that has thegeommodificator. For example a query without body geom;. Seeout statements.- Parameters:
query- Query string. Either Overpass QL or Overpass XML query string. The query must contain thegeommodificator.handler- function to feed the map data and geometry to- Throws:
OsmTooManyRequestsException- if the user is over his request quota. See getStatus, killMyQueriesde.westnordost.osmapi.common.errors.OsmBadUserInputException- if there is an error in the query
-
queryTable
public void queryTable(@NotNull java.lang.String query, @NotNull de.westnordost.osmapi.common.Handler<java.lang.String[]> handler, @NotNull java.lang.String separator)Executes the given query that has the output mode set to CSV.- Parameters:
query- Query string. Either Overpass QL or Overpass XML query string. The query must use the output mode CSV.handler- function to feed the map data and geometry toseparator- The separator to expect in the CSV response. The default is the tab character.- Throws:
OsmTooManyRequestsException- if the user is over his request quota. See getStatus, killMyQueriesde.westnordost.osmapi.common.errors.OsmBadUserInputException- if there is an error in the query
-
queryTable
public void queryTable(@NotNull java.lang.String query, @NotNull de.westnordost.osmapi.common.Handler<java.lang.String[]> handler)- See Also:
queryTable(String, Handler)
-
queryCount
@NotNull public ElementCount queryCount(@NotNull java.lang.String query)
Executes the given query to count the elements. For example a query without count;. Seeout statements.- Parameters:
query- Query string. Either Overpass QL or Overpass XML query string. The query must end without count;- Returns:
- the count for each element type
- Throws:
OsmTooManyRequestsException- if the user is over his request quota. See getStatus, killMyQueriesde.westnordost.osmapi.common.errors.OsmBadUserInputException- if there is an error in the query
-
query
public <T> T query(@NotNull java.lang.String query, de.westnordost.osmapi.ApiResponseReader<T> reader)Executes the given query. Since the output format and the content of the output can vary greatly depending on the type of query, you must specify yourself how you are going to parse the result.- Type Parameters:
T- what the type of object the reader returns- Parameters:
query- Query string. Either Overpass QL or Overpass XML query stringreader- the object reading the response- Returns:
- what the supplied reader returns
- Throws:
OsmTooManyRequestsException- if the user is over his request quota. See getStatus, killMyQueriesde.westnordost.osmapi.common.errors.OsmBadUserInputException- if there is an error in the query
-
killMyQueries
public void killMyQueries()
Kills all the queries sent from this IP. Useful if there is a runaway query that takes far too much time and blocks the user from making any more queries
-
getStatus
public OverpassStatus getStatus()
Get info about how many queries the user may make until reaching his quota- Returns:
- the current quota status
-
-