Skip to content

Instantly share code, notes, and snippets.

@afischer
Forked from fge/geometry.json
Created August 10, 2017 15:16
Show Gist options
  • Save afischer/199d9ffc92c7496511690b91befefad0 to your computer and use it in GitHub Desktop.
Save afischer/199d9ffc92c7496511690b91befefad0 to your computer and use it in GitHub Desktop.
JSON Schema (v4) for a geometry as defined by GeoJSON
{
"$schema": "http://json-schema.org/draft-04/schema#",
"id": "http://json-schema.org/geojson/geometry.json#",
"title": "geometry",
"description": "One geometry as defined by GeoJSON",
"type": "object",
"required": [ "type", "coordinates" ],
"oneOf": [
{
"title": "Point",
"properties": {
"type": { "enum": [ "Point" ] },
"coordinates": { "$ref": "#/definitions/position" }
}
},
{
"title": "MultiPoint",
"properties": {
"type": { "enum": [ "MultiPoint" ] },
"coordinates": { "$ref": "#/definitions/positionArray" }
}
},
{
"title": "LineString",
"properties": {
"type": { "enum": [ "LineString" ] },
"coordinates": { "$ref": "#/definitions/lineString" }
}
},
{
"title": "MultiLineString",
"properties": {
"type": { "enum": [ "MultiLineString" ] },
"coordinates": {
"type": "array",
"items": { "$ref": "#/definitions/lineString" }
}
}
},
{
"title": "Polygon",
"properties": {
"type": { "enum": [ "Polygon" ] },
"coordinates": { "$ref": "#/definitions/polygon" }
}
},
{
"title": "MultiPolygon",
"properties": {
"type": { "enum": [ "MultiPolygon" ] },
"coordinates": {
"type": "array",
"items": { "$ref": "#/definitions/polygon" }
}
}
}
],
"definitions": {
"position": {
"description": "A single position",
"type": "array",
"minItems": 2,
"items": [
{ "type": "number" },
{ "type": "number" }
],
"additionalItems": false
},
"positionArray": {
"description": "An array of positions",
"type": "array",
"items": { "$ref": "#/definitions/position" }
},
"lineString": {
"description": "An array of two or more positions",
"allOf": [
{ "$ref": "#/definitions/positionArray" },
{ "minItems": 2 }
]
},
"linearRing": {
"description": "An array of four positions where the first equals the last",
"allOf": [
{ "$ref": "#/definitions/positionArray" },
{ "minItems": 4 },
{ "maxItems": 4 }
]
},
"polygon": {
"description": "An array of linear rings",
"type": "array",
"items": { "$ref": "#/definitions/linearRing" }
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment