gpt4 book ai didi

google-maps-api-3 - 带有 Google Places API 视口(viewport)位置的 Elasticsearch geo_bbox

转载 作者:行者123 更新时间:2023-12-02 22:20:58 26 4
gpt4 key购买 nike

希望我能解释我的问题。

我正在使用 Google 的自动完成功能来获取人员目的地。一旦我有了目的地,我就可以使用谷歌的 place api 来查找几何视口(viewport)。但视口(viewport)是从北/东到南/西。我的问题是 Elasticsearch 的 geo_bbox 从上/左到下/右。请参阅下面的示例。

Google Place API 响应:

{
"html_attributions" : [],
"result" : {
"address_components" : [
{
"long_name" : "Devon",
"short_name" : "Devon",
"types" : [ "administrative_area_level_2", "political" ]
},
{
"long_name" : "England",
"short_name" : "England",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "United Kingdom",
"short_name" : "GB",
"types" : [ "country", "political" ]
}
],
"adr_address" : "\u003cspan class=\"region\"\u003eDevon\u003c/span\u003e, \u003cspan class=\"country-name\"\u003eUK\u003c/span\u003e",
"formatted_address" : "Devon, UK",
"geometry" : {
"location" : {
"lat" : 50.77721349999999,
"lng" : -3.9994610
},
"viewport" : {
"northeast" : {
"lat" : 51.24619840,
"lng" : -2.88664060
},
"southwest" : {
"lat" : 50.20189620,
"lng" : -4.68065630
}
}
},
"icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/geocode-71.png",
"id" : "065fb13848aeae653fe25ee19d8a0a0289bd64dc",
"name" : "Devon",
"reference" : "CnRoAAAAN84gxrolBJLF_flpuwIyGum7pjln_KP9NJIHydIHMfbAo93nUdHSyYbv90GPUlW8Jx5D2ba-2fJHyzcHAdkZLkaJzSBEfj7dkR4NnBWzK9mFikZdyz3cee9IvOruHCZaicKfiXJP18jSfxXkvVv8gBIQrAopOdNbGQ6ovqEaEUqrxxoUaUYJEahZx7mTfJwEWOnxjTP3e9A",
"types" : [ "administrative_area_level_2", "political" ],
"url" : "https://maps.google.com/maps/place?q=Devon&ftid=0x486bf8abdac00247:0x12c6ba0cca9c58fd"
},
"status" : "OK"
}

Elasticsearch 示例
{
"filtered" : {
"query" : {
"match_all" : {}
},
"filter" : {
"geo_bounding_box" : {
"pin.location" : {
"top_left" : {
"lat" : 40.73,
"lon" : -74.1
},
"bottom_right" : {
"lat" : 40.717,
"lon" : -73.99
}
}
}
}
}
}

有没有更好的方法从谷歌获取更多信息,或者 Elasticsearch 可以从其他角落工作。虽然文档没有这么说?

最佳答案

哦,天哪,我有多厚。
我需要做的就是将结果交换为我的 Elasticsearch 。即,

{
"filtered" : {
"query" : {
"match_all" : {}
},
"filter" : {
"geo_bounding_box" : {
"pin.location" : {
"top_left" : {
"lat" : result.northeast.lat,
"lon" : result.southwest.lon
},
"bottom_right" : {
"lat" : result.southwest.lat,
"lon" : result.northwest.lon
}
}
}
}
}
}

关于google-maps-api-3 - 带有 Google Places API 视口(viewport)位置的 Elasticsearch geo_bbox,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14260661/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com