Skip to content

Commit 16d2ec1

Browse files
committed
add unit test for no StreetElevationExtension for zero-length edge
1 parent 96bb85f commit 16d2ec1

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

street/src/test/java/org/opentripplanner/street/model/edge/StreetElevationExtensionBuilderTest.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,14 @@ class StreetElevationExtensionBuilderTest {
2626
new Coordinate(0, 0),
2727
new Coordinate(1, 1),
2828
};
29+
private static final Coordinate[] COORDINATES_ONE_POINT_TWICE = new Coordinate[] {
30+
new Coordinate(0, 0),
31+
new Coordinate(0, 0),
32+
};
2933
private static final PackedCoordinateSequence ELEVATION_PROFILE_TWO_POINTS =
3034
new PackedCoordinateSequence.Double(COORDINATES_TWO_POINTS, 2);
35+
private static final PackedCoordinateSequence ELEVATION_PROFILE_ONE_POINT_TWICE =
36+
new PackedCoordinateSequence.Double(COORDINATES_ONE_POINT_TWICE, 2);
3137

3238
private static final LineString GEOMETRY = GeometryUtils.getGeometryFactory().createLineString(
3339
new Coordinate[] {
@@ -65,6 +71,16 @@ void testValidElevationProfile() {
6571
assertFalse(streetElevationExtension.isEmpty());
6672
}
6773

74+
@Test
75+
void testZeroLengthEdge() {
76+
StreetElevationExtensionBuilder seeb = new StreetElevationExtensionBuilder()
77+
.withPermission(StreetTraversalPermission.ALL)
78+
.withDistanceInMeters(0)
79+
.withElevationProfile(ELEVATION_PROFILE_ONE_POINT_TWICE);
80+
Optional<StreetElevationExtension> streetElevationExtension = seeb.build();
81+
assertTrue(streetElevationExtension.isEmpty());
82+
}
83+
6884
@Test
6985
void testBuildFromStreetEdge() {
7086
StreetEdge se = streetEdgeBuilder.buildAndConnect();

0 commit comments

Comments
 (0)