Search in sources :

Example 1 with Quay

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

the class ServiceLinkMapper method addStraightLine.

private void addStraightLine(ServiceLink serviceLink, MutableInt sequenceCounter, MutableDouble distanceCounter, ReadOnlyHierarchicalMap<String, String> quayIdByStopPointRef, ReadOnlyHierarchicalVersionMapById<Quay> quayById, Collection<ShapePoint> shapePoints, FeedScopedId shapePointIdFromJourneyPatternId) {
    String fromPointQuayId = quayIdByStopPointRef.lookup(serviceLink.getFromPointRef().getRef());
    Quay fromPointQuay = quayById.lookupLastVersionById(fromPointQuayId);
    String toPointQuayId = quayIdByStopPointRef.lookup(serviceLink.getToPointRef().getRef());
    Quay toPointQuay = quayById.lookupLastVersionById(toPointQuayId);
    if (fromPointQuay != null && fromPointQuay.getCentroid() != null && toPointQuay != null && toPointQuay.getCentroid() != null) {
        issueStore.add(new MissingProjectionInServiceLink(serviceLink.getId()));
        ShapePoint fromShapePoint = new ShapePoint();
        fromShapePoint.setShapeId(shapePointIdFromJourneyPatternId);
        fromShapePoint.setLat(fromPointQuay.getCentroid().getLocation().getLatitude().doubleValue());
        fromShapePoint.setLon(fromPointQuay.getCentroid().getLocation().getLongitude().doubleValue());
        fromShapePoint.setSequence(sequenceCounter.toInteger());
        fromShapePoint.setDistTraveled(distanceCounter.getValue());
        shapePoints.add(fromShapePoint);
        sequenceCounter.increment();
        ShapePoint toShapePoint = new ShapePoint();
        toShapePoint.setShapeId(shapePointIdFromJourneyPatternId);
        toShapePoint.setLat(toPointQuay.getCentroid().getLocation().getLatitude().doubleValue());
        toShapePoint.setLon(toPointQuay.getCentroid().getLocation().getLongitude().doubleValue());
        toShapePoint.setSequence(sequenceCounter.toInteger());
        shapePoints.add(toShapePoint);
        sequenceCounter.increment();
        double distance;
        if (serviceLink.getDistance() != null) {
            distance = serviceLink.getDistance().doubleValue();
        } else {
            Coordinate fromCoord = new Coordinate(fromShapePoint.getLon(), fromShapePoint.getLat());
            Coordinate toCoord = new Coordinate(toShapePoint.getLon(), toShapePoint.getLat());
            distance = SphericalDistanceLibrary.distance(fromCoord, toCoord);
        }
        distanceCounter.add(distance);
        toShapePoint.setDistTraveled(distanceCounter.doubleValue());
    } else {
        LOG.warn("Ignore service link without projection and missing or unknown quays: " + serviceLink);
    }
}
Also used : ShapePoint(org.opentripplanner.model.ShapePoint) Coordinate(org.locationtech.jts.geom.Coordinate) MissingProjectionInServiceLink(org.opentripplanner.graph_builder.issues.MissingProjectionInServiceLink) Quay(org.rutebanken.netex.model.Quay)

Example 2 with Quay

use of org.rutebanken.netex.model.Quay 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);
        }
    }
}
Also used : Station(org.opentripplanner.model.Station) StopPlace(org.rutebanken.netex.model.StopPlace) Quay(org.rutebanken.netex.model.Quay) FareZone(org.opentripplanner.model.FareZone)

Example 3 with Quay

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

the class NetexImportDataIndexTest method lookupQuayById.

@Test
public void lookupQuayById() {
    Quay quayA = quay(ID, null);
    Quay quayB = quay(ID, "image_1");
    root.quayById.add(quayA);
    child.quayById.add(quayB);
    assertEquals(singletonList(quayA), root.quayById.lookup(ID));
    assertEquals(singletonList(quayB), child.quayById.lookup(ID));
    assertTrue(child.quayById.lookup(ID_2).isEmpty());
}
Also used : Quay(org.rutebanken.netex.model.Quay) Test(org.junit.Test)

Example 4 with Quay

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

the class NetexImportDataIndexTest method quay.

private static Quay quay(String id, String image) {
    Quay quay = new Quay();
    quay.setId(id);
    quay.withImage(image);
    return quay;
}
Also used : Quay(org.rutebanken.netex.model.Quay)

Example 5 with Quay

use of org.rutebanken.netex.model.Quay 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)

Aggregations

Quay (org.rutebanken.netex.model.Quay)9 Test (org.junit.Test)3 StopPlace (org.rutebanken.netex.model.StopPlace)3 ArrayList (java.util.ArrayList)2 DataImportIssueStore (org.opentripplanner.graph_builder.DataImportIssueStore)2 ShapePoint (org.opentripplanner.model.ShapePoint)2 Station (org.opentripplanner.model.Station)2 HierarchicalVersionMapById (org.opentripplanner.netex.loader.util.HierarchicalVersionMapById)2 JourneyPattern (org.rutebanken.netex.model.JourneyPattern)2 Quays_RelStructure (org.rutebanken.netex.model.Quays_RelStructure)2 ServiceLink (org.rutebanken.netex.model.ServiceLink)2 Collection (java.util.Collection)1 JAXBElement (javax.xml.bind.JAXBElement)1 Coordinate (org.locationtech.jts.geom.Coordinate)1 MissingProjectionInServiceLink (org.opentripplanner.graph_builder.issues.MissingProjectionInServiceLink)1 FareZone (org.opentripplanner.model.FareZone)1 Stop (org.opentripplanner.model.Stop)1 HierarchicalMap (org.opentripplanner.netex.loader.util.HierarchicalMap)1 HierarchicalMapById (org.opentripplanner.netex.loader.util.HierarchicalMapById)1 DayTypeRefsToServiceIdAdapter (org.opentripplanner.netex.support.DayTypeRefsToServiceIdAdapter)1