Skip to content

Instantly share code, notes, and snippets.

@pnorman
Created September 11, 2013 22:45
Show Gist options
  • Save pnorman/6530815 to your computer and use it in GitHub Desktop.
Save pnorman/6530815 to your computer and use it in GitHub Desktop.
WIP of json-schema schema for OSM data
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "OSM Data",
"description": "OSM Data, as returned by the API",
"type": "object",
"properties": {
"version": {
"description": "The OSM API version",
"type": "string",
"enum": ["0.6"]
},
"generator": {
"description": "The software used to generate the OSM JSON.",
"type": "string"
},
"copyright": {
"description": "The copyright of the data.",
"type": "string"
},
"attribution": {
"description": "The required attribution URL of the data.",
"type": "string"
},
"license": {
"description": "The URL of the license for the data.",
"type": "string"
},
"bounds": {
"description": "The bounding box for the area downloaded.",
"type": "object",
"properties": {
"minlat" : {
"description": "The minimum latitude of the bounding box",
"type": "number",
"minimum": -90.0,
"maximum": 90.0
},
"maxlat" : {
"description": "The maximum latitude of the bounding box",
"type": "number",
"minimum": -90.0,
"maximum": 90.0
},
"minlon" : {
"description": "The minimum latitude of the bounding box",
"type": "number",
"minimum": -180.0,
"maximum": 180
},
"maxlon" : {
"description": "The maximum longitude of the bounding box",
"type": "number",
"minimum": -180.0,
"maximum": 180
}
}
},
"nodes": {
"description": "The OSM nodes in the file",
"type": "array",
"items": {
"anyOf": [
{
"description": "A visible OSM node",
"type": "object",
"properties": {
"visible": {
"description": "If the node is visible (not deleted) in this version or not",
"type": "boolean",
"enum": [true]
},
"id": {
"description": "The ID of the node",
"$ref": "#/definitions/id"
},
"version": {
"description": "The version of the node",
"type": "integer",
"minimum": 1
},
"lat": {
"description": "The latitude of the node",
"type": "number",
"minimum": -90.0,
"maximum": 90.0
},
"lon": {
"description": "The longitude of the node",
"type": "number",
"minimum": -180.0,
"maximum": 180
},
"changeset": {
"description": "The changeset this version of this node was edited in",
"$ref": "#/definitions/id"
},
"uid": {
"description": "The user id",
"$ref": "#/definitions/id"
},
"user": {
"description": "The user name",
"type": "string"
},
"timestamp": {
"description": "The ISO 8601 combined date/time formatted time when this version of this node was modified at",
"type": "string"
},
"tags": {
"$ref": "#/definitions/tags"
}
},
"required": ["visible", "id", "version", "lat", "lon", "changeset", "timestamp", "tags"]
},
{
"description": "An anonymous visible OSM node",
"type": "object",
"properties": {
"visible": {
"description": "If the node is visible (not deleted) in this version or not",
"type": "boolean",
"enum": [true]
},
"id": {
"description": "The ID of the node",
"$ref": "#/definitions/id"
},
"version": {
"description": "The version of the node",
"type": "integer",
"minimum": 1
},
"lat": {
"description": "The latitude of the node",
"type": "number",
"minimum": -90.0,
"maximum": 90.0
},
"lon": {
"description": "The longitude of the node",
"type": "number",
"minimum": -180.0,
"maximum": 180
},
"changeset": {
"description": "The changeset this version of this node was edited in",
"$ref": "#/definitions/id"
},
"uid": {
"description": "The user id",
"type": "null"
},
"user": {
"description": "The user name",
"type": "null"
},
"timestamp": {
"description": "The ISO 8601 combined date/time formatted time when this version of this node was modified at",
"type": "string"
},
"tags": {
"$ref": "#/definitions/tags"
}
},
"required": ["visible", "id", "version", "lat", "lon", "changeset", "timestamp", "tags"]
},
{
"description": "A deleted OSM node",
"type": "object",
"properties": {
"visible": {
"description": "If the node is visible (not deleted) in this version or not",
"type": "boolean",
"enum": [false]
},
"id": {
"description": "The ID of the node",
"$ref": "#/definitions/id"
},
"version": {
"description": "The version of the node",
"type": "integer",
"minimum": 1
},
"lat": {
"description": "The latitude of the node",
"type": "null"
},
"lon": {
"description": "The longitude of the node",
"type": "null"
},
"changeset": {
"description": "The changeset this version of this node was edited in",
"$ref": "#/definitions/id"
},
"uid": {
"description": "The user id",
"$ref": "#/definitions/id"
},
"user": {
"description": "The user name",
"type": "string"
},
"timestamp": {
"description": "The ISO 8601 combined date/time formatted time when this version of this node was modified at",
"type": "string"
},
"tags": {
"$ref": "#/definitions/untagged"
}
},
"required": ["visible", "id", "version", "lat", "lon", "changeset", "timestamp", "tags"]
}
{
"description": "A deleted OSM node",
"type": "object",
"properties": {
"visible": {
"description": "If the node is visible (not deleted) in this version or not",
"type": "boolean",
"enum": [false]
},
"id": {
"description": "The ID of the node",
"$ref": "#/definitions/id"
},
"version": {
"description": "The version of the node",
"type": "integer",
"minimum": 1
},
"lat": {
"description": "The latitude of the node",
"type": "null"
},
"lon": {
"description": "The longitude of the node",
"type": "null"
},
"changeset": {
"description": "The changeset this version of this node was edited in",
"$ref": "#/definitions/id"
},
"uid": {
"description": "The user id",
"type": "null"
},
"user": {
"description": "The user name",
"type": "null"
},
"timestamp": {
"description": "The ISO 8601 combined date/time formatted time when this version of this node was modified at",
"type": "string"
},
"tags": {
"$ref": "#/definitions/untagged"
}
},
"required": ["visible", "id", "version", "lat", "lon", "changeset", "timestamp", "tags"]
}
]
}
}
},
"required": ["version", "nodes"],
"definitions": {
"id": {
"type": "integer",
"minimum": 1
},
"tags": {
"description": "The tags of the object",
"type": "object",
"patternProperties": {
"^.+$": {
"type": "string",
"minLength": 0
}
}
},
"untagged": {
"description": "The tags of the object",
"type": "object",
"maxProperties": 0
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment