0

I work in a project in java .. i want to specify the zoom in the overpass query ? because i want to draw the response (xml file) ??

public static Document getNodesViaOverpass(String query) throws IOException, ParserConfigurationException, SAXException {
    String hostname = OVERPASS_API;

    URL osm = new URL(hostname);
    HttpURLConnection connection = (HttpURLConnection) osm.openConnection();
    connection.setDoInput(true);
    connection.setDoOutput(true);
    connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");

    DataOutputStream printout = new DataOutputStream(connection.getOutputStream());
    printout.writeBytes("data=" + URLEncoder.encode(query, "utf-8"));
    printout.flush();
    printout.close();

    DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance();
    DocumentBuilder docBuilder = dbfac.newDocumentBuilder();
    return docBuilder.parse(connection.getInputStream());
}
Joe Mayo
  • 7,501
  • 7
  • 41
  • 60
Yasiz
  • 13
  • 4

1 Answers1

1

You cannot specify a zoom level but you can specify a bounding box. A bounding box defines the minimum and maximum latitude and longitude for your query, i.e. a rectangle. See bounding box in the Overpass Query Language documentation.

The bounding box parameters consist of southern-most latitude, western-most longitude, northern-most latitude, eastern-most longitude.

This is a simple example for an Overpass query with a bounding box:

node(50.745,7.17,50.75,7.18)[highway=bus_stop];
out;

If a simple rectangle doesn't fit your needs you can also specify a polygon.

scai
  • 20,297
  • 4
  • 56
  • 72