【问题标题】:Couchbase geospatial bounding box queryCouchbase 地理空间边界框查询
【发布时间】:2017-01-05 17:16:03
【问题描述】:

据我所知,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


    【解决方案1】:

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

    您需要为您的坐标创建地理空间视图并通过 Views 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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-06-19
      • 2016-12-28
      • 2014-02-08
      • 1970-01-01
      • 1970-01-01
      • 2012-07-10
      • 2016-06-11
      • 1970-01-01
      相关资源
      最近更新 更多