Browse Source

Revert "Loader: support json files where multiline strings are split as string-arrays"

This reverts commit 7255e20eee.

This change has some problems ... working on a better solution.
master
Stephan Bösch-Plepelits 7 years ago
parent
commit
0cec6f6ff5
  1. 2
      src/OpenStreetBrowserLoader.js
  2. 31
      src/json-multiline-strings.js

2
src/OpenStreetBrowserLoader.js

@ -1,5 +1,4 @@
var OverpassLayer = require('overpass-layer')
var jsonMultilineStrings = require('./json-multiline-strings')
function OpenStreetBrowserLoader () {
this.types = {}
@ -32,7 +31,6 @@ OpenStreetBrowserLoader.prototype.getCategory = function (id, callback) {
}
var data = JSON.parse(req.responseText)
data = jsonMultilineStrings.join(data)
this.getCategoryFromData(id, data, function (err, category) {
if (category) {

31
src/json-multiline-strings.js

@ -1,31 +0,0 @@
function isStringArray (arr) {
if (!Array.isArray(arr)) {
return false
}
var nonStringElements = arr.filter(function (x) {
return typeof x !== 'string'
})
if (nonStringElements.length) {
return false
}
return true
}
function join (data) {
for (var k in data) {
if (isStringArray(data[k])) {
data[k] = data[k].join('\n')
} else if (typeof data[k] === 'object') {
data[k] = join(data[k])
}
}
return data
}
module.exports = {
join: join
}
Loading…
Cancel
Save