Class ServiceLegImpl

    • 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 class
        nodeA - first vertex in the link
        nodeB - second vertex in the link
      • ServiceLegImpl

        protected ServiceLegImpl​(ServiceLegImpl other,
                                 boolean deepCopy)
        Copy Constructor. network layer links are shallow copied.
        Parameters:
        other - to copy
        deepCopy - 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 interface Edge
        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 interface Edge
        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 interface Edge
        Parameters:
        transformer - to use
        Throws:
        org.opengis.geometry.MismatchedDimensionException - thrown if error
        org.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 interface Edge
        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 interface Edge
        Overrides:
        getGeometry in class EdgeImpl<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 interface Edge
        Overrides:
        setGeometry in class EdgeImpl<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 interface Edge
        Overrides:
        getLengthKm in class EdgeImpl<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 interface ServiceLeg
        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 interface Edge
        Overrides:
        setLengthKm in class EdgeImpl<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 interface Edge
        Overrides:
        validate in class EdgeImpl<ServiceNode>
        Returns:
        true when valid, false otherwise