如何用猫鼬添加GeoJson数据?

问题描述

我正在发送对象以创建用户模型。

x = [1,3,2,3];
y = [2,4,1,3];    
S = [1,5; 1,0.001; 12,21,5];
linear_ind = x + (y-1)*size(S,1);
logical_ind = S(linear_ind)>0.1;
x_new = x(logical_ind);
y_new = y(logical_ind);

这是我创建的猫鼬模式。

"{ 
type: 'Point',coordinates: [ 25.2239771,51.4993224 ] 
}"

这是我用来添加geoJson类型文件的代码。但是,我得到一个错误。 在定义模式后,我还尝试添加索引

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

const UserProfileSchema = new Schema(
  {
 
    userId: {
      type: String,// required: true,unique: true,},userFirstName: {
      type: String,userLastName: {
      type: String,userGender: {
      type: String,userCoordinates: {
      type: {
        type: String,default: 'Point',coordinates: {
        type: [Number],index: '2dsphere',{ collection: 'userprofilemodels' }
);

module.exports = UserProfile = mongoose.model(
  'userprofilemodels',UserProfileSchema
);

如果我排除userCoordinates,则可以。因此,def我的geoJson对象是错误的。但是,我不知道哪里犯了错误。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)