sql - 查找半径重叠的Geopoint

标签 sql mongodb elasticsearch geolocation geometry

如下所示,我有

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/

相关文章:

curl - 通过curl的PUT索引映射导致错误(Content-Type header 修复不起作用)

sql - 在 WHERE 子句中混合使用 AND 和 OR 会产生意外结果

mysql - 从同一张表中选择分组依据

mongodb - 在 MongoDB 中添加副本会引发错误

mongodb - 导入mongo_dart程序包阻止显示文本

elasticsearch - ElasticSearch NEST简单术语查询需要.keyword

java - 从 Elasticsearch 中获取索引名称匹配模式的列表 - JAVA

php - 求和并显示总分

sql - 同一个表在另一个表中的多列

javascript - 如何使用 mongoose 和 node.js 将 mongodb 时间戳转换为 dd-mm-yyyy 格式?