Skip to content

Commit

Permalink
Merge pull request #6111 from ibi-group/escalator-geometry
Browse files Browse the repository at this point in the history
Add geometry for `EscalatorEdge`
  • Loading branch information
leonardehrenfried authored Oct 4, 2024
2 parents e78a9ca + 2eb3c19 commit ce798fd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package org.opentripplanner.street.model.edge;

import javax.annotation.Nonnull;
import org.locationtech.jts.geom.LineString;
import org.opentripplanner.framework.geometry.GeometryUtils;
import org.opentripplanner.framework.i18n.I18NString;
import org.opentripplanner.framework.i18n.LocalizedString;
import org.opentripplanner.street.model.vertex.Vertex;
Expand Down Expand Up @@ -36,6 +38,11 @@ public State[] traverse(State s0) {
} else return State.empty();
}

@Override
public LineString getGeometry() {
return GeometryUtils.makeLineString(fromv.getCoordinate(), tov.getCoordinate());
}

@Override
public double getDistanceMeters() {
return length;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.opentripplanner.street.model.edge;

import static com.google.common.truth.Truth.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;

import java.util.Locale;
Expand Down Expand Up @@ -42,15 +43,15 @@ void testCycling() {
var edge = EscalatorEdge.createEscalatorEdge(from, to, 10);
var req = StreetSearchRequest.of().withMode(StreetMode.BIKE);
var res = edge.traverse(new State(from, req.build()));
assertEquals(res.length, 0);
assertThat(res).isEmpty();
}

@Test
void testWheelchair() {
var edge = EscalatorEdge.createEscalatorEdge(from, to, 10);
var req = StreetSearchRequest.of().withMode(StreetMode.WALK).withWheelchair(true);
var res = edge.traverse(new State(from, req.build()));
assertEquals(res.length, 0);
assertThat(res).isEmpty();
}

@Test
Expand All @@ -59,4 +60,10 @@ void name() {
assertEquals("Rolltreppe", edge.getName().toString(Locale.GERMANY));
assertEquals("escalator", edge.getName().toString(Locale.ENGLISH));
}

@Test
void geometry() {
var edge = EscalatorEdge.createEscalatorEdge(from, to, 10);
assertThat(edge.getGeometry().getCoordinates()).isNotEmpty();
}
}

0 comments on commit ce798fd

Please sign in to comment.