{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "title": "The 'Energy ADE' cityjsonified -- BuildingPhysics only",

  "definitions": {

    "building-attributes": {
      "type": "object",
      "properties": {
        "creationDate" : {"type": "string"},
        "terminationDate" : {"type": "string"},
        "class": {"type": "string"},
        "function": {"type": "string"},
        "usage": {"type": "string"},
        "measuredHeight": { "type": "number"},
        "roofType": { "type": "string"},
        "storeysAboveGround": { "type": "integer" },
        "storeysBelowGround": { "type": "integer" },
        "storeyHeightsAboveGround": { 
          "type": "array",
          "items": {"type": "number"}
        },
        "storeyHeightsBelowGround": { 
          "type": "array",
          "items": {"type": "number"}
        },
        "yearOfConstruction": { "type": "integer"},
        "yearOfDemolition": { "type": "integer"}
      }
    },
    
    "address" : {
      "type": "object",
      "properties": {
        "CountryName": {"type": "string"},
        "LocalityName": {"type": "string"},
        "ThoroughfareNumber": {"type": "string"},
        "ThoroughfareName": {"type": "string"},
        "PostalCode": {"type": "string"},
        "location": {"$ref": "geomprimitives.json#/MultiPoint"}
      }
    }

  },


  "+EnergyBuilding": {
    "type": "object",
    "properties": {
      "type": { "enum": ["+EnergyBuilding"] },
      "attributes": { 
        "$ref": "#/definitions/building-attributes"  
      },
      "attributes-energy": { 
      	"type": "object",
        "properties": {
          "buildingType": { "type": "string" },
          "constructionWeight": { "enum": ["veryLight", "light", "medium", "heavy"] },
          "energyPerformanceCertification": {
            "type": "array",
            "items": { 
              "type": "object",
              "properties": {
                "rating" : { "type": "string" },
                "name" : { "type": "string" },
                "certificationId" : { "type": "string" }
              },
              "required": ["rating", "name"],
              "additionalProperties": false  
            }
          },
          "volume": {
            "type": "object",
            "properties": {
              "value": { "type": "number" },
              "uom": { "type": "string" }
            },
            "required": ["value", "uom"],
            "additionalProperties": false
          },
          "isLandmarked": { "type": "boolean" },
          "refurbishmentMeasure": {
            "type": "array",
            "items": { 
              "type": "object",
              "properties": {
                "date" : { "type": "string" },
                "level" : { "type": "string" },
                "description" : { "type": "string" }
              },
              "required": ["date", "level"],
              "additionalProperties": false  
            }
          },
          "floorArea": {
            "type": "object",
            "properties": {
              "value": { "type": "number" },
              "uom": { "type": "string" }
            },
            "required": ["value", "uom"],
            "additionalProperties": false  
          },
          "heightAboveGround": {
            "type": "object",
            "properties": {
              "value": { "type": "number" },
              "heightReference": { 
                "type": "string",
                "enum": [
                  "bottomOfConstruction",
                  "entrancePoint",
                  "generalEave",
                  "generalRoof",
                  "generalRoofEdge",
                  "highestEave",
                  "highestPoint",
                  "highestRoofEdge",
                  "lowestEave",
                  "lowestFloorAboveGround",
                  "lowestRoofEdge",
                  "topOfConstruction",
                  "topThermalBoundary",
                  "bottomThermalBoundary"
                ] 
              }
            },
            "required": ["value", "heightReference"],
            "additionalProperties": false  
          }
        },
        "additionalProperties": false  
      },
      "address": {
         "$ref": "#/definitions/address"
      }, 
      "children": {
        "type": "array",
        "items": {"type": "string"}
      },
      "bbox": {
        "type": "array",
        "items": { "type": "number" },
        "minItems": 6,    
        "maxItems": 6    
      },
      "geometry": {
        "type": "array",
        "items": {
          "oneOf": [
            {"$ref": "../geomprimitives.json#/Solid"},
            {"$ref": "../geomprimitives.json#/CompositeSolid"},
            {"$ref": "../geomprimitives.json#/MultiSurface"},
            {"$ref": "../geomtemplates.json#/GeometryInstance"}
          ] 
        }
      }
    },
    "required": ["type", "geometry"],
    "additionalProperties": false
  },

  
  "+ThermalZone": {
    "type": "object",
    "properties": {
      "type": { "enum": ["+ThermalZone"] },
      "attributes": {
        "type": "object",
        "properties": {
          "additionalThermalBridgeUValue": { "type": "string"},
          "isCooled": { "type": "boolean"},
          "isHeated": { "type": "boolean"},
          "volume": {
            "type": "object",
            "properties": {
              "value": { "type": "number" },
              "uom": { "type": "string" }
            },
            "required": ["value", "uom"],
            "additionalProperties": false
          },
          "floorArea": {
            "type": "object",
            "properties": {
              "value": { "type": "number" },
              "uom": { "type": "string" }
            },
            "required": ["value", "uom"],
            "additionalProperties": false  
          }
        },
        "additionalProperties": false  
      },
      "bbox": {
        "type": "array",
        "items": { "type": "number" },
        "minItems": 6,    
        "maxItems": 6    
      },
      "parent": {"type": "string"},
      "geometry": {
        "type": "array",
        "items": {
          "oneOf": [
            {"$ref": "../geomprimitives.json#/Solid"}
          ]
        }
      }
    },
    "required": ["type", "geometry", "parent"],
    "additionalProperties": false
  }

  
}