Prototype for HOTOSM Outreachy project
npm install
browserify js/app.js > dist/bundle.js
python -m http.server
relations ways nodes
Submit
, all data changes, within a given time period, over a specific geographic area is obtained from OSM using overpass query. This is then rendered on map.Objective is to view the edits made in a particular geography after a mapping event, something like Total number of buildings touched
or Total kms of highways touched
.
This is like questioning OpenStreetMap on Hey, show me all the edits made in Bangalore today
. This question can be put to OpenStreetMap in several ways.
Export
optionAll the above options have their merits in different situations.
Let's dig our question Hey, show me all the edits made in Bangalore today
to understand which option is better.
This question has three parts to it:
all the edits
- this is inclusive of all the feature types - buildings, highways. This part can be made very specific to say all building edits
or all highway edits
edits made in Bangalore
- question is specific to a placeedits made today
- edits made from the start of the day to the current time. All the three factors - kind of features edited, geography and timeframe are variable. We've to choose an option that could fit in these three factors.
Option | Feature filtering | Geography filter | Time filter |
---|---|---|---|
Query OpenStreetMap directly from user interface using Export option |
:heavy_multiplication_x: | only rectangluar bounding box | :heavy_multiplication_x: |
OpenStreetMap API | :heavy_multiplication_x: | only rectangluar bounding box | :heavy_multiplication_x: |
Overpass (read only API) | :heavy_check_mark: | :heavy_check_mark: (rectangular + polygon) | :heavy_check_mark: |
planet/geofabrik/metro extracts | custom script | custom script | custom script |
Obvious choice is Overpass API. In general Overpass is great for:
But before we go ahead, it's necessary to understand limitations to Overpass like:
Geography filter - Start with a rectangular bounding box form map view, that is get the bounds of the map from the current map view on the right pane. Use this bounds to construct a rectangular bbox This should be extended to accomodate any polygon boundary
let bounds = map.getBounds()
let north = bounds['_ne'].lat
let east = bounds['_ne'].lng
let south = bounds['_sw'].lat
let west = bounds['_sw'].lng
let bbox = south + ',' + west + ',' + north + ',' + east
Time filter - Provide two fields to gather start date and end date for the query. Default sets to today's timeframe.
Tag filter - Yet to be implemented
On hitting Fetch Data
, overpass query is constructed on the fly. Eg:
https://www.overpass-api.de/api/interpreter?data=[out:xml][timeout:25];(node (changed:'2018-03-21T18:30:01.000Z','2018-03-22T06:25:14.000Z') (12.227550060708552,76.3482848025194,14.011214271757382,78.9857151974922));(way (changed:'2018-03-21T18:30:01.000Z','2018-03-22T06:25:14.000Z')(12.227550060708552,76.3482848025194,14.011214271757382,78.9857151974922));(rel (changed:'2018-03-21T18:30:01.000Z','2018-03-22T06:25:14.000Z') (12.227550060708552,76.3482848025194,14.011214271757382,78.9857151974922));out body;>;out body qt;
This is sent to the overpass API and the result is obtained in xml
format. Other options include json
and csv
format. Whatever be the format, response data has to be processed further to get geojson
data. From xml
format, data is converted to geojson
using [osmtogeojson](https://github.com/tyrasd/osmtogeojson)
module.
Processed data is separated into three layers(node, way, relation) for map viz using mapbox-gl js and the count for each geometry is shown in the side bar.
relations ways nodes
This layering will change when tag filering comes into play.
View by geometry/feature - Each geometry type has a checkbox next to it. Based on what is checked, layers should display/disappear on the map