{ "$schema":                      "https://json-schema.org/draft/2020-12/schema",
  "$id":                          "https://schemas.mpai.community/OSD/V1.5/data/LocationObject.json",
  "title":                        "Location Object V1.5",
  "type":                         "object",
  "additionalProperties":         false,
  "required":                     [ "Header", "LocationObjectID", "LocationObjectSpaceTime" ],
  "properties":                   {

    "Header":                     { "type": "string", "pattern": "^OSD-LCO-V[0-9]{1,2}[.][0-9]{1,2}$", "description": "Location Object Header – Standard OSD-LCO-Vx.y" },
    "MInstanceID":                { "type": "string", "description": "Identifier of the M-Instance (Virtual Space) where this Location Object is or is intended to be located." },
    "UEnvironmentID":             { "type": "string", "description": "Identifier of the U-Environment (Real Space) where this Location Object is or is intended to be located." },
    "LocationObjectID":           { "type": "string", "description": "Unique identifier of this Location Object." },
    "LocationObjectTime":         { "$ref": "https://schemas.mpai.community/OSD/V1.5/data/SimpleTime.json", "description": "Time this Location Object was produced." },

    "LocationObjectSpaceTime":    { "$ref": "https://schemas.mpai.community/OSD/V1.5/data/SimpleTime.json", "description": "Space/Time where/when this Location Object is located." },

    "BasicLocationCount":         { "type": "integer", "minimum": 0, "description": "Number of Basic Locations contained in this Location Object." },

    "BasicLocations":             { "type": "array", "minItems": 0, "description": "Set of Basic Locations contained in this Location Object.",
                                    "items": { "type": "object", "additionalProperties": false, "properties": {
      "BasicLocationSpaceTime":   { "$ref": "https://schemas.mpai.community/OSD/V1.5/data/SimpleTime.json",
                                    "description": "Space/Time where/when this Basic Location is located within the containing Location Object. If absent, the Space/Time of the containing object applies." },
      "BasicLocIDOrBasicLoc":     { "$ref": "#/$defs/BasicLocIDOrBasicLoc", "description": "Either the ID of a Basic Location or the Basic Location itself." } } } },

    "SubLocationCount":           { "type": "integer", "minimum": 0, "description": "Number of child Locations contained in this Location Object." },

    "SubLocations":               { "type": "array", "minItems": 0, "description": "Set of child Locations contained in this Location Object.",
                                    "items": { "type": "object", "additionalProperties": false, "properties": {
      "SubLocationSpaceTime":     { "$ref": "https://schemas.mpai.community/OSD/V1.5/data/SimpleTime.json",
                                    "description": "Space/Time where/when this child Location is located within the containing Location Object. If absent, the Space/Time of the containing object applies." },
      "SubLocIDOrSubLoc":         { "$ref": "#/$defs/SubLocIDOrSubLoc", "description": "Either the ID of a child Location or the child Location itself." } } } },

    "LocationOrBasicLocation":    { "type": "array", "minItems": 0, "description": "A mixed array of Basic Locations and child Locations contained in this Location Object.",
                                    "items": { "$ref": "#/$defs/LocationOrBasicLocation" } },

    "DataXMData":                 { "$ref": "https://schemas.mpai.community/PTF/V1.0/data/DataExchangeMetadata.json",
                                    "description": "MPAI-PTF Data Exchange Metadata providing provenance, authorisation, legal, security, and confidence information associated with this Location Object in a trusted data exchange context." },
    "DescrMetadata":              { "type": "string", "maxLength": 2048, "description": "Human-readable descriptive metadata of the Location Object (plain text, max 2048 characters)." } },

  "$defs":                        {

    "LocationOrBasicLocation":    { "type": "array", "items": { "oneOf": [
                                    { "$ref": "https://schemas.mpai.community/OSD/V1.5/data/BasicLocationObject.json" },
                                    { "$ref": "#/$defs/LocationOrBasicLocation" } ] } },

    "BasicLocIDOrBasicLoc":       { "type": "array", "minItems": 1, "maxItems": 1, "items": { "oneOf": [
                                    { "$ref": "https://schemas.mpai.community/OSD/V1.5/data/BasicLocationObject.json" },
                                    { "type": "string" } ] } },

    "SubLocIDOrSubLoc":           { "type": "array", "minItems": 1, "maxItems": 1, "items": { "oneOf": [
                                    { "$ref": "https://schemas.mpai.community/OSD/V1.5/data/LocationObject.json" },
                                    { "type": "string" } ] } } } }
