From 1a37a20fd94a60ce686a6f1e11534b504b2e2308 Mon Sep 17 00:00:00 2001 From: slomo Date: Sat, 22 Jan 2011 13:31:32 +0100 Subject: the xml output works now --- src/nodejs/xmlGenerator.js | 53 ++++++++++++++-------------------------------- 1 file changed, 16 insertions(+), 37 deletions(-) (limited to 'src/nodejs/xmlGenerator.js') diff --git a/src/nodejs/xmlGenerator.js b/src/nodejs/xmlGenerator.js index 08ea833..921056d 100644 --- a/src/nodejs/xmlGenerator.js +++ b/src/nodejs/xmlGenerator.js @@ -8,50 +8,29 @@ var log4js = require('log4js')(); //note the need to call the function var log = log4js.getLogger('xmlGenerator'); log.setLevel(config.logLevel); -function toISO8601(date) { - //2007-03-31T00:09:22+01:00 - var pad_two = function(n) { - return (n < 10 ? '0' : '') + n; - }; +exports.createNode = function (node) { + log.debug(node); + var xmlNode = builder.begin('node') + .att('id', node.id) + .att('timestamp', node.timestamp) + .att('version', node.version) + .att('changeset', node.changeset) + .att('lat', node.lat) + .att('lon', node.lon); - return [ - date.getUTCFullYear(), - '-', - pad_two(date.getUTCMonth() + 1), - '-', - pad_two(date.getUTCDate()), - 'T', - pad_two(date.getUTCHours()), - ':', - pad_two(date.getUTCMinutes()), - ':', - pad_two(date.getUTCSeconds()), - '+01:00' //FIX ME - ].join(''); -} - -exports.createNode = function (row) { - log.debug(row); - var node = builder.begin('node') - .att('id', row.id) - .att('timestamp', toISO8601(row.tstamp)) - .att('version', row.version) - .att('changeset', row.changeset_id) - .att('lat', row.lat) - .att('lon', row.lon); - if(row.tags != '{}') { - var temp = row.tags.replace("{","").replace("}","").split(","); - for(var x=0;x