java mongodb geo_MongoDB GeoJSON奇怪的查询结果

我正在使用GeoJSON存储我想要稍后通过邻近查询的位置坐标,

我的架构如下所示:

'use strict';

var mongoose = require('mongoose'),

Schema = mongoose.Schema;

var BranchSchema = new Schema({

parentId: {

type: Schema.Types.ObjectId,

required: 'The ID of the restaurant is required.',

index: true

},

name: {

type: 'String',

required: 'The name is required.'

},

loc: {

'type': {

type: 'String',

default: 'Point'

},

coordinates: {

type: [Number],

default: [0,0]

}

}

});

BranchSchema.index({loc: "2dsphere"});

module.exports = mongoose.model('Branch', BranchSchema);

我正在使用mongoose,我的查询类似于以下内容:

Branch.where('loc').near({

center: [long, lat],

maxDistance: proximity,

spherical: true

}).exec(function (err, branches) {

if (err) {

return res.status(400)

.send({

message: errors.getErrorMessage(err)

});

}

return res.json(branches);

});

我使用以下坐标向数据库添加了一个新分支:纬度:34.237918经度:36.002197我使用以下坐标查询数据库:纬度:33.882957经度:35.502319,最大距离为100

这两个坐标之间的差异超过100米,但数据库返回结果,我缺少什么?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值