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:

<script src='https://github.com/mmmatthew/open2json/dist/open2json.min.js'></script>

You can then obtain data asynchronously:

<script>

    // create provider
    let provider = new open2json.Provider();

    // perform query (on osm and wikidata simultaneously. results are conflated to gether.)
    // calling without arguments uses default options and a bounding box for Basel, Switzerland
    provider.query()
    .then(data => {
        // do something with the data (it is a geojson)
    })
    .catch(error => {
        // if an error occurs you can do something with it here.
    })

</script>

Using open2json via npm install

> npm install --save open2json

You can then use open2json in your code:

var open2json = require('open2json');

// define options to use everywhere
var options = {};

let provider = new open2json.Provider(options); // etc.

Options

The query function takes an optional options argument with the following default values:

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 = require('open2json')

var bbox = {
    lonMin: 8.53,
    latMin: 47.37,
    lonMax: 8.55,
    latMax: 47.38
};

var options = {
    overpassTagFilters: [
    'drinking_water=yes'
  ]
};

var standardWikiGeoJson, standardOsmGeoJson;

// just get data from wikidata without any processing
open2json.queryWikidata(bbox, options).then(wikidataJson => {
    // standardize a typical Wikidata response
    standardWikiGeoJson = open2json.standardizeWikidata(wikidataJson);
})

// just get data from Osm without any processing
open2json.queryOsm(bbox, options).then(OsmJson => {
    // standardize a typical Osm response
    standardOsmGeoJson = open2json.standardizeOsm(OsmJson);
})

// conflate two standardized geojsons. This can only be run once both GeoJsons have been loaded
var conflated = open2json.conflate(standardOsmGeoJson, standardWikiGeoJson);

Read the docs

Find the docs here: link

For contributors

Build open2json

Other commands