{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "title": "Coverage",
    "description": "JSON encoding for the Coverage Implementation Schema (CIS) of ISO 19123-2:2025. Standardized for MultiPoint support.",
    "type": "object",
    "properties": {
        "id": { "type": "string" },
        "envelope": { "$ref": "#/definitions/envelope" },
        "domainSet": { "$ref": "#/definitions/domainSet" },
        "partitionSet": { "$ref": "#/definitions/partitionSet" },
        "rangeSet": { "$ref": "#/definitions/rangeSet" },
        "rangeType": { "$ref": "#/definitions/rangeType" },
        "metadata": { "$ref": "#/definitions/metadata" },
        "coverageFunction": { "$ref": "#/definitions/coverageFunction" }
    },
    "definitions": {
        "coverageFunction": {
            "type": "object",
            "properties": {
                "sequenceRule": { "type": "string" },
                "axisOrder": { "type": "array", "items": { "type": "string" } },
                "startPosition": { "type": "array", "items": { "type": "number" } }
            }
        },
        "envelope": {
            "type": "object",
            "properties": {
                "srsName": { "type": "string" },
                "axes": {
                    "type": "array",
                    "minItems": 1,
                    "items": {
                        "type": "object",
                        "properties": {
                            "axisLabel": { "type": "string" },
                            "uomLabel": { "type": "string" },
                            "lowerBound": { "type": ["string", "number"] },
                            "upperBound": { "type": ["string", "number"] }
                        }
                    }
                }
            }
        },
        "domainSet": {
            "type": ["object", "string"],
            "properties": {
                "srsName": { "type": "string" },
                "axisLabels": { "type": ["array", "string"] },
                "uomLabels": { "type": ["array", "string"] },
                "multiPoint": { "$ref": "#/definitions/multiPoint" },
                "generalGrid": { "$ref": "#/definitions/generalGrid" }
            }
        },
        "multiPoint": {
            "type": "array",
            "items": { "type": "array", "items": { "type": ["string", "number"] } }
        },
        "generalGrid": {
            "properties": {
                "srsName": { "type": "string" },
                "axisLabels": { "type": "array", "items": { "type": "string" } },
                "uomLabels": { "type": "array", "items": { "type": "string" } },
                "axes": {
                    "type": "array",
                    "minItems": 1,
                    "items": {
                        "anyOf": [
                            { "$ref": "#/definitions/indexAxis" },
                            { "$ref": "#/definitions/regularAxis" },
                            { "$ref": "#/definitions/irregularAxis" },
                            { "$ref": "#/definitions/displacementAxisNest" },
                            { "$ref": "#/definitions/transformationBySensorModel" }
                        ]
                    }
                },
                "gridLimits": {
                    "type": "array",
                    "minItems": 1,
                    "items": { "$ref": "#/definitions/indexAxis" }
                }
            }
        },
        "indexAxis": {
            "type": "object",
            "properties": {
                "axisLabel": { "type": "string" },
                "lowerBound": { "type": "number" },
                "upperBound": { "type": "number" }
            }
        },
        "regularAxis": {
            "type": "object",
            "properties": {
                "axisLabel": { "type": "string" },
                "uomLabel": { "type": "string" },
                "lowerBound": { "type": ["string", "number"] },
                "upperBound": { "type": ["string", "number"] },
                "resolution": { "type": ["string", "number"] }
            }
        },
        "irregularAxis": {
            "type": "object",
            "properties": {
                "axisLabel": { "type": "string" },
                "uomLabel": { "type": "string" },
                "positions": { "type": "array", "minItems": 1, "items": { "type": [ "string", "number" ]} }
            }
        },
        "displacementAxisNest": {
            "type": "object",
            "properties": {
                "axisLabels": { "type": "array", "minItems": 1, "items": { "type": "string" } },
                "uomLabels": { "type": "array", "minItems": 1, "items": { "type": "string" } },
                "sequenceRule": { "type": "string" },
                "positions": { "type": "array", "items": { "type": "string" } }
            }
        },
        "transformationBySensorModel": {
            "type": "object",
            "properties": {
                "axisLabels": { "type": "array", "items": { "type": "string" } },
                "uomLabels": { "type": "array", "items": { "type": "string" } },
                "axisType": { "type": "string" },
                "sensorModel": { "type": "string" },
                "sensorInstance": { "type": "string" }
            }
        },
        "partitionSet": {
            "type": "object",
            "properties": {
                "srsName": { "type": "string" },
                "axisLabels": { "type": "array", "items": { "type": "string" } },
                "uomLabels": { "type": "array", "items": { "type": "string" } },
                "partition": {
                    "type": "array",
                    "items": {
                        "anyOf": [
                            { "$ref": "#" },
                            { "type": "string" },
                            {
                                "type": "object",
                                "properties": {
                                    "envelope": { "$ref": "#/definitions/envelope" },
                                    "coverageRef": { "type": "string" }
                                },
                                "required": ["coverageRef"]
                            },
                            {
                                "type": "object",
                                "properties": {
                                    "position": { "type": "array", "items": { "type": ["string", "number"] } },
                                    "value": { "type": "array", "items": { "type": ["string", "number"] } }
                                }
                            }
                        ]
                    }
                }
            }
        },
        "rangeSet": {
            "type": ["array", "string"],
            "oneOf": [
                { "type": "array", "items": { "type": "number" } },
                { "type": "array", "items": { "type": "string" } },
                { "type": "string" }
            ]
        },
        "rangeType": {
            "title": "rangeType",
            "type": "object",
            "allOf": [ { "$ref": "./DataRecord.json" } ]
        },
        "metadata": {
            "type": ["array", "string"],
            "items": { "type": "string" }
        }
    }
}