Skip to content

Indicator vector format

mscholl edited this page Oct 7, 2014 · 1 revision

The Indicator vector format is very easy an straight forward. The data is stored in a simple JSON Object that has to follow some basic rules.

JSON Schema description

{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "description": "Indicator vector format schema",
    "definitions": {
        "commonProperties": {
            "description": "properties that are used by group and value alike",
            "type": "object",
            "properties": {
                "displayName": {
                    "description": "a human-readable name for the UI implementation",
                    "type": "string",
                    "pattern": "^.+$"
                },
                "iconResource": {
                    "description": "a URL to a icon resource that may be used by the UI implementation",
                    "type": "string",
                    "format": "uri",
                    "pattern": "^.+$"
                }
            },
            "required": ["displayName", "iconResource"]
        },
        "valueProperty": {
            "description": "the schema of an actual indicator value object",
            "type": "object",
            "allOf": [{
                    "$ref": "#/definitions/commonProperties"
                }, {
                    "properties": {
                        "unit": {
                            "description": "the unit of the indicator value",
                            "type": "string"
                        },
                        "value": {
                            "description": "the actual indicator value", 
                            "type": "number"
                        }
                    },
                    "required": ["unit", "value"]
                }
            ]
        },
        "groupProperty": {
            "description": "the schema of an indicator group",
            "type": "object",
            "allOf": [{
                    "$ref": "#/definitions/commonProperties"
                }, {
                    "patternProperties": {
                        "^(?!(^displayName$|^iconResource$)).+$": {
                            "$ref": "#/definitions/valueProperty"
                        }
                    }
                }
            ],
            "required": ["displayName", "iconResource"],
            "minProperties": 3
        }
    },
    "type": "object",
    "patternProperties": {
        "^.+$": {
            "$ref": "#/definitions/groupProperty"
        }
    },
    "additionalProperties": false,
    "minProperties": 1
}

Example

Pilot D:

{
  "casualties": {
    "displayName": "Casualties",
    "iconResource": "flower_16.png",
    "noOfDead": {
      "displayName": "Number of dead",
      "iconResource": "flower_dead_16.png",
      "value": 257,
      "unit": "People"
    },
    "noOfInjured": {
      "displayName": "Number of injured",
      "iconResource": "flower_injured_16.png",
      "value": 409,
      "unit": "People"
    },
    "noOfHomeless": {
      "displayName": "Number of homeless",
      "iconResource": "flower_homeless_16.png",
      "value": 129,
      "unit": "People"
    }
  },
  "cost": {
    "directDamageCost": {
      "displayName": "Direct damage cost",
      "iconResource": "dollar_direct_16.png",
      "value": 4582048.34,
      "unit": "Dollar"
    },
    "displayName": "Economic cost",
    "iconResource": "dollar_16.png",
    "indirectDamageCost": {
      "displayName": "Indirect damage cost",
      "iconResource": "dollar_indirect_16.png",
      "value": 830923892.47,
      "unit": "Dollar"
    },
    "restorationCost": {
      "displayName": "Direct restoration cost",
      "iconResource": "dollar_restoration_16.png",
      "value": 892930184.91,
      "unit": "Dollar"
    }
  },
  "damagedBuildings": {
    "displayName": "Damaged buildings",
    "iconResource": "home_16.png",
    "lostBuildings": {
      "displayName": "Lost buildings",
      "iconResource": "home_lost_16.png",
      "value": 49,
      "unit": "Buildings"
    },
    "unsafeBuildings": {
      "displayName": "Unsafe buildings",
      "iconResource": "home_unsafe_16.png",
      "value": 152,
      "unit": "Buildings"
    }
  },
  "damagedInfrastructure": {
    "damagedRoadSegments": {
      "displayName": "Number of damaged road segments",
      "iconResource": "road_damaged_16.png",
      "value": 34,
      "unit": "Road segments"
    },
    "displayName": "Damaged Infrastructure",
    "iconResource": "road_16.png"
  },
  "evacuationCost": {
    "displayName": "Evacuation cost",
    "iconResource": "money_evac_16.png",
    "totalEvacuationCost": {
      "displayName": "Total evacuation cost",
      "iconResource": "money_total_evac_16.png",
      "value": 3494023211.23,
      "unit": "Dollar"
    }
  }
}