我可以使用其他坐标类型在 MongoDB 中创建二维索引吗?

Can I use other coordinate types to create a 2d index in MongoDB?

我正在荷兰建立 属性 数据的 MongoDB 数据库。我希望能够对我的数据集执行地理空间查询。每个文档都没有经纬度坐标,但有一个叫做 "Rijksdriehoeks" 的坐标。这些 Rijksdriehoeks 坐标不符合 MongoDB 对二维坐标对的要求,因为它们可以超过 600.000 的值(此系统使用米作为单位)。这是一个问题,因为创建 2d 索引需要所有坐标对使用经度和纬度,因此值分别在 [-180, 180][-90, 90] 之间。

我需要为此数据集创建地理索引以将查询时间减少到可接受的水平,但是创建 "legacy" 二维索引会由于上述问题而出现此错误:

> db.Bag3DMembers.createIndex( { "properties.bbox" : "2d" })
{
    "ok" : 0,
    "errmsg" : "point not in interval of [ -180, 180 ] :: caused by :: { _id: ObjectId('5dfa7596cc0b7324e5331509'), type: \"Feature\", properties: { identificatie: \"0003100000117485\", aanduidingrecordinactief: false, aanduidingrecordcorrectie: 0, officieel: false, inonderzoek: false, documentnummer: \"FB 2010/PANDEN001\", documentdatum: \"2010-07-20\", bouwjaar: \"1991-01-01\", begindatumtijdvakgeldigheid: null, einddatumtijdvakgeldigheid: null, gemeentecode: \"0003\", ground-000: -0.43, ground-010: -0.34, ground-020: -0.31, ground-030: -0.3, ground-040: -0.27, ground-050: -0.25, roof-025: 10.58, rmse-025: 1.5, roof-050: 13.43, rmse-050: 1.28, roof-075: 13.46, rmse-075: 1.28, roof-090: 13.52, rmse-090: 1.27, roof-095: 13.87, rmse-095: 1.27, roof-099: 14.35, rmse-099: 1.27, roof_flat: false, nr_ground_pts: 220, nr_roof_pts: 6816, ahn_file_date: null, ahn_version: 2, height_valid: true, tile_id: \"07fz1\", gid: \"1\", bbox: [ [ 254052.046875, 593486.3125 ], [ 254076.625, 593504.6875 ] ] }, geometry: { type: \"Polygon\", coordinates: [ [ [ 254059.737, 593504.637, 0.0 ], [ 254059.227, 593500.0, 0.0 ], [ 254059.216, 593499.899, 0.0 ], [ 254058.242, 593500.0, 0.0 ], [ 254057.914, 593500.034, 0.0 ], [ 254057.893, 593500.0, 0.0 ], [ 254057.807, 593499.863, 0.0 ], [ 254052.074, 593490.692, 0.0 ], [ 254052.182, 593490.639, 0.0 ], [ 254058.138, 593490.002, 0.0 ], [ 254057.932, 593488.165, 0.0 ], [ 254074.487, 593486.4129999999, 0.0 ], [ 254075.981, 593500.0, 0.0 ], [ 254076.265, 593502.583, 0.0 ], [ 254076.561, 593502.55, 0.0 ], [ 254076.594, 593502.847, 0.0 ], [ 254059.737, 593504.637, 0.0 ] ] ] } }",
    "code" : 13027,
    "codeName" : "Location13027"
}

有什么方法可以说服 MongoDB 接受我的 "Rijksdriehoeks" 坐标,或者我需要将它们转换为经度和纬度值吗?

检查文档 Create a 2d Index:

On 2d indexes you can change the location range.

You can build a 2d geospatial index with a location range other than the default. Use the min and max options when creating the index.

会是

db.Bag3DMembers.createIndex( 
   { "properties.bbox" : "2d" }, 
   { min: -10000, max: 630000, bits: 24 }
)