{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://nodedc.ru/schemas/map-lod-policy-v0.1.schema.json",
  "title": "NODE.DC Map LOD Policy v0.1",
  "description": "Provider-neutral visibility and representation policy based on camera range in meters.",
  "type": "object",
  "additionalProperties": false,
  "required": ["schemaVersion", "template", "metric", "intervalRule", "policies"],
  "properties": {
    "schemaVersion": { "const": "0.1.0" },
    "template": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "version"],
      "properties": {
        "id": { "const": "map" },
        "version": { "const": "0.1.0" }
      }
    },
    "metric": { "const": "camera-range-meters" },
    "intervalRule": { "const": "min-inclusive-max-exclusive" },
    "policies": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["id", "target", "outsideRange", "hysteresisRatio", "bands"],
        "properties": {
          "id": { "$ref": "#/$defs/id" },
          "target": { "enum": ["grid", "place", "moving-object", "station", "route", "track", "zone", "label", "pin"] },
          "outsideRange": { "enum": ["hidden", "nearest-band"] },
          "hysteresisRatio": { "type": "number", "minimum": 0, "maximum": 0.5 },
          "bands": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": ["id", "minRange", "maxRange", "representation"],
              "properties": {
                "id": { "$ref": "#/$defs/id" },
                "minRange": { "type": "number", "minimum": 0 },
                "maxRange": { "type": "number", "exclusiveMinimum": 0 },
                "representation": { "enum": ["hidden", "cluster", "summary", "compact", "standard", "detailed", "geometry"] },
                "styleVariant": { "type": "string", "minLength": 1 },
                "density": { "type": "number", "exclusiveMinimum": 0 },
                "maxItems": { "type": "integer", "minimum": 1 }
              }
            }
          }
        }
      }
    }
  },
  "$defs": {
    "id": { "type": "string", "pattern": "^[a-z0-9]+(?:[._-][a-z0-9]+)*$" }
  }
}
