Search in sources :

Example 1 with ServiceLinkInJourneyPattern_VersionedChildStructure

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

the class ServiceLinkMapperTest method mapServiceLinks.

@Test
public void mapServiceLinks() {
    JourneyPattern journeyPattern = new JourneyPattern().withId("RUT:JourneyPattern:1300");
    journeyPattern.setLinksInSequence(new LinksInJourneyPattern_RelStructure().withServiceLinkInJourneyPatternOrTimingLinkInJourneyPattern(new ServiceLinkInJourneyPattern_VersionedChildStructure().withServiceLinkRef(new ServiceLinkRefStructure().withRef("RUT:ServiceLink:1"))).withServiceLinkInJourneyPatternOrTimingLinkInJourneyPattern(new ServiceLinkInJourneyPattern_VersionedChildStructure().withServiceLinkRef(new ServiceLinkRefStructure().withRef("RUT:ServiceLink:2"))));
    ServiceLink serviceLink1 = createServiceLink("RUT:ServiceLink:1", 200.0, new Double[] { COORDINATES[0], COORDINATES[1], COORDINATES[2], COORDINATES[3] });
    ServiceLink serviceLink2 = createServiceLink("RUT:ServiceLink:2", 100.0, new Double[] { COORDINATES[2], COORDINATES[3], COORDINATES[4], COORDINATES[5] });
    HierarchicalMapById<ServiceLink> serviceLinksById = new HierarchicalMapById<>();
    serviceLinksById.add(serviceLink1);
    serviceLinksById.add(serviceLink2);
    Quay quay1 = new Quay().withId("NSR:Quay:1");
    Quay quay2 = new Quay().withId("NSR:Quay:2");
    Quay quay3 = new Quay().withId("NSR:Quay:3");
    HierarchicalVersionMapById<Quay> quaysById = new HierarchicalVersionMapById<>();
    quaysById.add(quay1);
    quaysById.add(quay2);
    quaysById.add(quay3);
    HierarchicalMap<String, String> quayIdByStopPointRef = new HierarchicalMap<>();
    quayIdByStopPointRef.add("RUT:StopPoint:1", "NSR:Quay:1");
    quayIdByStopPointRef.add("RUT:StopPoint:2", "NSR:Quay:2");
    quayIdByStopPointRef.add("RUT:StopPoint:3", "NSR:Quay:3");
    ServiceLinkMapper serviceLinkMapper = new ServiceLinkMapper(new FeedScopedIdFactory("RB"), new DataImportIssueStore(false));
    Collection<ShapePoint> shapePoints = serviceLinkMapper.getShapePointsByJourneyPattern(journeyPattern, serviceLinksById, quayIdByStopPointRef, quaysById);
    List<ShapePoint> shapePointList = shapePoints.stream().sorted(Comparator.comparing(ShapePoint::getSequence)).collect(Collectors.toList());
    Assert.assertEquals(COORDINATES[0], shapePointList.get(0).getLat(), 0.0001);
    Assert.assertEquals(COORDINATES[1], shapePointList.get(0).getLon(), 0.0001);
    Assert.assertEquals(COORDINATES[2], shapePointList.get(1).getLat(), 0.0001);
    Assert.assertEquals(COORDINATES[3], shapePointList.get(1).getLon(), 0.0001);
    Assert.assertEquals(COORDINATES[2], shapePointList.get(2).getLat(), 0.0001);
    Assert.assertEquals(COORDINATES[3], shapePointList.get(2).getLon(), 0.0001);
    Assert.assertEquals(COORDINATES[4], shapePointList.get(3).getLat(), 0.0001);
    Assert.assertEquals(COORDINATES[5], shapePointList.get(3).getLon(), 0.0001);
}
Also used : ServiceLinkRefStructure(org.rutebanken.netex.model.ServiceLinkRefStructure) HierarchicalVersionMapById(org.opentripplanner.netex.loader.util.HierarchicalVersionMapById) HierarchicalMapById(org.opentripplanner.netex.loader.util.HierarchicalMapById) JourneyPattern(org.rutebanken.netex.model.JourneyPattern) ShapePoint(org.opentripplanner.model.ShapePoint) LinksInJourneyPattern_RelStructure(org.rutebanken.netex.model.LinksInJourneyPattern_RelStructure) ServiceLink(org.rutebanken.netex.model.ServiceLink) Quay(org.rutebanken.netex.model.Quay) DataImportIssueStore(org.opentripplanner.graph_builder.DataImportIssueStore) HierarchicalMap(org.opentripplanner.netex.loader.util.HierarchicalMap) ServiceLinkInJourneyPattern_VersionedChildStructure(org.rutebanken.netex.model.ServiceLinkInJourneyPattern_VersionedChildStructure) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 DataImportIssueStore (org.opentripplanner.graph_builder.DataImportIssueStore)1 ShapePoint (org.opentripplanner.model.ShapePoint)1 HierarchicalMap (org.opentripplanner.netex.loader.util.HierarchicalMap)1 HierarchicalMapById (org.opentripplanner.netex.loader.util.HierarchicalMapById)1 HierarchicalVersionMapById (org.opentripplanner.netex.loader.util.HierarchicalVersionMapById)1 JourneyPattern (org.rutebanken.netex.model.JourneyPattern)1 LinksInJourneyPattern_RelStructure (org.rutebanken.netex.model.LinksInJourneyPattern_RelStructure)1 Quay (org.rutebanken.netex.model.Quay)1 ServiceLink (org.rutebanken.netex.model.ServiceLink)1 ServiceLinkInJourneyPattern_VersionedChildStructure (org.rutebanken.netex.model.ServiceLinkInJourneyPattern_VersionedChildStructure)1 ServiceLinkRefStructure (org.rutebanken.netex.model.ServiceLinkRefStructure)1