Class EdgeImpl

  • All Implemented Interfaces:
    Serializable, Comparable<Edge>, Edge
    Direct Known Subclasses:
    ConnectoidImpl, LinkImpl

    public class EdgeImpl
    extends Object
    implements Edge
    Edge class connecting two vertices via some geometry. Each edge has one or two underlying edge segments in a particular direction which may carry additional information for each particular direction of the edge.
    Author:
    markr
    See Also:
    Serialized Form
    • Field Detail

      • id

        protected final long id
        Unique internal identifier
      • inputProperties

        protected Map<String,​Object> inputProperties
        Generic input property storage
      • name

        protected String name
        Name of the edge
      • vertexA

        protected Vertex vertexA
        Vertex A
      • vertexB

        protected Vertex vertexB
        Vertex B
      • length

        protected double length
        Length of edge
      • edgeSegmentAB

        protected EdgeSegment edgeSegmentAB
        Edge segment A to B direction
      • edgeSegmentBA

        protected EdgeSegment edgeSegmentBA
        Edge segment B to A direction
    • Constructor Detail

      • EdgeImpl

        protected EdgeImpl​(IdGroupingToken groupId,
                           Vertex vertexA,
                           Vertex vertexB,
                           double length)
                    throws PlanItException
        Constructor which injects link lengths directly
        Parameters:
        groupId - , contiguous id generation within this group for instances of this class
        vertexA - first vertex in the link
        vertexB - second vertex in the link
        length - length of the link
        Throws:
        PlanItException - thrown if there is an error
    • Method Detail

      • generateEdgeId

        protected static long generateEdgeId​(IdGroupingToken groupId)
        Generate edge id
        Parameters:
        groupId - , contiguous id generation within this group for instances of this class
        Returns:
        id of this Edge object
      • registerEdgeSegment

        protected EdgeSegment registerEdgeSegment​(EdgeSegment edgeSegment,
                                                  boolean directionAB)
                                           throws PlanItException
        Register EdgeSegment. If there already exists an edgeSegment for that direction it is replaced and returned
        Parameters:
        edgeSegment - EdgeSegment to be registered
        directionAB - direction of travel
        Returns:
        replaced LinkSegment
        Throws:
        PlanItException - thrown if there is an error
      • addInputProperty

        public void addInputProperty​(String key,
                                     Object value)
        Add a property from the original input that is not part of the readily available link members
        Specified by:
        addInputProperty in interface Edge
        Parameters:
        key - key (name) of input property
        value - value of input property
      • getInputProperty

        public Object getInputProperty​(String key)
        Get input property by its key
        Specified by:
        getInputProperty in interface Edge
        Parameters:
        key - key of input property
        Returns:
        value retrieved value of input property
      • getLength

        public double getLength()
        Return length of this edge in km
        Specified by:
        getLength in interface Edge
        Returns:
        length of this edge in km
      • getId

        public long getId()
        Return id of this instance. This id is expected to be generated using the org.planit.utils.misc.IdGenerator
        Specified by:
        getId in interface Edge
        Returns:
        id of this Edge object
      • getVertexA

        public Vertex getVertexA()
        Vertex A of the edge
        Specified by:
        getVertexA in interface Edge
        Returns:
        vertex A
      • getVertexB

        public Vertex getVertexB()
        Vertex B of the edge
        Specified by:
        getVertexB in interface Edge
        Returns:
        vertex B
      • getName

        public String getName()
        collect the name of the edge
        Specified by:
        getName in interface Edge
        Returns:
        the name
      • setName

        public void setName​(String name)
        set the name of this edge
        Parameters:
        name - the name of this edge
      • getEdgeSegmentAB

        public EdgeSegment getEdgeSegmentAB()
        Edge segment in the direction from A to B
        Specified by:
        getEdgeSegmentAB in interface Edge
        Returns:
        edge segment AB
      • getEdgeSegmentBA

        public EdgeSegment getEdgeSegmentBA()
        Edge segment in the direction from B to A
        Specified by:
        getEdgeSegmentBA in interface Edge
        Returns:
        edge segment BA