An indicator estimates data quality for OpenStreetMap (OSM). It takes an area of interest in form of a GeoJSON Feature and a Topic object describing the set of OSM features as input.
Each particular indicator class inherits from the BaseIndicator
class of the ohsome_quality_api/indicators/base.py
module. Following class diagram gives an overview of abstract methods and properties of this class:
Metadata is automatically loaded from a metadata.yaml
file found in the module of a particular indicator.
Metadata describes basic information about the indicator: The indicator name, for which projects the indicator can be used, the quality dimension, a short description of what it does and how it works, and a standardized interpretation of its possible results.
Please take a look at the topic documentation.
The result object consists of following attributes:
description (str)
: The result descriptiontimestamp (datetime)
: Timestamp of the creation of the indicatortimestamp_osm (datetime)
: Timestamp of the used OSM data (e.g. the latest timestamp of the ohsome API results)value (float)
: The result valueclass (int)
: The result class. An integer between 1 and 5. It maps to following result labels:1
:red
2
/3
:yellow
4
/5
:green
figure (dict)
: A plotly figurelabel (str)
: Traffic lights like quality label (green
,yellow
orred
)
A particular indicator class (child) need to implement three functions:
preprocess
calculate
create_figure
Following sequence diagram shows when those functions are called during the lifecycle of the indicator:
This function is used to fetch and preprocess the data needed for an indicator. Usually this involves querying the ohsome API by using the module ohsome/client.py
which does so using Pythons async/await pattern
All data created during the preprocessing will be stored as attributes of the indicator object.
This functions does the computation of the indicator. At the end the result object should be fully initialized and all attributes set (except the figure).
This function creates plotly figure base on the indicator result.