Couchbase 地理空间边界框查询

Couchbase geospatial bounding box query

据我所知,couchbase 支持地理空间数据,但我不确定如何使用它。

有谁知道,是否可以通过 couchbase 中的 N1QL SELECT 语句查询边界框内的元素? 如果是,SELECT 语句将如何使用边界框查询以下 json 中的元素?

{
  "type": "Feature",
  "properties": {
    "name": "Bermuda Triangle",
    "area": 1150180
  },
  "geometry": {
    "type": "Polygon",
    "coordinates": [
      [
        [-64.73, 32.31],
        [-80.19, 25.76],
        [-66.09, 18.43],
        [-64.73, 32.31]
      ]
    ]
  }
}


{
  "type": "Feature",
  "properties": {
    "name": "Flemish Diamond",
    "area": 2947
  },
  "geometry": {
    "type": "Polygon",
    "coordinates": [
      [
        [3.55, 51.08],
        [4.36, 50.73],
        [4.84, 50.85],
        [4.45, 51.30],
        [3.55, 51.08]
      ]
    ]
  }
}


{
  "type": "Feature",
  "properties": {
    "name": "Research Triangle",
    "area": 252
  },
  "geometry": {
    "type": "Polygon",
    "coordinates": [
      [
        [-78.93, 36.00],
        [-78.67, 35.78],
        [-79.04, 35.90],
        [-78.93, 36.00]
      ]
    ]
  }
}   

Couchbase 地理空间查询仅通过地理空间视图支持,不支持 N1QL 查询。

您需要为您的坐标创建地理空间视图并通过视图查询它 API。

您可以在 Couchbase 服务器文档中查看有关地理空间视图的更多信息:https://developer.couchbase.com/documentation/server/current/indexes/querying-using-spatial-views.html

技术上可以使用 N1QL 模拟地理空间查询,但是它不会得到空间索引的支持并且会导致显着的性能损失 - 特别是对于像这样的多边形数据你已经提供了。您可以在此处查看有关如何使用点数据执行此操作的文章:https://dzone.com/articles/speed-up-spatial-search-in-couchbase-n1ql