{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "title": "OSTRICH-SWMM Parameters",
    "description": "A set of parameters produced by OSTRICH to inject into SWMM input.",
    "type": "object",
    "properties": {
        "lids": {
            "type": "array",
            "items": {
                "$ref": "#/definitions/lid"
            }
        },
        "roofs": {
            "type": "array",
            "items": {
                "$ref": "#/definitions/roof"
            }
        }
    },
    "definitions": {
        "lid": {
            "type": "object",
            "properties": {
                "location": {
                    "oneOf": [
                        {
                            "type": "object",
                            "properties": {
                                "map": {
                                    "$ref": "#/definitions/mapCoordinates"
                                }
                            },
                            "required": [
                                "map"
                            ]
                        },
                        {
                            "type": "object",
                            "properties": {
                                "subcatchment": {
                                    "$ref": "#/definitions/subcatchment"
                                }
                            },
                            "required": [
                                "subcatchment"
                            ]
                        }
                    ]
                },
                "type": {
                    "type": "string",
                    "minLength": 1
                },
                "number": {
                    "type": "integer",
                    "minimum": 0
                },
                "area": {
                    "type": "number",
                    "minimum": 0
                },
                "width": {
                    "type": "number",
                    "minimum": 0
                },
                "initSat": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 100
                },
                "fromImp": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 100
                },
                "toPerv": {
                    "type": "number"
                },
                "rptFile": {
                    "type": "string",
                    "minLength": 1
                },
                "drainTo": {
                    "oneOf": [
                        {
                            "type": "object",
                            "properties": {
                                "map": {
                                    "$ref": "#/definitions/mapCoordinates"
                                }
                            },
                            "required": [
                                "map"
                            ]
                        },
                        {
                            "type": "object",
                            "properties": {
                                "subcatchment": {
                                    "$ref": "#/definitions/subcatchment"
                                }
                            },
                            "required": [
                                "subcatchment"
                            ]
                        },
                        {
                            "type": "object",
                            "properties": {
                                "node": {
                                    "$ref": "#/definitions/node"
                                }
                            },
                            "required": [
                                "node"
                            ]
                        }
                    ]
                }
            },
            "required": [
                "location",
                "type",
                "number",
                "area",
                "width",
                "initSat",
                "fromImp",
                "toPerv"
            ]
        },
        "roof": {
            "type": "object",
            "properties": {
                "location": {
                    "oneOf": [
                        {
                            "type": "object",
                            "properties": {
                                "map": {
                                    "$ref": "#/definitions/mapCoordinates"
                                }
                            },
                            "required": [
                                "map"
                            ]
                        },
                        {
                            "type": "object",
                            "properties": {
                                "subcatchment": {
                                    "$ref": "#/definitions/subcatchment"
                                }
                            },
                            "required": [
                                "subcatchment"
                            ]
                        }
                    ]
                },
                "type": {
                    "type": "string",
                    "minLength": 1
                },
                "number": {
                    "type": "integer",
                    "minimum": 0
                },
                "OutID": {
                    "type": "string",
                    "minLength": 1
                },
                "area": {
                    "type": "number",
                    "minimum": 0
                },
                "PctImperv": {
                    "type": "number",
                    "minimum": 0
                },
                "width": {
                    "type": "number",
                    "minimum": 0
                },
                "slope": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 100
                },
                "Nimp": {
                    "type": "number"
                },
                "Nperv": {
                    "type": "number"
                },
                "PctZero": {
                    "type": "number"
                }
            },
            "required": [
                "location",
                "OutID",
                "area",
                "slope",
                "width"
            ]
        },
        "mapCoordinates": {
            "type": "object",
            "properties": {
                "x": {
                    "type": "number"
                },
                "y": {
                    "type": "number"
                }
            },
            "required": [
                "x",
                "y"
            ]
        },
        "node": {
            "type": "string",
            "minLength": 1
        },
        "subcatchment": {
            "type": "string",
            "minLength": 1
        }
    }
}