package org.opentrafficsim.demo.ntm; import org.locationtech.jts.geom.Coordinate; import org.opentrafficsim.core.geometry.OTSPoint3D; import org.opentrafficsim.core.network.Network; import org.opentrafficsim.core.network.NetworkException; import org.opentrafficsim.core.network.OTSNode; /** *
* Copyright (c) 2013-2017 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
* BSD-style license. See OpenTrafficSim License.
*
* $LastChangedDate$, @version $Revision$, by $Author$,
* initial version 7 Oct 2014
* Copyright (c) 2013-2017 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
*
* $LastChangedDate$, @version $Revision$, by $Author$,
* initial version 10 Oct 2014
* @author Alexander Verbraeck
* @author Hans van Lint
* @author Peter Knoppers
* @author Guus Tamminga
* @author Yufei Yuan
*/
public class NTMNode extends OTSNode implements Comparable
* BSD-style license. See OpenTrafficSim License.
*
* @author Alexander Verbraeck
* @author Hans van Lint
* @author Peter Knoppers
* @author Guus Tamminga
* @author Yufei Yuan
*/
public enum TrafficBehaviourType
{
NTM,
CORDON,
FLOW,
CENTROID,
ROAD
};
/** */
/** */
// private static long indexNumber = 0;
private static final long serialVersionUID = 7273393005308265130L;
/** */
private TrafficBehaviourType behaviourType;
/** */
// private final long id;
/**
* @param nr String; to Identify
* @param point Coordinate; ...
* @param behaviourType TrafficBehaviourType; describes traffic behaviour of units moving through the "node"
* @throws NetworkException
*/
public NTMNode(final Network network, String nr, Coordinate point, TrafficBehaviourType behaviourType)
throws NetworkException
{
super(network, nr, new OTSPoint3D(point));
// long index = indexNumber++;
this.behaviourType = behaviourType;
}
/**
* create a ShpNode Point
* @param x1 double; coord
* @param y1 double; coord
* @return new Point
*/
public static Coordinate createPoint(double x1, double y1)
{
return new Coordinate(x1, y1);
}
/**
* @return behaviourType.
*/
public final TrafficBehaviourType getBehaviourType()
{
return this.behaviourType;
}
/**
* @param behaviourType TrafficBehaviourType; set behaviourType.
*/
public final void setBehaviourType(final TrafficBehaviourType behaviourType)
{
this.behaviourType = behaviourType;
}
/** {@inheritDoc} */
@SuppressWarnings("checkstyle:designforextension")
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + ((getPoint() == null) ? 0 : getPoint().hashCode());
return result;
}
/** {@inheritDoc} */
@SuppressWarnings({"checkstyle:needbraces", "checkstyle:designforextension"})
@Override
public boolean equals(final Object obj)
{
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
NTMNode other = (NTMNode) obj;
if (getPoint() == null)
{
if (other.getPoint().getCoordinate() != null)
return false;
}
else if (!getPoint().equals(other.getPoint().getCoordinate()))
return false;
return true;
}
/** {@inheritDoc} */
public int compareTo(NTMNode o)
{
return this.getId().compareTo(o.getId());
}
}