From f357f1064bdb4273c76222d6406415ed2ef1c0c7 Mon Sep 17 00:00:00 2001 From: ansons Date: Wed, 6 Nov 2024 16:53:18 -0500 Subject: [PATCH] Only process features with speed > 0 --- .../com/conveyal/r5/shapefile/SpeedMatcher.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/conveyal/r5/shapefile/SpeedMatcher.java b/src/main/java/com/conveyal/r5/shapefile/SpeedMatcher.java index 73c815925..6c918eb14 100644 --- a/src/main/java/com/conveyal/r5/shapefile/SpeedMatcher.java +++ b/src/main/java/com/conveyal/r5/shapefile/SpeedMatcher.java @@ -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); + } } } }