SimpleTransfer t = (SimpleTransfer) e; int time = (int) (t.getDistance() / request.walkSpeed); accessTimes.add(new Tuple2((TransitStop) e.getToVertex(), time));
Fun.Tuple2<String, String> routeKey = new Fun.Tuple2(currentRoute, compareRoute); if (compareRoute.equals(currentRoute)) { continue; Fun.Tuple2<StopTime, StopTime> missedTransfer = new Fun.Tuple2(compareTime, currentTime);
new Fun.Tuple2(wayId, null), new Fun.Tuple2(wayId, Fun.HI)); new Fun.Tuple2(wayId, null), new Fun.Tuple2(wayId, Fun.HI)); new Fun.Tuple2(relation, null), new Fun.Tuple2(relation, Fun.HI));
if (!currentTile.equals(tile)) { vehicleStates.placeVehicleInTile(tile, vehicleId);
new Fun.Tuple2(jumperId.b, null), true, // inclusive lower bound, null tests lower than anything new Fun.Tuple2(jumperId.b, Fun.HI), true // inclusive upper bound, HI tests higher than anything ); new Fun.Tuple2(jumperId.a, null), true, // inclusive lower bound, null tests lower than anything new Fun.Tuple2(jumperId.a, Fun.HI), true // inclusive upper bound, HI tests higher than anything ); Jumper adjacentJumper = jumperMap.get(new Fun.Tuple2<>(adjacentJumperId.b, adjacentJumperId.a));
@Override public void loadOneRow() throws IOException { StopTime st = new StopTime(); st.id = row + 1; // offset line number by 1 to account for 0-based row index st.trip_id = getStringField("trip_id", true); // TODO: arrival_time and departure time are not required, but if one is present the other should be // also, if this is the first or last stop, they are both required st.arrival_time = getTimeField("arrival_time", false); st.departure_time = getTimeField("departure_time", false); st.stop_id = getStringField("stop_id", true); st.stop_sequence = getIntField("stop_sequence", true, 0, Integer.MAX_VALUE); st.stop_headsign = getStringField("stop_headsign", false); st.pickup_type = getIntField("pickup_type", false, 0, 3); // TODO add ranges as parameters st.drop_off_type = getIntField("drop_off_type", false, 0, 3); st.shape_dist_traveled = getDoubleField("shape_dist_traveled", false, 0D, Double.MAX_VALUE); // FIXME using both 0 and NaN for "missing", define DOUBLE_MISSING st.timepoint = getIntField("timepoint", false, 0, 1, INT_MISSING); st.feed = null; // this could circular-serialize the whole feed feed.stop_times.put(new Fun.Tuple2(st.trip_id, st.stop_sequence), st); /* Check referential integrity without storing references. StopTime cannot directly reference Trips or Stops because they would be serialized into the MapDB. */ getRefField("trip_id", true, feed.trips); getRefField("stop_id", true, feed.stops); }
public static List<Fun.Tuple2<Integer, Integer>> getTilesForZ(final int x, final int y, int z, int internalZ) { int zScale, newTileX, newTileY; if(internalZ < z) { zScale = Math.abs(internalZ - z); if(zScale == 0) zScale = 1; newTileX = x / zScale; newTileY = y / zScale; zScale = 1; } else { zScale = internalZ - z; if(zScale == 0) zScale = 1; newTileX = x * zScale; newTileY = y * zScale; } List<Fun.Tuple2<Integer, Integer>> tiles = new ArrayList<>(); for(int xOffset = 0; xOffset < zScale; xOffset++) { for(int yOffset = 0; yOffset < zScale; yOffset++) { tiles.add(new Fun.Tuple2<>(newTileX + xOffset, newTileY + yOffset)); } } return tiles; }
/** * Find or build a linkage associating each feature in this PointSet with a nearby edge in the StreetLayer. * This is a rather slow operation involving a lot of geometry calculations, so we cache the resulting * LinkedPointSets. This method returns a linkage from the cache if this operation has already been performed. */ public LinkedPointSet getLinkage (StreetLayer streetLayer, StreetMode streetMode) { try { Tuple2<StreetLayer, StreetMode> key = new Tuple2<>(streetLayer, streetMode); LOG.info("Seeking linkage for ({}, {}) in cache...", streetLayer, streetMode); LinkedPointSet value = linkageMap.get(key); if (value == null) { value = linkageCache.get(new Tuple2<>(streetLayer, streetMode)); } return value; } catch (ExecutionException e) { throw new RuntimeException("Failed to link PointSet to StreetLayer.", e); } }
/** * Find or build a linkage associating each feature in this PointSet with a nearby edge in the StreetLayer. * This is a rather slow operation involving a lot of geometry calculations, so we cache the resulting * LinkedPointSets. This method returns a linkage from the cache if this operation has already been performed. */ public LinkedPointSet getLinkage (StreetLayer streetLayer, StreetMode streetMode) { try { Tuple2<StreetLayer, StreetMode> key = new Tuple2<>(streetLayer, streetMode); LOG.info("Seeking linkage for ({}, {}) in cache...", streetLayer, streetMode); LinkedPointSet value = linkageMap.get(key); if (value == null) { value = linkageCache.get(new Tuple2<>(streetLayer, streetMode)); } return value; } catch (ExecutionException e) { throw new RuntimeException("Failed to link PointSet to StreetLayer.", e); } }
public SummaryStatistics collectSummaryStatistics(Set<Long> segmentIds, Boolean normalize, Set<Integer> weeks, Set<Integer>hours) { SummaryStatistics summaryStatistics = new SummaryStatistics(normalize, hours); for(Long segmentId : segmentIds) { if(weeks == null || weeks.size() == 0) { summaryStatistics.add(cumulativeStats.get(segmentId), segmentId); } else { for(Integer week : weeks) { NavigableMap<Fun.Tuple2<Long, Integer>, SegmentStatistics> subMap = statsMap.subMap(new Fun.Tuple2(segmentId, week), true, new Fun.Tuple2(segmentId, week), true); for(Object stats : subMap.values()) { summaryStatistics.add((SegmentStatistics)stats, segmentId); } } } } return summaryStatistics; }
public Fun.Tuple2<Long, Long> getEndStartTuple() { return new Fun.Tuple2<>(endNodeId, startNodeId); }
public Fun.Tuple2<Long, Long> getStartEndTuple() { return new Fun.Tuple2<>(startNodeId, endNodeId); }
private Tuple2<String, Integer> makeKey (Object i) { return new Tuple2<String, Integer> (this.shapeId, (Integer) i); }
public SummaryStatistics collectSummaryStatistics(Long segmentId, Boolean normalize, Set<Integer> weeks, Set<Integer>hours) { SummaryStatistics summaryStatistics = new SummaryStatistics(normalize, hours); if(weeks == null || weeks.size() == 0) { summaryStatistics.add(cumulativeStats.get(segmentId), segmentId); } else { for(Integer week : weeks) { NavigableMap<Fun.Tuple2<Long, Integer>, SegmentStatistics> subMap = statsMap.subMap(new Fun.Tuple2(segmentId, week), true, new Fun.Tuple2(segmentId, week), true); for(Object stats : subMap.values()) { summaryStatistics.add((SegmentStatistics)stats, segmentId); } } } return summaryStatistics; }
public Jumper getJumper(Long startNodeId, Long endNodeId) { return jumperMap.get(new Fun.Tuple2<>(startNodeId, endNodeId)); }
public void save(SpeedSample speedSample) { synchronized (this) { int week = SegmentStatistics.getWeekSinceEpoch(speedSample.getTime()); int hour = SegmentStatistics.getHourOfWeek(speedSample.getTime()); weekSet.add(week); Fun.Tuple2<Long, Integer> sampleId = new Fun.Tuple2<>(speedSample.getSegmentId(), week); SegmentStatistics segmentStatistics; segmentStatistics = statsMap.get(sampleId); if(segmentStatistics == null) segmentStatistics = new SegmentStatistics(); segmentStatistics.addSample(speedSample); statsMap.put(sampleId, segmentStatistics); } }
public SummaryStatistics collectSummaryStatistics(Long segmentId, Boolean normalize, Integer week) { SummaryStatistics summaryStatistics = new SummaryStatistics(normalize, null); NavigableMap<Fun.Tuple2<Long, Integer>, SegmentStatistics> subMap; if(week == null){ summaryStatistics.add(cumulativeStats.get(segmentId), segmentId); } else { subMap = statsMap.subMap(new Fun.Tuple2(segmentId, week), true, new Fun.Tuple2(segmentId, week), true); for(SegmentStatistics stats : subMap.values()) { summaryStatistics.add(stats, segmentId); } } return summaryStatistics; }
public static Fun.Tuple2<Integer, Integer> getTile(final double lat, final double lon) { Integer tileX = SpatialDataStore.getTileX(lon, OSMDataStore.Z_INDEX); Integer tileY = SpatialDataStore.getTileY(lat, OSMDataStore.Z_INDEX); return new Fun.Tuple2<>(tileX, tileY); }
public Shape (GTFSFeed feed, String shape_id) { Map<Fun.Tuple2<String, Integer>, ShapePoint> points = feed.shape_points.subMap(new Fun.Tuple2(shape_id, null), new Fun.Tuple2(shape_id, Fun.HI)); Coordinate[] coords = points.values().stream() .map(point -> new Coordinate(point.shape_pt_lon, point.shape_pt_lat)) .toArray(i -> new Coordinate[i]); geometry = Util.geometryFactory.createLineString(coords); shape_dist_traveled = points.values().stream().mapToDouble(point -> point.shape_dist_traveled).toArray(); } }