GtuDataRoad.java
package org.opentrafficsim.road.network.sampling;
import org.opentrafficsim.core.network.NetworkException;
import org.opentrafficsim.kpi.interfaces.GtuData;
import org.opentrafficsim.road.gtu.lane.LaneBasedGtu;
/**
* Gtu representation in road sampler.
* <p>
* Copyright (c) 2013-2023 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
* BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
* </p>
* @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
* @author <a href="https://tudelft.nl/staff/p.knoppers-1">Peter Knoppers</a>
* @author <a href="https://dittlab.tudelft.nl">Wouter Schakel</a>
*/
public class GtuDataRoad implements GtuData
{
/** Gtu. */
private final LaneBasedGtu gtu;
/**
* @param gtu LaneBasedGtu; gtu
*/
public GtuDataRoad(final LaneBasedGtu gtu)
{
this.gtu = gtu;
}
/**
* @return gtu.
*/
public final LaneBasedGtu getGtu()
{
return this.gtu;
}
/** {@inheritDoc} */
@Override
public final String getId()
{
return this.gtu.getId();
}
/** {@inheritDoc} */
@Override
public final String getOriginId()
{
try
{
return this.gtu.getStrategicalPlanner().getRoute().originNode().getId();
}
catch (NetworkException exception)
{
throw new RuntimeException("Could not get origin node.", exception);
}
}
/** {@inheritDoc} */
@Override
public final String getDestinationId()
{
try
{
return this.gtu.getStrategicalPlanner().getRoute().destinationNode().getId();
}
catch (NetworkException exception)
{
throw new RuntimeException("Could not get destination node.", exception);
}
}
/** {@inheritDoc} */
@Override
public final String getGtuId()
{
return this.gtu.getType().getId();
}
/** {@inheritDoc} */
@Override
public final String getRouteId()
{
return this.gtu.getStrategicalPlanner().getRoute().getId();
}
/** {@inheritDoc} */
@Override
public final String toString()
{
return "GtuData [gtu=" + this.gtu + "]";
}
}