Search in sources :

Example 16 with GenericLocation

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);
}
Also used : GenericLocation(org.opentripplanner.model.GenericLocation) TraverseModeSet(org.opentripplanner.routing.core.TraverseModeSet) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 17 with GenericLocation

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;
        }
    }
}
Also used : GraphPath(org.opentripplanner.routing.spt.GraphPath) Itinerary(org.opentripplanner.model.plan.Itinerary) TripPlan(org.opentripplanner.model.plan.TripPlan) GenericLocation(org.opentripplanner.model.GenericLocation) RoutingRequest(org.opentripplanner.routing.api.request.RoutingRequest)

Example 18 with GenericLocation

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());
}
Also used : Coordinate(org.locationtech.jts.geom.Coordinate) GenericLocation(org.opentripplanner.model.GenericLocation) Test(org.junit.Test)

Example 19 with GenericLocation

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());
}
Also used : Coordinate(org.locationtech.jts.geom.Coordinate) GenericLocation(org.opentripplanner.model.GenericLocation) Test(org.junit.Test)

Example 20 with GenericLocation

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);
}
Also used : GenericLocation(org.opentripplanner.model.GenericLocation) Test(org.junit.Test)

Aggregations

GenericLocation (org.opentripplanner.model.GenericLocation)25 Test (org.junit.Test)14 TraverseModeSet (org.opentripplanner.routing.core.TraverseModeSet)11 RoutingRequest (org.opentripplanner.routing.api.request.RoutingRequest)8 Test (org.junit.jupiter.api.Test)4 Instant (java.time.Instant)3 Assertions (org.junit.jupiter.api.Assertions)3 Geometry (org.locationtech.jts.geom.Geometry)3 ConstantsForTests (org.opentripplanner.ConstantsForTests)3 PolylineAssert.assertThatPolylinesAreEqual (org.opentripplanner.PolylineAssert.assertThatPolylinesAreEqual)3 FeedScopedId (org.opentripplanner.model.FeedScopedId)3 GraphPathToItineraryMapper (org.opentripplanner.routing.algorithm.mapping.GraphPathToItineraryMapper)3 TraverseMode (org.opentripplanner.routing.core.TraverseMode)3 Graph (org.opentripplanner.routing.graph.Graph)3 GraphPathFinder (org.opentripplanner.routing.impl.GraphPathFinder)3 RouterConfig (org.opentripplanner.standalone.config.RouterConfig)3 Router (org.opentripplanner.standalone.server.Router)3 PolylineEncoder (org.opentripplanner.util.PolylineEncoder)3 Ignore (org.junit.Ignore)2 Coordinate (org.locationtech.jts.geom.Coordinate)2