Pass estimated cost factor to kinematic calc
(only to use different formula > 4.9)
This commit is contained in:
parent
6a19b53dc0
commit
7f481b8db3
2 changed files with 13 additions and 7 deletions
|
|
@ -489,8 +489,9 @@ BR.Routing = L.Routing.extend({
|
|||
return btools.util.CheapRuler.calcDistance(ilon1, ilat1, ilon2, ilat2);
|
||||
},
|
||||
|
||||
_computeKinematic: function (distance, deltaHeight) {
|
||||
_computeKinematic: function (distance, deltaHeight, costFactor) {
|
||||
const rc = new BR.RoutingContext(this.profile);
|
||||
rc.expctxWay = new BR.BExpressionContextWay(undefined, costFactor);
|
||||
const stdPath = new BR.StdPath();
|
||||
|
||||
stdPath.computeKinematic(rc, distance, deltaHeight, true);
|
||||
|
|
@ -498,7 +499,7 @@ BR.Routing = L.Routing.extend({
|
|||
},
|
||||
|
||||
_getCostFactor: function (line) {
|
||||
let costFactor = null;
|
||||
let costFactor;
|
||||
if (line) {
|
||||
const props = line.feature.properties;
|
||||
const length = props['track-length'];
|
||||
|
|
@ -530,7 +531,7 @@ BR.Routing = L.Routing.extend({
|
|||
if (beforeCostFactor != null && afterCostFactor != null) {
|
||||
costFactor = Math.max(beforeCostFactor, afterCostFactor);
|
||||
} else {
|
||||
costFactor = beforeCostFactor ?? afterCostFactor ?? 0;
|
||||
costFactor = beforeCostFactor ?? afterCostFactor;
|
||||
}
|
||||
|
||||
for (const beeline of serialBeelines) {
|
||||
|
|
@ -538,7 +539,7 @@ BR.Routing = L.Routing.extend({
|
|||
const distance = props['track-length'];
|
||||
const deltaHeight = (serialDelta * distance) / serialDistance;
|
||||
|
||||
const stdPath = this._computeKinematic(distance, deltaHeight);
|
||||
const stdPath = this._computeKinematic(distance, deltaHeight, costFactor);
|
||||
props['total-energy'] = stdPath.getTotalEnergy();
|
||||
props['total-time'] = stdPath.getTotalTime();
|
||||
|
||||
|
|
@ -551,7 +552,7 @@ BR.Routing = L.Routing.extend({
|
|||
props['plain-ascend'] = Math.trunc(deltaHeight + 0.5);
|
||||
// do not set interpolated alt value, to explicitly show missing data, e.g. in height graph
|
||||
|
||||
props['cost'] = Math.round(distance * costFactor);
|
||||
props['cost'] = Math.round(distance * (costFactor ?? 0));
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -2,11 +2,15 @@
|
|||
// Calculates time and energy stats
|
||||
|
||||
class BExpressionContextWay {
|
||||
constructor(maxspeed = 45.0, costfactor = 1.0) {
|
||||
this.maxspeed = maxspeed;
|
||||
this.costfactor = costfactor;
|
||||
}
|
||||
getMaxspeed() {
|
||||
return 45.0;
|
||||
return this.maxspeed;
|
||||
}
|
||||
getCostfactor() {
|
||||
return 1.0;
|
||||
return this.costfactor;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -156,4 +160,5 @@
|
|||
|
||||
BR.StdPath = StdPath;
|
||||
BR.RoutingContext = RoutingContext;
|
||||
BR.BExpressionContextWay = BExpressionContextWay;
|
||||
})();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue