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 protectedServiceLegImpl(ServiceLegImpl other, boolean deepCopy)Copy Constructor.protectedServiceLegImpl(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.EnvelopecreateEnvelope()Create based on underlying links that have a geometryServiceLegImpldeepClone()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.LineStringgetGeometry()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.doublegetLengthKm()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).doublegetLengthKm(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)booleanhasGeometry()check if geometry is availablebooleanisGeometryInAbDirection()verify if the geometry is in the A to B direction of the link, both vertices must have geometry present.voidsetGeometry(org.locationtech.jts.geom.LineString lineString)Not allowed, set geometry via underlying leg segment physical links insteadvoidsetLengthKm(double lengthInKm)Not allowed, set length via underlying links insteadServiceLegImplshallowClone()Create a shallow copy of this entityvoidtransformGeometry(org.opengis.referencing.operation.MathTransform transformer)Not allowed on service leg, perform on underlying links instead.booleanvalidate()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:Edgecheck if geometry is available- Specified by:
hasGeometryin interfaceEdge- Returns:
- true when all underlying service leg segments have a geometry, false otherwise
-
isGeometryInAbDirection
public boolean isGeometryInAbDirection()
Description copied from interface:Edgeverify if the geometry is in the A to B direction of the link, both vertices must have geometry present.- Specified by:
isGeometryInAbDirectionin 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.TransformExceptionNot allowed on service leg, perform on underlying links instead. Always throws exception- Specified by:
transformGeometryin 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:
createEnvelopein 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:
getGeometryin interfaceEdge- Overrides:
getGeometryin 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:
setGeometryin interfaceEdge- Overrides:
setGeometryin 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:
getLengthKmin interfaceEdge- Overrides:
getLengthKmin 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:
getLengthKmin 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:
setLengthKmin interfaceEdge- Overrides:
setLengthKmin 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:
validatein interfaceEdge- Overrides:
validatein classEdgeImpl<ServiceNode>- Returns:
- true when valid, false otherwise
-
shallowClone
public ServiceLegImpl shallowClone()
Create a shallow copy of this entity- Specified by:
shallowClonein interfaceDirectedEdge- Specified by:
shallowClonein interfaceEdge- Specified by:
shallowClonein interfaceGraphEntity- Specified by:
shallowClonein interfaceIdAble- Specified by:
shallowClonein interfaceServiceLeg- Overrides:
shallowClonein 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:
deepClonein interfaceDirectedEdge- Specified by:
deepClonein interfaceEdge- Specified by:
deepClonein interfaceGraphEntity- Specified by:
deepClonein interfaceIdAble- Specified by:
deepClonein interfaceServiceLeg- Overrides:
deepClonein classDirectedEdgeImpl<ServiceNode,ServiceLegSegment>- Returns:
- deep copy of entity
-
-