This repository contains a set of charts based on the data from OSM analytics site and API.
It was developed primarily to integrate the above mentioned data on the OpenDRI website but it can be easily used in other contexts.
It also contains a basic application server that hosts a sandbox containing the charts above, for development and test purposes.
Use npm to install all dependencies.
npm install
To start a development server run:
npm run server
The sandbox page should now be available on http://localhost:8080
The project comes preconfigured with sensible defaults, which should work in most cases.
If you want to override the default endpoints configuration, you need to duplicate the configuration file:
cp public/env.sample.js public/env.js
Then edit to override. You may need to restart the application server after you change the settings.
To bundle all the dependencies and minify the code run:
npm run build
This creates public/bundle.js
and public/styles.css
which contain the minified, production-ready version of this library.
Presents a set of configurable statistics about contributions done to OSM.
- statistics (mandatory) (
[{featureType: 'highways', stat: 'users'}]
) an array of widgets objects, each being of the following form:
{
featureType: 'highways'|'buildings'|'waterways'
stat: 'activity'|'users'
}
- country or polygon (mandatory) ISO3 country code or an encoded polyline of the area of interest related to the project (ie
ifv%7BDndwkBx%60%40aYwQev%40sHkPuf%40ss%40%7BfA_%40uq%40xdCn%7D%40%5E
)) - start_date (mandatory) (
2016-01-01
) represents the start date of an OpenDRI project - end_date (mandatory) (
2017-01-01
) represents the end date of an OpenDRI project - precision (
13
) value between 1 and 13, specifying accuracy of data to display.
Renders a plain value, with no formatting or unit.
- country or polygon (mandatory) ISO3 country code or an encoded polyline of the area of interest related to the project (ie
ifv%7BDndwkBx%60%40aYwQev%40sHkPuf%40ss%40%7BfA_%40uq%40xdCn%7D%40%5E
)) - start_date (mandatory) (
2016-01-01
) represents the start date of an OpenDRI project - end_date (mandatory) (
2017-01-01
) represents the end date of an OpenDRI project - feature_type (mandatory) (
buildings
)buildings
,waterways
orwaterways
- statistic (mandatory) (
users
) type should be eitherusers
oractivity
.users
statistics are only available if precision is set to 13. - precision (
13
) value between 1 and 13, specifying accuracy of data to display.
The compare map consists of a trimmed-down, embedded version of the OSM Analytics site. It uses a slider to show the status of OSM contributions in two dates, allowing a seamless visual comparison between them.
- width
- height
- settings.default_feature_type (
buildings
) comparebuildings
orhighways
orwaterways
- settings.iframe_base_url
- settings.polygon an encoded polyline of the area of interest related to the project (ie
ifv%7BDndwkBx%60%40aYwQev%40sHkPuf%40ss%40%7BfA_%40uq%40xdCn%7D%40%5E
)) - settings.default_start_year (
2016
) represents the default start year - settings.default_end_year (
now
) represents the default end year.now
can also be provided to compare with latest OSM data
The activity charts illustrate a comparison between contributions done on multiple OSM features. As the features may not be directly aggregatable, a simplified [https://en.wikipedia.org/wiki/Mahalanobis_distance](Mahalanobis distance) calculation is used to aggregate contributions.
- data (mandatory) raw data from the OSM Analytics API, it has to be loaded externally
- apiUrl provide an API url for the 'Download data' button
- range (mandatory) (
[2010-03-06,2016-01-01
) time range displayed, as a [from, to] array, regardless of the data provided - facet visible facet when loading the widget, must be 'users' or 'features' (default).
users
statistics are only available if precision is set to 13. - granularity visible granularity by default, must be 'monthly', 'weekly' or 'daily' (default)
- precision (
13
) value between 1 and 13, specifying accuracy of data to display.
As information regarding activity in the OSM database is expressed in different units (i.e. number of km for roads or number of individual entries in the case of buildings) we had to normalize the values in order to aggregate them in a meaningful way. The approach we chose is a simplified Mahalanobis distance (multi-dimensional generalization of the idea of measuring how many standard deviations away a point is from the mean of a distribution) in which, by removing the original dimension from the original data, we are able to describe the features in regards to the whole set of points, allowing us to finally aggregate features of different units in the same histogram.
More info: source code
The contributors chart shows a list of the top users for the given filter options, and an aggregated value for the remaining contributions
- data (mandatory) raw data from the OSM Analytics API, it has to be loaded externally
- apiUrl provide an API url for the 'Download data' button
- numUsers number of users displayed, defaults to 10,
- featureType (
buildings
) buildings, highways or waterways