Commit 6667b7b0 authored by Michael Zilske's avatar Michael Zilske

works with hardcoded date

parent 70a71924
......@@ -82,7 +82,7 @@ final class GraphExplorer {
final List<VirtualEdgeIteratorState> extraEdges = reverse ? extraEdgesByDestination.get(label.adjNode) : extraEdgesBySource.get(label.adjNode);
return Stream.concat(
label.adjNode < graph.getNodes() ? mainEdgesAround(label) : Stream.empty(),
extraEdges.stream()).peek(e -> {if (label.adjNode == 2579) {
extraEdges.stream()).peek(e -> {if (label.adjNode == 2581) {
System.out.println(e);
}}).filter(new EdgeIteratorStatePredicate(label));
}
......@@ -183,7 +183,7 @@ final class GraphExplorer {
@Override
public boolean test(EdgeIteratorState edgeIterator) {
if (edgeIterator.getBaseNode() == 2589) {
if (edgeIterator.getBaseNode() == 2579) {
System.out.println("wurst");
}
final GtfsStorage.EdgeType edgeType = flagEncoder.getEdgeType(edgeIterator.getFlags());
......
......@@ -120,12 +120,12 @@ class GtfsReader {
this.feed = this.gtfsStorage.getGtfsFeeds().get(id);
this.transfers = new Transfers(feed);
this.i = graph.getNodes();
this.startDate = feed.calculateStats().getStartDate();
this.endDate = feed.calculateStats().getEndDate();
this.gtfsStorage.getFares().putAll(feed.fares);
}
void readGraph() {
this.startDate = feed.calculateStats().getStartDate();
this.endDate = feed.calculateStats().getEndDate();
gtfsStorage.getFares().putAll(feed.fares);
buildPtNetwork();
connectStopsToStreetNetwork();
connectStopsToStationNodes();
......@@ -195,7 +195,7 @@ class GtfsReader {
Collection<Frequency> frequencies = feed.getFrequencies(trips.iterator().next().trip.trip_id);
for (Frequency frequency : (frequencies.isEmpty() ? Collections.singletonList(SINGLE_FREQUENCY) : frequencies)) {
for (int time = frequency.start_time; time < frequency.end_time; time += frequency.headway_secs) {
addTrips(startDate, endDate, zoneId, trips, time);
addTrips(zoneId, trips, time);
}
}
});
......@@ -246,7 +246,7 @@ class GtfsReader {
}
}
void addTrips(LocalDate startDate, LocalDate endDate, ZoneId zoneId, List<TripWithStopTimes> trips, int time) {
void addTrips(ZoneId zoneId, List<TripWithStopTimes> trips, int time) {
List<Integer> arrivalNodes = new ArrayList<>();
for (TripWithStopTimes trip : trips) {
IntArrayList boardEdges = new IntArrayList();
......
......@@ -43,6 +43,7 @@ import java.util.List;
import java.util.stream.Collectors;
import static com.google.transit.realtime.GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SKIPPED;
import static java.time.temporal.ChronoUnit.DAYS;
public class RealtimeFeed {
private final IntHashSet blockedEdges;
......@@ -243,10 +244,12 @@ public class RealtimeFeed {
return stopTime;
})
.collect(Collectors.toList());
BitSet validity = new BitSet();
return new GtfsReader.TripWithStopTimes(trip, stopTimes, validity);
BitSet validOnDay = new BitSet();
LocalDate startDate = staticGtfs.getGtfsFeeds().get("gtfs_0").calculateStats().getStartDate();
validOnDay.set((int) DAYS.between(startDate, LocalDate.of(2007,1,1)));
return new GtfsReader.TripWithStopTimes(trip, stopTimes, validOnDay);
})
.forEach(trip -> gtfsReader.addTrips(LocalDate.now(), LocalDate.now(), ZoneId.systemDefault(), Collections.singletonList(trip), 0));
.forEach(trip -> gtfsReader.addTrips(ZoneId.systemDefault(), Collections.singletonList(trip), 0));
gtfsReader.wireUpStops();
gtfsReader.connectStopsToStationNodes();
return new RealtimeFeed(blockedEdges, additionalEdges);
......
......@@ -204,8 +204,8 @@ public class RealtimeIT {
.addStopTimeUpdateBuilder()
.setStopSequence(2)
.setStopId("BEATTY_AIRPORT")
.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setTime(LocalDateTime.of(2007,1,1,7,0).atZone(zoneId).toEpochSecond()))
.setDeparture(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setTime(LocalDateTime.of(2007,1,1,7,0).atZone(zoneId).toEpochSecond()));
.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setTime(LocalDateTime.of(2007,1,1,7,15).atZone(zoneId).toEpochSecond()))
.setDeparture(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setTime(LocalDateTime.of(2007,1,1,7,15).atZone(zoneId).toEpochSecond()));
GHResponse response = graphHopperFactory.createWith(feedMessageBuilder.build()).route(ghRequest);
assertEquals(1, response.getAll().size());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment