Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package org.opentripplanner.client.model;

public record Coordinate(double lat, double lon) implements PlaceParameter {
public record Coordinate(double lat, double lon, String name) implements PlaceParameter {
public Coordinate(double lat, double lon) {
this(lat, lon, String.format("%s,%s", lat, lon));
}

@Override
public String toString() {
Expand All @@ -9,6 +12,6 @@ public String toString() {

@Override
public String toPlaceString() {
return String.format("%s,%s::%s,%s", lat, lon, lat, lon);
return String.format("%s::%s,%s", name, lat, lon);
}
}
18 changes: 18 additions & 0 deletions client/src/test/java/org/opentripplanner/IntegrationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,24 @@ public void planPlaceToPlace() throws IOException {
assertEquals(List.of(), leg.fareProducts());
}

@Test
public void planNamedCoordinate() throws IOException {
var result =
client.plan(
TripPlanParameters.builder()
.withFrom(new Coordinate(OSLO_EAST.lat(), OSLO_EAST.lon(), "Oslo East"))
.withTo(OSLO_WEST)
.withTime(LocalDateTime.now())
.withModes(RequestMode.TRANSIT)
.withNumberOfItineraries(3)
.build());

assertFalse(result.itineraries().isEmpty());
var firstLeg = result.itineraries().get(0).legs().get(0);

assertEquals("Oslo East", firstLeg.from().name());
}

@Test
public void planPlaceToPlaceWithSearchWindow() throws IOException {
var result =
Expand Down