Interface RoadSegment

    • Method Detail

      • getUUID

        @Pure
        UUID getUUID()
        Description copied from interface: GISPrimitive
        Replies the Unique identifier.
        Specified by:
        getUUID in interface GISPrimitive
        Returns:
        the Unique identifier, never null.
      • getRoadNetwork

        @Pure
        RoadNetwork getRoadNetwork()
        Replies the road network that contains this segment.
        Returns:
        the road network that contains this segment.
      • getAntepenulvianPoint

        @Pure
        Point2d getAntepenulvianPoint()
        Replies the coordinates of the antepenulvian (before last) point.
        Returns:
        the coordinates of the antepenulvian (before last) point.
      • getFirstPoint

        @Pure
        Point2d getFirstPoint()
        Description copied from interface: Segment1D
        Replies the 2D cooordinate of the first point of the segment.
        Specified by:
        getFirstPoint in interface Segment1D<Point2d,​Vector2d>
        Returns:
        the 2D coordinate or null if 2D mapping is impossible.
      • getLastPoint

        @Pure
        Point2d getLastPoint()
        Description copied from interface: Segment1D
        Replies the 2D cooordinates of the last point of the segment.
        Specified by:
        getLastPoint in interface Segment1D<Point2d,​Vector2d>
        Returns:
        the 2D coordinates or null if 2D mapping is impossible.
      • getRoadBorderDistance

        @Pure
        double getRoadBorderDistance()
        Replies the distance to the road border according to the driving side on the road.

        This function is similar to calls to {@link #getWidth()} / 2 but with a big difference: the previous expression is always positive, the value returned by getRoadBorderDistance() has a positive or negative sign depending on the side where cars are running.

        Returns:
        shift distance from the segment's center to the road border.
        Since:
        14.0
      • getWidth

        @Pure
        double getWidth()
        Returns the road width in the geo-located referencial. The width is the distance between the border lines of the road.
        Returns:
        the width of the road in meters.
      • setWidth

        void setWidth​(double width)
        Set the road width in the geo-located referencial. The width is the distance between the border lines of the road.
        Parameters:
        width - is the width of the road in meters.
        Since:
        4.0
      • getName

        @Pure
        String getName()
        Returns the name of the road.
        Returns:
        the name of the road.
        Since:
        4.0
      • setName

        void setName​(String name)
        Set the name of the road.
        Parameters:
        name - is the name of the road.
        Since:
        4.0
      • isConnectedTo

        @Pure
        boolean isConnectedTo​(RoadSegment otherSegment)
        Replies if this segment is connected to the specified segment.
        Parameters:
        otherSegment - a segment.
        Returns:
        true if this segment is connected to the given one, otherwise false
      • getSharedConnectionWith

        @Pure
        RoadConnection getSharedConnectionWith​(RoadSegment otherSegment)
        Replies the shared connection between this segment and the specified one.
        Parameters:
        otherSegment - a segment.
        Returns:
        a shared connection if the two segments are connected, otherwise null
      • getDistanceFromStart

        @Pure
        double getDistanceFromStart​(double ratio)
        Replies the distance from the starting point.
        Parameters:
        ratio - is the position on the segment. 0 for the starting point and 1 for the ending point.
        Returns:
        the distance
      • getDistanceToEnd

        @Pure
        double getDistanceToEnd​(double ratio)
        Replies the distance to the ending point.
        Parameters:
        ratio - is the position on the segment. 0 for the starting point and 1 for the ending point.
        Returns:
        the distance
      • getGeoLocationForLocationRatio

        @Pure
        Point2d getGeoLocationForLocationRatio​(double ratio)
        Replies the geo-location of the point described by the location ratio. The location ratio is 0 for the starting point and 1 for the ending point.
        Parameters:
        ratio - is the location ratio.
        Returns:
        the location.
      • getGeoLocationForLocationRatio

        @Pure
        Point2d getGeoLocationForLocationRatio​(double ratio,
                                               double shifting)
        Replies the geo-location of the point described by the location ratio. The location ratio is 0 for the starting point and 1 for the ending point.

        The shifting value depends on the given 2D coordinate system.

        Parameters:
        ratio - is the location ratio.
        shifting - is the shifting distance.
        Returns:
        the geo-location.
      • getGeoLocationForLocationRatio

        @Pure
        Point2d getGeoLocationForLocationRatio​(double ratio,
                                               double shifting,
                                               Vector2D<?,​?> tangent)
        Replies the geo-location of the point described by the location ratio. The location ratio is 0 for the starting point and 1 for the ending point.
        Parameters:
        ratio - is the location ratio.
        shifting - is the shifting distance.
        tangent - is the vector which will be set by the coordinates of the tangent at the replied point. If null the tangent will not be computed.
        Returns:
        the geo-location.
      • getGeoLocationForLocationRatio

        void getGeoLocationForLocationRatio​(double ratio,
                                            Point2D<?,​?> geoLocation)
        Replies the geo-location of the point described by the location ratio. The location ratio is 0 for the starting point and 1 for the ending point.
        Parameters:
        ratio - is the location ratio.
        geoLocation - is the point to set with geo-localized coordinates.
      • getGeoLocationForLocationRatio

        void getGeoLocationForLocationRatio​(double ratio,
                                            double shifting,
                                            Point2D<?,​?> geoLocation)
        Replies the geo-location of the point described by the location ratio. The location ratio is 0 for the starting point and 1 for the ending point.

        The shifting value depends on the given 2D coordinate system.

        Parameters:
        ratio - is the location ratio.
        shifting - is the shifting distance.
        geoLocation - is the point to set with geo-localized coordinates.
      • getGeoLocationForLocationRatio

        void getGeoLocationForLocationRatio​(double ratio,
                                            double shifting,
                                            Point2D<?,​?> geoLocation,
                                            Vector2D<?,​?> tangent)
        Replies the geo-location of the point described by the location ratio. The location ratio is 0 for the starting point and 1 for the ending point.
        Parameters:
        ratio - is the location ratio.
        shifting - is the shifting distance.
        geoLocation - is the point to set with geo-localized coordinates.
        tangent - is the vector which will be set by the coordinates of the tangent at the replied point. If null the tangent will not be computed.
      • getGeoLocationForDistance

        @Pure
        Point2d getGeoLocationForDistance​(double desired_distance)
        Replies the geo-location of the point described by the specified distance. The desired distance is 0 for the starting point and getLength() for the ending point.
        Parameters:
        desired_distance - is the distance for which the geo location must be computed.
        Returns:
        the geo-location.
      • getGeoLocationForDistance

        @Pure
        Point2d getGeoLocationForDistance​(double desired_distance,
                                          double shifting)
        Replies the geo-location of the point described by the specified distance. The desired distance is 0 for the starting point and getLength() for the ending point.
        Parameters:
        desired_distance - is the distance for which the geo location must be computed.
        shifting - is the shifting distance.
        Returns:
        the geo-location.
      • getGeoLocationForDistance

        @Pure
        Point2d getGeoLocationForDistance​(double desired_distance,
                                          double shifting,
                                          Vector2D<?,​?> tangent)
        Replies the geo-location of the point described by the specified distance. The desired distance is 0 for the starting point and getLength() for the ending point.
        Parameters:
        desired_distance - is the distance for which the geo location must be computed.
        shifting - is the shifting distance.
        tangent - is the vector which will be set by the coordinates of the tangent at the replied point. If null the tangent will not be computed.
        Returns:
        the geo-location.
      • getGeoLocationForDistance

        void getGeoLocationForDistance​(double desired_distance,
                                       Point2D<?,​?> geoLocation)
        Replies the geo-location of the point described by the specified distance. The desired distance is 0 for the starting point and getLength() for the ending point.
        Parameters:
        desired_distance - is the distance for which the geo location must be computed.
        geoLocation - is the point to set with geo-localized coordinates.
      • getGeoLocationForDistance

        void getGeoLocationForDistance​(double desired_distance,
                                       double shifting,
                                       Point2D<?,​?> geoLocation)
        Replies the geo-location of the point described by the specified distance. The desired distance is 0 for the starting point and getLength() for the ending point.
        Parameters:
        desired_distance - is the distance for which the geo location must be computed.
        shifting - is the shifting distance.
        geoLocation - is the point to set with geo-localized coordinates.
      • getGeoLocationForDistance

        void getGeoLocationForDistance​(double desired_distance,
                                       double shifting,
                                       Point2D<?,​?> geoLocation,
                                       Vector2D<?,​?> tangent)
        Replies the geo-location of the point described by the specified distance. The desired distance is 0 for the starting point and getLength() for the ending point.
        Parameters:
        desired_distance - is the distance for which the geo location must be computed.
        shifting - is the shifting distance.
        geoLocation - is the point to set with geo-localized coordinates.
        tangent - is the vector which will be set by the coordinates of the tangent at the replied point. If null the tangent will not be computed.
      • getSegmentChain

        @Pure
        List<RoadSegment> getSegmentChain()
        Replies a list of chained road segments without any cross-road which contains this road segment.
        Returns:
        a list of road segments.
      • getSegmentChain

        @Pure
        List<RoadSegment> getSegmentChain​(boolean forward_search,
                                          boolean backward_search)
        Replies a list of chained road segments without any cross-road which contains this road segment.
        Parameters:
        forward_search - must be true to search the chain's segments in the forward direction for this road segment.
        backward_search - must be true to search the chain's segments in the backward direction for this road segment.
        Returns:
        a list of road segments.
      • iterator

        @Pure
        GraphIterator<RoadSegment,​RoadConnection> iterator​(RoadConnection starting_point,
                                                                 boolean allowManyReplies,
                                                                 boolean assumeOrientedSegments)
        Replies an iterator that permits to move along the road segment's graph starting from this road segment and from the specified starting point. If the specified starting point is not one of the ends of th segment, this function assumes to start from the point replied by getBeginPoint().
        Parameters:
        starting_point - is the point from which the iteration must start.
        allowManyReplies - is true to allow cycles during iterations, otherwise false
        assumeOrientedSegments - indicates if the iterator is taking into account the orientation of the road segments. If true it assumes that a segment could be reached by both its end points. If false it assumes that a segment could be reach only one time. This parameter is used only when allowManyReplies was set to true.
        Returns:
        an iterator
      • iterator

        @Pure
        GraphIterator<RoadSegment,​RoadConnection> iterator()
        Replies an iterator that permits to move along the road segment's graph starting from this road segment and from the specified starting point. This function assumes to start from the point replied by getBeginPoint(). This function does not allow the cycles during the iterations.
        Returns:
        an iterator
      • depthIterator

        @Pure
        default GraphIterator<RoadSegment,​RoadConnection> depthIterator​(double depth,
                                                                              double position_from_starting_point,
                                                                              RoadConnection starting_point,
                                                                              boolean allowManyReplies,
                                                                              boolean assumeOrientedSegments)
        Replies an iterator that permits to move along the road segment's graph starting from this road segment and from the specified starting point. If the specified starting point is not one of the ends of th segment, this function assumes to start from the point replied by getBeginPoint().
        Parameters:
        depth - is the maximal depth to reach (in meters).
        position_from_starting_point - is the starting position from the starting_point (in meters).
        starting_point - is the point from which the iteration must start.
        allowManyReplies - may be true to allow to reply many times the same segment, otherwise false.
        assumeOrientedSegments - may be true to assume that the same segment has two different instances for graph iteration: the first instance is associated the first point of the segment and the second instance is associated to the last point of the segment. If this parameter is false to assume that the end points of a segment are not distinguished.
        Returns:
        an iterator
        See Also:
        depthIterator(double, double, RoadConnection, boolean, boolean, DynamicDepthUpdater)
      • depthIterator

        @Pure
        GraphIterator<RoadSegment,​RoadConnection> depthIterator​(double depth,
                                                                      double position_from_starting_point,
                                                                      RoadConnection starting_point,
                                                                      boolean allowManyReplies,
                                                                      boolean assumeOrientedSegments,
                                                                      DynamicDepthUpdater<RoadSegment,​RoadConnection> dynamicDepthUpdater)
        Replies an iterator that permits to move along the road segment's graph starting from this road segment and from the specified starting point. If the specified starting point is not one of the ends of th segment, this function assumes to start from the point replied by getBeginPoint().
        Parameters:
        depth - is the maximal depth to reach (in meters).
        position_from_starting_point - is the starting position from the starting_point (in meters).
        starting_point - is the point from which the iteration must start.
        allowManyReplies - may be true to allow to reply many times the same segment, otherwise false.
        assumeOrientedSegments - may be true to assume that the same segment has two different instances for graph iteration: the first instance is associated the first point of the segment and the second instance is associated to the last point of the segment. If this parameter is false to assume that the end points of a segment are not distinguished.
        dynamicDepthUpdater - if not null, it is invoked to dynamically update the depth.
        Returns:
        an iterator
        Since:
        16.0
        See Also:
        depthIterator(double, double, RoadConnection, boolean, boolean)
      • hasUserData

        @Pure
        boolean hasUserData​(String id)
        Replies if at least one user data is associated to the given identifier.

        The user data ar not stored as attributes because they are assumed as transient.

        Parameters:
        id - is the identifier of the group
        Returns:
        true if one user data exists, otherwise false
      • containsUserData

        @Pure
        boolean containsUserData​(String id,
                                 Object data)
        Replies if the given one user data is associated to the given identifier.

        The user data ar not stored as attributes because they are assumed as transient.

        Parameters:
        id - is the identifier of the group
        data - is the data to insert in the group
        Returns:
        true if the user data exists, otherwise false
      • addUserData

        void addUserData​(String id,
                         Object data)
        Add an user data associated to this segment.

        The user data ar not stored as attributes because they are assumed as transient.

        Parameters:
        id - is the identifier of the group
        data - is the data to insert in the group
      • setUserData

        void setUserData​(String id,
                         Object data)
        Set an user data associated to this segment.

        The user data ar not stored as attributes because they are assumed as transient.

        Parameters:
        id - is the identifier of the group
        data - is the data to insert in the group
      • removeUserData

        boolean removeUserData​(String id,
                               Object data)
        Remove an user data associated to this segment.

        The user data ar not stored as attributes because they are assumed as transient.

        Parameters:
        id - is the identifier of the group
        data - is the data to remove from the group
        Returns:
        true if the data was removed, otherwise false.
      • clearUserData

        void clearUserData​(String id)
        Clear all the data from a group.

        The user data ar not stored as attributes because they are assumed as transient.

        Parameters:
        id - is the identifier of the group
      • clearUserData

        void clearUserData()
        Clear all the data from all the groups.

        The user data ar not stored as attributes because they are assumed as transient.

      • getUserData

        @Pure
        <T> T getUserData​(String id)
        Replies an user data associated to this segment.

        The user data are not stored as attributes because they are assumed as transient.

        Type Parameters:
        T - is the type of the data to reply
        Parameters:
        id - is the identifier of the group
        Returns:
        the first data in the group or null.
      • getUserDataCollection

        @Pure
        <T> Collection<? extends T> getUserDataCollection​(String id)
        Replies the user data associated to this segment.

        The user data are not stored as attributes because they are assumed as transient.

        Type Parameters:
        T - is the type of the data to reply
        Parameters:
        id - is the identifier of the group
        Returns:
        the list of the user data in the group, never null.
      • distance

        @Pure
        double distance​(Point2D<?,​?> point)
        Replies the distance between this MapElement and point.
        Parameters:
        point - a point
        Returns:
        the distance. Could be negative depending of the implementation type.
      • distance

        @Pure
        double distance​(Point2D<?,​?> point,
                        double width)
        Replies the distance between this figure and the specified point.
        Parameters:
        point - is the coordinate of the point.
        width - is the width of the polyline.
        Returns:
        the computed distance
      • distanceToEnd

        @Pure
        double distanceToEnd​(Point2D<?,​?> point)
        Replies the distance between the nearest end of this MapElement and the point.
        Parameters:
        point - a point.
        Returns:
        the distance. Should be negative depending of the MapElement type.
      • distanceToEnd

        @Pure
        double distanceToEnd​(Point2D<?,​?> point,
                             double width)
        Replies the distance between the nearest end of this MapElement and the point.
        Parameters:
        point - is the coordinate of the point.
        width - is the width of the polyline.
        Returns:
        the computed distance
      • contains

        @Pure
        boolean contains​(Point2D<?,​?> point,
                         double delta)
        Replies if the specified point (x,y) was inside the figure of this MapElement.
        Parameters:
        point - is a geo-referenced coordinate
        delta - is the geo-referenced distance that corresponds to a approximation distance in the screen coordinate system
        Returns:
        true if the specified point has a distance nearest than delta to this element, otherwise false
      • contains

        @Pure
        boolean contains​(Point2D<?,​?> point)
        Replies if the specified point (x,y) was inside the figure of this MapElement.

        If this MapElement has no associated figure, this method always returns false.

        Parameters:
        point - is a geo-referenced coordinate
        Returns:
        true if this MapElement had an associated figure and the specified point was inside this bounds of this figure, otherwise false
      • getGeoLocation

        @Pure
        GeoLocation getGeoLocation()
        Description copied from interface: GISPrimitive
        Replies the geo-location.

        A GeoLocation is unique according to the geo-location of the element. If two elements have the same points in the same order, or if two elements have the same points in a reverse order, they must have equal GeoLocations.

        The following code is always true (where the arguments of the constructors are the list of points of the polyline). It illustrates that for two elements with the same geo-localized points, they have the same geo-location identifier (Geo-Id) and they have different unique ientifier (Uid):

        
         GISElement obj1 = new MapPolyline(100,10,200,30,300,4);
         GISElement obj2 = new MapPolyline(100,10,200,30,300,4);
         assert( obj1.getGeoId().equals(obj2.getGeoId()) );
         assert( obj2.getGeoId().equals(obj1.getGeoId()) );
         assert( ! obj1.getUid().equals(obj2.getUid()) );
         assert( ! obj2.getUid().equals(obj1.getUid()) );
         
        Specified by:
        getGeoLocation in interface GISPrimitive
        Returns:
        a location
        See Also:
        GISPrimitive.getGeoId(), GISPrimitive.getGeoLocation()
      • getPointCount

        @Pure
        int getPointCount()
        Replies the count of points in all the parts.
        Returns:
        the count of points
      • points

        @Pure
        Iterable<Point2d> points()
        Replies the iterator on the points.
        Returns:
        the iterator on the points.
      • pointIterator

        @Pure
        Iterator<Point2d> pointIterator()
        Replies the iterator on the points.
        Returns:
        the iterator on the points.
      • getPointAt

        @Pure
        Point2d getPointAt​(int index)
        Replies the specified point at the given index.

        If the index is negative, it will corresponds to an index starting from the end of the list.

        Parameters:
        index - is the index of the desired point
        Returns:
        the point at the given index
        Throws:
        IndexOutOfBoundsException - in case of error.
      • intersects

        @Pure
        boolean intersects​(Shape2D<?,​?,​?,​?,​?,​? extends Rectangle2afp<?,​?,​?,​?,​?,​?>> bounds)
        Replies if this element has an intersection with the specified rectangle.

        If this MapElement has no associated figure, this method always returns false.

        Parameters:
        bounds - the bounds.s
        Returns:
        true if this MapElement has an associated figure and the specified rectangle intersecting the figure, otherwise false
      • getBoundingBox

        @Pure
        Rectangle2d getBoundingBox()
        Replies the bounding box of this element.
        Returns:
        the bounding box or null if not applicable.
      • getLaneCount

        @Pure
        int getLaneCount()
        Replies the count of lanes on this road segment.
        Returns:
        the count of lanes on this road segment.
      • getLaneDirection

        @Pure
        Direction1D getLaneDirection​(int laneIndex)
        Replies the direction of the lane at the given index.

        The lane order is influence by the side-rule of the road network, which is replied by RoadNetwork.isLeftSidedTrafficDirection() or by RoadNetwork.isRightSidedTrafficDirection(): if left-sided the left-most lane has index 0, if right-sided the right-most lane has index 0.

        Parameters:
        laneIndex - the lane index.
        Returns:
        the count of lanes on this road segment.
      • getLaneSize

        @Pure
        double getLaneSize​(int laneIndex)
        Replies the size of the lane at the given index.

        The lane order is influence by the side-rule of the road network, which is replied by RoadNetwork.isLeftSidedTrafficDirection() or by RoadNetwork.isRightSidedTrafficDirection(): if left-sided the left-most lane has index 0, if right-sided the right-most lane has index 0.

        Parameters:
        laneIndex - the lane index.
        Returns:
        the size of the lane in meters
      • getLaneCenter

        @Pure
        double getLaneCenter​(int laneIndex)
        Replies the center line of the lane at the given index.

        The center is given by the jutting distance from the road segment center to the center of the lane.

        The lane order is influence by the side-rule of the road network, which is replied by RoadNetwork.isLeftSidedTrafficDirection() or by RoadNetwork.isRightSidedTrafficDirection(): if left-sided the left-most lane has index 0, if right-sided the right-most lane has index 0.

        Parameters:
        laneIndex - the lane index.
        Returns:
        shift distance from the segment's center to the lane center.
      • getWrappedRoadSegment

        @Pure
        RoadSegment getWrappedRoadSegment()
        Replies the wrapped road segment if this object is a wrapper to another road segment. If this object is not a wrapper to another road segment, relies this object iteself.
        Returns:
        the wrapped road segment or this road segment itself.
      • isTraversableFrom

        @Pure
        boolean isTraversableFrom​(RoadConnection point)
        Replies if this road segment is traversable from the given point.

        If the given point is not the start point nor the end point, then this function replies false.

        Parameters:
        point - a point.
        Returns:
        true if this segment is traversable starting from the given point; otherwise false.
      • getTrafficDirection

        @Pure
        TrafficDirection getTrafficDirection()
        Replies the traffic direction on this road segment.
        Returns:
        the traffic direction
        Since:
        4.0
      • setTrafficDirection

        void setTrafficDirection​(TrafficDirection direction)
        Set the traffic direction on this road segment.
        Parameters:
        direction - is the new traffic direction. If null, the default traffic direction will be set.
        Since:
        4.0
      • getRoadType

        @Pure
        RoadType getRoadType()
        Replies the type of the road segment.
        Returns:
        the type of the road segment.
        Since:
        4.0
      • setRoadType

        void setRoadType​(RoadType type)
        Set the type of the road segment.
        Parameters:
        type - is the type of the road segment.
        Since:
        4.0
      • getNearestPosition

        @Pure
        Point1d getNearestPosition​(Point2D<?,​?> pos,
                                   double lateralDistance)
        Return the nearest point 1.5D from a 2D position.
        Parameters:
        pos - is the testing position.
        lateralDistance - the lateral distance to put into the replied point, if any.
        Returns:
        the nearest 1.5D position on the road network.
        Since:
        16.0
        See Also:
        getNearestPosition(Point2D)
      • getNearestPositionOnBorder

        @Pure
        default Point1d getNearestPositionOnBorder​(Point2D<?,​?> pos)
        Return the nearest point 1.5D on the border of the road segment from a 2D position.
        Parameters:
        pos - is the testing position.
        Returns:
        the nearest 1.5D position on the road segment's border.
        Since:
        16.0
        See Also:
        getNearestPosition(Point2D)
      • getRoadNumber

        @Pure
        String getRoadNumber()
        Replies the number of the road segment.
        Returns:
        the number of the road segment.
        Since:
        4.0
      • setRoadNumber

        void setRoadNumber​(String number)
        Set the number of the road segment.
        Parameters:
        number - is the number of the road segment.
        Since:
        4.0
      • toPath2D

        @Pure
        default Path2d toPath2D()
        Replies the path representing this road segment.
        Returns:
        the path.
      • toPath2D

        default Path2d toPath2D​(double startPosition,
                                double endPosition)
        Replies the path representing this road segment.
        Parameters:
        startPosition - the position along the segment at which the path representation should start. If Double.NaN or negative, the path starts at the beginning of the road segment.
        endPosition - the position along the segment at which the path representation should end. If Double.NaN or greater than the segment length, the path ends at the end of the road segment.
        Returns:
        the path.
      • toPath2D

        default void toPath2D​(Path2d path)
        Fill the given path with the values representing this road segment.
        Parameters:
        path - the path to fill out.
      • toPath2D

        void toPath2D​(Path2d path,
                      double startPosition,
                      double endPosition)
        Fill the given path with the values representing this road segment.
        Parameters:
        path - the path to fill out.
        startPosition - the position along the segment at which the path representation should start. If Double.NaN or negative, the path starts at the beginning of the road segment.
        endPosition - the position along the segment at which the path representation should end. If Double.NaN or greater than the segment length, the path ends at the end of the road segment.