@Override public Collection<TransitStopFacility> getAllPStops() { return this.scheduleWithStopsOnly.getFacilities().values(); }
@Override public Collection<TransitStopFacility> getAllPStops() { return this.scheduleWithStopsOnly.getFacilities().values(); }
@Override public Collection<TransitStopFacility> getAllPStops() { return this.scheduleWithStopsOnly.getFacilities().values(); }
@Override public TransitStopFacility getItem(Id<TransitStopFacility> id) { return this.schedule.getFacilities().get(id); }
@Override public Collection<TransitStopFacility> getAllPStops() { return this.scheduleWithStopsOnly.getFacilities().values(); }
public CreateOperatorFromTransitSchedule(OperatorFactory operatorFactory, PRouteProvider routeProvider, PConfigGroup pConfig, TransitSchedule originalSchedule) { this.operatorFactory = operatorFactory; this.routeProvider = routeProvider; this.pConfig = pConfig; this.originalStops = new LinkedHashMap<>(); for (TransitStopFacility stop : originalSchedule.getFacilities().values()) { this.originalStops.put(stop.getId().toString(), stop); } }
@Inject public TransitPerformanceFromEventBasedRouterInterfaces(WaitTime waitTimes, StopStopTime stopStopTimes, TransitSchedule transitSchedule) { this.waitTimes = waitTimes; this.stopStopTimes = stopStopTimes; this.transitLines = transitSchedule.getTransitLines(); this.stopFacilities = transitSchedule.getFacilities(); }
@Override public double getStopStopTime(Id<TransitStopFacility> stopOId, Id<TransitStopFacility> stopDId, double time) { // ATTENTION! This could be optimized. Basically, we probably don't need to // route here. However, finding the travel time even on one route is not a // computationally efficient task, because the same transit stop id may occur // multiple times on the same route. TransitStopFacility originFacility = schedule.getFacilities().get(stopOId); TransitStopFacility destinationFacility = schedule.getFacilities().get(stopDId); List<Leg> legs = transitRouter.calcRoute(originFacility, destinationFacility, time, null); return legs.stream().mapToDouble(l -> l.getTravelTime()).sum(); }
@Override public void writeDynData(ByteBuffer out) throws IOException { for (TransitStopFacility facility : this.schedule.getFacilities().values()) { out.putInt(this.agentTracker.getAgentsAtFacility(facility.getId()).size()); } }
private void removePreviousPTransitScheduleFromOriginalOne(TransitSchedule transitSchedule) { for (Id<TransitLine> transitLineId : currentExclusivePTransitLineIDs) { transitSchedule.removeTransitLine(transitSchedule.getTransitLines().get(transitLineId)); } currentExclusivePTransitLineIDs.clear(); for (Id<TransitStopFacility> facilityId : currentExclusivePFacilityIDs) { transitSchedule.removeStopFacility(transitSchedule.getFacilities().get(facilityId)); } currentExclusivePFacilityIDs.clear(); }
private static void printStatistic(TransitSchedule transitSchedule){ int nStops = 0; int nLines = 0; int nRoutes = 0; int nDepartures = 0; nStops = transitSchedule.getFacilities().values().size(); for (TransitLine transitLine : transitSchedule.getTransitLines().values()) { nLines++; for (TransitRoute transitRoute : transitLine.getRoutes().values()) { nRoutes++; nDepartures += transitRoute.getDepartures().size(); } } log.info("Transit schedule stats: " + nStops + " stops, " + nLines + " lines, " + nRoutes + " routes, " + nDepartures + " departures."); }
private void addPTransitScheduleToOriginalOne(TransitSchedule baseSchedule, TransitSchedule pSchedule) { if(pSchedule == null){ log.info("pSchedule does not exist, doing nothing"); return; } for (TransitStopFacility pStop : pSchedule.getFacilities().values()) { if (!baseSchedule.getFacilities().containsKey(pStop.getId())) { baseSchedule.addStopFacility(pStop); currentExclusivePFacilityIDs.add(pStop.getId()); } } for (TransitLine pLine : pSchedule.getTransitLines().values()) { if (!baseSchedule.getTransitLines().containsKey(pLine.getId())) { baseSchedule.addTransitLine(pLine); currentExclusivePTransitLineIDs.add(pLine.getId()); } } }
private void assertCorrectlyReprojected( final TransitSchedule originalSchedule, final TransitSchedule transformedSchedule) { Assert.assertEquals( "unexpected number of stops", originalSchedule.getFacilities().size(), transformedSchedule.getFacilities().size() ); for ( Id<TransitStopFacility> stopId : originalSchedule.getFacilities().keySet() ) { final Coord original = originalSchedule.getFacilities().get( stopId ).getCoord(); final Coord transformed = transformedSchedule.getFacilities().get( stopId ).getCoord(); Assert.assertEquals( "wrong reprojected X value", transformation.transform(original), transformed); } }
private void writeTransitStops() throws UncheckedIOException { this.writeStartTag(Constants.TRANSIT_STOPS, null); List<Tuple<String, String>> attributes = new ArrayList<Tuple<String, String>>(5); for (TransitStopFacility stop : this.schedule.getFacilities().values()) { attributes.clear(); attributes.add(this.createTuple(Constants.ID, stop.getId().toString())); final Coord coord = coordinateTransformation.transform( stop.getCoord() ); attributes.add(this.createTuple("x", coord.getX())); attributes.add(this.createTuple("y", coord.getY())); if (stop.getLinkId() != null) { attributes.add(this.createTuple("linkRefId", stop.getLinkId().toString())); } if (stop.getName() != null) { attributes.add(this.createTuple("name", stop.getName())); } attributes.add(this.createTuple("isBlocking", stop.getIsBlockingLane())); this.writeStartTag(Constants.STOP_FACILITY, attributes, true); } this.writeEndTag(Constants.TRANSIT_STOPS); }
@Override public void afterSim() { double now = this.qSim.getSimTimer().getTimeOfDay(); for (Entry<Id<TransitStopFacility>, List<PTPassengerAgent>> agentsAtStop : this.agentTracker.getAgentsAtStop().entrySet()) { TransitStopFacility stop = this.schedule.getFacilities().get(agentsAtStop.getKey()); for (PTPassengerAgent agent : agentsAtStop.getValue()) { this.qSim.getEventsManager().processEvent(new PersonStuckEvent( now, agent.getId(), stop.getLinkId(), ((MobsimAgent)agent).getMode())); this.qSim.getAgentCounter().decLiving(); this.qSim.getAgentCounter().incLost(); } } }
private boolean stopIdInServiceArea(Id<TransitStopFacility> stopId) { TransitStopFacility stop = this.transitSchedule.getFacilities().get(stopId); if (stop.getCoord().getX() < this.minX) { return false; } if (stop.getCoord().getX() > this.maxX) { return false; } if (stop.getCoord().getY() < this.minY) { return false; } if (stop.getCoord().getY() > this.maxY) { return false; } return true; }
public static ValidationResult validateAllStopsExist(final TransitSchedule schedule) { ValidationResult result = new ValidationResult(); for (TransitLine line : schedule.getTransitLines().values()) { for (TransitRoute route : line.getRoutes().values()) { for (TransitRouteStop stop : route.getStops()) { if (stop.getStopFacility() == null) { result.addIssue(new ValidationResult.ValidationIssue(ValidationResult.Severity.ERROR, "Transit line " + line.getId() + ", route " + route.getId() + " contains a stop (dep-offset=" + stop.getDepartureOffset() + ") without stop-facility. Most likely, a wrong id was specified in the file.", ValidationResult.Type.HAS_MISSING_STOP_FACILITY, Collections.singletonList(route.getId()))); } else if (schedule.getFacilities().get(stop.getStopFacility().getId()) == null) { result.addIssue(new ValidationResult.ValidationIssue(ValidationResult.Severity.ERROR, "Transit line " + line.getId() + ", route " + route.getId() + " contains a stop (stop-facility " + stop.getStopFacility().getId() + ") that is not contained in the list of all stop facilities.", ValidationResult.Type.HAS_MISSING_STOP_FACILITY, Collections.singletonList(route.getId()))); } } } } return result; }
@Test public void testAddStopFacility() { TransitSchedule schedule = new TransitScheduleImpl(new TransitScheduleFactoryImpl()); TransitStopFacility stop1 = new TransitStopFacilityImpl(Id.create(1, TransitStopFacility.class), new Coord((double) 0, (double) 0), false); TransitStopFacility stop2 = new TransitStopFacilityImpl(Id.create(2, TransitStopFacility.class), new Coord((double) 1, (double) 1), false); assertEquals(0, schedule.getFacilities().size()); schedule.addStopFacility(stop1); assertEquals(1, schedule.getFacilities().size()); assertEquals(stop1, schedule.getFacilities().get(stop1.getId())); schedule.addStopFacility(stop2); assertEquals(2, schedule.getFacilities().size()); assertEquals(stop1, schedule.getFacilities().get(stop1.getId())); assertEquals(stop2, schedule.getFacilities().get(stop2.getId())); }
void notifyScoring(ScoringEvent event) { if (this.subsidy != null) { subsidy.computeSubsidy(); } Map<Id<Vehicle>, PScoreContainer> driverId2ScoreMap = this.scorePlansHandler.getDriverId2ScoreMap(); for (Operator operator : this.operators) { operator.score(driverId2ScoreMap, subsidy, routeDesignScoreManager); } // why is the following done twice (see notifyIterationstarts)? this.pTransitSchedule = new TransitScheduleFactoryImpl().createTransitSchedule(); for (TransitStopFacility stop : this.pStopsOnly.getFacilities().values()) { this.pTransitSchedule.addStopFacility(stop); } for (Operator operator : this.operators) { this.pTransitSchedule.addTransitLine(operator.getCurrentTransitLine()); } writeScheduleToFile(this.pTransitSchedule, event.getServices().getControlerIO().getIterationFilename(event.getIteration(), "transitScheduleScored.xml.gz")); }
@Test public void testGetFacilitiesImmutable() { TransitSchedule schedule = new TransitScheduleImpl(new TransitScheduleFactoryImpl()); TransitStopFacility stop1 = new TransitStopFacilityImpl(Id.create(1, TransitStopFacility.class), new Coord((double) 0, (double) 0), false); try { schedule.getFacilities().put(stop1.getId(), stop1); fail("missing exception."); } catch (UnsupportedOperationException e) { log.info("catched expected exception.", e); } }