简体   繁体   English

overpass-api方式查询包括坐标

[英]overpass-api ways query include coordinates

I'm trying to query Hotels in a specific area. 我正在尝试查询特定区域的酒店。 Unfortunately I need to query nodes and ways, because some Hotels are only stored as way and some as nodes. 不幸的是,我需要查询节点和方法,因为一些酒店只存储方式,一些存储节点。

http://overpass.osm.rambler.ru/cgi/interpreter?data=%28way[tourism~hotel]%28around:5000,50.10707,8.76040%29%29;out;

The result of a way-query doesn't contain any coordinates, only lots of node-refs: 方式查询的结果不包含任何坐标,只有很多node-refs:

<nd ref="1438833423"/>

Is there a way also to include the coordinates of the nodes in the output or do have to start lots of additional queries for each node? 是否还有一种方法可以在输出中包含节点的坐标,或者是否必须为每个节点启动大量其他查询?

Tom 汤姆

Yes, there are several ways to also get geometries for non-node features via the Overpass API. 是的,有几种方法可以通过Overpass API获取非节点功能的几何。 The easiest is probably to use the center output mode (replace out; with out center; ): http://overpass-turbo.eu/s/4O4 . 最简单的可能是使用center输出模式(替换out; out center; ): http//overpass-turbo.eu/s/4O4 Other options would be to fetch the node references in a recursion step: http://overpass-turbo.eu/s/4O5 or using the full geometry output mode . 其他选项是在递归步骤中获取节点引用: http//overpass-turbo.eu/s/4O5或使用完整几何输出模式

PS: Don't forget that a hotel can also be mapped as a (multipolygon) relation in OSM, not just as a node or way. PS:不要忘记,酒店也可以在OSM中映射为(多面)关系,而不仅仅是作为节点或方式。

Necromancing. Necromancing。

And to actually answer the question: 并实际回答这个问题:

[out:json];
way(29858799);
out ids geom;

Which will give you the geometries for each point in the selected way. 这将为您提供所选方式中每个点的几何形状。

{
  "version": 0.6,
  "generator": "Overpass API",
  "osm3s": {
    "timestamp_osm_base": "2017-10-06T13:59:02Z",
    "copyright": "The data included in this document is from www.openstreetmap.org. The data is made available under ODbL."
  },
  "elements": [

{
  "type": "way",
  "id": 29858799,
  "bounds": {
    "minlat": 47.3604067,
    "minlon": 8.5342631,
    "maxlat": 47.3612503,
    "maxlon": 8.5352457
  },
  "geometry": [
    { "lat": 47.3612503, "lon": 8.5351944 },
    { "lat": 47.3612252, "lon": 8.5342631 },
    { "lat": 47.3610145, "lon": 8.5342755 },
    { "lat": 47.3610212, "lon": 8.5345227 },
    { "lat": 47.3606405, "lon": 8.5345451 },
    { "lat": 47.3606350, "lon": 8.5343411 },
    { "lat": 47.3604067, "lon": 8.5343545 },
    { "lat": 47.3604120, "lon": 8.5345623 },
    { "lat": 47.3604308, "lon": 8.5352457 },
    { "lat": 47.3606508, "lon": 8.5352328 },
    { "lat": 47.3606413, "lon": 8.5348784 },
    { "lat": 47.3610383, "lon": 8.5348551 },
    { "lat": 47.3610477, "lon": 8.5352063 },
    { "lat": 47.3612503, "lon": 8.5351944 }
  ]
}

  ]
}

https://overpass-turbo.eu/ https://overpass-turbo.eu/

All the options for out are listed here: 这里列出了所有输出选项:
https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL#Print_.28out.29 https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL#Print_.28out.29

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2025 STACKOOM.COM