gpt4 book ai didi

sql - 查找半径重叠的Geopoint

转载 作者:行者123 更新时间:2023-12-03 01:18:01 25 4
gpt4 key购买 nike

如下所示,我有

3具有一定半径的GeoPoint A,B,C
1个GeoPoint K,

enter image description here

我想找到半径重叠为K Geo的所有GeoPoint

因此答案应该是B,C。

那么如何实现呢?

目前,我正在使用Mongodb。但是任何其他数据库也可以。

最佳答案

这个问题是基于观点的,就像“任何其他数据库都可以”这样的陈述一样。
但是,记录下来,在ES中实现的方式如下:

PUT circles
{
"mappings": {
"properties": {
"location": {
"type": "geo_shape",
"strategy": "recursive"
}
}
}
}

PUT circles/_doc/A
{
"location": {
"type": "circle",
"coordinates": [
16.34817123413086,
48.20968893477074
],
"radius": "2km"
}
}

PUT circles/_doc/B
{
"location": {
"type": "circle",
"coordinates": [
16.374435424804688,
48.20122291334052
],
"radius": "3km"
}
}

PUT circles/_doc/C
{
"location": {
"type": "circle",
"coordinates": [
16.386451721191406,
48.21586595914765
],
"radius": "4km"
}
}

GET circles/_search
{
"query": {
"geo_shape": {
"location": {
"shape": {
"type": "point",
"coordinates": [
16.386795043945312,
48.208773756674425
]
},
"relation": "intersects"
}
}
}
}

屈服
[
{
"_index":"circles",
"_type":"_doc",
"_id":"B",
"_score":1.0,
"_source":{

}
},
{
"_index":"circles",
"_type":"_doc",
"_id":"C",
"_score":1.0,
"_source":{

}
}
]

关于sql - 查找半径重叠的Geopoint,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61591195/

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