使用 OpenStreetMap 和 Nominatim 查找指定的地点类型

Look for specified place type with OpenStreetMap and Nominatim

在我的应用程序中,我将 Leaflet 与 OpenStreetMap 结合使用。我还使用 Nominatim 获取地点详细信息。我想查一下这个地方是不是加油站。 但是,当我指向加油站并获取地点详细信息时,JSON 文件通常有不同的 "type" 属性。 它可以是:

type: "fuel"   <-- this is great
or
type: "convenience"
or
type: "yes"
or maybe even other

我能否以某种方式指定该地点是否真的是加油站?

示例 JSON 加油站的输出 https://nominatim.openstreetmap.org/reverse?format=jsonv2&lat=50.0487556&lon=21.999057381458194

place_id: 143194204, licence: "Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright", osm_type: "way", osm_id: 230603036, lat: "50.0487556", …}
place_id: 143194204
licence: "Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright"
osm_type: "way"
osm_id: 230603036
lat: "50.0487556"
lon: "21.999057381458194"
place_rank: 30
category: "shop"
type: "convenience"
importance: 0
addresstype: "shop"
name: "Orlen"
display_name: "Orlen, 10, Warszawska, 1000-Lecia, Rzeszów, województwo podkarpackie, 35-205, Polska"
address: {convenience: "Orlen", house_number: "10", road: "Warszawska", suburb: "1000-Lecia", city: "Rzeszów", …}
boundingbox: (4) ["50.0486885", "50.0488243", "21.9989449", "21.9991699"]
__proto__: Object

我考虑过使用 Google 地点 API 和地理编码 API,但地理编码需要结算帐户,所以我不会使用它。

编辑:

感谢以下评论,我设法通过使用来自 nominatim 反向地理编码调用的 osm_id 从 OSM 获取原始数据。只需使用: http://overpass-api.de/api/interpreter?data=[out:json];way(MY_OSM_ID);out;

object from your question is both a gas station and a convenience shop. It is tagged as amenity=fuel and shop=convenience。然而,Nominatim 必须决定要打印哪个 type,显然便利性比燃料具有更高的优先级。

如果您想检查特定对象的标签,那么 Nominatim 可能是错误的选择。 Nominatim 是一个地理编码器,用于将名称转换为地理坐标(地理编码)或反之(反向地理编码)。如果您已经知道 OSM ID 和 element type then you can download its raw data directly from OSM to check all original tags. If you just know the rough location then you could use Overpass API 下载该地区的特定兴趣点(例如加油站)。