我想在绘制响应的查询中指定缩放

我想在绘制响应的查询中指定缩放

本文介绍了查询以在 Java 中通过 api ......我想在绘制响应的查询中指定缩放......我必须在我的代码中添加什么才能做到这一点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Java 项目中工作 .. 我想在立交桥查询中指定缩放比例?因为我想绘制响应(xml文件)??

public static Document getNodesViaOverpass(String query) throws IOException, ParserConfigurationException, SAXException {字符串主机名 = OVERPASS_API;URL osm = 新 URL(主机名);HttpURLConnection 连接 = (HttpURLConnection) osm.openConnection();connection.setDoInput(true);connection.setDoOutput(true);connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");DataOutputStream 打印输出 = new DataOutputStream(connection.getOutputStream());printout.writeBytes("data=" + URLEncoder.encode(query, "utf-8"));打印输出.flush();打印输出.关闭();DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance();DocumentBuilder docBuilder = dbfac.newDocumentBuilder();返回 docBuilder.parse(connection.getInputStream());}
解决方案

您不能指定缩放级别,但可以指定边界框.边界框定义了查询的最小和最大纬度和经度,即矩形.请参阅立交桥查询语言文档中的边界框.>

边界框参数由最南纬度、最西经度、最北纬度、最东经度组成.

这是一个带有边界框的 Overpass 查询的简单示例:

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

如果一个简单的矩形不适合您的需要,您还可以指定一个 多边形.

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());
}
解决方案

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.

这篇关于查询以在 Java 中通过 api ......我想在绘制响应的查询中指定缩放......我必须在我的代码中添加什么才能做到这一点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 17:05