Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wish: define specific fields on a GeoJSON Feature #1

Open
markstos opened this issue Mar 31, 2014 · 2 comments
Open

wish: define specific fields on a GeoJSON Feature #1

markstos opened this issue Mar 31, 2014 · 2 comments

Comments

@markstos
Copy link
Contributor

A benefit of using Mongoose over raw Mongo is that field names are
explicitly defined and validated.

It would be nice if GeoJSON.Feature could allow defining specific
'properties' as well as continuing to provide the boilerplate schema
that it already does.

Some potential syntax options:

// Option 1:
// Allow defining just properties:
geoFeature: GeoJSON.Feature({
  a: 1,
  b: 2,
);


//Option 2:
// Allow defining anything or everything. 
// Internally, add any missing bits from the boilerplate
geoFeature: GeoJSON.Feature({
    properties: {
      a: 1,
      b: 2,
    },
});

Option 2 is the more flexible way to go. I don't think either is
backcompat, though. You would to start doing this:

geoFeature: GeoJSON.Feature();

But, perhaps that's a good direction to go anyway, as it allows you to
add extra validation to any GeoJSON schema element:

myPolyGon : geoJSON.Polygon({ required: true, validator: myValidator });
joshkopecek added a commit that referenced this issue May 4, 2016
@markstos
Copy link
Contributor Author

markstos commented May 4, 2016

@joshkopecek What do you think about this "wish" request? It addresses the wish to mark some GeoJSON schema elements as required, add extra validation, or fill in default values for particular fields in the Schema.

@joshkopecek
Copy link
Contributor

So I think there are two separate issues here:
required: true could be done through

myPolygon: {
   type: mongoose.SchemaTypes.Polygon,
   required: true
}

The default values for properties are another issue. The only place the GeoJSON schema provides an room for flexibility is in the properties, so I can see this being one way to do it:

myPolygon: {
   type: mongoose.SchemaTypes.Polygon,
   required: true,
   properties: {
      a: { type: String, validator: myValidator },
      b: { type: Number, validator: numberValdator }
   }
}

and the other use case would be specifying your own validator for the CSR stuff, but I really don't know how much usage there would be for that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants