Skip to content

Commit

Permalink
JIBE walk stress update
Browse files Browse the repository at this point in the history
  • Loading branch information
CorinStaves committed Dec 7, 2023
1 parent 8671193 commit 8327633
Showing 1 changed file with 5 additions and 42 deletions.
47 changes: 5 additions & 42 deletions src/main/java/routing/disutility/components/LinkStress.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,16 @@
public class LinkStress {

public static double getStress(Link link, String mode) {
if(mode.equals("walk")) {
return getWalkStress(link);
} else if (mode.equals("bike")) {
return getCycleStress(link);
} else {
throw new RuntimeException("unknown mode " + mode);
}
}

private static double getCycleStress(Link link) {

if(!link.getAllowedModes().contains("bike")) {
if(!mode.equals("walk") && !mode.equals("bike")) {
throw new RuntimeException("unknown mode " + mode);
} else if(!link.getAllowedModes().contains(mode)) {
return Double.NaN;
} else {
double stress = 0;
if((boolean) link.getAttributes().getAttribute("allowsCar")) {
String junction = (String) link.getAttributes().getAttribute("junction");
if (junction.equals("roundabout") || junction.equals("circular")) {
if (mode.equals("bike") && (junction.equals("roundabout") || junction.equals("circular"))) {
stress = 1.;
} else {
double speedLimit = ((Integer) link.getAttributes().getAttribute("speedLimitMPH")).doubleValue();
Expand All @@ -45,7 +37,7 @@ private static double getCycleStress(Link link) {
intercept = 0;
speedFactor = 0;
aadtFactor = 0;
} else if(protection.equals(PROTECTED)) {
} else if(mode.equals("walk") || protection.equals(PROTECTED)) {
intercept = -1.5;
speedFactor = 0.05;
aadtFactor = 0;
Expand Down Expand Up @@ -74,35 +66,6 @@ private static double getCycleStress(Link link) {
}
}

private static double getWalkStress(Link link) {

if(!link.getAllowedModes().contains("walk")) {
return Double.NaN;
} else {

double stress = 0;

if ((boolean) link.getAttributes().getAttribute("allowsCar")) {
double speedLimit = ((Integer) link.getAttributes().getAttribute("speedLimitMPH")).doubleValue();
double speed85perc = (double) link.getAttributes().getAttribute("veh85percSpeedKPH") * 0.621371;
if (speed85perc >= speedLimit * 1.1) {
speedLimit = speed85perc;
}

double freightPoiFactor = getFreightPoiFactor(link);

stress = -1.5 + 0.05 * speedLimit + 0.2 * freightPoiFactor;

if (stress < 0.) {
stress = 0;
} else if (stress > 1.) {
stress = 1;
}
}
return stress;
}
}

public static double getFreightPoiFactor (Link link){
int hgvPois = (int) link.getAttributes().getAttribute("hgvPOIs");
return Math.min(1., 24 * hgvPois / link.getLength());
Expand Down

0 comments on commit 8327633

Please sign in to comment.