{
  "$id": "https://tigroo31.github.io/its-client/schema/denm",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "description": "DENM JSon schema",
  "properties": {
    "message": {
      "properties": {
        "alacarte_container": {
          "properties": {
            "lane_position": {
              "description": "offTheRoad(-1), innerHardShoulder(0), innermostDrivingLane(1), secondLaneFromInside(2), outterHardShoulder(14)",
              "maximum": 14,
              "minimum": -1,
              "type": "integer"
            },
            "positioning_solution": {
              "description": "noPositioningSolution(0), sGNSS(1), dGNSS(2), sGNSSplusDR(3), dGNSSplusDR(4), dR(5)",
              "minimum": 0,
              "type": "integer"
            }
          },
          "type": "object"
        },
        "location_container": {
          "properties": {
            "confidence": {
              "properties": {
                "event_position_heading": {
                  "description": "Unit: 0,1 degree. equalOrWithinZeroPointOneDegree (1), equalOrWithinOneDegree (10), outOfRange(126), unavailable(127)",
                  "maximum": 127,
                  "minimum": 1,
                  "type": "integer"
                },
                "event_speed": {
                  "description": "Unit: 0.01 m/s. equalOrWithinOneCentimeterPerSec(1), equalOrWithinOneMeterPerSec(100), outOfRange(126), unavailable(127)",
                  "maximum": 127,
                  "minimum": 1,
                  "type": "integer"
                }
              },
              "type": "object"
            },
            "event_position_heading": {
              "description": "Unit: 0,1 degree. wgs84North(0), wgs84East(900), wgs84South(1800), wgs84West(2700), unavailable(3601)",
              "maximum": 3601,
              "minimum": 0,
              "type": "integer"
            },
            "event_speed": {
              "description": "Unit 0,01 m/s. standstill(0), oneCentimeterPerSec(1), unavailable(16383)",
              "maximum": 16383,
              "minimum": 0,
              "type": "integer"
            },
            "road_type": {
              "description": "Type of a road segment. urban-NoStructuralSeparationToOppositeLanes(0), urban-WithStructuralSeparationToOppositeLanes(1), nonUrban-NoStructuralSeparationToOppositeLanes(2), nonUrban-WithStructuralSeparationToOppositeLanes(3)",
              "maximum": 3,
              "minimum": 0,
              "type": "integer"
            },
            "traces": {
              "description": "the traces, 1 or more path history",
              "items": {
                "properties": {
                  "path_history": {
                    "description": "the path history, a path with a set of path points",
                    "items": {
                      "properties": {
                        "path_delta_time": {
                          "description": "time travelled by the detecting ITS-S since the previous detected event point (reference_time). tenMilliSecondsInPast(1)",
                          "maximum": 65535,
                          "minimum": 1,
                          "type": "integer"
                        },
                        "path_position": {
                          "description": "offset position of a detected event point with regards to the previous detected event point (event_position).",
                          "properties": {
                            "delta_altitude": {
                              "$comment": "if not provided, 'delta_altitude' = 12800 (unavailable)",
                              "default": 12800,
                              "description": "oneCentimeterUp (1), oneCentimeterDown (-1), unavailable(12800)",
                              "maximum": 12800,
                              "minimum": -12700,
                              "type": "integer"
                            },
                            "delta_latitude": {
                              "$comment": "if not provided, 'delta_latitude' = 131072 (unavailable)",
                              "default": 131072,
                              "description": "oneMicrodegreeNorth (10), oneMicrodegreeSouth (-10) , unavailable(131072)",
                              "maximum": 131072,
                              "minimum": -131071,
                              "type": "integer"
                            },
                            "delta_longitude": {
                              "$comment": "if not provided, 'delta_longitude' = 131072 (unavailable)",
                              "default": 131072,
                              "description": "oneMicrodegreeEast (10), oneMicrodegreeWest (-10), unavailable(131072)",
                              "maximum": 131072,
                              "minimum": -131071,
                              "type": "integer"
                            }
                          },
                          "type": "object"
                        }
                      },
                      "required": [
                        "path_position"
                      ],
                      "type": "object"
                    },
                    "maxItems": 40,
                    "type": "array"
                  }
                },
                "required": [
                  "path_history"
                ],
                "type": "object"
              },
              "maxItems": 7,
              "minItems": 1,
              "type": "array"
            }
          },
          "required": [
            "traces"
          ],
          "type": "object"
        },
        "management_container": {
          "properties": {
            "action_id": {
              "properties": {
                "originating_station_id": {
                  "description": "identifier of an its station",
                  "maximum": 4294967295,
                  "minimum": 0,
                  "type": "integer"
                },
                "sequence_number": {
                  "description": "The sequence number is set each time a new DENM is created. It is used to differentiate from events detected by the same ITS-S.",
                  "maximum": 65535,
                  "minimum": 0,
                  "type": "integer"
                }
              },
              "required": [
                "originating_station_id",
                "sequence_number"
              ],
              "type": "object"
            },
            "confidence": {
              "$comment": "mandatory on ETSI specification, FIXME?",
              "properties": {
                "altitude": {
                  "$comment": "if not provided, 'altitude' = 15 (unavailable)",
                  "default": 15,
                  "description": "alt-000-01 (0), alt-000-02 (1), alt-000-05 (2), alt-000-10 (3), alt-000-20 (4), alt-000-50 (5), alt-001-00 (6), alt-002-00 (7), alt-005-00 (8), alt-010-00 (9), alt-020-00 (10), alt-050-00 (11), alt-100-00 (12), alt-200-00 (13), outOfRange (14), unavailable (15)",
                  "maximum": 15,
                  "minimum": 0,
                  "type": "integer"
                },
                "position_confidence_ellipse": {
                  "$comment": "mandatory on ETSI specification, FIXME?",
                  "properties": {
                    "semi_major_confidence": {
                      "$comment": "if not provided, 'semi_major_confidence' = 4095 (unavailable)",
                      "default": 4095,
                      "description": "oneCentimeter(1), outOfRange(4094), unavailable(4095)",
                      "maximum": 4095,
                      "minimum": 0,
                      "type": "integer"
                    },
                    "semi_major_orientation": {
                      "$comment": "if not provided, 'semi_major_orientation' = 3601 (unavailable)",
                      "default": 3601,
                      "description": "wgs84North(0), wgs84East(900), wgs84South(1800), wgs84West(2700), unavailable(3601)",
                      "maximum": 3601,
                      "minimum": 0,
                      "type": "integer"
                    },
                    "semi_minor_confidence": {
                      "$comment": "if not provided, 'semi_minor_confidence' = 4095 (unavailable)",
                      "default": 4095,
                      "description": "oneCentimeter(1), outOfRange(4094), unavailable(4095)",
                      "maximum": 4095,
                      "minimum": 0,
                      "type": "integer"
                    }
                  },
                  "type": "object"
                }
              },
              "type": "object"
            },
            "detection_time": {
              "description": "Unit: millisecond since ETSI epoch (2004/01/01, so 1072915200000). Time at which the event is detected by the originating ITS-S. For the DENM repetition, this DE shall remain unchanged. utcStartOf2004(0), oneMillisecAfterUTCStartOf2004(1)",
              "maximum": 4398046511103,
              "minimum": 0,
              "type": "integer"
            },
            "event_position": {
              "properties": {
                "altitude": {
                  "default": 800001,
                  "description": "Unit: 0.01 meter. referenceEllipsoidSurface(0), oneCentimeter(1), unavailable(800001)",
                  "maximum": 800001,
                  "minimum": -100000,
                  "type": "integer"
                },
                "latitude": {
                  "default": 900000001,
                  "description": "Unit: 0,1 microdegree. oneMicrodegreeNorth (10), oneMicrodegreeSouth (-10), unavailable(900000001)",
                  "maximum": 900000001,
                  "minimum": -900000000,
                  "type": "integer"
                },
                "longitude": {
                  "default": 1800000001,
                  "description": "Unit: 0,1 microdegree. oneMicrodegreeEast (10), oneMicrodegreeWest (-10), unavailable(1800000001)",
                  "maximum": 1800000001,
                  "minimum": -1800000000,
                  "type": "integer"
                }
              },
              "required": [
                "latitude",
                "longitude",
                "altitude"
              ],
              "type": "object"
            },
            "reference_time": {
              "description": "Unit: millisecond since ETSI epoch (2004/01/01, so 1072915200000). Time at which a new DENM, an update DENM or a cancellation DENM is generated. utcStartOf2004(0), oneMillisecAfterUTCStartOf2004(1)",
              "maximum": 4398046511103,
              "minimum": 0,
              "type": "integer"
            },
            "relevance_distance": {
              "description": "lessThan50m(0), lessThan100m(1), lessThan200m(2), lessThan500m(3), lessThan1000m(4), lessThan5km(5), lessThan10km(6), over10km(7)",
              "maximum": 7,
              "minimum": 0,
              "type": "integer"
            },
            "relevance_traffic_direction": {
              "description": "allTrafficDirections(0), upstreamTraffic(1), downstreamTraffic(2), oppositeTraffic(3)",
              "maximum": 3,
              "minimum": 0,
              "type": "integer"
            },
            "station_type": {
              "$comment": "if not provided, 'station_type' = 0 (unknown)",
              "default": 0,
              "description": "unknown(0), pedestrian(1), cyclist(2), moped(3), motorcycle(4), passengerCar(5), bus(6), lightTruck(7), heavyTruck(8), trailer(9), specialVehicles(10), tram(11), roadSideUnit(15)",
              "maximum": 255,
              "minimum": 0,
              "type": "integer"
            },
            "termination": {
              "description": "isCancellation(0), isNegation (1)",
              "maximum": 1,
              "minimum": 0,
              "type": "integer"
            },
            "transmission_interval": {
              "description": "Unit: millisecond. oneMilliSecond(1), tenSeconds(10000)",
              "maximum": 10000,
              "minimum": 1,
              "type": "integer"
            },
            "validity_duration": {
              "default": 600,
              "description": "Unit: second. timeOfDetection(0), oneSecondAfterDetection(1)",
              "maximum": 86400,
              "minimum": 0,
              "type": "integer"
            }
          },
          "required": [
            "action_id",
            "detection_time",
            "reference_time",
            "event_position"
          ],
          "type": "object"
        },
        "protocol_version": {
          "description": "version of the ITS message and/or communication protocol",
          "examples": [
            1
          ],
          "maximum": 255,
          "minimum": 0,
          "type": "integer"
        },
        "situation_container": {
          "properties": {
            "event_type": {
              "properties": {
                "cause": {
                  "description": "reserved (0),trafficCondition (1),accident (2),roadworks (3),adverseWeatherCondition-Adhesion (6),hazardousLocation-SurfaceCondition (9),hazardousLocation-ObstacleOnTheRoad (10),hazardousLocation-AnimalOnTheRoad (11),humanPresenceOnTheRoad (12),wrongWayDriving (14),rescueAndRecoveryWorkInProgress (15),adverseWeatherCondition-ExtremeWeatherCondition (17),adverseWeatherCondition-Visibility (18),adverseWeatherCondition-Precipitation (19),slowVehicle (26),dangerousEndOfQueue (27),vehicleBreakdown (91),postCrash (92),humanProblem (93),stationaryVehicle (94),emergencyVehicleApproaching (95),hazardousLocation-DangerousCurve (96),collisionRisk (97),signalViolation (98),dangerousSituation (99)",
                  "maximum": 255,
                  "minimum": 0,
                  "type": "integer"
                },
                "subcause": {
                  "$comment": "if not provided, 'subcause' = 0 (unavailable)",
                  "default": 0,
                  "description": "trafficCondition: unavailable(0), increasedVolumeOfTraffic(1), trafficJamSlowlyIncreasing(2), trafficJamIncreasing(3), trafficJamStronglyIncreasing(4), trafficStationary(5), trafficJamSlightlyDecreasing(6), trafficJamDecreasing(7), trafficJamStronglyDecreasing(8). accident: unavailable(0), multiVehicleAccident(1), heavyAccident(2), accidentInvolvingLorry(3), accidentInvolvingBus(4), accidentInvolvingHazardousMaterials(5), accidentOnOppositeLane(6), unsecuredAccident(7), assistanceRequested(8). roadworks: unavailable(0), majorRoadworks(1), roadMarkingWork(2), slowMovingRoadMaintenance(3), shortTermStationaryRoadworks(4), streetCleaning(5), winterService(6). humanPresenceOnTheRoad: unavailable(0), childrenOnRoadway(1), cyclistOnRoadway(2), motorcyclistOnRoadway(3). wrongWayDriving: unavailable(0), wrongLane(1), wrongDirection(2). adverseWeatherCondition-ExtremeWeatherCondition: unavailable(0), strongWinds(1), damagingHail(2), hurricane(3), thunderstorm(4), tornado(5), blizzard(6). adverseWeatherCondition-Adhesion: unavailable(0), heavyFrostOnRoad(1), fuelOnRoad(2), mudOnRoad(3), snowOnRoad(4), iceOnRoad(5), blackIceOnRoad(6), oilOnRoad(7), looseChippings(8), instantBlackIce(9), roadsSalted(10). adverseWeatherCondition-Visibility: unavailable(0), fog(1), smoke(2), heavySnowfall(3), heavyRain(4), heavyHail(5), lowSunGlare(6), sandstorms(7), swarmsOfInsects(8). adverseWeatherCondition-Precipitation: unavailable(0), heavyRain(1), heavySnowfall(2), softHail(3). slowVehicle: unavailable(0), maintenanceVehicle(1), vehiclesSlowingToLookAtAccident(2), abnormalLoad(3), abnormalWideLoad(4), convoy(5), snowplough(6), deicing(7), saltingVehicles(8). stationaryVehicle: unavailable(0), humanProblem(1), vehicleBreakdown(2), postCrash(3), publicTransportStop(4), carryingDangerousGoods(5). humanProblem: unavailable(0), glycemiaProblem(1), heartProblem(2). emergencyVehicleApproaching: unavailable(0), emergencyVehicleApproaching(1), prioritizedVehicleApproaching(2). hazardousLocation-DangerousCurve: unavailable(0), dangerousLeftTurnCurve(1), dangerousRightTurnCurve(2), multipleCurvesStartingWithUnknownTurningDirection(3), multipleCurvesStartingWithLeftTurn(4), multipleCurvesStartingWithRightTurn(5). hazardousLocation-SurfaceCondition: unavailable(0), rockfalls(1), earthquakeDamage(2), sewerCollapse(3), subsidence(4), snowDrifts(5), stormDamage(6), burstPipe(7), volcanoEruption(8), fallingIce(9). hazardousLocation-ObstacleOnTheRoad: unavailable(0), shedLoad(1), partsOfVehicles(2), partsOfTyres(3), bigObjects(4), fallenTrees(5), hubCaps(6), waitingVehicles(7). HazardousLocation-AnimalOnTheRoad: unavailable(0), wildAnimals(1), herdOfAnimals(2), smallAnimals(3), largeAnimals(4). CollisionRisk: unavailable(0), longitudinalCollisionRisk(1), crossingCollisionRisk(2), lateralCollisionRisk(3), vulnerableRoadUser(4). SignalViolation: unavailable(0), stopSignViolation(1), trafficLightViolation(2), turningRegulationViolation(3). RescueAndRecoveryWorkInProgress: unavailable(0), emergencyVehicles(1), rescueHelicopterLanding(2), policeActivityOngoing(3), medicalEmergencyOngoing(4), childAbductionInProgress(5). DangerousEndOfQueue: unavailable(0), suddenEndOfQueue(1), queueOverHill(2), queueAroundBend(3), queueInTunnel(4). DangerousSituation: unavailable(0), emergencyElectronicBrakeEngaged(1), preCrashSystemEngaged(2), espEngaged(3), absEngaged(4), aebEngaged(5), brakeWarningEngaged(6), collisionRiskWarningEngaged(7). VehicleBreakdown: unavailable(0), lackOfFuel (1), lackOfBatteryPower (2), engineProblem(3), transmissionProblem(4), engineCoolingProblem(5), brakingSystemProblem(6), steeringProblem(7), tyrePuncture(8). PostCrash: unavailable(0), accidentWithoutECallTriggered (1), accidentWithECallManuallyTriggered (2), accidentWithECallAutomaticallyTriggered (3), accidentWithECallTriggeredWithoutAccessToCellularNetwork(4)",
                  "maximum": 255,
                  "minimum": 0,
                  "type": "integer"
                }
              },
              "required": [
                "cause"
              ],
              "type": "object"
            },
            "information_quality": {
              "$comment": "if not provided, 'information_quality' = 0 (unavailable)",
              "default": 0,
              "description": "unavailable(0), lowest(1), highest(7)",
              "maximum": 7,
              "minimum": 0,
              "type": "integer"
            },
            "linked_cause": {
              "properties": {
                "cause": {
                  "description": "see the event type cause description",
                  "maximum": 255,
                  "minimum": 0,
                  "type": "integer"
                },
                "subcause": {
                  "$comment": "if not provided, 'subcause' = 0 (unavailable)",
                  "default": 0,
                  "description": "see the event type subcause description",
                  "maximum": 255,
                  "minimum": 0,
                  "type": "integer"
                }
              },
              "required": [
                "cause"
              ],
              "type": "object"
            }
          },
          "required": [
            "event_type"
          ],
          "type": "object"
        },
        "station_id": {
          "description": "identifier for an ITS-S",
          "examples": [
            1,
            42
          ],
          "maximum": 4294967295,
          "minimum": 0,
          "type": "integer"
        }
      },
      "required": [
        "protocol_version",
        "station_id",
        "management_container"
      ],
      "type": "object"
    },
    "origin": {
      "description": "the entity responsible for this message",
      "enum": [
        "self",
        "global_application",
        "mec_application",
        "on_board_application"
      ],
      "type": "string"
    },
    "path": {
      "description": "List of ordered elements root source of the message",
      "items": {
        "properties": {
          "message_type": {
            "description": "root message type source of the element",
            "enum": [
              "denm",
              "cam",
              "cpm",
              "po"
            ]
          },
          "position": {
            "properties": {
              "altitude": {
                "default": 800001,
                "description": "Unit: 0.01 meter. referenceEllipsoidSurface(0), oneCentimeter(1), unavailable(800001)",
                "maximum": 800001,
                "minimum": -100000,
                "type": "integer"
              },
              "latitude": {
                "default": 900000001,
                "description": "Unit: 0,1 microdegree. oneMicrodegreeNorth (10), oneMicrodegreeSouth (-10), unavailable(900000001)",
                "maximum": 900000001,
                "minimum": -900000000,
                "type": "integer"
              },
              "longitude": {
                "default": 1800000001,
                "description": "Unit: 0,1 microdegree. oneMicrodegreeEast (10), oneMicrodegreeWest (-10), unavailable(1800000001)",
                "maximum": 1800000001,
                "minimum": -1800000000,
                "type": "integer"
              }
            },
            "required": [
              "latitude",
              "longitude",
              "altitude"
            ],
            "type": "object"
          }
        },
        "required": [
          "position",
          "message_type"
        ],
        "type": "object"
      },
      "minItems": 1,
      "type": "array"
    },
    "source_uuid": {
      "examples": [
        "UNKNOWN",
        "CCU6",
        "MEC2"
      ],
      "type": "string"
    },
    "timestamp": {
      "description": "Unit: millisecond. The timestamp when the message was generated since Unix Epoch (1970/01/01)",
      "examples": [
        1574778515424
      ],
      "maximum": 1830297600000,
      "minimum": 1514764800000,
      "type": "integer"
    },
    "type": {
      "enum": [
        "denm"
      ]
    },
    "version": {
      "const": "1.1.1",
      "description": "json message format version",
      "type": "string"
    }
  },
  "required": [
    "type",
    "origin",
    "version",
    "source_uuid",
    "timestamp",
    "message"
  ],
  "type": "object"
}