use of com.conveyal.gtfs.GTFSFeed in project graphhopper by graphhopper.
the class TransfersTest method init.
@BeforeAll
public void init() throws IOException {
GTFSFeed gtfsFeed1 = new GTFSFeed();
gtfsFeed1.loadFromZipfileOrDirectory(new File("files/sample-feed"), "");
sampleFeed = new Transfers(gtfsFeed1);
GTFSFeed gtfsFeed2 = new GTFSFeed();
gtfsFeed2.loadFromZipfileOrDirectory(new File("files/another-sample-feed"), "");
anotherSampleFeed = new Transfers(gtfsFeed2);
}
use of com.conveyal.gtfs.GTFSFeed in project graphhopper by graphhopper.
the class PtLocationSnapper method findByStopId.
private Snap findByStopId(GHStationLocation station, int indexForErrorMessage) {
for (Map.Entry<String, GTFSFeed> entry : gtfsStorage.getGtfsFeeds().entrySet()) {
final Integer node = gtfsStorage.getStationNodes().get(new GtfsStorage.FeedIdWithStopId(entry.getKey(), station.stop_id));
if (node != null) {
Stop stop = gtfsStorage.getGtfsFeeds().get(entry.getKey()).stops.get(station.stop_id);
final Snap stationSnap = new Snap(stop.stop_lat, stop.stop_lon);
stationSnap.setClosestNode(node);
return stationSnap;
}
}
throw new PointNotFoundException("Cannot find station: " + station.stop_id, indexForErrorMessage);
}
use of com.conveyal.gtfs.GTFSFeed in project graphhopper by graphhopper.
the class GtfsStorage method loadGtfsFromZipFileOrDirectory.
void loadGtfsFromZipFileOrDirectory(String id, File zipFileOrDirectory) {
File dbFile = new File(dir.getLocation() + "/" + id);
try {
Files.deleteIfExists(dbFile.toPath());
GTFSFeed feed = new GTFSFeed(dbFile);
feed.loadFromFileAndLogErrors(zipFileOrDirectory);
this.gtfsFeeds.put(id, feed);
} catch (IOException e) {
throw new RuntimeException(e);
}
this.gtfsFeedIds.add(id);
}
use of com.conveyal.gtfs.GTFSFeed in project graphhopper by graphhopper.
the class GtfsStorage method loadExisting.
boolean loadExisting() {
File file = new File(dir.getLocation() + "/transit_schedule");
if (!file.exists()) {
return false;
}
this.data = DBMaker.newFileDB(file).transactionDisable().mmapFileEnable().readOnly().make();
init();
for (String gtfsFeedId : this.gtfsFeedIds) {
File dbFile = new File(dir.getLocation() + "/" + gtfsFeedId);
if (!dbFile.exists()) {
throw new RuntimeException(String.format("The mapping of the gtfsFeeds in the transit_schedule DB does not reflect the files in %s. " + "dbFile %s is missing.", dir.getLocation(), dbFile.getName()));
}
GTFSFeed feed = new GTFSFeed(dbFile);
this.gtfsFeeds.put(gtfsFeedId, feed);
}
postInit();
return true;
}
use of com.conveyal.gtfs.GTFSFeed in project graphhopper by graphhopper.
the class GtfsStorage method close.
public void close() {
if (!isClosed) {
isClosed = true;
data.close();
for (GTFSFeed feed : gtfsFeeds.values()) {
feed.close();
}
}
}
Aggregations