如何使用MongoDB几何特征实现圆

时间:2018-01-12 10:03:41

标签: mongodb geometry geospatial

我想保存圆,就像我们使用地理空间在mongodb中保存多边形一样,当我的纬度存在于那个圆圈中时,得到那个圆圈。

1 个答案:

答案 0 :(得分:1)

  

以下是您可以保存圆圈的格式:

let mongoose = require('mongoose');
let Schema = mongoose.Schema;
require('mongoose-double')(mongoose);
let SchemaTypes = mongoose.Schema.Types;

let deliveryZones= new Schema({
name:{type:String},//location name
location: {
    'type: {type: String,},//if want to save circle coordinates: type-circle
    coordinates: {type: Array} // centre coordinates of circle
},
 radius: {type:SchemaTypes.Double},// radius of circle
})