use of org.rutebanken.netex.model.StopPlace in project OpenTripPlanner by opentripplanner.
the class StopAndStationMapper method mapStopPlaceAllVersionsToStation.
private Station mapStopPlaceAllVersionsToStation(List<StopPlace> stopPlaceAllVersions) {
// Map the highest priority StopPlace version to station
StopPlace selectedStopPlace = first(stopPlaceAllVersions);
Station station = stationMapper.map(selectedStopPlace);
if (selectedStopPlace.getParentSiteRef() != null) {
resultStationByMultiModalStationRfs.put(selectedStopPlace.getParentSiteRef().getRef(), station);
}
resultStations.add(station);
return station;
}
use of org.rutebanken.netex.model.StopPlace in project OpenTripPlanner by opentripplanner.
the class StopAndStationMapper method mapParentAndChildStops.
/**
* @param stopPlaces all stop places including multiple versions of each.
*/
void mapParentAndChildStops(final Collection<StopPlace> stopPlaces) {
// Prioritize StopPlace versions. Highest priority first.
// TODO OTP2 - This should pushed up into the ReadOnlyHierarchicalVersionMapById as part of
// - Issue: Netex import resolve version for all entities , not just stops #2781
List<StopPlace> stopPlaceAllVersions = sortStopPlacesByValidityAndVersionDesc(stopPlaces);
Station station = mapStopPlaceAllVersionsToStation(stopPlaceAllVersions);
List<FareZone> fareZones = mapTariffZones(stopPlaceAllVersions);
// never versions of the StopPlace
for (StopPlace stopPlace : stopPlaceAllVersions) {
for (Quay quay : listOfQuays(stopPlace)) {
addNewStopToParentIfNotPresent(quay, station, fareZones);
}
}
}
use of org.rutebanken.netex.model.StopPlace in project OpenTripPlanner by opentripplanner.
the class NetexImportDataIndexTest method stopPlace.
/* private methods */
private static StopPlace stopPlace(String id, String image) {
StopPlace stopPlace = new StopPlace();
stopPlace.setId(id);
stopPlace.withImage(image);
return stopPlace;
}
use of org.rutebanken.netex.model.StopPlace in project OpenTripPlanner by opentripplanner.
the class NetexImportDataIndexTest method lookupStopsById.
@Test
public void lookupStopsById() {
StopPlace stopPlaceA = stopPlace(ID, null);
StopPlace stopPlaceB = stopPlace(ID, "image_1");
root.stopPlaceById.add(stopPlaceA);
child.stopPlaceById.add(stopPlaceB);
assertEquals(singletonList(stopPlaceA), root.stopPlaceById.lookup(ID));
assertEquals(singletonList(stopPlaceB), child.stopPlaceById.lookup(ID));
assertTrue(child.stopPlaceById.lookup(ID_2).isEmpty());
}
use of org.rutebanken.netex.model.StopPlace 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());
}
Aggregations