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); }
HandleTransitStopResult handleTransitStop(final double now, final QVehicle veh, final TransitDriverAgent transitDriver, Id<Link> linkId) { TransitStopFacility stop = transitDriver.getNextTransitStop(); if ((stop != null) && (stop.getLinkId().equals(linkId))) { double delay = transitDriver.handleTransitStop(stop, now); if (delay > 0.0) { veh.setEarliestLinkExitTime(now + delay); // (if the vehicle is not removed from the queue in the following lines, then this will effectively block the lane if (!stop.getIsBlockingLane()) { transitVehicleStopQueue.add(veh); // transit vehicle which is removed to the transit stop space return HandleTransitStopResult.accepted; } else { // transit vehicle which blocks its lane by getting its exit time increased return HandleTransitStopResult.rehandle; } } else { // transit vehicle which instantaneously delivered passangers return HandleTransitStopResult.rehandle; } } else { // transit vehicle which either arrives or continues driving return HandleTransitStopResult.continue_driving; } }
public void testBlockingStop() { Id<TransitStopFacility> id = Id.create(2491, TransitStopFacility.class); Coord coord = new Coord((double) 30, (double) 5); TransitStopFacility stop = createTransitStopFacility(id, coord, false); assertFalse(stop.getIsBlockingLane()); stop = createTransitStopFacility(id, coord, true); assertTrue(stop.getIsBlockingLane()); }
attributes.add(createTuple(Constants.STOP_AREA_ID, stop.getStopAreaId().toString())); attributes.add(createTuple("isBlocking", stop.getIsBlockingLane())); if (AttributesUtils.isEmpty(stop.getAttributes())) { this.writeStartTag(Constants.STOP_FACILITY, attributes, true);
TransitStopFacility newFacility = this.schedule.getFactory().createTransitStopFacility(newId, toFacility.getCoord(), toFacility.getIsBlockingLane()); newFacility.setStopAreaId(Id.create(toFacility.getId(), TransitStopArea.class)); newFacility.setLinkId(link.getId());
public void testInitialization() { Id<TransitStopFacility> id = Id.create(2491, TransitStopFacility.class); Coord coord = new Coord((double) 30, (double) 5); TransitStopFacility stop = createTransitStopFacility(id, coord, false); assertEquals(id.toString(), stop.getId().toString()); assertEquals(coord.getX(), stop.getCoord().getX(), EPSILON); assertEquals(coord.getY(), stop.getCoord().getY(), EPSILON); assertFalse(stop.getIsBlockingLane()); }
@Test public void testStopFacility_isBlocking() { TransitSchedule schedule = new TransitScheduleFactoryImpl().createTransitSchedule(); TransitScheduleReaderV1 reader = new TransitScheduleReaderV1(schedule, new RouteFactories()); Stack<String> context = new Stack<String>(); Attributes emptyAtts = AttributesBuilder.getEmpty(); reader.startTag(Constants.TRANSIT_SCHEDULE, emptyAtts, context); context.push(Constants.TRANSIT_SCHEDULE); reader.startTag(Constants.TRANSIT_STOPS, emptyAtts, context); context.push(Constants.TRANSIT_STOPS); Attributes atts = new AttributesBuilder().add(Constants.ID, "stop1"). add(Constants.X, "79").add(Constants.Y, "80").add(Constants.IS_BLOCKING, "true").get(); reader.startTag(Constants.STOP_FACILITY, atts, context); reader.endTag(Constants.STOP_FACILITY, EMPTY_STRING, context); reader.endTag(context.pop(), EMPTY_STRING, context);// TRANSIT_STOPS reader.endTag(context.pop(), EMPTY_STRING, context);// TRANSIT_SCHEDULE assertEquals(1, schedule.getFacilities().size()); TransitStopFacility stop = schedule.getFacilities().get(Id.create("stop1", TransitStopFacility.class)); assertNotNull(stop); assertEquals(79.0, stop.getCoord().getX(), MatsimTestCase.EPSILON); assertEquals(80.0, stop.getCoord().getY(), MatsimTestCase.EPSILON); assertTrue(stop.getIsBlockingLane()); }
@Test public void testStopFacility_Minimalistic() { TransitSchedule schedule = new TransitScheduleFactoryImpl().createTransitSchedule(); TransitScheduleReaderV1 reader = new TransitScheduleReaderV1(schedule, new RouteFactories()); Stack<String> context = new Stack<String>(); Attributes emptyAtts = AttributesBuilder.getEmpty(); reader.startTag(Constants.TRANSIT_SCHEDULE, emptyAtts, context); context.push(Constants.TRANSIT_SCHEDULE); reader.startTag(Constants.TRANSIT_STOPS, emptyAtts, context); context.push(Constants.TRANSIT_STOPS); Attributes atts = new AttributesBuilder().add(Constants.ID, "stop1"). add(Constants.X, "79").add(Constants.Y, "80").get(); reader.startTag(Constants.STOP_FACILITY, atts, context); reader.endTag(Constants.STOP_FACILITY, EMPTY_STRING, context); reader.endTag(context.pop(), EMPTY_STRING, context);// TRANSIT_STOPS reader.endTag(context.pop(), EMPTY_STRING, context);// TRANSIT_SCHEDULE assertEquals(1, schedule.getFacilities().size()); TransitStopFacility stop = schedule.getFacilities().get(Id.create("stop1", TransitStopFacility.class)); assertNotNull(stop); assertEquals(79.0, stop.getCoord().getX(), MatsimTestCase.EPSILON); assertEquals(80.0, stop.getCoord().getY(), MatsimTestCase.EPSILON); assertNull(stop.getLinkId()); assertNull(stop.getName()); assertFalse(stop.getIsBlockingLane()); }
assertEquals("different y coordinates.", stopE.getCoord().getY(), stopA.getCoord().getY(), EPSILON); assertEquals("different link information.", stopE.getLinkId(), stopA.getLinkId()); assertEquals("different isBlocking.", stopE.getIsBlockingLane(), stopA.getIsBlockingLane()); assertEquals("different names.", stopE.getName(), stopA.getName());
@Test public void testCreateTransitStopFacility() { TransitScheduleFactory builder = createTransitScheduleBuilder(); Id<TransitStopFacility> id1 = Id.create(6, TransitStopFacility.class); Coord coord1 = new Coord((double) 511, (double) 1980); Id<TransitStopFacility> id2 = Id.create(7, TransitStopFacility.class); Coord coord2 = new Coord((double) 105, (double) 1979); TransitStopFacility stopFacility1 = builder.createTransitStopFacility(id1, coord1, false); Assert.assertEquals(id1, stopFacility1.getId()); Assert.assertEquals(coord1.getX(), stopFacility1.getCoord().getX(), MatsimTestUtils.EPSILON); Assert.assertEquals(coord1.getY(), stopFacility1.getCoord().getY(), MatsimTestUtils.EPSILON); Assert.assertFalse(stopFacility1.getIsBlockingLane()); TransitStopFacility stopFacility2 = builder.createTransitStopFacility(id2, coord2, true); Assert.assertEquals(id2, stopFacility2.getId()); Assert.assertEquals(coord2.getX(), stopFacility2.getCoord().getX(), MatsimTestUtils.EPSILON); Assert.assertEquals(coord2.getY(), stopFacility2.getCoord().getY(), MatsimTestUtils.EPSILON); Assert.assertTrue(stopFacility2.getIsBlockingLane()); }