Skip to content

Commit

Permalink
Only process features with speed > 0
Browse files Browse the repository at this point in the history
  • Loading branch information
ansoncfit committed Nov 6, 2024
1 parent e688484 commit f357f10
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/main/java/com/conveyal/r5/shapefile/SpeedMatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,19 @@ public SpeedMatcher (StreetLayer streets) {
}

/**
* Set the speed value of an edge using a supplied feature with a speed attribute (in kilometers per hour)
* Set the speed value of an edge using a supplied feature with a speed attribute (converts from miles per hour).
* If a supplied feature has speed 0 or less, it is ignored.
*/
@Override
void setEdgePair (SimpleFeature feature, int attributeIndex, EdgeStore.Edge edge) {
if (feature.getAttribute(attributeIndex) != null) {
double speedKph = KPH_PER_MPH * ((Number) feature.getAttribute(attributeIndex)).doubleValue();
edge.setSpeedKph(speedKph);
edge.advance();
edge.setSpeedKph(speedKph);
double speedMph = ((Number) feature.getAttribute(attributeIndex)).doubleValue();
if (speedMph > 0) {
double speedKph = KPH_PER_MPH * speedMph;
edge.setSpeedKph(speedKph);
edge.advance();
edge.setSpeedKph(speedKph);
}
}
}
}

0 comments on commit f357f10

Please sign in to comment.