Search in sources :

Example 6 with DataImportIssueStore

use of org.opentripplanner.graph_builder.DataImportIssueStore in project OpenTripPlanner by opentripplanner.

the class GtfsContextBuilder method contextBuilder.

public static GtfsContextBuilder contextBuilder(String defaultFeedId, String path) throws IOException {
    GtfsImport gtfsImport = gtfsImport(defaultFeedId, path);
    GtfsFeedId feedId = gtfsImport.getFeedId();
    OtpTransitServiceBuilder transitBuilder = mapGtfsDaoToInternalTransitServiceBuilder(gtfsImport.getDao(), feedId.getId(), new DataImportIssueStore(false));
    return new GtfsContextBuilder(feedId, transitBuilder).withDataImportIssueStore(new DataImportIssueStore(false));
}
Also used : OtpTransitServiceBuilder(org.opentripplanner.model.impl.OtpTransitServiceBuilder) GtfsFeedId(org.opentripplanner.graph_builder.module.GtfsFeedId) DataImportIssueStore(org.opentripplanner.graph_builder.DataImportIssueStore)

Example 7 with DataImportIssueStore

use of org.opentripplanner.graph_builder.DataImportIssueStore in project OpenTripPlanner by opentripplanner.

the class OpenStreetMapParserTest method testBinaryParser.

@Test
public void testBinaryParser() throws Exception {
    File osmFile = new File(URLDecoder.decode(getClass().getResource("map.osm.pbf").getPath(), "UTF-8"));
    BinaryOpenStreetMapProvider pr = new BinaryOpenStreetMapProvider(osmFile, true);
    OSMDatabase osmdb = new OSMDatabase(new DataImportIssueStore(false));
    pr.readOSM(osmdb);
    assertEquals(2297, osmdb.nodeCount());
    OSMNode nodeA = osmdb.getNode(314192918L);
    assertEquals(314192918, nodeA.getId());
    assertEquals(52.3750447, nodeA.lat, 0.0000001);
    assertEquals(16.8431974, nodeA.lon, 0.0000001);
    assertTrue(nodeA.hasTag("railway"));
    assertEquals("level_crossing", nodeA.getTag("railway"));
    assertEquals(545, osmdb.wayCount());
    OSMWay wayA = osmdb.getWay(13490353L);
    assertEquals(13490353, wayA.getId());
    TLongList nodeRefsA = wayA.getNodeRefs();
    assertEquals(2, nodeRefsA.size());
    assertEquals(123978834, nodeRefsA.get(0));
    assertEquals(123980465, nodeRefsA.get(1));
    assertTrue(wayA.hasTag("highway"));
    assertEquals("Potlatch 0.9a", wayA.getTag("created_by"));
    assertEquals("secondary", wayA.getTag("highway"));
}
Also used : OSMWay(org.opentripplanner.openstreetmap.model.OSMWay) TLongList(gnu.trove.list.TLongList) DataImportIssueStore(org.opentripplanner.graph_builder.DataImportIssueStore) BinaryOpenStreetMapProvider(org.opentripplanner.openstreetmap.BinaryOpenStreetMapProvider) OSMNode(org.opentripplanner.openstreetmap.model.OSMNode) File(java.io.File) Test(org.junit.Test)

Example 8 with DataImportIssueStore

use of org.opentripplanner.graph_builder.DataImportIssueStore in project OpenTripPlanner by opentripplanner.

the class CalendarServiceDataFactoryImplTest method createCtxBuilder.

private static GtfsContext createCtxBuilder() throws IOException {
    GtfsContextBuilder ctxBuilder = contextBuilder(FEED_ID, ConstantsForTests.FAKE_GTFS);
    OtpTransitServiceBuilder builder = ctxBuilder.withDataImportIssueStore(new DataImportIssueStore(false)).getTransitBuilder();
    Agency agency = agency(builder);
    // Supplement test data with at least one entity in all collections
    builder.getCalendarDates().add(removeMondayFromAlldays());
    builder.getFareAttributes().add(createFareAttribute(agency));
    builder.getFareRules().add(new FareRule());
    builder.getFeedInfos().add(new FeedInfo());
    return ctxBuilder.build();
}
Also used : OtpTransitServiceBuilder(org.opentripplanner.model.impl.OtpTransitServiceBuilder) Agency(org.opentripplanner.model.Agency) GtfsContextBuilder(org.opentripplanner.gtfs.GtfsContextBuilder) FareRule(org.opentripplanner.model.FareRule) FeedInfo(org.opentripplanner.model.FeedInfo) DataImportIssueStore(org.opentripplanner.graph_builder.DataImportIssueStore)

Example 9 with DataImportIssueStore

use of org.opentripplanner.graph_builder.DataImportIssueStore 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 10 with DataImportIssueStore

use of org.opentripplanner.graph_builder.DataImportIssueStore 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

DataImportIssueStore (org.opentripplanner.graph_builder.DataImportIssueStore)12 Test (org.junit.Test)5 Graph (org.opentripplanner.routing.graph.Graph)4 OtpTransitServiceBuilder (org.opentripplanner.model.impl.OtpTransitServiceBuilder)3 File (java.io.File)2 ArrayList (java.util.ArrayList)2 SimpleStreetSplitter (org.opentripplanner.graph_builder.linking.SimpleStreetSplitter)2 Stop (org.opentripplanner.model.Stop)2 HierarchicalVersionMapById (org.opentripplanner.netex.loader.util.HierarchicalVersionMapById)2 BinaryOpenStreetMapProvider (org.opentripplanner.openstreetmap.BinaryOpenStreetMapProvider)2 BikeRentalStationService (org.opentripplanner.routing.bike_rental.BikeRentalStationService)2 TransitStopVertex (org.opentripplanner.routing.vertextype.TransitStopVertex)2 Quay (org.rutebanken.netex.model.Quay)2 Iterables (com.google.common.collect.Iterables)1 TLongList (gnu.trove.list.TLongList)1 Collections (java.util.Collections)1 Comparator (java.util.Comparator)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1