From 4e79cd9bc6de55732370e486973e4b91dcadfe54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6sch-Plepelits?= Date: Sun, 18 Nov 2018 14:07:52 +0100 Subject: [PATCH] exportAll: new export type 'OSMXML' --- lang/en.json | 1 + lib/modulekit/form | 2 +- src/exportAll.js | 20 +++++++++++++++++++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/lang/en.json b/lang/en.json index e941c1b2..d85e1e15 100644 --- a/lang/en.json +++ b/lang/en.json @@ -4,6 +4,7 @@ "closed": "closed", "default": "default", "download:geojson": "Download as GeoJSON", + "download:osmxml": "Download as OSMXML", "edit": "edit", "error": { "message": "Error", diff --git a/lib/modulekit/form b/lib/modulekit/form index 8a2d3015..5d39b2f6 160000 --- a/lib/modulekit/form +++ b/lib/modulekit/form @@ -1 +1 @@ -Subproject commit 8a2d3015ec181b14441037a79e7db3869453b135 +Subproject commit 5d39b2f61b7eda9a635414acaeb3c4e0dc524490 diff --git a/src/exportAll.js b/src/exportAll.js index 59b041e8..b5ca998f 100644 --- a/src/exportAll.js +++ b/src/exportAll.js @@ -14,6 +14,15 @@ function prepareDownload (callback) { global.baseCategory.allMapFeatures((err, data) => { let chunks = chunkSplit(data, 1000) + let parentNode + + switch (conf.type) { + case 'geojson': + break + case 'osmxml': + parentNode = document.createElement('osm') + break + } async.mapLimit( chunks, @@ -25,6 +34,9 @@ function prepareDownload (callback) { case 'geojson': done(null, ob.object.GeoJSON(conf)) break + case 'osmxml': + ob.object.exportOSMXML(conf, parentNode, done) + break default: done('wrong type') } @@ -49,6 +61,11 @@ function prepareDownload (callback) { fileType = 'application/json' extension = 'geojson' break + case 'osmxml': + result = '' + parentNode.innerHTML + '' + fileType = 'application/xml' + extension = 'osm.xml' + break } var blob = new Blob([ result ], { type: fileType + ';charset=utf-8' }) @@ -74,7 +91,8 @@ register_hook('init', function () { name: 'Type', type: 'radio', values: { - geojson: lang('download:geojson') + geojson: lang('download:geojson'), + osmxml: lang('download:osmxml') }, default: 'geojson' }