Filter out slight/sharp modifiers, and fix stateful XML parsing bug.
This commit is contained in:
parent
e5b4a14dfd
commit
ce995454c6
@ -12,9 +12,6 @@ const errorReason = require('../lib/utils').errorReason;
|
||||
|
||||
const child_process = require('child_process');
|
||||
|
||||
const osmtogeojson = require('osmtogeojson');
|
||||
const osmxmltojson = require('osmtogeojson/parse_osmxml');
|
||||
|
||||
module.exports = function () {
|
||||
this.setGridSize = (meters) => {
|
||||
// the constant is calculated (with BigDecimal as: 1.0/(DEG_TO_RAD*EARTH_RADIUS_IN_METERS
|
||||
@ -176,11 +173,14 @@ module.exports = function () {
|
||||
var q = d3.queue(1);
|
||||
|
||||
q.defer(fs.writeFile, this.scenarioCacheFile, xml);
|
||||
q.defer((cb) => {
|
||||
q.defer((xml, cb) => {
|
||||
delete require.cache[require.resolve('osmtogeojson/parse_osmxml')];
|
||||
var osmtogeojson = require('osmtogeojson');
|
||||
var osmxmltojson = require('osmtogeojson/parse_osmxml');
|
||||
var json = osmxmltojson.parseFromString(xml);
|
||||
var geojson = osmtogeojson(json);
|
||||
fs.writeFile(`${this.scenarioCacheFile}.geojson`,JSON.stringify(geojson),cb);
|
||||
});
|
||||
fs.writeFile(`${this.scenarioCacheFile}.geojson`, JSON.stringify(geojson), cb);
|
||||
}, xml);
|
||||
|
||||
var params = ['cat',this.scenarioCacheFile,'-O','-o',this.scenarioCacheFilePBF, '--no-progress'];
|
||||
q.defer(child_process.execFile,'/usr/local/bin/osmium', params, {maxBuffer: 1024 * 1024 * 1000, env: {}});
|
||||
|
||||
15
package-lock.json
generated
15
package-lock.json
generated
@ -13062,6 +13062,21 @@
|
||||
"lodash": "4.17.4"
|
||||
}
|
||||
},
|
||||
"xmldoc": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/xmldoc/-/xmldoc-1.1.0.tgz",
|
||||
"integrity": "sha1-JckvCPJj80TayNCzI3CnAe6dDpM=",
|
||||
"requires": {
|
||||
"sax": "1.2.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"sax": {
|
||||
"version": "1.2.4",
|
||||
"resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz",
|
||||
"integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"xmldom": {
|
||||
"version": "0.1.27",
|
||||
"resolved": "https://registry.npmjs.org/xmldom/-/xmldom-0.1.27.tgz",
|
||||
|
||||
@ -12,6 +12,7 @@
|
||||
"node-pre-gyp": "^0.6.36",
|
||||
"osmtogeojson": "^3.0.0-beta.3"
|
||||
"rimraf": "^2.5.4"
|
||||
"xmldoc": "^1.1.0"
|
||||
},
|
||||
"browserify": {
|
||||
"transform": [
|
||||
|
||||
@ -73,6 +73,22 @@ var stylesheet = `
|
||||
<TextSymbolizer face-name="Arial Regular" size="10" fill="black" placement="line" allow-overlap="false" dy='8'>'highway=' + [highway]</TextSymbolizer>
|
||||
</Rule>
|
||||
|
||||
<Rule>
|
||||
<Filter>[highway] = 'secondary' or [highway] = 'secondary_link' or [highway] = 'tertiary' or [highway] = 'tertiary_link' or [highway] = 'residential' or [highway] = 'service' or [highway] = 'living_street'</Filter>
|
||||
<LineSymbolizer stroke-width="10" stroke-linejoin="round" stroke-linecap="round" stroke="#bbbbbb" />
|
||||
<LineSymbolizer stroke-width="8" stroke-linejoin="round" stroke-linecap="round" stroke="#77bb77" />
|
||||
<TextSymbolizer face-name="Arial Regular" size="10" fill="black" placement="line" allow-overlap="false" dy='-8'>'name=' + [name]</TextSymbolizer>
|
||||
<TextSymbolizer face-name="Arial Regular" size="10" fill="black" placement="line" allow-overlap="false" dy='8'>'highway=' + [highway]</TextSymbolizer>
|
||||
</Rule>
|
||||
|
||||
<Rule>
|
||||
<Filter>[route] = 'ferry'</Filter>
|
||||
<LineSymbolizer stroke-width="10" stroke-linejoin="round" stroke-linecap="round" stroke="#bbbbbb" />
|
||||
<LineSymbolizer stroke-width="8" stroke-linejoin="round" stroke-linecap="round" stroke="#7777bb" />
|
||||
<TextSymbolizer face-name="Arial Regular" size="10" fill="black" placement="line" allow-overlap="false" dy='-8'>'name=' + [name]</TextSymbolizer>
|
||||
<TextSymbolizer face-name="Arial Regular" size="10" fill="black" placement="line" allow-overlap="false" dy='8'>'route=' + [route]</TextSymbolizer>
|
||||
</Rule>
|
||||
|
||||
</Style>
|
||||
|
||||
<Layer name="testmap" srs="+init=epsg:4326">
|
||||
@ -136,18 +152,24 @@ find('test/cache').filter((f) => f.match(/[0-9]+_results.json$/)).forEach((f) =>
|
||||
|
||||
var results = JSON.parse(fs.readFileSync(f));
|
||||
|
||||
|
||||
|
||||
// Generate map image
|
||||
|
||||
var imagefile = `${files[1]}_${files[2]}`.replace(/\//g,'_');
|
||||
|
||||
var imagefile = `${files[1]}_${files[2]}.png`.replace(/\//g,'_');
|
||||
/*
|
||||
var png = makemappng(`${files[1]}.geojson`, `${files[1]}_${files[2]}_shape.geojson`, (png) => {
|
||||
fs.writeFileSync(`report/${imagefile}`,png);
|
||||
});
|
||||
*/
|
||||
|
||||
toc.push({ title: `${results.feature} - ${results.scenario}`, link: imagefile });
|
||||
|
||||
if (typeof results.got.turns === 'object')
|
||||
results.got.turns = results.got.turns.join(',');
|
||||
|
||||
if (typeof results.expected.turns === 'string')
|
||||
results.expected.turns = results.expected.turns.replace(/slight /g,'').replace(/sharp /g, '');
|
||||
if (typeof results.got.turns === 'string')
|
||||
results.got.turns = results.got.turns.replace(/slight /g,'').replace(/sharp /g, '');
|
||||
|
||||
report += `<div class='scenario ${results.got.turns == results.expected.turns ? 'ok' : 'error'}'>
|
||||
<h2><a name="${imagefile}">${results.feature} - ${results.scenario}</a></h2>
|
||||
<table class="row">
|
||||
@ -158,8 +180,8 @@ find('test/cache').filter((f) => f.match(/[0-9]+_results.json$/)).forEach((f) =>
|
||||
<td>
|
||||
<table class="results">
|
||||
<tr><th/><th style='text-align: left'>Route</th><th style='text-align: left'>Turns</th></tr>
|
||||
<tr><th style='text-align: right'>Expected</th><td>${results.expected.route}</td><td>${results.expected.turns}</td></tr>
|
||||
<tr><th style='text-align: right'>Got</th><td>${results.got.route}</td><td class='${results.got.turns == results.expected.turns ? 'ok' : 'error'}'>${results.got.turns}</td></tr>
|
||||
<tr><th style='text-align: right'>OSRM</th><td>${results.expected.route}</td><td>${results.expected.turns}</td></tr>
|
||||
<tr><th style='text-align: right'>Valhalla</th><td>${results.got.route}</td><td class='${results.got.turns == results.expected.turns ? 'ok' : 'error'}'>${results.got.turns}</td></tr>
|
||||
</table>
|
||||
</td></tr></table>
|
||||
</div>
|
||||
@ -182,6 +204,8 @@ console.log(`
|
||||
.error { color: red; }
|
||||
</style>
|
||||
<body>
|
||||
Notes: OSRM "slight" and "sharp" indicators have been removed for comparison purposes.
|
||||
<hr/>
|
||||
`);
|
||||
toc.forEach(r => {
|
||||
console.log(`<a href='#${r.link}'>${r.title}</a><br/>`);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user