osm-p2p-server
Advanced tools
Comparing version 1.0.1 to 1.0.2
45
index.js
@@ -7,2 +7,3 @@ var routes = require('routes') | ||
var randombytes = require('randombytes') | ||
var toxml = require('osm-p2p-xml') | ||
@@ -59,41 +60,7 @@ module.exports = Router | ||
r.once('error', function (err) { res.end(err + '\n') }) | ||
res.write(h('?xml', { version: '1.0', encoding: 'UTF-8' }, [ | ||
h('osm!', [ | ||
h('bounds/', { | ||
minlat: q[0][0], maxlat: q[0][1], | ||
minlon: q[1][0], maxlon: q[1][1] | ||
}) | ||
]) | ||
])) | ||
r.pipe(through.obj(write, end)).pipe(res) | ||
function write (row, enc, next) { | ||
var children = [] | ||
;(row.refs || []).forEach(function (ref) { | ||
children.push(h('nd/', { ref: ref })) | ||
}) | ||
delete row.refs | ||
Object.keys(row.members || []).forEach(function (ref) { | ||
children.push(h('member/', { | ||
type: 'relation', | ||
ref: ref, | ||
role: '' | ||
})) | ||
}) | ||
delete row.members | ||
Object.keys(row.tags || {}).forEach(function (key) { | ||
children.push(h('tag', { k: key, v: row.tags[key] })) | ||
}) | ||
delete row.tags | ||
var tag = row.type | ||
delete row.type | ||
next(null, h(tag, row, children)) | ||
} | ||
function end (next) { | ||
this.push('</osm>\n') | ||
next() | ||
} | ||
res.setHeader('content-type', 'text/xml; charset=utf-8') | ||
res.setHeader('content-disposition', 'attachment; filename="map.osm"') | ||
res.setHeader('content-encoding', 'identity') | ||
res.setHeader('cache-control', 'no-cache') | ||
r.pipe(toxml(q)).pipe(res) | ||
} | ||
@@ -100,0 +67,0 @@ |
{ | ||
"name": "osm-p2p-server", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "serve osm http endpoints over a p2p db", | ||
@@ -23,2 +23,3 @@ "main": "index.js", | ||
"inherits": "^2.0.1", | ||
"osm-p2p-xml": "^1.0.0", | ||
"randombytes": "^2.0.1", | ||
@@ -25,0 +26,0 @@ "routes": "^2.1.0", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8607
6
163
+ Addedosm-p2p-xml@^1.0.0
+ Addedosm-p2p-xml@1.0.3(transitive)