Class ServiceLegSegmentImpl
- java.lang.Object
-
- org.goplanit.utils.id.IdAbleImpl
-
- org.goplanit.utils.id.ExternalIdAbleImpl
-
- org.goplanit.graph.GraphEntityImpl
-
- org.goplanit.graph.directed.EdgeSegmentImpl<ServiceLeg>
-
- org.goplanit.network.layer.service.ServiceLegSegmentImpl
-
- All Implemented Interfaces:
Serializable
,Comparable<IdAble>
,EdgeSegment
,GraphEntity
,ExternalIdAble
,IdAble
,ManagedId
,ServiceLegSegment
public class ServiceLegSegmentImpl extends EdgeSegmentImpl<ServiceLeg> implements ServiceLegSegment
A service leg segment implementation.- Author:
- markr
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected List<? extends LinkSegment>
networkLayerLinkSegments
Service leg's underlying links connecting its two service nodes-
Fields inherited from interface org.goplanit.utils.graph.directed.EdgeSegment
EDGE_SEGMENT_ID_CLASS, getDownstreamVertex, getUpstreamVertex
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ServiceLegSegmentImpl(ServiceLegSegmentImpl other, boolean deepCopy)
Copy constructorprotected
ServiceLegSegmentImpl(IdGroupingToken tokenId, ServiceLeg parentLeg, boolean directionAB)
Constructor with no reference to underlying physical links (to be populated later)protected
ServiceLegSegmentImpl(IdGroupingToken tokenId, ServiceLeg parentLeg, boolean directionAB, List<LinkSegment> networkLayerLinkSegments)
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ServiceLegSegmentImpl
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.org.locationtech.jts.geom.LineString
getGeometry()
Collect the geometry of this service leg segment.double
getLengthKm()
Sum of the underlying network layer link lengths.ServiceLeg
getParent()
Collect the parent edge of the segmentList<? extends LinkSegment>
getPhysicalParentSegments()
Collect the links that make up this leg ordered and in direction from A to Bboolean
hasGeometry()
verify if geometry is present based on parent's geometryvoid
setPhysicalParentSegments(List<? extends LinkSegment> networkLayerLinkSegments)
Set the network layer links that make up this leg irrespective wether they have been set before.ServiceLegSegmentImpl
shallowClone()
Create a shallow copy of this entityboolean
validate()
Validate based on edge that it is, but also make sure that the references to parent network are consistent, i.e., the service nodes reside on the parent links in the right location as well-
Methods inherited from class org.goplanit.graph.directed.EdgeSegmentImpl
isDirectionAb, removeParentEdge, setParent, validate
-
Methods inherited from class org.goplanit.graph.GraphEntityImpl
generateAndSetId, generateId, recreateManagedIds, toString
-
Methods inherited from class org.goplanit.utils.id.ExternalIdAbleImpl
getExternalId, getXmlId, setExternalId, setXmlId
-
Methods inherited from class org.goplanit.utils.id.IdAbleImpl
equals, generateAndSetId, getId, hashCode, setId
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.goplanit.utils.graph.directed.EdgeSegment
getDownstreamVertex, getIdClass, getOppositeDirectionSegment, getParentName, getUpstreamVertex, hasParent, hasParentName, isAdjacent, isDirectionAb, isParentGeometryInSegmentDirection, removeParentEdge, setParent
-
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
-
Methods inherited from interface org.goplanit.utils.network.layer.service.ServiceLegSegment
getDownstreamServiceNode, getFirstPhysicalLinkSegment, getLastPhysicalLinkSegment, getUpstreamServiceNode, hasPhysicalParentSegments
-
-
-
-
Field Detail
-
networkLayerLinkSegments
protected List<? extends LinkSegment> networkLayerLinkSegments
Service leg's underlying links connecting its two service nodes
-
-
Constructor Detail
-
ServiceLegSegmentImpl
protected ServiceLegSegmentImpl(IdGroupingToken tokenId, ServiceLeg parentLeg, boolean directionAB)
Constructor with no reference to underlying physical links (to be populated later)- Parameters:
tokenId
- contiguous id generation within this group for instances of this classparentLeg
- parent leg of segmentdirectionAB
- direction of travel
-
ServiceLegSegmentImpl
protected ServiceLegSegmentImpl(IdGroupingToken tokenId, ServiceLeg parentLeg, boolean directionAB, List<LinkSegment> networkLayerLinkSegments)
Constructor- Parameters:
tokenId
- contiguous id generation within this group for instances of this classparentLeg
- parent leg of segmentdirectionAB
- direction of travelnetworkLayerLinkSegments
- to use
-
ServiceLegSegmentImpl
protected ServiceLegSegmentImpl(ServiceLegSegmentImpl other, boolean deepCopy)
Copy constructor- Parameters:
other
- to copydeepCopy
- when true, create a deep cpy, shallow copy otherwise
-
-
Method Detail
-
getParent
public ServiceLeg getParent()
Collect the parent edge of the segment- Specified by:
getParent
in interfaceEdgeSegment
- Specified by:
getParent
in interfaceServiceLegSegment
- Overrides:
getParent
in classEdgeSegmentImpl<ServiceLeg>
- Returns:
- parentEdge
-
getGeometry
public org.locationtech.jts.geom.LineString getGeometry()
Collect the geometry of this service leg segment. Because service leg segments comprise one or more physical link segments, they may have unique geometry compared to their opposite direction counterpart. Therefore, they are expected to be able to provide their own unique access to their geometry rather than rely on their parent, also this may be generated on the fly rather than stored on the instance- Specified by:
getGeometry
in interfaceServiceLegSegment
- Returns:
- lineString
-
getLengthKm
public double getLengthKm()
Sum of the underlying network layer link lengths. If no links are registered 0 is returned- Specified by:
getLengthKm
in interfaceEdgeSegment
- Returns:
- found length
-
hasGeometry
public boolean hasGeometry()
Description copied from interface:EdgeSegment
verify if geometry is present based on parent's geometry- Specified by:
hasGeometry
in interfaceEdgeSegment
- Specified by:
hasGeometry
in interfaceServiceLegSegment
- Returns:
- true when all underlying links have a geometry, false otherwise
-
getPhysicalParentSegments
public List<? extends LinkSegment> getPhysicalParentSegments()
Collect the links that make up this leg ordered and in direction from A to B- Specified by:
getPhysicalParentSegments
in interfaceServiceLegSegment
- Returns:
- parent links this leg represents
-
setPhysicalParentSegments
public void setPhysicalParentSegments(List<? extends LinkSegment> networkLayerLinkSegments)
Set the network layer links that make up this leg irrespective wether they have been set before. Use with caution- Specified by:
setPhysicalParentSegments
in interfaceServiceLegSegment
- Parameters:
networkLayerLinkSegments
- to use
-
validate
public boolean validate()
Validate based on edge that it is, but also make sure that the references to parent network are consistent, i.e., the service nodes reside on the parent links in the right location as well- Specified by:
validate
in interfaceEdgeSegment
- Overrides:
validate
in classEdgeSegmentImpl<ServiceLeg>
- Returns:
- true when valid, false otherwise
-
shallowClone
public ServiceLegSegmentImpl shallowClone()
Create a shallow copy of this entity- Specified by:
shallowClone
in interfaceEdgeSegment
- Specified by:
shallowClone
in interfaceGraphEntity
- Specified by:
shallowClone
in interfaceIdAble
- Specified by:
shallowClone
in interfaceServiceLegSegment
- Overrides:
shallowClone
in classEdgeSegmentImpl<ServiceLeg>
- Returns:
- shallow copy of entity
-
deepClone
public ServiceLegSegmentImpl 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 interfaceEdgeSegment
- Specified by:
deepClone
in interfaceGraphEntity
- Specified by:
deepClone
in interfaceIdAble
- Specified by:
deepClone
in interfaceServiceLegSegment
- Overrides:
deepClone
in classEdgeSegmentImpl<ServiceLeg>
- Returns:
- deep copy of entity
-
-