Skip to content

Commit

Permalink
Merge pull request #19
Browse files Browse the repository at this point in the history
minor corrections Duration Function
  • Loading branch information
mg4gh committed Apr 19, 2024
2 parents d9e27ae + b660214 commit 8c1e966
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public CostCalculatorMTB(WayAttributs wayTagEval, CostCalculatorTwoPieceFunc pro
short surfaceCat = TagEval.getSurfaceCat(wayTagEval);
// surfaceCat = ( surfaceCat == 0) ? 4: surfaceCat;
if (TagEval.getNoAccess(wayTagEval)) {
mfud = 4;
mfdd = 4;
mfud = 10;
mfdd = 10;
surfaceCat = 4;
} else {
if (wayTagEval.mtbScaleUp != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,26 +42,34 @@ public CubicSpline getDurationSplineFunction(short klevel, short slevel, short s
double[] slopes ;
double[] durations;
if (bicType > 0) {
slopes = new double[]{-0.4, -0.2, -0.05, 0, 0.05, 0.1, 0.7};
slopes = new double[]{-0.4, -0.2, -0.05, 0, 0.05, 0.10, 0.24,0.6};
durations = new double[slopes.length];
double watt;
double ACw;
double Cr;
double fd;
double fdown;
double fr;
double f1u;
double f2u;
if (bicType == 1){
watt = 80 + 40*klevel;
watt = 90 + 35*klevel;
ACw = 0.4 + surfaceLevel * 0.05 ;
// fd = Math.exp(-(slevel-2)*Math.log(Math.sqrt(2.0)))/1.6;
fd = 1.104 - slevel/4.53;
// fd = 1.104 - slevel/4.53;
fd = 1.1 - slevel/4.55;
if (surfaceLevel <= 3){
Cr = 0.005 + 0.004*surfaceLevel;
Cr = 0.004 + 0.001*surfaceLevel;
} else {
Cr = 0.015 + 0.015*fd + 0.01*(surfaceLevel - 4);
}
// Cr = 0.004 + 0.002*surfaceLevel;
fr = 1.1 - fd * (0.5+surfaceLevel/20.0);
f1u = 1.0 + 0.5*surfaceLevel*surfaceLevel/16.0;
f2u = 1.2 + 1.4*surfaceLevel*surfaceLevel/16.0;
fdown = fd*(3.5+surfaceLevel*0.6);
slopes[5] = 0.07+0.015*klevel;
slopes[6] = 0.24+0.02*klevel;
} else { //if (bicType ==3) {
watt = 130;
if (surfaceLevel <= 2) {
Expand All @@ -75,14 +83,18 @@ public CubicSpline getDurationSplineFunction(short klevel, short slevel, short s
fr = 0.6;
fdown = 3.5 + (surfaceLevel - 2);
}
f1u = 1.2;
f2u = 2.5;
}
double m = 90;
durations[0] = (-slopes[0]-0.075)*fdown;
durations[1] = (-slopes[1]-0.075)*fdown;
durations[2] = 1 / (getFrictionBasedVelocity(slopes[2], watt, Cr, ACw, m) * fr);
for (int i = 3; i < slopes.length; i++) {
for (int i = 3; i < slopes.length - 2; i++) {
durations[i] = 1 / getFrictionBasedVelocity(slopes[i], watt, Cr, ACw, m);
}
durations[6] = f1u / getFrictionBasedVelocity(slopes[6], watt, Cr, ACw, m) ;
durations[7] = f2u / getFrictionBasedVelocity(slopes[7], watt, Cr, ACw, m) ;
} else { // bicType == 0 -> hiking
double fu = 9.0;
double fd = 10.5;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@ public class TagEval {
private TagEval(){}

protected static boolean getNoAccess(WayAttributs wayTagEval) {
return wayTagEval.highway == null || ("private".equals(wayTagEval.bicycle) || (("private".equals(wayTagEval.access) ||
"acc_no".equals(wayTagEval.access)) && !("bic_yes".equals(wayTagEval.bicycle) ||
"bic_designated".equals(wayTagEval.bicycle) || "bic_permissive".equals(wayTagEval.bicycle) ||
"lcn".equals(wayTagEval.network) || "rcn".equals(wayTagEval.network) || "icn".equals(wayTagEval.network) ||
wayTagEval.mtbScaleUp != null || wayTagEval.mtbScale != null)) ||
"motorway".equals(wayTagEval.highway) || "trunk".equals(wayTagEval.highway));
return wayTagEval.highway == null ||
"motorway".equals(wayTagEval.highway) || "trunk".equals(wayTagEval.highway) ||
"private".equals(wayTagEval.bicycle) ||
( ( "private".equals(wayTagEval.access) || "acc_no".equals(wayTagEval.access) ) &&
!( "bic_yes".equals(wayTagEval.bicycle) || "bic_designated".equals(wayTagEval.bicycle) ||
"bic_permissive".equals(wayTagEval.bicycle) || "lcn".equals(wayTagEval.network) ||
"rcn".equals(wayTagEval.network) || "icn".equals(wayTagEval.network) ||
wayTagEval.mtbScaleUp != null || wayTagEval.mtbScale != null
)
);
}

protected static short getSurfaceCat(WayAttributs wayTagEval){
Expand Down

0 comments on commit 8c1e966

Please sign in to comment.