Collect and merge drinking fountains from wikidata and OpenStreetMap
A working version of the code can be found here: link
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>
> 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.
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
}
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);
Find the docs here: link
query
method of Provider: linknpm install
in the command linenpm 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 the dist/docs
directory.npm run test
npm version [patch | minor | major]
npm run publish
Generated using TypeDoc