Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

osm-p2p-server

Package Overview
Dependencies
Maintainers
4
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

osm-p2p-server - npm Package Compare versions

Comparing version 2.1.2 to 2.1.3

.npmignore

17

api/get_map.js
var collect = require('collect-stream')
var pumpify = require('pumpify')
var mapStream = require('through2-map')
var collectTransform = require('../lib/collect-transform-stream')
var filterForkedElements = require('../lib/filter_forked_elements')
var collectTransform = require('collect-transform-stream')
var defork = require('osm-p2p-defork')

@@ -28,3 +28,3 @@ var refs2nodes = require('../lib/util').refs2nodes

if (!opts.forks) {
pipeline.push(filterForkedElementsStream())
pipeline.push(deforkStream())
}

@@ -44,4 +44,11 @@

function filterForkedElementsStream () {
return collectTransform(filterForkedElements)
function deforkStream () {
return collectTransform(function (res) {
return defork(res).sort(cmpType)
})
}
var typeOrder = { node: 0, way: 1, relation: 2 }
function cmpType (a, b) {
return typeOrder[a.type] - typeOrder[b.type]
}

@@ -5,2 +5,21 @@ # Change Log

## [2.1.3]
### Added
- Added `nyc` for test running, `codecov` for coverage
### Changed
- Upgraded `collect-transform-stream@1.1.1`
- Use TAP v10 + parallel tests
- Removed timeout on tests
### Fixed
- Fixed OSM API upload failing when ways come before nodes ([#31](https://github.com/digidem/osm-p2p-server/issues/31))
## [2.1.2]
### Fixed
- Removed unused dev dependency (was already a regular dep)
## [2.1.1]
### Fixed
- Removed rogue `console.log`
## [2.1.0]

@@ -7,0 +26,0 @@ ### Added

@@ -19,2 +19,5 @@ var util = require('../lib/util')

var dupIds = []
// First pass to generate ids for the elements that are created.
// This ensures that by the second pass we have all the ids generated
// to replace them in the way's nodes.
var changesWithIds = changes.map(function (change) {

@@ -31,4 +34,9 @@ var mapped = Object.assign({}, change)

}
return mapped
})
// Second pass. Handle id replacement.
.map(function (change) {
// no need to Object.assign() here because we have already cloned and can mutate
if (change.type === 'way' && change.nodes) {
mapped.nodes = change.nodes.map(function (ref) {
change.nodes = change.nodes.map(function (ref) {
return idMap.node[ref] || ref

@@ -38,3 +46,3 @@ })

if (change.type === 'relation' && change.members) {
mapped.members = change.members.map(function (member) {
change.members = change.members.map(function (member) {
if (!idMap[member.type][member.ref]) return Object.assign({}, member)

@@ -44,3 +52,3 @@ return Object.assign({}, member, {ref: idMap[member.type][member.ref]})

}
return mapped
return change
})

@@ -47,0 +55,0 @@ if (dupIds.length) {

{
"name": "osm-p2p-server",
"version": "2.1.2",
"version": "2.1.3",
"description": "Peer-to-peer OpenStreetMap API v0.6 Server",

@@ -20,3 +20,7 @@ "main": "index.js",

],
"author": "substack",
"author": [
"substack",
"gmaclennan",
"noffle"
],
"contributors": [

@@ -34,2 +38,3 @@ {

"collect-stream": "^1.1.1",
"collect-transform-stream": "0.0.2",
"content-type": "^1.0.2",

@@ -42,2 +47,3 @@ "debug": "^2.2.0",

"once": "^1.3.3",
"osm-p2p-defork": "^1.0.0",
"osm2json": "^2.1.0",

@@ -56,2 +62,3 @@ "pumpify": "^1.3.5",

"devDependencies": {
"codecov": "^1.0.1",
"concat-stream": "^1.6.0",

@@ -64,2 +71,3 @@ "express": "^4.14.0",

"memdb": "^1.3.1",
"nyc": "^10.1.2",
"osm-p2p": "^1.4.0",

@@ -69,2 +77,3 @@ "osm-p2p-db": "^3.9.1",

"standard": "^8.0.0",
"tap": "^10.1.0",
"tape": "^4.4.0",

@@ -77,3 +86,4 @@ "xml-parser": "^1.2.1"

"scripts": {
"test": "tape 'test/**/*.js'",
"test": "nyc tap --no-timeout -j4 'test/**/*.js'",
"coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov",
"lint": "standard"

@@ -80,0 +90,0 @@ },

@@ -360,18 +360,36 @@ var test = require('tape')

function step9 (done) {
var opts = {
hostname: 'localhost',
port: url.parse(osmServer.base).port,
path: '/api/0.6/map?bbox=-90,-90,90,90',
headers: {
'Accept': 'application/json'
function query (forks, done) {
var opts = {
hostname: 'localhost',
port: url.parse(osmServer.base).port,
path: '/api/0.6/map?bbox=-90,-90,90,90' + (forks ? '&forks=true' : ''),
headers: {
'Accept': 'application/json'
}
}
http.get(opts, function (res) {
res.pipe(concat(function (json) {
done(null, json)
}))
})
}
http.get(opts, function (res) {
res.pipe(concat(function (json) {
var data = JSON.parse(json)
var nodeIds = data.elements
.filter(function (elm) { return elm.type === 'node' })
.map(function (elm) { return elm.id })
var ways = data.elements.filter(function (elm) { return elm.type === 'way' })
query(false, function (_, json) {
var data = JSON.parse(json)
var nodeIds = data.elements
.filter(function (elm) { return elm.type === 'node' })
.map(function (elm) { return elm.id })
var ways = data.elements.filter(function (elm) { return elm.type === 'way' })
// TODO(noffle): Test for a failure, and if so, dump lots of debug
// information so we can try and track down this bug
// (https://github.com/digidem/osm-p2p-server/issues/28)
if (nodeIds.length !== 2) {
console.error('ERROR -- show @noffle this output!')
query(true, function (_, json) {
console.error(json.toString())
osmServer.server.cleanup(done)
})
} else {
// Ensure the way present matches the deleted fork, and the extra node

@@ -384,3 +402,3 @@ // is not returned.

osmServer.server.cleanup(done)
}))
}
})

@@ -387,0 +405,0 @@ }

@@ -80,1 +80,25 @@ var test = require('tape')

})
test('replacePlaceholderIds: input order', t => {
var input = [
{action: 'create', type: 'way', id: 'A', nodes: ['A', 'B']},
{action: 'modify', type: 'way', id: 'B', nodes: ['A', 'X']},
{action: 'create', type: 'node', id: 'A'},
{action: 'create', type: 'node', id: 'B'}
]
replacePlaceholderIds(input, function (err, result) {
t.error(err)
var nodeA = result[2]
var nodeB = result[3]
t.notEqual(nodeA.id, input[2].id, 'id replaced')
t.notEqual(nodeB.id, input[3].id, 'id replaced')
// Ids should be replaced for way nodes.
var wayA = result[0]
var wayB = result[1]
t.notEqual(wayA.nodes[0], 'A', 'way node id replaced')
t.notEqual(wayA.nodes[1], 'B', 'way node id replaced')
t.notEqual(wayB.nodes[0], 'A', 'way node id replaced')
t.equal(wayB.nodes[1], 'X', 'way node id replaced')
t.end()
})
})

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc