【问题标题】:MongoDB geometry query not workingMongoDB几何查询不起作用
【发布时间】:2013-04-14 22:04:22
【问题描述】:

我在我的数据库中存储了一些 GeoJSON 点,我无法使用新的 geoWithin (2.4.1) 查询它们。

这是我收藏的索引:

> db.features1.getIndexes();
[
    {
        "v" : 1,
        "key" : {
            "_id" : 1
        },
        "ns" : "sagedb.features1",
        "name" : "_id_"
    },
    {
        "v" : 1,
        "key" : {
            "geometry" : "2dsphere"
        },
        "ns" : "sagedb.features1",
        "name" : "geometry_2dsphere"
    }
]

这是我的数据库中的一份文件

> db.features1.find();
{ 
  "_id" : ObjectId("51672e677a62bb0000000003"), 
  "geometry" : { 
    "type" : "Point", 
    "coordinates" : [ -106.8610919, 49.665165099999996 ] }, 
  "__v" : 0 }

我正在尝试运行此查询:

> db.features1.find( {
  geometry: { 
    $geoWithin: { 
      $geometry: { 
        type: "Polygon", 
        coordinates: [ [ [-180,-90], [-180,90], [180,90], [180,-90], [-180,-90] ] ] } } } });

但我什么也得不到。任何想法我做错了什么?

【问题讨论】:

    标签: mongodb mongoose


    【解决方案1】:

    边界多边形必须是

    2.4.1 文档中缺少此内容。

    【讨论】:

      猜你喜欢
      • 2012-06-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-24
      相关资源
      最近更新 更多