Tag: mongoose geojson

Mongoose模式更新GeoJSON

我有以下Mongoose模式代表一个移动的对象 var vehicleSchema = new Schema({ properties:{ obj:String, name:String, id:String }, geometry : { type: {type : String}, coordinates : [ Number, Number ] } }); 我试图用下面的对象和命令更新它,如果我在mongo控制台中input,但是在节点函数中使用时不更新文档,它将完美地工作。 这是要更新的对象: var updatedVehicle = new Vehicle( {properties:{ obj:"Answer", name:"is", id:"42" }, geometry:{ type:"Point", coordinates:[42,42] } }) 这是更新命令 Vehicle.update( {$and:[ {'properties.obj':data.properties.obj}, {'properties.id':data.properties.id} ]}, {$set: {properties:data.properties, geometry:data.geometry} }, {upsert: true}, […]

在mongoose模式中使用geoJSON并在查询中使用它

我是新来的mongoDB和其中的geoJSON的使用。 我有我使用mongoose模块创build的以下架构: var mongoose = require('mongoose'); var hikeSchema = mongoose.Schema({ name: String, area: String, length: Number, time: String, Difficulty: { type : Number, min : 0 , max :5 }, start_coord: { lon: Number, lat: Number }, rank_count: Number, avg_overall_rating: { type : Number, min : 0 , max :5 }, completed_count: Number, description: String, […]

MongoDB $ geoIntersects不支持包含负顶点的多边形

我在数据库中存储了跨越x和y轴的多边形,我想search包含给定点的多边形。 为此,我使用$ geoIntersects操作符来指定一个点,但是,当MongoDB跨越一个轴时,它不会返回任何多边形。 我可以对我的查询或模式做任何小的更改,这将允许这样做吗? 查询: { polygon: { $geoIntersects: { $geometry: { type: 'Point', coordinates: [long, lat] } } } } 数据库中的对象: polygon: { type: 'Polygon', name: 'Name', coordinates: [[ [-180, -90], [-180, 90], [180, 90], [180, -90], [-180, -90] ]] }