Search in sources :

Example 1 with Quays_RelStructure

use of org.rutebanken.netex.model.Quays_RelStructure in project OpenTripPlanner by opentripplanner.

the class StopAndStationMapperTest method mapStopPlaceAndQuays.

@Test
public void mapStopPlaceAndQuays() {
    Collection<StopPlace> stopPlaces = new ArrayList<>();
    StopPlace stopPlaceNew = createStopPlace("NSR:StopPlace:1", "Oslo S", "2", 59.909584, 10.755165, VehicleModeEnumeration.TRAM);
    StopPlace stopPlaceOld = createStopPlace("NSR:StopPlace:1", "Oslo S", "1", 59.909584, 10.755165, VehicleModeEnumeration.TRAM);
    stopPlaces.add(stopPlaceNew);
    stopPlaces.add(stopPlaceOld);
    Quay quay1a = createQuay("NSR:Quay:1", "", "1", 59.909323, 10.756205, "a");
    Quay quay1b = createQuay("NSR:Quay:1", "", "2", 59.909911, 10.753008, "A");
    Quay quay2 = createQuay("NSR:Quay:2", "", "1", 59.909911, 10.753008, "B");
    Quay quay3 = createQuay("NSR:Quay:3", "", "1", 59.909911, 10.753008, "C");
    stopPlaceNew.setQuays(new Quays_RelStructure().withQuayRefOrQuay(quay1b).withQuayRefOrQuay(quay2));
    stopPlaceOld.setQuays(new Quays_RelStructure().withQuayRefOrQuay(quay1a).withQuayRefOrQuay(quay3));
    HierarchicalVersionMapById<Quay> quaysById = new HierarchicalVersionMapById<>();
    quaysById.add(quay1a);
    quaysById.add(quay1a);
    quaysById.add(quay2);
    quaysById.add(quay3);
    StopAndStationMapper stopMapper = new StopAndStationMapper(MappingSupport.ID_FACTORY, quaysById, null, new DataImportIssueStore(false));
    stopMapper.mapParentAndChildStops(stopPlaces);
    Collection<Stop> stops = stopMapper.resultStops;
    Collection<Station> stations = stopMapper.resultStations;
    assertEquals(3, stops.size());
    assertEquals(1, stations.size());
    Station parentStop = stations.stream().filter(s -> s.getId().getId().equals("NSR:StopPlace:1")).findFirst().get();
    Stop childStop1 = stops.stream().filter(s -> s.getId().getId().equals("NSR:Quay:1")).findFirst().get();
    Stop childStop2 = stops.stream().filter(s -> s.getId().getId().equals("NSR:Quay:2")).findFirst().get();
    Stop childStop3 = stops.stream().filter(s -> s.getId().getId().equals("NSR:Quay:3")).findFirst().get();
    assertEquals("NSR:StopPlace:1", parentStop.getId().getId());
    assertEquals("NSR:Quay:1", childStop1.getId().getId());
    assertEquals("NSR:Quay:2", childStop2.getId().getId());
    assertEquals("NSR:Quay:3", childStop3.getId().getId());
    assertEquals(59.909911, childStop1.getLat(), 0.0001);
    assertEquals(10.753008, childStop1.getLon(), 0.0001);
    assertEquals("A", childStop1.getCode());
}
Also used : StopPlace(org.rutebanken.netex.model.StopPlace) HierarchicalVersionMapById(org.opentripplanner.netex.loader.util.HierarchicalVersionMapById) Stop(org.opentripplanner.model.Stop) ArrayList(java.util.ArrayList) Quays_RelStructure(org.rutebanken.netex.model.Quays_RelStructure) Station(org.opentripplanner.model.Station) Quay(org.rutebanken.netex.model.Quay) DataImportIssueStore(org.opentripplanner.graph_builder.DataImportIssueStore) Test(org.junit.Test)

Example 2 with Quays_RelStructure

use of org.rutebanken.netex.model.Quays_RelStructure in project OpenTripPlanner by opentripplanner.

the class StopAndStationMapper method listOfQuays.

/**
 * Return the list of quays for the given {@code stopPlace} or an empty list if
 * no quays exist.
 * <p>
 * We do not support quay references, all quays must be included as part of the
 * given stopPlace.
 */
private static List<Quay> listOfQuays(StopPlace stopPlace) {
    Quays_RelStructure quays = stopPlace.getQuays();
    if (quays == null) {
        LOG.warn("StopPlace {} has no quays.", stopPlace.getId());
        return Collections.emptyList();
    }
    List<Quay> result = new ArrayList<>();
    for (Object it : quays.getQuayRefOrQuay()) {
        if (it instanceof Quay) {
            result.add((Quay) it);
        } else {
            LOG.warn("StopPlace {} has unsupported quay reference: {}", stopPlace.getId(), it);
        }
    }
    return result;
}
Also used : Quays_RelStructure(org.rutebanken.netex.model.Quays_RelStructure) ArrayList(java.util.ArrayList) Quay(org.rutebanken.netex.model.Quay)

Aggregations

ArrayList (java.util.ArrayList)2 Quay (org.rutebanken.netex.model.Quay)2 Quays_RelStructure (org.rutebanken.netex.model.Quays_RelStructure)2 Test (org.junit.Test)1 DataImportIssueStore (org.opentripplanner.graph_builder.DataImportIssueStore)1 Station (org.opentripplanner.model.Station)1 Stop (org.opentripplanner.model.Stop)1 HierarchicalVersionMapById (org.opentripplanner.netex.loader.util.HierarchicalVersionMapById)1 StopPlace (org.rutebanken.netex.model.StopPlace)1