From a418bea0a669b18e6baeefd6d08d60c83c62ee57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6sch-Plepelits?= Date: Sun, 2 Dec 2018 17:49:01 +0100 Subject: [PATCH] Add 'export to OSM JSON' as additional option --- src/ExportOSMJSON.js | 24 ++++++++++++++++++++++++ src/exportAll.js | 3 ++- 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 src/ExportOSMJSON.js diff --git a/src/ExportOSMJSON.js b/src/ExportOSMJSON.js new file mode 100644 index 00000000..1929c478 --- /dev/null +++ b/src/ExportOSMJSON.js @@ -0,0 +1,24 @@ +class ExportOSMXML { + constructor (conf) { + this.conf = conf + this.elements = {} + } + + each (ob, callback) { + ob.object.exportOSMJSON(this.conf, this.elements, callback) + } + + finish (list) { + return { + content: JSON.stringify({ + version: '0.6', + generator: 'OpenStreetBrowser', + elements: Object.values(this.elements) + }, null, ' '), + fileType: 'application/json', + extension: 'osm.json' + } + } +} + +module.exports = ExportOSMXML diff --git a/src/exportAll.js b/src/exportAll.js index 1900b4af..6e30240a 100644 --- a/src/exportAll.js +++ b/src/exportAll.js @@ -6,7 +6,8 @@ const chunkSplit = require('./chunkSplit') const types = { GeoJSON: require('./ExportGeoJSON'), - OSMXML: require('./ExportOSMXML') + OSMXML: require('./ExportOSMXML'), + OSMJSON: require('./ExportOSMJSON') } let tab