use of org.opentripplanner.datastore.DataSource in project OpenTripPlanner by opentripplanner.
the class GsDataSourceRepository method createCompositeSource.
private CompositeDataSource createCompositeSource(BlobId blobId, FileType type) {
if (GsHelper.isRoot(blobId)) {
return new GsDirectoryDataSource(storage, blobId, type);
}
if (blobId.getName().endsWith(".zip")) {
Blob blob = storage.get(blobId);
if (blob == null) {
throw new IllegalArgumentException(type.text() + " not found: " + GsHelper.toUriString(blobId));
}
DataSource gsSource = new GsFileDataSource(blob, type);
return new ZipStreamDataSourceDecorator(gsSource);
}
return new GsDirectoryDataSource(storage, blobId, type);
}
use of org.opentripplanner.datastore.DataSource in project OpenTripPlanner by opentripplanner.
the class GraphBuilder method create.
/**
* Factory method to create and configure a GraphBuilder with all the appropriate modules to
* build a graph from the given data source and configuration directory.
*/
public static GraphBuilder create(BuildConfig config, GraphBuilderDataSources dataSources, Graph baseGraph) {
boolean hasOsm = dataSources.has(OSM);
boolean hasDem = dataSources.has(DEM);
boolean hasGtfs = dataSources.has(GTFS);
boolean hasNetex = dataSources.has(NETEX);
boolean hasTransitData = hasGtfs || hasNetex;
GraphBuilder graphBuilder = new GraphBuilder(baseGraph);
if (hasOsm) {
List<BinaryOpenStreetMapProvider> osmProviders = Lists.newArrayList();
for (DataSource osmFile : dataSources.get(OSM)) {
osmProviders.add(new BinaryOpenStreetMapProvider(osmFile, config.osmCacheDataInMem));
}
OpenStreetMapModule osmModule = new OpenStreetMapModule(osmProviders);
DefaultStreetEdgeFactory streetEdgeFactory = new DefaultStreetEdgeFactory();
streetEdgeFactory.useElevationData = hasDem;
osmModule.edgeFactory = streetEdgeFactory;
osmModule.customNamer = config.customNamer;
osmModule.setDefaultWayPropertySetSource(config.osmWayPropertySet);
osmModule.skipVisibility = !config.areaVisibility;
osmModule.platformEntriesLinking = config.platformEntriesLinking;
osmModule.staticBikeRental = config.staticBikeRental;
osmModule.staticBikeParkAndRide = config.staticBikeParkAndRide;
osmModule.staticParkAndRide = config.staticParkAndRide;
osmModule.banDiscouragedWalking = config.banDiscouragedWalking;
osmModule.banDiscouragedBiking = config.banDiscouragedBiking;
graphBuilder.addModule(osmModule);
PruneFloatingIslands pruneFloatingIslands = new PruneFloatingIslands();
pruneFloatingIslands.setPruningThresholdIslandWithoutStops(config.pruningThresholdIslandWithoutStops);
pruneFloatingIslands.setPruningThresholdIslandWithStops(config.pruningThresholdIslandWithStops);
graphBuilder.addModule(pruneFloatingIslands);
}
if (hasGtfs) {
List<GtfsBundle> gtfsBundles = Lists.newArrayList();
for (DataSource gtfsData : dataSources.get(GTFS)) {
GtfsBundle gtfsBundle = new GtfsBundle((CompositeDataSource) gtfsData);
// TODO OTP2 - In OTP2 we have deleted the transfer edges from the street graph.
// - The new transfer generation do not take this config param into
// - account any more. This needs some investigation and probably
// - a fix, but we are unsure if this is used any more. The Pathways.txt
// - and osm import replaces this functionality.
gtfsBundle.setTransfersTxtDefinesStationPaths(config.useTransfersTxt);
if (config.parentStopLinking) {
gtfsBundle.linkStopsToParentStations = true;
}
gtfsBundle.parentStationTransfers = config.stationTransfers;
gtfsBundle.subwayAccessTime = config.getSubwayAccessTimeSeconds();
gtfsBundle.maxInterlineDistance = config.maxInterlineDistance;
gtfsBundles.add(gtfsBundle);
}
GtfsModule gtfsModule = new GtfsModule(gtfsBundles, config.getTransitServicePeriod());
gtfsModule.setFareServiceFactory(config.fareServiceFactory);
graphBuilder.addModule(gtfsModule);
}
if (hasNetex) {
graphBuilder.addModule(netexModule(config, dataSources.get(NETEX)));
}
if (hasTransitData && (hasOsm || graphBuilder.graph.hasStreets)) {
if (config.matchBusRoutesToStreets) {
graphBuilder.addModule(new BusRouteStreetMatcher());
}
graphBuilder.addModule(new TransitToTaggedStopsModule());
}
// This module is outside the hasGTFS conditional block because it also links things like bike rental
// which need to be handled even when there's no transit.
StreetLinkerModule streetLinkerModule = new StreetLinkerModule();
streetLinkerModule.setAddExtraEdgesToAreas(config.areaVisibility);
graphBuilder.addModule(streetLinkerModule);
// Load elevation data and apply it to the streets.
// We want to do run this module after loading the OSM street network but before finding transfers.
List<ElevationGridCoverageFactory> elevationGridCoverageFactories = new ArrayList<>();
if (config.elevationBucket != null) {
// Download the elevation tiles from an Amazon S3 bucket
S3BucketConfig bucketConfig = config.elevationBucket;
File cacheDirectory = new File(dataSources.getCacheDirectory(), "ned");
DegreeGridNEDTileSource awsTileSource = new DegreeGridNEDTileSource();
awsTileSource.awsAccessKey = bucketConfig.accessKey;
awsTileSource.awsSecretKey = bucketConfig.secretKey;
awsTileSource.awsBucketName = bucketConfig.bucketName;
elevationGridCoverageFactories.add(new NEDGridCoverageFactoryImpl(cacheDirectory, awsTileSource));
} else if (dataSources.has(DEM)) {
// Load the elevation from a file in the graph inputs directory
for (DataSource demSource : dataSources.get(DEM)) {
elevationGridCoverageFactories.add(new GeotiffGridCoverageFactoryImpl(demSource));
}
}
// ElevationModule class.
for (ElevationGridCoverageFactory factory : elevationGridCoverageFactories) {
graphBuilder.addModule(new ElevationModule(factory, new File(dataSources.getCacheDirectory(), "cached_elevations.obj"), config.readCachedElevations, config.writeCachedElevations, config.elevationUnitMultiplier, config.distanceBetweenElevationSamples, config.includeEllipsoidToGeoidDifference, config.multiThreadElevationCalculations));
}
if (hasTransitData) {
// Add links to flex areas after the streets has been split, so that also the split edges are connected
if (OTPFeature.FlexRouting.isOn()) {
graphBuilder.addModule(new FlexLocationsToStreetEdgesMapper());
}
// The stops can be linked to each other once they are already linked to the street network.
if (!config.useTransfersTxt) {
// This module will use streets or straight line distance depending on whether OSM data is found in the graph.
graphBuilder.addModule(new DirectTransferGenerator(config.maxTransferDistance));
}
// Analyze routing between stops to generate report
if (OTPFeature.TransferAnalyzer.isOn()) {
graphBuilder.addModule(new DirectTransferAnalyzer(config.maxTransferDistance));
}
}
if (config.dataImportReport) {
graphBuilder.addModule(new DataImportIssuesToHTML(dataSources.getBuildReportDir(), config.maxDataImportIssuesPerFile));
}
return graphBuilder;
}
use of org.opentripplanner.datastore.DataSource in project OpenTripPlanner by opentripplanner.
the class GraphBuilderDataSources method logSkippedAndSelectedFiles.
private void logSkippedAndSelectedFiles() {
LOG.info("Process data sources: {}", String.join(", ", store.getRepositoryDescriptions()));
// Sort data input files by type
LOG.info("Load files:");
for (FileType type : FileType.values()) {
for (DataSource source : inputData.get(type)) {
if (type == FileType.CONFIG) {
LOG.info(BULLET_POINT + source.detailedInfo());
} else {
LOG.info(BULLET_POINT + source.detailedInfo());
}
}
}
LOG.info("Skip files:");
for (FileType type : FileType.values()) {
for (DataSource source : skipData.get(type)) {
LOG.info(BULLET_POINT + source.detailedInfo());
}
}
}
use of org.opentripplanner.datastore.DataSource in project OpenTripPlanner by opentripplanner.
the class NetexConfig method netexModule.
private NetexModule netexModule(Iterable<DataSource> netexSources) {
List<NetexBundle> netexBundles = new ArrayList<>();
for (DataSource it : netexSources) {
NetexBundle netexBundle = netexBundle((CompositeDataSource) it);
netexBundles.add(netexBundle);
}
return new NetexModule(buildParams.netex.netexFeedId, buildParams.parentStopLinking, buildParams.stationTransfers, buildParams.getSubwayAccessTimeSeconds(), buildParams.maxInterlineDistance, buildParams.getTransitServicePeriod(), netexBundles);
}
Aggregations