diff options
Diffstat (limited to 'src/nodejs/xmlGenerator.js')
-rw-r--r-- | src/nodejs/xmlGenerator.js | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/src/nodejs/xmlGenerator.js b/src/nodejs/xmlGenerator.js index a477457..6ba0191 100644 --- a/src/nodejs/xmlGenerator.js +++ b/src/nodejs/xmlGenerator.js @@ -30,23 +30,24 @@ exports.createNode = function (node) { // FIXME: make this shit working exports.createWay = function (row) { - var way = builder.begin('way') + var xmlWay = builder.begin('way') .att('id', row.id) - .att('timestamp', toISO8601(row.tstamp)) + .att('timestamp', row.timestamp) .att('version', row.version) - .att('changeset', row.changeset_id); - if(row.tags != '{}') { - temp = row.tags.replace("{","").replace("}","").split(","); - for(var x=0;x<temp.length;x=x+2){ - way.ele('tag') - .att('k',escape(temp[x])) - .att('v',escape(temp[x+1])); - } - } - temp = row.nodes.replace("{","").replace("}","").split(","); - for(var i=0;i<temp.length;i++) { - way.ele('nd').att('ref',temp[i]); + .att('changeset', row.changeset); + + if(row.tags) { + row.tags.forEach(function(tuple){ + xmlWay.ele('tag') + .att('k',escape(tuple.key)) + .att('v',escape(tuple.value)); + }); } + + //temp = row.nodes.replace("{","").replace("}","").split(","); + //for(var i=0;i<temp.length;i++) { + // way.ele('nd').att('ref',temp[i]); + //} return builder.toString({pretty:'true'}); }; |