Skip to content

Commit

Permalink
Better fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Teemu Peltonen committed Nov 12, 2018
1 parent 1818955 commit d8abd1d
Showing 1 changed file with 14 additions and 5 deletions.
Expand Up @@ -2,6 +2,7 @@

import org.opentripplanner.common.geometry.CompactElevationProfile;
import org.opentripplanner.common.geometry.PackedCoordinateSequence;
import org.opentripplanner.common.geometry.SphericalDistanceLibrary;
import org.opentripplanner.routing.util.ElevationUtils;
import org.opentripplanner.routing.util.SlopeCosts;
import org.opentripplanner.routing.vertextype.StreetVertex;
Expand Down Expand Up @@ -38,11 +39,6 @@ public StreetWithElevationEdge(StreetVertex v1, StreetVertex v2, LineString geom
I18NString name, double length, StreetTraversalPermission permission, boolean back) {
super(v1, v2, geometry, name, length, permission, back);

// Fix issue with effectiveWalkLength_mm being zero despite best efforts @ StreetEdge.split
if (length < 0.1) {
this.calculateLengthFromGeometry();
}

// Initiate to "flat" distance, use #setElevationProfile() to set elevation adjusted value
this.effectiveWalkLength_mm = getLength_mm();
}
Expand Down Expand Up @@ -113,6 +109,19 @@ public double getSlopeWalkSpeedEffectiveLength() {
return effectiveWalkLength_mm / 1000d;
}

@Override
protected void calculateLengthFromGeometry () {
double accumulatedMeters = 0;

LineString geom = getGeometry();

for (int i = 1; i < geom.getNumPoints(); i++) {
accumulatedMeters += SphericalDistanceLibrary.distance(geom.getCoordinateN(i - 1), geom.getCoordinateN(i));
}

effectiveWalkLength_mm = (int) (accumulatedMeters * 1000);
}

@Override
public String toString() {
return "StreetWithElevationEdge(" + getId() + ", " + getName() + ", " + fromv + " -> "
Expand Down

0 comments on commit d8abd1d

Please sign in to comment.