- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
Showing
23 changed files
with
363 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
test/ | ||
package-lock.json | ||
bin/transform-package-json.js | ||
Makefile | ||
package-lock.json | ||
package.json | ||
readme.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/env node | ||
import path from 'path'; | ||
|
||
async function main() { | ||
const baseURL = 'https://geojson.org/schema/'; | ||
const command = path.basename(process.argv[1]); | ||
const usage = `${command} <input> | ||
Provided the path to a schema module (e.g. src/schema/Point.js), ${command} | ||
will write the formatted JSON schema to stdout. | ||
`; | ||
|
||
if (!process.argv[2]) { | ||
throw new Error(usage); | ||
} | ||
|
||
const input = path.resolve(process.argv[2]); | ||
|
||
let schema; | ||
try { | ||
const mod = await import(input); | ||
schema = mod.default; | ||
} catch (err) { | ||
throw new Error(`Failed to import ${input}: ${err.message}\n`); | ||
} | ||
|
||
return Object.assign( | ||
{ | ||
$schema: 'http://json-schema.org/draft-07/schema#', | ||
$id: `${baseURL}${path.basename(input)}on`, | ||
}, | ||
schema | ||
); | ||
} | ||
|
||
main() | ||
.then((schema) => { | ||
process.stdout.write(JSON.stringify(schema, null, 2) + '\n'); | ||
}) | ||
.catch((err) => { | ||
process.stderr.write(err.message + '\n', () => process.exit(1)); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# MIT License | ||
|
||
Copyright (c) 2018 Tim Schaub | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import BoundingBox from './ref/BoundingBox.js'; | ||
import GeometryCollection from './GeometryCollection.js'; | ||
import LineString from './LineString.js'; | ||
import MultiLineString from './MultiLineString.js'; | ||
import MultiPoint from './MultiPoint.js'; | ||
import MultiPolygon from './MultiPolygon.js'; | ||
import Point from './Point.js'; | ||
import Polygon from './Polygon.js'; | ||
|
||
export default { | ||
title: 'GeoJSON Feature', | ||
type: 'object', | ||
required: ['type', 'properties', 'geometry'], | ||
properties: { | ||
type: { | ||
type: 'string', | ||
enum: ['Feature'], | ||
}, | ||
id: { | ||
oneOf: [{type: 'number'}, {type: 'string'}], | ||
}, | ||
properties: { | ||
oneOf: [{type: 'null'}, {type: 'object'}], | ||
}, | ||
geometry: { | ||
oneOf: [ | ||
{type: 'null'}, | ||
Point, | ||
LineString, | ||
Polygon, | ||
MultiPoint, | ||
MultiLineString, | ||
MultiPolygon, | ||
GeometryCollection, | ||
], | ||
}, | ||
bbox: BoundingBox, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import BoundingBox from './ref/BoundingBox.js'; | ||
import Feature from './Feature.js'; | ||
|
||
export default { | ||
title: 'GeoJSON FeatureCollection', | ||
type: 'object', | ||
required: ['type', 'features'], | ||
properties: { | ||
type: { | ||
type: 'string', | ||
enum: ['FeatureCollection'], | ||
}, | ||
features: { | ||
type: 'array', | ||
items: Feature, | ||
}, | ||
bbox: BoundingBox, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import Feature from './Feature.js'; | ||
import FeatureCollection from './FeatureCollection.js'; | ||
import GeometryCollection from './GeometryCollection.js'; | ||
import LineString from './LineString.js'; | ||
import MultiLineString from './MultiLineString.js'; | ||
import MultiPoint from './MultiPoint.js'; | ||
import MultiPolygon from './MultiPolygon.js'; | ||
import Point from './Point.js'; | ||
import Polygon from './Polygon.js'; | ||
|
||
export default { | ||
title: 'GeoJSON', | ||
oneOf: [ | ||
Point, | ||
LineString, | ||
Polygon, | ||
MultiPoint, | ||
MultiLineString, | ||
MultiPolygon, | ||
GeometryCollection, | ||
Feature, | ||
FeatureCollection, | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import LineString from './LineString.js'; | ||
import MultiLineString from './MultiLineString.js'; | ||
import MultiPoint from './MultiPoint.js'; | ||
import MultiPolygon from './MultiPolygon.js'; | ||
import Point from './Point.js'; | ||
import Polygon from './Polygon.js'; | ||
|
||
export default { | ||
title: 'GeoJSON Geometry', | ||
oneOf: [ | ||
Point, | ||
LineString, | ||
Polygon, | ||
MultiPoint, | ||
MultiLineString, | ||
MultiPolygon, | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import BoundingBox from './ref/BoundingBox.js'; | ||
import LineString from './LineString.js'; | ||
import MultiLineString from './MultiLineString.js'; | ||
import MultiPoint from './MultiPoint.js'; | ||
import MultiPolygon from './MultiPolygon.js'; | ||
import Point from './Point.js'; | ||
import Polygon from './Polygon.js'; | ||
|
||
export default { | ||
title: 'GeoJSON GeometryCollection', | ||
type: 'object', | ||
required: ['type', 'geometries'], | ||
properties: { | ||
type: { | ||
type: 'string', | ||
enum: ['GeometryCollection'], | ||
}, | ||
geometries: { | ||
type: 'array', | ||
items: { | ||
oneOf: [ | ||
Point, | ||
LineString, | ||
Polygon, | ||
MultiPoint, | ||
MultiLineString, | ||
MultiPolygon, | ||
], | ||
}, | ||
}, | ||
bbox: BoundingBox, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import BoundingBox from './ref/BoundingBox.js'; | ||
import LineStringCoordinates from './ref/LineStringCoordinates.js'; | ||
|
||
export default { | ||
title: 'GeoJSON LineString', | ||
type: 'object', | ||
required: ['type', 'coordinates'], | ||
properties: { | ||
type: { | ||
type: 'string', | ||
enum: ['LineString'], | ||
}, | ||
coordinates: LineStringCoordinates, | ||
bbox: BoundingBox, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import BoundingBox from './ref/BoundingBox.js'; | ||
import LineStringCoordinates from './ref/LineStringCoordinates.js'; | ||
|
||
export default { | ||
title: 'GeoJSON MultiLineString', | ||
type: 'object', | ||
required: ['type', 'coordinates'], | ||
properties: { | ||
type: { | ||
type: 'string', | ||
enum: ['MultiLineString'], | ||
}, | ||
coordinates: { | ||
type: 'array', | ||
items: LineStringCoordinates, | ||
}, | ||
bbox: BoundingBox, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import BoundingBox from './ref/BoundingBox.js'; | ||
import PointCoordinates from './ref/PointCoordinates.js'; | ||
|
||
export default { | ||
title: 'GeoJSON MultiPoint', | ||
type: 'object', | ||
required: ['type', 'coordinates'], | ||
properties: { | ||
type: { | ||
type: 'string', | ||
enum: ['MultiPoint'], | ||
}, | ||
coordinates: { | ||
type: 'array', | ||
items: PointCoordinates, | ||
}, | ||
bbox: BoundingBox, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import BoundingBox from './ref/BoundingBox.js'; | ||
import PolygonCoordinates from './ref/PolygonCoordinates.js'; | ||
|
||
export default { | ||
title: 'GeoJSON MultiPolygon', | ||
type: 'object', | ||
required: ['type', 'coordinates'], | ||
properties: { | ||
type: { | ||
type: 'string', | ||
enum: ['MultiPolygon'], | ||
}, | ||
coordinates: { | ||
type: 'array', | ||
items: PolygonCoordinates, | ||
}, | ||
bbox: BoundingBox, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import BoundingBox from './ref/BoundingBox.js'; | ||
import PointCoordinates from './ref/PointCoordinates.js'; | ||
|
||
export default { | ||
title: 'GeoJSON Point', | ||
type: 'object', | ||
required: ['type', 'coordinates'], | ||
properties: { | ||
type: { | ||
type: 'string', | ||
enum: ['Point'], | ||
}, | ||
coordinates: PointCoordinates, | ||
bbox: BoundingBox, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import BoundingBox from './ref/BoundingBox.js'; | ||
import PolygonCoordinates from './ref/PolygonCoordinates.js'; | ||
|
||
export default { | ||
title: 'GeoJSON Polygon', | ||
type: 'object', | ||
required: ['type', 'coordinates'], | ||
properties: { | ||
type: { | ||
type: 'string', | ||
enum: ['Polygon'], | ||
}, | ||
coordinates: PolygonCoordinates, | ||
bbox: BoundingBox, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default { | ||
type: 'array', | ||
minItems: 4, | ||
items: { | ||
type: 'number', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import PointCoordinates from './PointCoordinates.js'; | ||
|
||
export default { | ||
type: 'array', | ||
minItems: 2, | ||
items: PointCoordinates, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import PointCoordinates from './PointCoordinates.js'; | ||
|
||
export default { | ||
type: 'array', | ||
minItems: 4, | ||
items: PointCoordinates, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default { | ||
type: 'array', | ||
minItems: 2, | ||
items: { | ||
type: 'number', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import LinearRingCoordinates from './LinearRingCoordinates.js'; | ||
|
||
export default { | ||
type: 'array', | ||
items: LinearRingCoordinates, | ||
}; |