-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not combine a segregated edge with a roundabout (#5040)
* Do not combine a segregated edge with a roundabout, add test
- Loading branch information
1 parent
020c0d1
commit 2e38d3c
Showing
4 changed files
with
113 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/********************************* | ||
* Takes an XML `.osm` file and converts it into a cucumber scenario definition like | ||
* Given the node locations | ||
* | node | lon | lat | | ||
* ..... | ||
* Given the ways | ||
* | nodes | tag1 | tag2 | tag3 | | ||
* ..... | ||
* | ||
* Note that cucumber tests are limited to 26 nodes (labelled a-z), so | ||
* you'll need to use pretty small OSM extracts to get this to work. | ||
*****************************************/ | ||
var fs = require('fs'); | ||
var parseString = require('xml2js').parseString; | ||
|
||
var data = fs.readFileSync('filename.osm', 'utf8'); | ||
|
||
const items = parseString(data, (err, result) => { | ||
var idmap = {}; | ||
|
||
console.log('Given the node locations'); | ||
console.log(' | node | lon | lat |'); | ||
result.osm.node.filter(n => !n.$.action || n.$.action !== 'delete').forEach(i => { | ||
var code = String.fromCharCode(97 + Object.keys(idmap).length) | ||
idmap[i.$.id] = code; | ||
console.log(` | ${code} | ${i.$.lon} | ${i.$.lat} |`); | ||
}); | ||
|
||
var allkeys = {}; | ||
var waytags = {}; | ||
|
||
result.osm.way.filter(n => !n.$.action || n.$.action !== 'delete').forEach(w => { | ||
if (!waytags[w.$.id]) waytags[w.$.id] = {}; | ||
w.tag.forEach(t => { allkeys[t.$.k] = t.$.v; waytags[w.$.id][t.$.k] = t.$.v; }); | ||
}); | ||
|
||
console.log('And the ways'); | ||
console.log(` | nodes | ${Object.keys(allkeys).join(' | ')} |`); | ||
|
||
result.osm.way.filter(n => !n.$.action || n.$.action !== 'delete').forEach(w => { | ||
console.log(` | ${w.nd.map(n => idmap[n.$.ref]).join('')} | ${Object.keys(allkeys).map(k => waytags[w.$.id][k] || '').join(' | ')} |`); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters