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.
Implements
System.IEquatable<AbstractGraphElement>
System.Collections.Generic.IEqualityComparer<IGraphEntity>
Inherited Members
System.Object.Equals(System.Object, System.Object)
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Mars.Components.Environments
Assembly: Mars.Components.dll
Syntax
[MessagePackObject(true)]
public class SpatialEdge : AbstractGraphElement, IEquatable<AbstractGraphElement>, ISpatialEdge, IEdge<ISpatialEdge, ISpatialNode>, IGraphEntity, IEqualityComparer<IGraphEntity>
Constructors
| Improve this Doc View SourceSpatialEdge()
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.
Declaration
[SerializationConstructor]
public SpatialEdge()
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. |
SpatialEdge(ISpatialNode, ISpatialNode)
Creates a new instance of the SpatialEdge without source or target.
Declaration
public SpatialEdge(ISpatialNode from, ISpatialNode to)
Parameters
| Type | Name | Description |
|---|---|---|
| ISpatialNode | from | |
| ISpatialNode | to |
Properties
| Improve this Doc View SourceAttributes
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 |
|---|---|
| System.Collections.Generic.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
Gets or sets the SpatialLanes
without initialization.
Declaration
public List<SpatialLane> DataLanes { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.List<SpatialLane> |
DataModalities
Gets or sets the Modalities
without initialization.
Declaration
public ISet<SpatialModalityType> DataModalities { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.ISet<SpatialModalityType> |
DataModalityLaneRanges
Gets or sets the DataModalityLaneRanges
without initialization.
Declaration
public IDictionary<SpatialModalityType, (int, int)> DataModalityLaneRanges { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.IDictionary<SpatialModalityType, System.ValueTuple<System.Int32, System.Int32>> |
EdgeConnections
Gets or sets the EdgeData assigned to the representing road.
Declaration
public List<EdgeData> EdgeConnections { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.List<EdgeData> |
Entities
Gets all the entities on this edge as
a readonly collection.
Declaration
[IgnoreMember]
public IReadOnlyCollection<ISpatialGraphEntity> Entities { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.IReadOnlyCollection<ISpatialGraphEntity> |
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
[IgnoreMember]
public List<IEntityLane<ISpatialGraphEntity>> EntityLanes { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.List<IEntityLane<ISpatialGraphEntity>> |
From
The starting point (node) of the edge
Declaration
[IgnoreMember]
public ISpatialNode From { get; }
Property Value
| Type | Description |
|---|---|
| ISpatialNode |
FromNode
Gets or sets the key used to identify the From node.
Declaration
public int FromNode { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
Remarks
This property is only be used for de-/serialization purposes.
|
Improve this Doc
View Source
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
| Type | Description |
|---|---|
| Position[] |
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
| Type | Description |
|---|---|
| HighwayType |
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
[IgnoreMember]
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
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerable<ISpatialLane> |
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
| Type | Description |
|---|---|
| System.Collections.Generic.ISet<SpatialModalityType> |
ModalityLaneRanges
Gets the mapping of each SpatialModalityType to their lane range on this edge
e.g. CarDriving --> (0,1)
Cycling --> (2,2)
Declaration
[IgnoreMember]
public IDictionary<SpatialModalityType, (int, int)> ModalityLaneRanges { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.IDictionary<SpatialModalityType, System.ValueTuple<System.Int32, System.Int32>> |
RoadArea
Gets the polygon representing the area of this road segment.
Declaration
[IgnoreMember]
public Polygon RoadArea { get; set; }
Property Value
| Type | Description |
|---|---|
| NetTopologySuite.Geometries.Polygon |
SpatialEdgeLock
Gets the lock to handle concurrency on the edge.
Declaration
[IgnoreMember]
public ReaderWriterLockSlim SpatialEdgeLock { get; }
Property Value
| Type | Description |
|---|---|
| System.Threading.ReaderWriterLockSlim |
SpatialLanes
Gets or sets the individual lane array describing each lane with restrictions, geometry and width.
Declaration
[IgnoreMember]
public List<SpatialLane> SpatialLanes { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.List<SpatialLane> |
Examples
______________________________________ [ | | driving [_ _ _ _ _ _ | | [ | | driving,cycling [_ _ _ _ _ _ | Intersection | [#####################| | cycling,walking [/\/\/\/\/\/\/\/\/\/ >| | walking [O O O O O O O O O O >|______________| | Improve this Doc View SourceTo
The end point (node) of the edge
Declaration
[IgnoreMember]
public ISpatialNode To { get; }
Property Value
| Type | Description |
|---|---|
| ISpatialNode |
ToNode
Gets or sets the key used to identify the To node.
Declaration
public int ToNode { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
Remarks
This property is only be used for de-/serialization purposes.
|
Improve this Doc
View Source
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
| Improve this Doc View SourceClear()
Removes all entities on this edge.
Declaration
public void Clear()
Explore(ISpatialGraphEntity, Double, ISpatialEdge)
Explore the agents surroundings
Declaration
public EdgeExploreResult Explore(ISpatialGraphEntity entity, double distance = 15, 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)
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.
Declaration
public int ExploreInLaneOnEdge(ISpatialGraphEntity entity, double distance = 15)
Parameters
| Type | Name | Description |
|---|---|---|
| ISpatialGraphEntity | entity | |
| System.Double | distance |
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)
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.
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)
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.
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
| Type | Name | Description |
|---|---|---|
| ISpatialGraphEntity | entity | The respective entity to remove. |
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
System.IEquatable<T>
System.Collections.Generic.IEqualityComparer<T>