Class ServiceLegImpl
- java.lang.Object
-
- org.goplanit.utils.id.IdAbleImpl
-
- org.goplanit.utils.id.ExternalIdAbleImpl
-
- org.goplanit.graph.GraphEntityImpl
-
- org.goplanit.graph.EdgeImpl<V>
-
- org.goplanit.graph.directed.DirectedEdgeImpl<ServiceNode,ServiceLegSegment>
-
- org.goplanit.network.layer.service.ServiceLegImpl
-
- All Implemented Interfaces:
Serializable
,Comparable<IdAble>
,DirectedEdge
,Edge
,GraphEntity
,ExternalIdAble
,IdAble
,ManagedId
,ServiceLeg
public class ServiceLegImpl extends DirectedEdgeImpl<ServiceNode,ServiceLegSegment> implements ServiceLeg
A service leg connects two service nodes. Underlying are one or more physical links represented by this single service leg.- Author:
- markr
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.goplanit.utils.network.layer.service.ServiceLeg
ServiceLeg.LengthType
-
-
Field Summary
-
Fields inherited from class org.goplanit.graph.EdgeImpl
inputProperties, lengthInKm, lineGeometry, name
-
Fields inherited from interface org.goplanit.utils.graph.Edge
EDGE_ID_CLASS
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ServiceLegImpl(ServiceLegImpl other, boolean deepCopy)
Copy Constructor.protected
ServiceLegImpl(IdGroupingToken tokenId, ServiceNode nodeA, ServiceNode nodeB)
Constructor which injects link lengths directly
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.locationtech.jts.geom.Envelope
createEnvelope()
Create based on underlying links that have a geometryServiceLegImpl
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()
Because each service leg segment may comprise different physical link(s) (segments) they may have different geometry for either direction, so no single geometry may exist on the (non-directional) leg.double
getLengthKm()
Will apply #LengthType.AVERAGE to obtain average length across service leg segments (in case both service leg segments are mapped to the leg and have different lengths due to different underlying physical link segments).double
getLengthKm(ServiceLeg.LengthType lengthType)
determine length based on desired length type (in case both service leg segments are mapped to the leg and have different lengths due to different underlying physical link segments)boolean
hasGeometry()
check if geometry is availableboolean
isGeometryInAbDirection()
verify if the geometry is in the A to B direction of the link, both vertices must have geometry present.void
setGeometry(org.locationtech.jts.geom.LineString lineString)
Not allowed, set geometry via underlying leg segment physical links insteadvoid
setLengthKm(double lengthInKm)
Not allowed, set length via underlying links insteadServiceLegImpl
shallowClone()
Create a shallow copy of this entityvoid
transformGeometry(org.opengis.referencing.operation.MathTransform transformer)
Not allowed on service leg, perform on underlying links instead.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-
Methods inherited from class org.goplanit.graph.directed.DirectedEdgeImpl
getEdgeSegmentAb, getEdgeSegmentBa, registerEdgeSegment, removeEdgeSegmentAb, removeEdgeSegmentBa, replace, setEdgeSegmentAb, setEdgeSegmentBa
-
Methods inherited from class org.goplanit.graph.EdgeImpl
addInputProperty, getInputProperty, getName, getVertexA, getVertexB, removeVertex, removeVertexA, removeVertexB, replace, setName, setVertexA, setVertexB
-
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.DirectedEdge
forEachSegment, getEdgeSegment, getEdgeSegmentAb, getEdgeSegmentBa, getEdgeSegments, getVertexA, getVertexB, hasEdgeSegment, hasEdgeSegmentAb, hasEdgeSegmentBa, registerEdgeSegment, registerEdgeSegment, removeEdgeSegment, removeEdgeSegmentAb, removeEdgeSegmentBa, removeEdgeSegments, replace
-
Methods inherited from interface org.goplanit.utils.graph.Edge
addInputProperty, getIdClass, getInputProperty, getName, hasVertex, hasVertexA, hasVertexB, hasVertices, isGeometryInAbDirection, isVertexA, populateBasicGeometry, removeVertex, replace, setName, updateGeometryInjectCoordinateAtProjectedLocation
-
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.ServiceLeg
getLegSegment, getLegSegmentAb, getLegSegments, getLinkSegmentBa, getServiceNodeA, getServiceNodeB, hasLegSegmentAb, hasLegSegmentBa, hasName
-
-
-
-
Constructor Detail
-
ServiceLegImpl
protected ServiceLegImpl(IdGroupingToken tokenId, ServiceNode nodeA, ServiceNode nodeB)
Constructor which injects link lengths directly- Parameters:
tokenId
- contiguous id generation within this group for instances of this classnodeA
- first vertex in the linknodeB
- second vertex in the link
-
ServiceLegImpl
protected ServiceLegImpl(ServiceLegImpl other, boolean deepCopy)
Copy Constructor. network layer links are shallow copied.- Parameters:
other
- to copydeepCopy
- when true, create a deep cpy, shallow copy otherwise
-
-
Method Detail
-
hasGeometry
public boolean hasGeometry()
Description copied from interface:Edge
check if geometry is available- Specified by:
hasGeometry
in interfaceEdge
- Returns:
- true when all underlying service leg segments have a geometry, false otherwise
-
isGeometryInAbDirection
public boolean isGeometryInAbDirection()
Description copied from interface:Edge
verify if the geometry is in the A to B direction of the link, both vertices must have geometry present.- Specified by:
isGeometryInAbDirection
in interfaceEdge
- Returns:
- true when geometry is present and all underlying links are in ab direction, false otherwise
-
transformGeometry
public void transformGeometry(org.opengis.referencing.operation.MathTransform transformer) throws org.opengis.geometry.MismatchedDimensionException, org.opengis.referencing.operation.TransformException
Not allowed on service leg, perform on underlying links instead. Always throws exception- Specified by:
transformGeometry
in interfaceEdge
- Parameters:
transformer
- to use- Throws:
org.opengis.geometry.MismatchedDimensionException
- thrown if errororg.opengis.referencing.operation.TransformException
- thrown if error
-
createEnvelope
public org.locationtech.jts.geom.Envelope createEnvelope()
Create based on underlying links that have a geometry- Specified by:
createEnvelope
in interfaceEdge
- Returns:
- composite envelope, null if no underlying links, or links have no geometry
-
getGeometry
public org.locationtech.jts.geom.LineString getGeometry()
Because each service leg segment may comprise different physical link(s) (segments) they may have different geometry for either direction, so no single geometry may exist on the (non-directional) leg. Hence, we construct an on-the-fy and as-the-crow flies line between the service nodes instead (if the underlying service nodes do have a location)- Specified by:
getGeometry
in interfaceEdge
- Overrides:
getGeometry
in classEdgeImpl<ServiceNode>
- Returns:
- straight line between service node a position and service node b position if they have a position, otherwise null
-
setGeometry
public void setGeometry(org.locationtech.jts.geom.LineString lineString)
Not allowed, set geometry via underlying leg segment physical links instead- Specified by:
setGeometry
in interfaceEdge
- Overrides:
setGeometry
in classEdgeImpl<ServiceNode>
- Parameters:
lineString
- to use
-
getLengthKm
public double getLengthKm()
Will apply #LengthType.AVERAGE to obtain average length across service leg segments (in case both service leg segments are mapped to the leg and have different lengths due to different underlying physical link segments).- Specified by:
getLengthKm
in interfaceEdge
- Overrides:
getLengthKm
in classEdgeImpl<ServiceNode>
- Returns:
- found length, if no underlying service leg segments are present, length is set to infinite
-
getLengthKm
public double getLengthKm(ServiceLeg.LengthType lengthType)
determine length based on desired length type (in case both service leg segments are mapped to the leg and have different lengths due to different underlying physical link segments)- Specified by:
getLengthKm
in interfaceServiceLeg
- Parameters:
lengthType
- to apply- Returns:
- found length, if no underlying service leg segments are present, length is set to zero
-
setLengthKm
public void setLengthKm(double lengthInKm)
Not allowed, set length via underlying links instead- Specified by:
setLengthKm
in interfaceEdge
- Overrides:
setLengthKm
in classEdgeImpl<ServiceNode>
- Parameters:
lengthInKm
- 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 interfaceEdge
- Overrides:
validate
in classEdgeImpl<ServiceNode>
- Returns:
- true when valid, false otherwise
-
shallowClone
public ServiceLegImpl shallowClone()
Create a shallow copy of this entity- Specified by:
shallowClone
in interfaceDirectedEdge
- Specified by:
shallowClone
in interfaceEdge
- Specified by:
shallowClone
in interfaceGraphEntity
- Specified by:
shallowClone
in interfaceIdAble
- Specified by:
shallowClone
in interfaceServiceLeg
- Overrides:
shallowClone
in classDirectedEdgeImpl<ServiceNode,ServiceLegSegment>
- Returns:
- shallow copy of entity
-
deepClone
public ServiceLegImpl 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 interfaceDirectedEdge
- Specified by:
deepClone
in interfaceEdge
- Specified by:
deepClone
in interfaceGraphEntity
- Specified by:
deepClone
in interfaceIdAble
- Specified by:
deepClone
in interfaceServiceLeg
- Overrides:
deepClone
in classDirectedEdgeImpl<ServiceNode,ServiceLegSegment>
- Returns:
- deep copy of entity
-
-