Skip to content

Commit

Permalink
feat: add shapefile speed matcher
Browse files Browse the repository at this point in the history
  • Loading branch information
ansoncfit committed May 23, 2022
1 parent e007770 commit 2564cb1
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/main/java/com/conveyal/r5/shapefile/SpeedMatcher.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.conveyal.r5.shapefile;

import com.conveyal.r5.streets.EdgeStore;
import com.conveyal.r5.streets.StreetLayer;
import org.opengis.feature.simple.SimpleFeature;

public class SpeedMatcher extends ShapefileMatcher {

public SpeedMatcher (StreetLayer streets) {
super(streets);
}

/**
* Set the speed value of an edge using a supplied feature with a speed attribute (in kilometers per hour)
*/
@Override
void setEdgePair (SimpleFeature feature, int attributeIndex, EdgeStore.Edge edge) {
if (feature.getAttribute(attributeIndex) != null) {
double speedKph = ((Number) feature.getAttribute(attributeIndex)).doubleValue();
edge.setSpeedKph(speedKph);
edge.advance();
edge.setSpeedKph(speedKph);
}
}
}

0 comments on commit 2564cb1

Please sign in to comment.