use of org.opentripplanner.model.GenericLocation in project OpenTripPlanner by opentripplanner.
the class TestIntermediatePlaces method testOneIntermediatePlace.
@Test
@Ignore
public void testOneIntermediatePlace() {
GenericLocation fromLocation = new GenericLocation(39.93080, -82.98522);
GenericLocation toLocation = new GenericLocation(39.96383, -82.96291);
GenericLocation[] intermediateLocations = { new GenericLocation(39.92099, -82.95570) };
handleRequest(fromLocation, toLocation, intermediateLocations, new TraverseModeSet(TraverseMode.WALK), false);
handleRequest(fromLocation, toLocation, intermediateLocations, new TraverseModeSet(TraverseMode.WALK), true);
}
use of org.opentripplanner.model.GenericLocation in project OpenTripPlanner by opentripplanner.
the class TestIntermediatePlaces method handleRequest.
private void handleRequest(GenericLocation from, GenericLocation to, GenericLocation[] via, TraverseModeSet modes, boolean arriveBy) {
RoutingRequest request = new RoutingRequest(modes);
request.setDateTime("2016-04-20", "13:00", timeZone);
request.setArriveBy(arriveBy);
request.from = from;
request.to = to;
for (GenericLocation intermediateLocation : via) {
request.addIntermediatePlace(intermediateLocation);
}
List<GraphPath> paths = graphPathFinder.graphPathFinderEntryPoint(request);
assertNotNull(paths);
assertFalse(paths.isEmpty());
List<Itinerary> itineraries = GraphPathToItineraryMapper.mapItineraries(paths);
TripPlan plan = TripPlanMapper.mapTripPlan(request, itineraries);
assertLocationIsVeryCloseToPlace(from, plan.from);
assertLocationIsVeryCloseToPlace(to, plan.to);
assertTrue(1 <= plan.itineraries.size());
for (Itinerary itinerary : plan.itineraries) {
validateIntermediatePlacesVisited(itinerary, via);
assertTrue(via.length < itinerary.legs.size());
validateLegsTemporally(request, itinerary);
validateLegsSpatially(plan, itinerary);
if (modes.contains(TraverseMode.TRANSIT)) {
assert itinerary.transitTimeSeconds > 0;
}
}
}
use of org.opentripplanner.model.GenericLocation in project OpenTripPlanner by opentripplanner.
the class LocationStringParserTest method testWithCoordOnly.
@Test
public void testWithCoordOnly() {
GenericLocation loc = LocationStringParser.fromOldStyleString("1.0,2.5");
assertNull(loc.label);
assertNull(loc.stopId);
assertEquals(Double.valueOf(1.0), loc.lat);
assertEquals(Double.valueOf(2.5), loc.lng);
assertEquals(new Coordinate(2.5, 1.0), loc.getCoordinate());
loc = LocationStringParser.fromOldStyleString(" -15.0, 200");
assertNull(loc.label);
assertNull(loc.stopId);
assertEquals(Double.valueOf(-15.0), loc.lat);
assertEquals(Double.valueOf(200), loc.lng);
assertEquals(new Coordinate(200, -15), loc.getCoordinate());
loc = LocationStringParser.fromOldStyleString("122,-22.3 ");
assertNull(loc.label);
assertNull(loc.stopId);
assertEquals(Double.valueOf(122), loc.lat);
assertEquals(Double.valueOf(-22.3), loc.lng);
assertEquals(new Coordinate(-22.3, 122), loc.getCoordinate());
}
use of org.opentripplanner.model.GenericLocation in project OpenTripPlanner by opentripplanner.
the class LocationStringParserTest method testWithLabelAndCoord.
@Test
public void testWithLabelAndCoord() {
GenericLocation loc = LocationStringParser.fromOldStyleString("name::1.0,2.5");
assertEquals("name", loc.label);
assertNull(loc.stopId);
assertEquals(Double.valueOf(1.0), loc.lat);
assertEquals(Double.valueOf(2.5), loc.lng);
assertEquals(new Coordinate(2.5, 1.0), loc.getCoordinate());
loc = LocationStringParser.fromOldStyleString("Label Label::-15.0, 200");
assertEquals("Label Label", loc.label);
assertNull(loc.stopId);
assertEquals(Double.valueOf(-15.0), loc.lat);
assertEquals(Double.valueOf(200), loc.lng);
assertEquals(new Coordinate(200, -15), loc.getCoordinate());
loc = LocationStringParser.fromOldStyleString("A Label::122,-22.3");
assertEquals("A Label", loc.label);
assertNull(loc.stopId);
assertEquals(Double.valueOf(122), loc.lat);
assertEquals(Double.valueOf(-22.3), loc.lng);
assertEquals(new Coordinate(-22.3, 122), loc.getCoordinate());
}
use of org.opentripplanner.model.GenericLocation in project OpenTripPlanner by opentripplanner.
the class LocationStringParserTest method testFromOldStyleStringIncomplete.
@Test
public void testFromOldStyleStringIncomplete() {
String input = "0::";
GenericLocation loc = LocationStringParser.fromOldStyleString(input);
assertEquals("0", loc.label);
assertNull(loc.stopId);
input = "::1";
loc = LocationStringParser.fromOldStyleString(input);
assertEquals("", loc.label);
assertNull(loc.stopId);
input = "::";
loc = LocationStringParser.fromOldStyleString(input);
assertEquals("", loc.label);
assertNull(loc.stopId);
}
Aggregations