【问题标题】:Data type for bounding box in MongoDB and Mongoose?MongoDB和Mongoose中边界框的数据类型?
【发布时间】:2016-12-17 05:09:07
【问题描述】:

我正在考虑在 MongoDB 中存储一个引用路由的条目,该条目存储在外部文件中,但在数据库中具有该路由的边界框。我不确定是否应该为此使用 Polygon 或是否有更好的数据类型?需要考虑的主要事情是这将用于搜索。例如,路线是区域的搜索。起点和终点是不够的,因为它们不一定代表范围(例如,轨道可以在起点处结束)。

我正在使用mongoosemongoose-geojson-schema

到目前为止,我有类似的东西:

const mongoose = require('mongoose');
const mongooseGeoJSON = require('mongoose-geojson-schema');

const hikeSchema = mongoose.Schema({
    title: String,
    description: String,
    when: Date,
    startPoint: mongoose.Schema.Types.Point,
    endPoint: mongoose.Schema.Types.Point,
    boundingBox: //Not sure?
});

更新:现在我只打算使用 Polygon 类型,没有更好的建议。

【问题讨论】:

    标签: node.js mongodb mongoose geojson


    【解决方案1】:

    作为一个注释,以防你最终来到这里,这是我使用的(猫鼬 3.6) - 仍然使用多边形,但那是我怀疑的正确方式:

    Place.where('location').intersects().geometry({
        type: "Polygon",
        coordinates: [[
            [ minLongitude, minLatitude ],
            [ minLongitude, maxLatitude ],
            [ maxLongitude, maxLatitude ],
            [ maxLongitude, minLatitude ],
            [ minLongitude, minLatitude ]
        ]]
    }).exec()
    

    【讨论】:

      猜你喜欢
      • 2022-12-09
      • 2015-06-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-05
      • 2021-01-24
      • 2013-05-31
      • 1970-01-01
      相关资源
      最近更新 更多