open2json
Collect and merge drinking fountains from wikidata and OpenStreetMap
Demo
A working version of the code can be found here: link
Using open2json in a front-end project
If your code runs in the browser without transpiling, then include the prepackaged code in your HTML head:
You can then obtain data asynchronously:
Using open2json via npm install
> npm install --save open2json
You can then use open2json in your code:
var open2json = ; // define options to use everywherevar options = {}; let provider = options; // etc.
Options
The query function takes an optional options
argument with the following default values:
- overpassTagFilters (array of strings): Array of tag filters for querying OSM as defined here.
- overpassUrl (string): Url root for overpass. There are several defined here
- overpassTimeout (number): Number of seconds before overpass query should time out.
- wdLangs (string): List of language codes to be used for obtaining object label from Wikidata, in order of preference.
- wdEntityClasses (array of strings): Array of Wikidata entity IDs for filtering results
- wdImageWidth (integer): width of image for which a url is to be provided
- conflateRadius (integer): Wikidata objects are matched with the closest OpenStreetMap object that is within this distance (in meters)
The default values for these options are defined as follows:
const defaultOptions = overpassTagFilters: 'amenity=drinking_water' 'drinking_water=yes' overpassUrl: 'https://z.overpass-api.de/api/interpreter' wdLangs: 'en,de,fr,it,es' wdEntityClasses: 'Q1630622' // drinking water fountain (Q1630622) 'Q483453' // fountain (Q483453) 'Q43483' // water well (Q43483) wdImageWidth: 350 // width in pixels of image to return (just url) conflateRadius: 10 // search radius for fountains, in meters
Using unit functions
var open2json = var bbox = lonMin: 853 latMin: 4737 lonMax: 855 latMax: 4738; var options = overpassTagFilters: 'drinking_water=yes' ; var standardWikiGeoJson standardOsmGeoJson; // just get data from wikidata without any processingopen2json // just get data from Osm without any processingopen2json // conflate two standardized geojsons. This can only be run once both GeoJsons have been loadedvar conflated = open2json;
Read the docs
Find the docs here: link
- query OpenStreetMap: link
- query Wikidata: link
- standardize OpenStreetMap: link
- standardize Wikidata: link
- conflate: link
- do everything at once with the
query
method of Provider: link
For contributors
Build open2json
- install NodeJS
- clone this repo
- in the directory that the code was cloned into, run
npm install
in the command line - to build the module, run
npm run build
. This transpiles the TypeScript to Javascript (output into/lib
directory) and packages the module for loading into a module (output into/dist/webpack
directory). Additionally, the documentation is generated in thedist/docs
directory.
Other commands
- test the code: run
npm run test
- increment the package version: run
npm version [patch | minor | major]
- publish to npm: run
npm run publish