geometry-schema.json 3.16 KB
Newer Older
canterafonsj's avatar
canterafonsj committed
{
Stefan Wiedemann's avatar
Stefan Wiedemann committed
  "$schema": "http://json-schema.org/draft-04/schema#",
  "$id": "https://forge.etsi.org/rep/NGSI-LD/NGSI-LD/raw/master/schema/geometry-schema.json",
  "title": "geometry",
  "description": "One geometry as defined by GeoJSON. Licensed as per original source is https://github.com/fge/sample-json-schemas/blob/master/geojson/geometry.json",
  "type": "object",
  "required": [
    "type",
    "coordinates"
  ],
  "oneOf": [
    {
      "title": "Point",
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "Point"
          ]
canterafonsj's avatar
canterafonsj committed
        },
Stefan Wiedemann's avatar
Stefan Wiedemann committed
        "coordinates": {
          "$ref": "#/definitions/position"
        }
      }
    },
    {
      "title": "MultiPoint",
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "MultiPoint"
          ]
canterafonsj's avatar
canterafonsj committed
        },
Stefan Wiedemann's avatar
Stefan Wiedemann committed
        "coordinates": {
          "$ref": "#/definitions/positionArray"
        }
      }
    },
    {
      "title": "LineString",
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "LineString"
          ]
canterafonsj's avatar
canterafonsj committed
        },
Stefan Wiedemann's avatar
Stefan Wiedemann committed
        "coordinates": {
          "$ref": "#/definitions/lineString"
        }
      }
    },
    {
      "title": "MultiLineString",
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "MultiLineString"
          ]
canterafonsj's avatar
canterafonsj committed
        },
Stefan Wiedemann's avatar
Stefan Wiedemann committed
        "coordinates": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/lineString"
          }
        }
      }
    },
    {
      "title": "Polygon",
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "Polygon"
          ]
canterafonsj's avatar
canterafonsj committed
        },
Stefan Wiedemann's avatar
Stefan Wiedemann committed
        "coordinates": {
          "$ref": "#/definitions/polygon"
canterafonsj's avatar
canterafonsj committed
        }
Stefan Wiedemann's avatar
Stefan Wiedemann committed
      }
    },
    {
      "title": "MultiPolygon",
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "MultiPolygon"
          ]
canterafonsj's avatar
canterafonsj committed
        },
Stefan Wiedemann's avatar
Stefan Wiedemann committed
        "coordinates": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/polygon"
          }
        }
      }
    }
  ],
  "definitions": {
    "position": {
      "description": "A single position",
      "type": "array",
      "minItems": 2,
      "items": [
        {
          "type": "number"
canterafonsj's avatar
canterafonsj committed
        },
Stefan Wiedemann's avatar
Stefan Wiedemann committed
        {
          "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"
canterafonsj's avatar
canterafonsj committed
        },
Stefan Wiedemann's avatar
Stefan Wiedemann committed
        {
          "minItems": 2
        }
      ]
    },
    "linearRing": {
      "description": "An array of four positions where the first equals the last",
      "allOf": [
        {
          "$ref": "#/definitions/positionArray"
canterafonsj's avatar
canterafonsj committed
        },
Stefan Wiedemann's avatar
Stefan Wiedemann committed
        {
          "minItems": 4
canterafonsj's avatar
canterafonsj committed
        }
Stefan Wiedemann's avatar
Stefan Wiedemann committed
      ]
    },
    "polygon": {
      "description": "An array of linear rings",
      "type": "array",
      "items": {
        "$ref": "#/definitions/linearRing"
      }
canterafonsj's avatar
canterafonsj committed
    }
Stefan Wiedemann's avatar
Stefan Wiedemann committed
  }
canterafonsj's avatar
canterafonsj committed
}