docs: @Pure
  	public double getLength() {
  		double length = this.roadSegments.getLength();
  		if (isValidPrimitive()) {
  			BusItineraryHalt halt = this.validHalts.get(0);
  			assert halt != null;
  			RoadSegment sgmt = halt.getRoadSegment();
  			assert sgmt != null;
  			Direction1D dir = this.roadSegments.getRoadSegmentDirectionAt(halt.getRoadSegmentIndex());
  			assert dir != null;
  			if (dir == Direction1D.SEGMENT_DIRECTION) {
  				length -= halt.getPositionOnSegment();
  			} else {
  				length -= sgmt.getLength() - halt.getPositionOnSegment();
  			}
  
  			halt = this.validHalts.get(this.validHalts.size() - 1);
  			assert halt != null;
  			sgmt = halt.getRoadSegment();
  			assert sgmt != null;
  			dir = this.roadSegments.getRoadSegmentDirectionAt(halt.getRoadSegmentIndex());
  			assert dir != null;
  			if (dir == Direction1D.SEGMENT_DIRECTION) {
  				length -= sgmt.getLength() - halt.getPositionOnSegment();
  			} else {
  				length -= halt.getPositionOnSegment();
  			}
  
  			if (length < 0.) {
  				length = 0.;
  			}
  		}
  		return length;
  	}