001/* *********************************************************************** * 002 * project: org.matsim.* 003 * * 004 * *********************************************************************** * 005 * * 006 * copyright : (C) 2017 by the members listed in the COPYING, * 007 * LICENSE and WARRANTY file. * 008 * email : info at matsim dot org * 009 * * 010 * *********************************************************************** * 011 * * 012 * This program is free software; you can redistribute it and/or modify * 013 * it under the terms of the GNU General Public License as published by * 014 * the Free Software Foundation; either version 2 of the License, or * 015 * (at your option) any later version. * 016 * See also COPYING, LICENSE and WARRANTY file * 017 * * 018 * *********************************************************************** */ 019 020package org.matsim.contrib.drt.passenger.events; 021 022import java.util.Map; 023 024import org.matsim.api.core.v01.Id; 025import org.matsim.api.core.v01.network.Link; 026import org.matsim.api.core.v01.population.Person; 027import org.matsim.contrib.dvrp.optimizer.Request; 028import org.matsim.contrib.dvrp.passenger.PassengerRequestSubmittedEvent; 029 030/** 031 * @author michalm 032 */ 033public class DrtRequestSubmittedEvent extends PassengerRequestSubmittedEvent { 034 public static final String EVENT_TYPE = "DrtRequest submitted"; 035 036 public static final String ATTRIBUTE_UNSHARED_RIDE_TIME = "unsharedRideTime"; 037 public static final String ATTRIBUTE_UNSHARED_RIDE_DISTANCE = "unsharedRideDistance"; 038 039 private final double unsharedRideTime; 040 private final double unsharedRideDistance; 041 042 public DrtRequestSubmittedEvent(double time, String mode, Id<Request> requestId, Id<Person> personId, 043 Id<Link> fromLinkId, Id<Link> toLinkId, double unsharedRideTime, double unsharedRideDistance) { 044 super(time, mode, requestId, personId, fromLinkId, toLinkId); 045 this.unsharedRideTime = unsharedRideTime; 046 this.unsharedRideDistance = unsharedRideDistance; 047 } 048 049 @Override 050 public String getEventType() { 051 return EVENT_TYPE; 052 } 053 054 /** 055 * @return estimated travel time it would take to ride without any detours 056 */ 057 public final double getUnsharedRideTime() { 058 return unsharedRideTime; 059 } 060 061 /** 062 * @return estimated distance it would take to ride without any detours 063 */ 064 public final double getUnsharedRideDistance() { 065 return unsharedRideDistance; 066 } 067 068 @Override 069 public Map<String, String> getAttributes() { 070 Map<String, String> attr = super.getAttributes(); 071 attr.put(ATTRIBUTE_UNSHARED_RIDE_TIME, unsharedRideTime + ""); 072 attr.put(ATTRIBUTE_UNSHARED_RIDE_DISTANCE, unsharedRideDistance + ""); 073 return attr; 074 } 075}