gpt4 book ai didi

node.js - 蒙哥错误: Can't project geometry into spherical CRS

转载 作者:可可西里 更新时间:2023-11-01 10:02:37 25 4
gpt4 key购买 nike

我正在尝试在 Mongo 中存储实体的位置。我似乎只对输入的几个位置有问题。我得到的错误是

MongoError:无法提取地理键:无法将几何投影到球形 CRS:[ 26.1633829,91.78194759999997]。索引有问题吗?我正在开发 mongodb 3.4 版

我的架构如下

var mongoose = require('mongoose');
var Schema = mongoose.Schema;

var modelSchema = new mongoose.Schema({

email: {type: String, lowercase: true},
username: {type: String, unique: true, lowercase: true, index: true},
branchName: String,
address: {
address1: String,
address2: String,
locality: String,
pinCode: Number,
sublocality_level_2: String,
sublocality_level_1: String,
localityName: String,
administrative_area_level_2: String,
administrative_area_level_1: String,
country: String,
postal_code: String,
geo: {
type: [Number],
index: '2dsphere'
}
},
branchPAN: String,
branchType: String,
});

module.exports = mongoose.model('SampleModel', modelSchema);

最佳答案

在这里阅读了更多内容。 https://docs.mongodb.com/manual/reference/geojson/#point

该链接中有注释

重要始终按经度、纬度顺序列出坐标。

我以相反的方式传递值。

关于node.js - 蒙哥错误: Can't project geometry into spherical CRS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42763592/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com