I'm trying to define the GeoJSON schema in node-simple-schema
to use in my application.
I'm trying to define the position, linestring, linering and polygon arrays to use them later when defining the Point, LineString,.. geometries.
This is what I'm doing now, and it does not work.
const Position = new SimpleSchema({
position: {
type: Array,
label: 'A single position. ...',
minCount: 2,
maxCount: 3,
},
'position.$': {
type: Number,
label: 'A number representing...',
},
});
const Point = new SimpleSchema({
type: {
type: String,
label: 'The type of the feature.',
allowedValues: ['Point'],
},
coordinates: {
type: Position.pick('position'),
// this does not work either
// type: Position.getObjectSchema('position'),
label: 'A single position',
},
});
When I try to validate like this I get an error.
const PointExample = {
type: 'Point',
coordinates: [180.0, 46.5, 100],
};
Point.validate(PointExample);
Extracted schemas matches objects with both keys and values. Therefore the following provided the key 'position' validates.