Class SpatialEdge
Represents a spatial or geometric edge of this graph which is able to persist and to manage
entities on a continuous geometric line in meters.
Inheritance
System.Object
SpatialEdge
Assembly: Mars.Components.dll
Syntax
public class SpatialEdge : AbstractGraphElement, IEquatable<AbstractGraphElement>, ISpatialEdge, IEdge<ISpatialEdge, ISpatialNode>, IGraphEntity, IEqualityComparer<IGraphEntity>
Constructors
SpatialEdge()
Declaration
SpatialEdge(ISpatialNode, ISpatialNode)
Creates a new instance of the
SpatialEdge without source or target.
Declaration
public SpatialEdge(ISpatialNode from, ISpatialNode to)
Parameters
SpatialEdge(ISpatialNode, ISpatialNode, Double, Int32, SpatialModalityType[])
Creates a new instance of the directed
ISpatialEdge with no parent graph environment
Declaration
public SpatialEdge(ISpatialNode from, ISpatialNode to, double length, int laneCount = 1, SpatialModalityType[] passableTypes = null)
Parameters
Type |
Name |
Description |
ISpatialNode |
from |
The origin of this edge |
ISpatialNode |
to |
The target of this edge |
System.Double |
length |
The length of this spatial edge |
System.Int32 |
laneCount |
The amount of lanes of this spatial edge. |
SpatialModalityType[] |
passableTypes |
The set of SpatialModalityTypes which can access this edge. |
Properties
Attributes
Gets all all data associated to this edge get out by the importer from the provided source
Declaration
public IDictionary<string, object> Attributes { get; set; }
Property Value
Type |
Description |
IDictionary<System.String, System.Object> |
|
DataLaneCount
Gets or sets the
LaneCount without
initialization.
Declaration
public int DataLaneCount { get; set; }
Property Value
Type |
Description |
System.Int32 |
|
DataLanes
Declaration
public List<SpatialLane> DataLanes { get; set; }
Property Value
Type |
Description |
List<SpatialLane> |
|
DataModalities
Gets or sets the
Modalities without
initialization.
Declaration
public ISet<SpatialModalityType> DataModalities { get; set; }
Property Value
DataModalityLaneRanges
Declaration
public IDictionary<SpatialModalityType, > DataModalityLaneRanges { get; set; }
Property Value
EdgeConnections
Gets or sets the
EdgeData assigned to the representing road.
Declaration
public List<EdgeData> EdgeConnections { get; }
Property Value
Entities
Gets all the entities on this edge as
a readonly collection.
Declaration
public IReadOnlyCollection<ISpatialGraphEntity> Entities { get; }
Property Value
EntityLanes
Gets the internal index maintaining all entities positioned along an edge and
separated into multiple lane by the index of the outer array.
Declaration
public List<IEntityLane<ISpatialGraphEntity>> EntityLanes { get; set; }
Property Value
From
The starting point (node) of the edge
Declaration
public ISpatialNode From { get; }
Property Value
FromNode
Gets or sets the key used to identify the
From node.
Declaration
public int FromNode { get; set; }
Property Value
Type |
Description |
System.Int32 |
|
Geometry
Gets the line and curve form of this spatial edge
as a set of ordered geospatial points.
Declaration
public Position[] Geometry { get; set; }
Property Value
GeometryLength
Gets the line with each element representing the length codes as integer (value * 10000) until this point.
This is helper collection to improve the lookup for nearest coordinates along the path in log(log(n)
complexity,
performed by the interpolation search (Geometry).
Declaration
public int[] GeometryLength { get; set; }
Property Value
Type |
Description |
System.Int32[] |
|
HighwayType
Gets or sets the highway kind of this road segment.
Declaration
public HighwayType HighwayType { get; set; }
Property Value
IsOneWay
Gets or sets a flag indicating that this edge has no opposite edge.
Declaration
public bool IsOneWay { get; set; }
Property Value
Type |
Description |
System.Boolean |
|
LaneCount
The amount of lanes where agents can be placed on.
Declaration
public int LaneCount { get; set; }
Property Value
Type |
Description |
System.Int32 |
|
Lanes
Gets the lanes of this road edge.
Declaration
public IEnumerable<ISpatialLane> Lanes { get; }
Property Value
Length
Gets the length in meters of this spatial edge
Declaration
public double Length { get; set; }
Property Value
Type |
Description |
System.Double |
|
MaxSpeed
Defines the max speed for this edge in m/s. If the attribute value holds multiple max speeds, then the min
value is chosen.
Declaration
public double MaxSpeed { get; set; }
Property Value
Type |
Description |
System.Double |
|
Modalities
Gets or sets the modalities, identified as string to distinguish imported multiple graphs.
Declaration
public ISet<SpatialModalityType> Modalities { get; }
Property Value
ModalityLaneRanges
Declaration
public IDictionary<SpatialModalityType, > ModalityLaneRanges { get; set; }
Property Value
RoadArea
Gets the polygon representing the area of this road segment.
Declaration
public Polygon RoadArea { get; set; }
Property Value
SpatialEdgeLock
Gets the lock to handle concurrency on the edge.
Declaration
public ReaderWriterLockSlim SpatialEdgeLock { get; }
Property Value
Type |
Description |
ReaderWriterLockSlim |
|
SpatialLanes
Gets or sets the individual lane array describing each lane with restrictions, geometry and width.
Declaration
public List<SpatialLane> SpatialLanes { get; set; }
Property Value
Type |
Description |
List<SpatialLane> |
|
Examples
______________________________________
[ | |
driving [_ _ _ _ _ _ | |
[ | |
driving,cycling [_ _ _ _ _ _ | Intersection |
[#####################| |
cycling,walking [/\/\/\/\/\/\/\/\/\/ >| |
walking [O O O O O O O O O O >|______________|
To
The end point (node) of the edge
Declaration
public ISpatialNode To { get; }
Property Value
ToNode
Gets or sets the key used to identify the
To node.
Declaration
public int ToNode { get; set; }
Property Value
Type |
Description |
System.Int32 |
|
TravelTime
Gets the static
travel time in seconds
required to cross this edge
when the max-speed restrictions and the length are considered.
Declaration
public double TravelTime { get; }
Property Value
Type |
Description |
System.Double |
|
Methods
Clear()
Removes all entities on this edge.
Declaration
Explore(ISpatialGraphEntity, Double, ISpatialEdge)
Explore the agents surroundings
Declaration
public EdgeExploreResult Explore(ISpatialGraphEntity entity, double distance = null, ISpatialEdge nextEdge = null)
Parameters
Type |
Name |
Description |
ISpatialGraphEntity |
entity |
the agent around the explore takes place |
System.Double |
distance |
determines which objects the agent see's
objects that are farther ahead than "distance" will not be returned
|
ISpatialEdge |
nextEdge |
the next edge the agent will move to after
traversing the current edge
|
Returns
Type |
Description |
EdgeExploreResult |
an edge explore result which contains the found agents |
Explore(ISpatialGraphEntity, Double, Boolean, ExploreDirection, ISpatialEdge, Int32[])
Explore the agents surrounded entities for a specified
distance
in meters and a selected set of lanes or the whole
ISpatialEdge
if nothing was defined. Every entity what can be see within the distance are collected.
Explored entities will be returned grouped by lane in the
EdgeExploreResult
and ordered by the
distance
to the outgoing source
agent
.
Declaration
public EdgeExploreResult Explore(ISpatialGraphEntity entity, double distance, bool onlyNext = false, ExploreDirection direction = ExploreDirection.Forward, ISpatialEdge nextEdge = null, params int[] lanes)
Parameters
Type |
Name |
Description |
ISpatialGraphEntity |
entity |
The outgoing agent specifying the source the exploration. |
System.Double |
distance |
The exploration distance in meters. |
System.Boolean |
onlyNext |
The flag indicating that no the entity behind another
one with different position shall be explored.
Default is false so that each entity also them behind the next one will be collected.
|
ExploreDirection |
direction |
The direction of the exploration. Default is forward same direction as the edge. |
ISpatialEdge |
nextEdge |
The next edge the agent will move to after traversing the current edge. |
System.Int32[] |
lanes |
The selected lanes to explore as indices, starting with 0.
If no lane was passed each lane will be queried.
|
Returns
Type |
Description |
EdgeExploreResult |
An EdgeExploreResult containing a grouping of explores by each lane.
Each lane exploration is ordered by the distance of the object to the source.
|
Explore(Double, Double, Boolean, ExploreDirection, ISpatialEdge, Int32[])
Explore the agents surrounded entities for a specified
distance
in meters and a selected set of lanes or the whole
ISpatialEdge
if nothing was defined. Every entity what can be see within the distance are collected.
Explored entities will be returned grouped by lane in the
EdgeExploreResult
and ordered by the
distance
to the outgoing source
agent
.
Declaration
public EdgeExploreResult Explore(double source, double distance, bool onlyNext = false, ExploreDirection direction = ExploreDirection.Both, ISpatialEdge nextEdge = null, params int[] lanes)
Parameters
Type |
Name |
Description |
System.Double |
source |
The outgoing source position from which to start the exploration. |
System.Double |
distance |
The exploration distance in meters. |
System.Boolean |
onlyNext |
The flag indicating that no the entity behind another
one with different position shall be explored.
Default is false so that each entity also them behind the next one will be collected.
|
ExploreDirection |
direction |
The direction of the exploration. Default is forward same direction as the edge. |
ISpatialEdge |
nextEdge |
The next edge the agent will move to after traversing the current edge. |
System.Int32[] |
lanes |
The selected lanes to explore as indices, starting with 0.
If no lane was passed each lane will be queried.
|
Returns
Type |
Description |
EdgeExploreResult |
An EdgeExploreResult containing a grouping of explores by each lane.
Each lane exploration is ordered by the distance of the object to the source.
|
ExploreInLaneOnEdge(ISpatialGraphEntity, Double)
Declaration
public int ExploreInLaneOnEdge(ISpatialGraphEntity entity, double distance = null)
Parameters
Returns
Type |
Description |
System.Int32 |
|
Insert(ISpatialGraphEntity, Double, Int32)
Add an entity to the edge
Declaration
public bool Insert(ISpatialGraphEntity entity, double position, int laneIndex)
Parameters
Type |
Name |
Description |
ISpatialGraphEntity |
entity |
The respective entity to insert |
System.Double |
position |
The position it should be inserted |
System.Int32 |
laneIndex |
The lane it should be inserted |
Returns
Type |
Description |
System.Boolean |
true -> entity was inserted at desired position and lane
false -> the entity was already on the edge
or the desired position is already occupied
or the desired position is ahead of another entity
which would result in an unwanted overtaking maneuver
|
InsertUnsafe(ISpatialGraphEntity, Double, Int32)
Add an entity to the edge
Declaration
public bool InsertUnsafe(ISpatialGraphEntity entity, double position, int laneIndex)
Parameters
Type |
Name |
Description |
ISpatialGraphEntity |
entity |
The respective entity to insert |
System.Double |
position |
The position it should be inserted |
System.Int32 |
laneIndex |
The lane it should be inserted |
Returns
Type |
Description |
System.Boolean |
true -> entity was inserted at desired position and lane
false -> the entity was already on the edge
or the desired position is already occupied
or the desired position is ahead of another entity
which would result in an unwanted overtaking maneuver
|
IsLaneFree(Int32)
Declaration
public bool IsLaneFree(int lane)
Parameters
Type |
Name |
Description |
System.Int32 |
lane |
|
Returns
Type |
Description |
System.Boolean |
|
Merge(EdgeData)
Initialize and merges each lanes from given
EdgeData.
Declaration
public void Merge(EdgeData laneEdges)
Parameters
Type |
Name |
Description |
EdgeData |
laneEdges |
|
Move(ISpatialGraphEntity, Double, Int32)
Move an entity on the edge
Declaration
public bool Move(ISpatialGraphEntity entity, double distance, int desiredLane)
Parameters
Type |
Name |
Description |
ISpatialGraphEntity |
entity |
the entity to move |
System.Double |
distance |
the distance the entity shall be moved forth |
System.Int32 |
desiredLane |
the lane the entities wants to move on. This can either
be his current lane which or another lane (overtaking maneuver)
|
Returns
Type |
Description |
System.Boolean |
an edge move results which contains information about the movement
like a success statement and the entities new position (if successfully)
|
PosAt(ISpatialGraphEntity, Double, Int32)
Declaration
public bool PosAt(ISpatialGraphEntity entity, double position, int desiredLaneIndex)
Parameters
Type |
Name |
Description |
ISpatialGraphEntity |
entity |
|
System.Double |
position |
|
System.Int32 |
desiredLaneIndex |
|
Returns
Type |
Description |
System.Boolean |
|
Remove(ISpatialGraphEntity)
Remove an entity from the edge and from the respective lane
Declaration
public bool Remove(ISpatialGraphEntity entity)
Parameters
Returns
Type |
Description |
System.Boolean |
true -> entity was removed
false -> entity wasn't on the edge
or the remove failed
|
RemoveUnsafe(ISpatialGraphEntity, Int32)
Provides a custom remove operation based on specific passed position
value, where look at on the
specified lane to remove the desired entity
.
Declaration
public bool RemoveUnsafe(ISpatialGraphEntity entity, int lane = 0)
Parameters
Type |
Name |
Description |
ISpatialGraphEntity |
entity |
The entity to remove. |
System.Int32 |
lane |
The concrete or maybe last lane on which to remove the entity. Default is 0 |
Returns
Type |
Description |
System.Boolean |
Returns true, when the old entry was successfully removed with the passed pos , otherwise false.
|
Implements
IEquatable<>
IEqualityComparer<>