Permalink
Browse files

added schema for GeoJSON Feature, experimented with build system

  • Loading branch information...
1 parent 1a463e8 commit 67f6bdc91e3a33527704fc91ba39e3fe165d22fb @nilclass nilclass committed Feb 8, 2013
Showing with 107 additions and 0 deletions.
  1. +2 −0 .gitignore
  2. +13 −0 Makefile
  3. +15 −0 build/compile-schemas.js
  4. +13 −0 build/wrap-combine.js
  5. +62 −0 schema/feature.json
  6. +2 −0 src/locations.js
View
@@ -1 +1,3 @@
*~
+tmp/
+remoteStorage.locations.js
View
@@ -0,0 +1,13 @@
+NODE := node
+
+
+remoteStorage.locations.js: tmp/schemas.js src/locations.js
+ $(NODE) build/wrap-combine.js $@ tmp/schemas.js src/locations.js
+
+tmp/schemas.js: schema/*.json
+ mkdir -p tmp/
+ $(NODE) build/compile-schemas.js $@ schema/*.json
+
+clean:
+ rm -rf tmp/
+ rm -f remoteStorage.locations.js
View
@@ -0,0 +1,15 @@
+
+var fs = require('fs');
+
+var outputName = process.argv[2];
+var inputNames = process.argv.slice(3);
+
+var output = 'var $schemas = {\n';
+inputNames.forEach(function(inputName) {
+ var input = fs.readFileSync(inputName, 'UTF-8');
+ var name = inputName.split('/').slice(-1)[0].replace(/\.json$/, '');
+ output += '"' + name + '": ' + input + '\n';
+});
+output += "};\n";
+
+fs.writeFileSync(outputName, output, 'UTF-8');
View
@@ -0,0 +1,13 @@
+var fs = require('fs');
+
+var outputName = process.argv[2];
+var inputNames = process.argv.slice(3);
+
+var output = "(function() {\n";
+inputNames.forEach(function(inputName) {
+ var input = fs.readFileSync(inputName, 'UTF-8');
+ output += '\n' + input + '\n';
+});
+output += "})();";
+
+fs.writeFileSync(outputName, output, 'UTF-8');
View
@@ -0,0 +1,62 @@
+{
+ "name": "feature",
+ "type": "object",
+ "properties": {
+ "type": {
+ "type": "string",
+ "description": "GeoJSON type, for features always 'Feature'",
+ "required": true,
+ "pattern": "^Feature$"
+ },
+ "geometry": {
+ "type": "object",
+ "description": "A GeoJSON Geometry object",
+ "required": true,
+ "properties": {
+ "type": {
+ "type": "string",
+ "required": true,
+ "enum": ["Point", "MultiPoint", "LineString", "MultiLineString",
+ "Polygon", "MultiPolygon"]
+ },
+ "coordinates": {
+ "type": "array",
+ "description": "Coordinates of this Geometry. Format varies with type.",
+ "required": true,
+ "items": {
+ "type": ["number", "array"]
+ }
+ }
+ }
+ },
+ "properties": {
+ "type": "object",
+ "description": "Opaque object of properties associated with this Feature.",
+ "required": true
+ },
+ "crs": {
+ "type": "object",
+ "description": "Coordinate System Reference",
+ "properties": {
+ "type": {
+ "type": "string",
+ "required": true,
+ "enum": ["name", "link"]
+ },
+ "properties": {
+ "type": "object",
+ "required": true
+ }
+ }
+ },
+ "bbox": {
+ "type": "array",
+ "description": "Bounding box that contains this feature",
+ "minItems": 4,
+ "maxItems": 4,
+ "items": {
+ "type": "number"
+ }
+ }
+ }
+}
View
@@ -1,5 +1,7 @@
remoteStorage.defineModule('locations', function(privClient, pubClient) {
+ pubClient.declareType('feature', $schemas.feature);
+
var curry = remoteStorage.util.curry;
var watchers = {};

2 comments on commit 67f6bdc

Owner

skddc replied Feb 8, 2013

Cool!

Just a thought on the feature.json: should we think about namespacing types by categories? Like e.g. geo/feature.json, music/playlist, etc.

Member

nilclass replied Feb 8, 2013

@skddc this is "feature.json" within "locations", so the JSON-LD @type would be "https://remotestoragejs.com/spec/modules/locations/feature". That way it's already namespaced.

Please sign in to comment.