Fix stats tests by summarizing integer distances
This commit is contained in:
parent
7c8c71a3de
commit
025eb02a6a
4 changed files with 14 additions and 4 deletions
|
|
@ -109,8 +109,17 @@ btools = {};
|
||||||
btools.util.CheapRuler.__static_initialize();
|
btools.util.CheapRuler.__static_initialize();
|
||||||
|
|
||||||
btools.util.CheapRuler.toIntegerLngLat = (coordinate) => {
|
btools.util.CheapRuler.toIntegerLngLat = (coordinate) => {
|
||||||
const ilon = (coordinate[0] + 180) * 1e6;
|
const ilon = Math.round((coordinate[0] + 180) * 1e6);
|
||||||
const ilat = (coordinate[1] + 90) * 1e6;
|
const ilat = Math.round((coordinate[1] + 90) * 1e6);
|
||||||
|
|
||||||
return [ilon, ilat];
|
return [ilon, ilat];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
btools.util.CheapRuler.calcDistance = (ilon1, ilat1, ilon2, ilat2) => {
|
||||||
|
const distanceFloat = btools.util.CheapRuler.distance(ilon1, ilat1, ilon2, ilat2);
|
||||||
|
|
||||||
|
// Convert to integer (no decimals) values to match BRouter OsmPathElement.calcDistance:
|
||||||
|
// `(int)(CheapRuler.distance(ilon, ilat, p.getILon(), p.getILat()) + 1.0 );`
|
||||||
|
// https://github.com/abrensch/brouter/blob/1640bafa800f8bab7aebde797edc99fdbeea3b07/brouter-core/src/main/java/btools/router/OsmPathElement.java#L81
|
||||||
|
return Math.trunc(distanceFloat + 1.0);
|
||||||
|
};
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ require('../../js/format/Gpx.js');
|
||||||
|
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
|
||||||
|
// lonlats=8.467712,49.488117;8.470598,49.488849 + turnInstructionMode = 5 (gpsies-style)
|
||||||
const geoJson = require('./data/track.json');
|
const geoJson = require('./data/track.json');
|
||||||
// lonlats=8.467712,49.488117;8.469354,49.488394;8.470556,49.488946;8.469982,49.489176 + turnInstructionMode = 5
|
// lonlats=8.467712,49.488117;8.469354,49.488394;8.470556,49.488946;8.469982,49.489176 + turnInstructionMode = 5
|
||||||
// console log in Export._formatTrack
|
// console log in Export._formatTrack
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ test('total distance', () => {
|
||||||
const [ilon1, ilat1] = btools.util.CheapRuler.toIntegerLngLat(coord1);
|
const [ilon1, ilat1] = btools.util.CheapRuler.toIntegerLngLat(coord1);
|
||||||
const [ilon2, ilat2] = btools.util.CheapRuler.toIntegerLngLat(coord2);
|
const [ilon2, ilat2] = btools.util.CheapRuler.toIntegerLngLat(coord2);
|
||||||
|
|
||||||
const distance = btools.util.CheapRuler.distance(ilon1, ilat1, ilon2, ilat2);
|
const distance = btools.util.CheapRuler.calcDistance(ilon1, ilat1, ilon2, ilat2);
|
||||||
totalDistance += distance;
|
totalDistance += distance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ test('simple track', () => {
|
||||||
const [ilon1, ilat1] = btools.util.CheapRuler.toIntegerLngLat(coord1);
|
const [ilon1, ilat1] = btools.util.CheapRuler.toIntegerLngLat(coord1);
|
||||||
const [ilon2, ilat2] = btools.util.CheapRuler.toIntegerLngLat(coord2);
|
const [ilon2, ilat2] = btools.util.CheapRuler.toIntegerLngLat(coord2);
|
||||||
|
|
||||||
const distance = btools.util.CheapRuler.distance(ilon1, ilat1, ilon2, ilat2);
|
const distance = btools.util.CheapRuler.calcDistance(ilon1, ilat1, ilon2, ilat2);
|
||||||
const deltaHeight = coord2[2] - coord1[2];
|
const deltaHeight = coord2[2] - coord1[2];
|
||||||
|
|
||||||
stdPath.computeKinematic(rc, distance, deltaHeight, true);
|
stdPath.computeKinematic(rc, distance, deltaHeight, true);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue