geojson for MultiPoint with mongodb and nodejs

0

I have defined this Scheme:

let capaSchema = new Schema({
nombrecapa: {
    type: String,
    required: [true, 'El nombre de la capa es necesario']
},
descripcion: {
    type: String,
    required: [false]
},
geojson: Object([
    geoSchema
])

});

const geoSchema = new Schema({
type: {
    type: String,
    default: 'FeatureCollection',
},
features: [
    Object({
        type: {
            type: String,
            default: 'Feature',
        },
        geometry: {
            type: {
                type: String,
                default: 'MultiPoint'
            },
            coordinates: {
                type: []

            }
        }
    })
],});

based on the previous scheme I want to save the following:

 let capa = new Capa({
    nombrecapa: body.nombrecapa,
    descripcion: body.descripcion,
    geojson: {
        type: body.typefeature,
        features: [{
                type: body.featurestype,
                geometry: {
                    type: body.geometrytype,
                    coordinates: Array([55.18777533242337, 55.18777533242337])
                }
            }

        ]
    }
});
capa.save((err, capadb) => {
        if (err) {
            return res.status(400).json({
                ok: false,
                err
            })
        }
        res.json({
            ok: true,
            capa: capadb
        })
    })

but it returns the following error:

{
"ok": false,
"err": {
    "driver": true,
    "name": "MongoError",
    "index": 0,
    "code": 16755,
    "errmsg": "Can't extract geo keys: { _id: ObjectId('5c2548f4c2932c1afc8df228'), nombrecapa: \"capa prueba prueba\", descripcion: \"descripcion de capaa\", geojson: [ { type: \"FeatureCollection\", _id: ObjectId('5c2548f4c2932c1afc8df229'), features: [ { geometry: { type: \"MultiPoint\", coordinates: [ [ 55.18777533242337, 55.18777533242337 ] ] }, type: \"Feature\", _id: ObjectId('5c2548f4c2932c1afc8df22a') } ] } ], __v: 0 }  Point must only contain numeric elements"
}

}

I do not understand why the error, based on this what would be the correct way to work with Geojson in nodejs?

    
asked by Eze 27.12.2018 в 23:00
source

0 answers