查找半径与地理点重叠的地理点
Find Geopoint with radius which are overlapping geopoint
正如你在下面看到的,我有
3 个具有一定半径的 GeoPoint A、B、C
1 个地理点 K,
我想找到半径与 K Geo 重叠的所有 GeoPoint
所以答案应该是B,C。
那么如何实现呢?
目前我正在使用Mongodb。但任何其他数据库也可以。
这个问题和陈述 "any other db is fine" 一样都是基于意见的。
但郑重声明,在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":{
}
}
]
正如你在下面看到的,我有
3 个具有一定半径的 GeoPoint A、B、C
1 个地理点 K,
我想找到半径与 K Geo 重叠的所有 GeoPoint
所以答案应该是B,C。
那么如何实现呢?
目前我正在使用Mongodb。但任何其他数据库也可以。
这个问题和陈述 "any other db is fine" 一样都是基于意见的。 但郑重声明,在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":{
}
}
]