Interface EdgeSegment
-
- All Superinterfaces:
Comparable<IdAble>
,ExternalIdAble
,GraphEntity
,IdAble
,ManagedId
,Serializable
- All Known Subinterfaces:
ConjugateConnectoidSegment
,ConjugateEdgeSegment
,ConjugateLinkSegment
,ConnectoidSegment
,LinkSegment
,MacroscopicLinkSegment
,ServiceLegSegment
- All Known Implementing Classes:
ConjugateConnectoidSegmentImpl
,ConjugateEdgeSegmentImpl
,ConjugateLinkSegmentImpl
,ConnectoidSegmentImpl
,EdgeSegmentImpl
,LinkSegmentBase
,MacroscopicLinkSegmentImpl
,ServiceLegSegmentImpl
public interface EdgeSegment extends Serializable, GraphEntity
EdgeSegment represents an edge in a particular (single) direction. Each edge has either one or two edge segments where each edge segment may have a more detailed geography than its parent edge- Author:
- markr
-
-
Field Summary
Fields Modifier and Type Field Description static Class<EdgeSegment>
EDGE_SEGMENT_ID_CLASS
id class for generating idsstatic Function<EdgeSegment,DirectedVertex>
getDownstreamVertex
Function collecting downstream vertex for edge segmentstatic Function<EdgeSegment,DirectedVertex>
getUpstreamVertex
Function collecting upstream vertex for edge segment
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description EdgeSegment
deepClone()
An id entity should always support a deep copy, i.e., all "owned" members will be deep copied when a clone of this instance is created via this call.default DirectedVertex
getDownstreamVertex()
Get the segment's downstream vertexdefault Class<? extends EdgeSegment>
getIdClass()
All edges use the EDGE_SEGMENT_ID_CLASS to generate the unique internal idsdefault double
getLengthKm()
Provides the length in km based on its parent's informationdefault EdgeSegment
getOppositeDirectionSegment()
Collect the opposite direction segment of this edge segment (if any)DirectedEdge
getParent()
Collect the parent edge of the segmentdefault String
getParentName()
verify if parent (edge) has a namedefault DirectedVertex
getUpstreamVertex()
Get the segment's upstream vertexstatic Function<EdgeSegment,DirectedVertex>
getVertexForEdgeSegmentLambda(boolean upstreamVertex)
Collect vertex of given edge segment lambdadefault boolean
hasGeometry()
verify if geometry is present based on parent's geometrydefault boolean
hasParent()
Verify if segment has parent setdefault boolean
hasParentName()
verify if parent (edge) has a namestatic boolean
hasSegment(EdgeSegment edgeSegment, Iterable<? extends EdgeSegment> edgeSegments)
Find segment in iterable of segmentsdefault boolean
isAdjacent(EdgeSegment other, boolean allowUTurn)
Verify if provided edge segment is adjacent to this edge segment taking direction into account, i.e., either an upstream segment is directly adjacent to this segment, or this segment connects to a directly adjcent downstream segmentboolean
isDirectionAb()
check if edge segment runs from vertex a to b or b to adefault boolean
isParentGeometryInSegmentDirection(boolean allowSingleVertexWithoutGeometry)
Assuming geometry is present, if not false is returned, we verify if the geometry is provided in the direction of the segment or notvoid
removeParentEdge()
remove the parent edge from this edge segmentvoid
setParent(DirectedEdge parentEdge)
Set the parent edgeEdgeSegment
shallowClone()
Create a shallow copy of this entityboolean
validate()
validate the contents of this edge segment-
Methods inherited from interface org.goplanit.utils.id.ExternalIdAble
appendExternalId, appendExternalId, getExternalId, getIdsAsString, getSplitExternalId, getSplitExternalId, getXmlId, hasExternalId, hasXmlId, setExternalId, setXmlId, setXmlId
-
Methods inherited from interface org.goplanit.utils.id.IdAble
compareTo, getId, idEquals, idHashCode
-
Methods inherited from interface org.goplanit.utils.id.ManagedId
recreateManagedIds, resetChildManagedIdEntities
-
-
-
-
Field Detail
-
EDGE_SEGMENT_ID_CLASS
static final Class<EdgeSegment> EDGE_SEGMENT_ID_CLASS
id class for generating ids
-
getUpstreamVertex
static final Function<EdgeSegment,DirectedVertex> getUpstreamVertex
Function collecting upstream vertex for edge segment
-
getDownstreamVertex
static final Function<EdgeSegment,DirectedVertex> getDownstreamVertex
Function collecting downstream vertex for edge segment
-
-
Method Detail
-
getVertexForEdgeSegmentLambda
static Function<EdgeSegment,DirectedVertex> getVertexForEdgeSegmentLambda(boolean upstreamVertex)
Collect vertex of given edge segment lambda- Parameters:
upstreamVertex
- when true collect upstream vertex, downstream vertex otherwise- Returns:
- lambda function
-
hasSegment
static boolean hasSegment(EdgeSegment edgeSegment, Iterable<? extends EdgeSegment> edgeSegments)
Find segment in iterable of segments- Parameters:
edgeSegment
- to findedgeSegments
- to find them in- Returns:
- true when present, false otherwise
-
getUpstreamVertex
default DirectedVertex getUpstreamVertex()
Get the segment's upstream vertex- Returns:
- upstream vertex
-
getDownstreamVertex
default DirectedVertex getDownstreamVertex()
Get the segment's downstream vertex- Returns:
- downstream vertex
-
getParent
DirectedEdge getParent()
Collect the parent edge of the segment- Returns:
- parentEdge
-
hasParent
default boolean hasParent()
Verify if segment has parent set- Returns:
- true if present, false otherwise
-
removeParentEdge
void removeParentEdge()
remove the parent edge from this edge segment
-
isDirectionAb
boolean isDirectionAb()
check if edge segment runs from vertex a to b or b to a- Returns:
- true when running from a to b, otherwise false
-
validate
boolean validate()
validate the contents of this edge segment- Returns:
- true when valid, false otherwise
-
shallowClone
EdgeSegment shallowClone()
Create a shallow copy of this entity- Specified by:
shallowClone
in interfaceGraphEntity
- Specified by:
shallowClone
in interfaceIdAble
- Returns:
- shallow copy of entity
-
deepClone
EdgeSegment deepClone()
An id entity should always support a deep copy, i.e., all "owned" members will be deep copied when a clone of this instance is created via this call. To be used with caution if not called by managed id container related code- Specified by:
deepClone
in interfaceGraphEntity
- Specified by:
deepClone
in interfaceIdAble
- Returns:
- deep copy of entity
-
setParent
void setParent(DirectedEdge parentEdge)
Set the parent edge- Parameters:
parentEdge
- to set
-
getIdClass
default Class<? extends EdgeSegment> getIdClass()
All edges use the EDGE_SEGMENT_ID_CLASS to generate the unique internal ids- Specified by:
getIdClass
in interfaceManagedId
- Returns:
- idClass to use for generating ids for instances of this idable derived class
-
hasParentName
default boolean hasParentName()
verify if parent (edge) has a name- Returns:
- true when present, false otherwise
-
getParentName
default String getParentName()
verify if parent (edge) has a name- Returns:
- true when present, false otherwise
-
getOppositeDirectionSegment
default EdgeSegment getOppositeDirectionSegment()
Collect the opposite direction segment of this edge segment (if any)- Returns:
- opposite direction segment, null if not present
-
isParentGeometryInSegmentDirection
default boolean isParentGeometryInSegmentDirection(boolean allowSingleVertexWithoutGeometry)
Assuming geometry is present, if not false is returned, we verify if the geometry is provided in the direction of the segment or not- Parameters:
allowSingleVertexWithoutGeometry
- when true, we assume that geometry of edge is ok to be not matching vertex on one end- Returns:
- true when geometry direction coincides with segment direction, false otherwise
-
isAdjacent
default boolean isAdjacent(EdgeSegment other, boolean allowUTurn)
Verify if provided edge segment is adjacent to this edge segment taking direction into account, i.e., either an upstream segment is directly adjacent to this segment, or this segment connects to a directly adjcent downstream segment- Parameters:
other
- edge segment to verify adjacencyallowUTurn
- when true the opposite direction segment is considered adjacent, otherwise not- Returns:
- true when adjacent, false otherwise
-
getLengthKm
default double getLengthKm()
Provides the length in km based on its parent's information- Returns:
- length in km of the segment
-
hasGeometry
default boolean hasGeometry()
verify if geometry is present based on parent's geometry- Returns:
- true when parent has geometry, false otherwise
-
-