File tree Expand file tree Collapse file tree
main/java/org/opentripplanner/street/model/edge
test/java/org/opentripplanner/street/model/edge Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -773,7 +773,7 @@ protected void copyPropertiesToSplitEdge(
773773 );
774774
775775 StreetElevationExtensionBuilder .of (seb )
776- .withDistanceInMeters (defaultMillimeterLength ( seb . geometry ()) / 1000. )
776+ .withDistanceInMeters (toDistance - fromDistance )
777777 .withElevationProfile (partialElevationProfileFromParent )
778778 .build ()
779779 .ifPresent (seb ::withElevationExtension );
Original file line number Diff line number Diff line change @@ -39,7 +39,11 @@ public static StreetElevationExtensionBuilder of(StreetEdgeBuilder<?> seb) {
3939 }
4040
4141 public Optional <StreetElevationExtension > build () {
42- if (elevationProfileHasAtLeastTwoPoints () && (!isSlopeOverride || computed )) {
42+ if (
43+ distanceInMeters > 0.01 &&
44+ elevationProfileHasAtLeastTwoPoints () &&
45+ (!isSlopeOverride || computed )
46+ ) {
4347 return Optional .of (buildInternal ());
4448 }
4549 return Optional .empty ();
Original file line number Diff line number Diff line change @@ -30,8 +30,14 @@ class StreetElevationExtensionBuilderTest {
3030 new Coordinate (0 , 0 ),
3131 new Coordinate (1 , 1 ),
3232 };
33+ private static final Coordinate [] COORDINATES_ONE_POINT_TWICE = new Coordinate [] {
34+ new Coordinate (0 , 0 ),
35+ new Coordinate (0 , 0 ),
36+ };
3337 private static final PackedCoordinateSequence ELEVATION_PROFILE_TWO_POINTS =
3438 new PackedCoordinateSequence .Double (COORDINATES_TWO_POINTS , 2 );
39+ private static final PackedCoordinateSequence ELEVATION_PROFILE_ONE_POINT_TWICE =
40+ new PackedCoordinateSequence .Double (COORDINATES_ONE_POINT_TWICE , 2 );
3541
3642 private static final LineString GEOMETRY = GeometryUtils .getGeometryFactory ().createLineString (
3743 new Coordinate [] {
@@ -68,6 +74,15 @@ void testValidElevationProfile() {
6874 assertFalse (streetElevationExtension .isEmpty ());
6975 }
7076
77+ @ Test
78+ void testZeroLengthEdge () {
79+ StreetElevationExtensionBuilder seeb = new StreetElevationExtensionBuilder ()
80+ .withDistanceInMeters (0 )
81+ .withElevationProfile (ELEVATION_PROFILE_ONE_POINT_TWICE );
82+ Optional <StreetElevationExtension > streetElevationExtension = seeb .build ();
83+ assertTrue (streetElevationExtension .isEmpty ());
84+ }
85+
7186 @ Test
7287 void testBuildFromStreetEdge () {
7388 StreetEdge se = streetEdgeBuilder .buildAndConnect ();
You can’t perform that action at this time.
0 commit comments