aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Engel <mark.c.engel@gmail.com>2011-01-21 16:30:44 +0100
committerMark Engel <mark.c.engel@gmail.com>2011-01-21 16:30:44 +0100
commit42712e80a4444805c8dd3136c40ef891bb638e25 (patch)
treebff974a8a879abb32bb6e944a377842742d743d8
parentc5f5b0ddbbf17525976bf16c02e7ebd6bb0373c5 (diff)
downloadosm-xapi-42712e80a4444805c8dd3136c40ef891bb638e25.tar.gz
osm-xapi-42712e80a4444805c8dd3136c40ef891bb638e25.tar.xz
osm-xapi-42712e80a4444805c8dd3136c40ef891bb638e25.zip
refactored creation of rows to xml into own function
-rw-r--r--src/nodejs/no1.js38
1 files changed, 21 insertions, 17 deletions
diff --git a/src/nodejs/no1.js b/src/nodejs/no1.js
index 1b71766..79d50f5 100644
--- a/src/nodejs/no1.js
+++ b/src/nodejs/no1.js
@@ -103,28 +103,32 @@ function nodeBboxHandler(req, res, key, value, left, bottom, right, top) {
res.write("<xml>");
}
- console.log(row);
-
- var node = builder.begin('node')
- .att('id', row.id)
- .att('timetamp', 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<temp.length;x=x+2)
- node.ele('tag')
- .att('k',escape(temp[x]))
- .att('v',escape(temp[x+1]));
- }
+
- res.write(builder.toString({ pretty: true }));
+ res.write(createXmlFromRow(row));
});
});
}
+function createXmlFromRow(row) {
+ console.log(row);
+ var node = builder.begin('node')
+ .att('id', row.id)
+ .att('timetamp', 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<temp.length;x=x+2)
+ node.ele('tag')
+ .att('k',escape(temp[x]))
+ .att('v',escape(temp[x+1]));
+ }
+ return builder.toString({ pretty: true });
+}
+
function wayWorldHandler(req, res, key, value) {
res.writeHead(200, {'Content-Type': 'text/plain'});
}