Class SpatialGraphEnvironment
The geometric graph environment for entities. Provides exploration and movement queries
to change the internal positioning of entities along edges and node.
In addition provides a routing component to find paths.
Inheritance
System.Object
SpatialGraphEnvironment
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Assembly: Mars.Components.dll
Syntax
public class SpatialGraphEnvironment : ISpatialGraphEnvironment, IGraphEnvironment<ISpatialEdge, ISpatialNode>, IEnvironment, IModelObject, IRoutePlanner
Constructors
|
Improve this Doc
View Source
SpatialGraphEnvironment()
Create a new instance of the
ISpatialGraphEnvironment which has no source associated to it
and where the graph can be constructed by the user itself.
Declaration
public SpatialGraphEnvironment()
|
Improve this Doc
View Source
SpatialGraphEnvironment(SpatialGraph)
Declaration
public SpatialGraphEnvironment(SpatialGraph existingSpatialGraph)
Parameters
Type |
Name |
Description |
SpatialGraph |
existingSpatialGraph |
Existing graph structure. |
|
Improve this Doc
View Source
Declaration
public SpatialGraphEnvironment(Input import)
Parameters
Type |
Name |
Description |
Input |
import |
The source referencing objects or files. |
|
Improve this Doc
View Source
SpatialGraphEnvironment(SpatialGraphOptions)
Declaration
public SpatialGraphEnvironment(SpatialGraphOptions options)
Parameters
Exceptions
Type |
Condition |
System.ArgumentNullException |
The import is null. |
|
Improve this Doc
View Source
SpatialGraphEnvironment(String)
Create a new instance of the
ISpatialGraphEnvironment which uses the passed
graphName
as the data source and constructs the graph from that.
Declaration
public SpatialGraphEnvironment(string graphName)
Parameters
Type |
Name |
Description |
System.String |
graphName |
The graph file to import from. |
Properties
|
Improve this Doc
View Source
BoundingBox
Gets the bounding box covering the whole network with including the farthest nodes and edges.
Declaration
public BoundingBox BoundingBox { get; set; }
Property Value
|
Improve this Doc
View Source
Edges
Set of all nodes in the graph
Declaration
[IgnoreMember]
public IDictionary<int, ISpatialEdge> Edges { get; }
Property Value
Type |
Description |
System.Collections.Generic.IDictionary<System.Int32, ISpatialEdge> |
|
|
Improve this Doc
View Source
EdgesInternal
Gets or sets the internal collection of all
SpatialEdges
used for serialization and deserialization.
Declaration
public IDictionary<int, SpatialEdge> EdgesInternal { get; set; }
Property Value
Type |
Description |
System.Collections.Generic.IDictionary<System.Int32, SpatialEdge> |
|
|
Improve this Doc
View Source
Entities
Gets all entities stored in this environment
Declaration
[IgnoreMember]
public IDictionary<ISpatialGraphEntity, IGraphEntity> Entities { get; }
Property Value
|
Improve this Doc
View Source
FeatureCollection
Gets the vector feature collection of this network and environment
Declaration
[IgnoreMember]
public FeatureCollection FeatureCollection { get; }
Property Value
Type |
Description |
NetTopologySuite.Features.FeatureCollection |
|
|
Improve this Doc
View Source
Graph
Gets the underlying graph data model representing the modality network.
Declaration
public SpatialGraph Graph { get; }
Property Value
|
Improve this Doc
View Source
Modalities
Holds all
SpatialModalityType
s that occur in the environments lanes.
Declaration
public ISet<SpatialModalityType> Modalities { get; }
Property Value
|
Improve this Doc
View Source
Nodes
Set of all nodes in the graph
Declaration
[IgnoreMember]
public ICollection<ISpatialNode> Nodes { get; }
Property Value
Type |
Description |
System.Collections.Generic.ICollection<ISpatialNode> |
|
|
Improve this Doc
View Source
NodesInternal
Gets or sets the internal collection of all
SpatialNodes
used for serialization and deserialization.
Declaration
public IDictionary<int, SpatialNode> NodesInternal { get; set; }
Property Value
Type |
Description |
System.Collections.Generic.IDictionary<System.Int32, SpatialNode> |
|
|
Improve this Doc
View Source
NodesMap
Gets the mapping of each node index to their concrete node instance.
Declaration
[IgnoreMember]
public IDictionary<int, ISpatialNode> NodesMap { get; }
Property Value
Type |
Description |
System.Collections.Generic.IDictionary<System.Int32, ISpatialNode> |
|
|
Improve this Doc
View Source
NodeTree
Gets all nodes ordered by their geographic position
Declaration
[IgnoreMember]
public K2DTree<int> NodeTree { get; }
Property Value
Type |
Description |
K2DTree<System.Int32> |
|
|
Improve this Doc
View Source
Options
Gets the used settings for this environment, with inputs,
index configurations and modality restrictions.
Declaration
public SpatialGraphOptions Options { get; }
Property Value
|
Improve this Doc
View Source
ShortestPathDatabase
Gets or creates the compressed path database when.
Declaration
[IgnoreMember]
public CompressedPathDatabase ShortestPathDatabase { get; set; }
Property Value
|
Improve this Doc
View Source
World
Declaration
[IgnoreMember]
public KnnGraph<double[], double> World { get; set; }
Property Value
Type |
Description |
KnnGraph<System.Double[], System.Double> |
|
Methods
|
Improve this Doc
View Source
AddEdge(ISpatialNode, ISpatialNode, IDictionary<String, Object>)
Creates a new edge and add references in the affected nodes.
Declaration
public ISpatialEdge AddEdge(ISpatialNode origin, ISpatialNode destination, IDictionary<string, object> attributes = null)
Parameters
Type |
Name |
Description |
ISpatialNode |
origin |
the node where the edge starts. |
ISpatialNode |
destination |
the node where the edge ends. |
System.Collections.Generic.IDictionary<System.String, System.Object> |
attributes |
All associated data to this edge e.g., the amount of lanes the length or maximum speed constraints.
|
Returns
|
Improve this Doc
View Source
AddEdge(ISpatialNode, ISpatialNode, Double, IDictionary<String, Object>, SpatialModalityType)
Create a new edge with specified length overwriting the optional containing attributes
and add references in the affected nodes.
Declaration
public ISpatialEdge AddEdge(ISpatialNode origin, ISpatialNode destination, double length, IDictionary<string, object> attributes, SpatialModalityType modalityTypes)
Parameters
Type |
Name |
Description |
ISpatialNode |
origin |
The ISpatialNode where the edge starts. |
ISpatialNode |
destination |
The ISpatialNode where the edge ends. |
System.Double |
length |
the length of this edge. |
System.Collections.Generic.IDictionary<System.String, System.Object> |
attributes |
All associated data to this edge e.g., the amount of lanes the length or maximum speed constraints.
|
SpatialModalityType |
modalityTypes |
The modality types supported by this edge. |
Returns
|
Improve this Doc
View Source
AddEdge(ISpatialNode, ISpatialNode, Double, IDictionary<String, Object>, SpatialModalityType[])
Create a new edge with specified length overwriting the optional containing attributes
and add references in the affected nodes.
Declaration
public ISpatialEdge AddEdge(ISpatialNode origin, ISpatialNode destination, double length, IDictionary<string, object> attributes = null, SpatialModalityType[] modalityTypes = null)
Parameters
Type |
Name |
Description |
ISpatialNode |
origin |
The ISpatialNode where the edge starts. |
ISpatialNode |
destination |
The ISpatialNode where the edge ends. |
System.Double |
length |
the length of this edge. |
System.Collections.Generic.IDictionary<System.String, System.Object> |
attributes |
All associated data to this edge e.g., the amount of lanes the length or maximum speed constraints.
|
SpatialModalityType[] |
modalityTypes |
The optional collection of modality types supported by this edge. |
Returns
|
Improve this Doc
View Source
AddNode(IDictionary<String, Object>)
Creates a new node and adds it to the set of nodes
Declaration
public ISpatialNode AddNode(IDictionary<string, object> attributes = null)
Parameters
Type |
Name |
Description |
System.Collections.Generic.IDictionary<System.String, System.Object> |
attributes |
All associated data to this edge (e.g., the amount of lanes the length or maximum speed constraints).
|
Returns
|
Improve this Doc
View Source
AddNode(Double, Double)
Add a new spatial node with specified longitude/x and latitude/y coordinate.
Declaration
public ISpatialNode AddNode(double x, double y)
Parameters
Type |
Name |
Description |
System.Double |
x |
The x or longitude component of the source coordinate. |
System.Double |
y |
The y or latitude component of the source coordinate. |
Returns
|
Improve this Doc
View Source
Explore(ISpatialGraphEntity, Route, Double, Boolean, ExploreDirection)
Explores multiple edges in front of an entity on forward, backward
or both directions up to the requested distance.
Declaration
public SpatialGraphExploreResult Explore(ISpatialGraphEntity entity, Route route, double distance, bool onlyNext = true, ExploreDirection direction = ExploreDirection.Forward)
Parameters
Type |
Name |
Description |
ISpatialGraphEntity |
entity |
The already inserted entity in the environment from which to start the query. |
Route |
route |
The route with edges that shall be explored along the path. |
System.Double |
distance |
The distance in meter up to which the explore should go. |
System.Boolean |
onlyNext |
The flag, when true, indicating that only the first explored entity of each edge and
lane shall be returned an nothing more what could also behind the explored one.
|
ExploreDirection |
direction |
The direction whether forward, backward or in both shall be queried for other entities. |
Returns
|
Improve this Doc
View Source
ExploreLazy(ISpatialGraphEntity, Route, Double, ExploreDirection)
Performs a lazy
exploration query on the network with the route
given as the path where along all
entities
within the exploration distance
in meter shall be returned. The exploration is started from the point the
input
entity
and does not include it.
Declaration
public IEnumerable<EdgeExploreResult> ExploreLazy(ISpatialGraphEntity entity, Route route, double distance, ExploreDirection direction = ExploreDirection.Forward)
Parameters
Type |
Name |
Description |
ISpatialGraphEntity |
entity |
The entity from which to start the exploration. |
Route |
route |
The route with edges and lanes along to explore |
System.Double |
distance |
The distance in meter how far shall be looked. |
ExploreDirection |
direction |
The direction whether forward, backward or in both shall be queried for other entities. |
Returns
Type |
Description |
System.Collections.Generic.IEnumerable<EdgeExploreResult> |
Returns an System.Collections.Generic.IEnumerable<T> of EdgeExploreResult which are collected lazy
only when an access on the element is required.
|
|
Improve this Doc
View Source
FindFastestRoute(ISpatialNode, ISpatialNode, Func<ISpatialEdge, Boolean>)
Calculates a
Route in which the whole length is
the fastest (as travel time in seconds) under consideration of max speed. When no route was found null will be
returned.
Declaration
public Route FindFastestRoute(ISpatialNode source, ISpatialNode target, Func<ISpatialEdge, bool> filter = null)
Parameters
Returns
Type |
Description |
Route |
Returns a common Route container, containing the path from from to target
which is the fastest (travel time) or null when no route was found.
|
|
Improve this Doc
View Source
FindRoute(ISpatialNode, ISpatialNode, Func<ISpatialNode, ISpatialEdge, ISpatialNode, Double>, Func<ISpatialEdge, Boolean>)
Calculates a route from a given from
node to a specified to
node and constructed
using the passed heuristic
function applying a cost on each visited edge e.g. the length or travel-time.
Using the optional filter
the whole network can first be filtered out for all edges evaluate to true.
Declaration
public Route FindRoute(ISpatialNode from, ISpatialNode to, Func<ISpatialNode, ISpatialEdge, ISpatialNode, double> heuristic = null, Func<ISpatialEdge, bool> filter = null)
Parameters
Type |
Name |
Description |
ISpatialNode |
from |
INode where the search starts |
ISpatialNode |
to |
INode where the search ends |
System.Func<ISpatialNode, ISpatialEdge, ISpatialNode, System.Double> |
heuristic |
The heuristic function which receives an
input start node, the actual visited edge associated with
from an to and the goal node
|
System.Func<ISpatialEdge, System.Boolean> |
filter |
The subgraph predicate to filter only those next edges which are evaluate to true. |
Returns
Type |
Description |
Route |
Returns a common Route container responsible
for all route updates and the underlying path of edges and nodes.
|
|
Improve this Doc
View Source
FindShortestHopRoute(ISpatialNode, ISpatialNode, SpatialModalityType)
Calculates a route which has the minimum number of intermediate edge
between source
and target
and is applicable for the specified modality
.
Declaration
public Route FindShortestHopRoute(ISpatialNode source, ISpatialNode target, SpatialModalityType modality)
Parameters
Returns
Type |
Description |
Route |
Returns a new Route with minimum amount of intermediate
edge or null when no path was found.
|
|
Improve this Doc
View Source
FindShortestHopRoute(ISpatialNode, ISpatialNode, Func<ISpatialEdge, Boolean>)
Get a route using iterative deepening depth search
Declaration
public Route FindShortestHopRoute(ISpatialNode source, ISpatialNode target, Func<ISpatialEdge, bool> filter = null)
Parameters
Returns
Type |
Description |
Route |
List of edges on that route |
|
Improve this Doc
View Source
FindShortestRoute(ISpatialNode, ISpatialNode, Func<ISpatialEdge, Boolean>)
Calculates a
Route in which the whole length is
the shortest to the desired destination or null if no rout to the target was found.
Declaration
public Route FindShortestRoute(ISpatialNode source, ISpatialNode target, Func<ISpatialEdge, bool> filter = null)
Parameters
Returns
Type |
Description |
Route |
Returns a common Route container, containing the path from from to target
which is the shortest (minimum length) or null when no route was found.
|
|
Improve this Doc
View Source
GetRandomNode()
Returns a random selected nod of this environment. Often be helpful
for testing purposes.
Declaration
public ISpatialNode GetRandomNode()
Returns
|
Improve this Doc
View Source
GetRandomNode(SpatialModalityType)
Returns a random selected node of this environment that is reachable by given modality type.
Declaration
public ISpatialNode GetRandomNode(SpatialModalityType spatialModalityType)
Parameters
Returns
|
Improve this Doc
View Source
Insert(ISpatialGraphEntity, ISpatialEdge, Double, Int32)
Insert an entity
at the specified edge with the offset (Default is zero) in the environment
and assign them the spatial position of this edge + offset
.
Declaration
public bool Insert(ISpatialGraphEntity entity, ISpatialEdge edge, double offset = 0, int lane = 0)
Parameters
Type |
Name |
Description |
ISpatialGraphEntity |
entity |
The entity to insert into the environment. |
ISpatialEdge |
edge |
The edge at which the agent shall be inserted. |
System.Double |
offset |
The position offset in meter on the specified edge specifying
at which distance to the source the entity shall be inserted.
|
System.Int32 |
lane |
The lane index on which lane the entity shall be inserted |
Returns
Type |
Description |
System.Boolean |
Returns true if the agent could be inserted or false otherwise
(e.g., caused by collisions with other entities).
|
|
Improve this Doc
View Source
Insert(ISpatialGraphEntity, ISpatialNode)
Insert an entity
at the specified node in the environment
and assign them the spatial position of this node
and
no edge and zero edge offset.
Declaration
public bool Insert(ISpatialGraphEntity entity, ISpatialNode node)
Parameters
Type |
Name |
Description |
ISpatialGraphEntity |
entity |
The entity to insert into the environment. |
ISpatialNode |
node |
The node at which the agent shall be inserted in inherit the spatial position. |
Returns
Type |
Description |
System.Boolean |
Returns true if the agent was inserted or false otherwise.
|
|
Improve this Doc
View Source
Move(ISpatialGraphEntity, Route, Double)
Move an
entity
forward using the specified edges and lanes on them
and updates the
ISpatialGraphEntitys respective attributes.
Declaration
public bool Move(ISpatialGraphEntity entity, Route route, double distance)
Parameters
Type |
Name |
Description |
ISpatialGraphEntity |
entity |
The entity to be moved |
Route |
route |
The entities route depicting the edge stops and lanes the instance desired. |
System.Double |
distance |
The distance how fare the agents want to move. |
Returns
Type |
Description |
System.Boolean |
Returns true when a movement action was successfully and the entity has been updated. |
|
Improve this Doc
View Source
NearestNode(Position, Nullable<SpatialModalityType>, Nullable<SpatialModalityType>, Double)
Resolve the passed
position
and returns the nearest
ISpatialNode.
Declaration
public ISpatialNode NearestNode(Position position, SpatialModalityType? incomingModality = null, SpatialModalityType? outgoingModality = null, double radiusInMeter = 1.7976931348623157E+308)
Parameters
Type |
Name |
Description |
Position |
position |
The coordinate to resolve |
System.Nullable<SpatialModalityType> |
incomingModality |
Filters nodes to only those that have given modality in incoming edges. |
System.Nullable<SpatialModalityType> |
outgoingModality |
Filters nodes to only those that have given modality in outgoing edges. |
System.Double |
radiusInMeter |
The radius to lookup in meter, Default is infinity |
Returns
|
Improve this Doc
View Source
NearestNode(Double[], Nullable<SpatialModalityType>, Nullable<SpatialModalityType>, Double)
Resolves the passed
position
to find the top
nearest
ISpatialNode within the
radiusInMeter
.
Declaration
public ISpatialNode NearestNode(double[] position, SpatialModalityType? incomingModality = null, SpatialModalityType? outgoingModality = null, double radiusInMeter = 1.7976931348623157E+308)
Parameters
Type |
Name |
Description |
System.Double[] |
position |
The source position for the query. |
System.Nullable<SpatialModalityType> |
incomingModality |
Filters nodes to only those that have given modality in incoming edges. |
System.Nullable<SpatialModalityType> |
outgoingModality |
Filters nodes to only those that have given modality in outgoing edges. |
System.Double |
radiusInMeter |
The exploration radius in meter. |
Returns
Type |
Description |
ISpatialNode |
Returns the nearest node within the radiusInMeter or null if nothing was found.
|
|
Improve this Doc
View Source
NearestNodes(Position, Double, Nullable<Int32>)
Resolve the passed
coordinate
and returns the nearest
ISpatialNode.
Declaration
public IEnumerable<ISpatialNode> NearestNodes(Position coordinate, double radiusInMeter = 1.7976931348623157E+308, int? limit = null)
Parameters
Type |
Name |
Description |
Position |
coordinate |
The coordinate to resolve |
System.Double |
radiusInMeter |
The radius to lookup in meter, Default is infinity |
System.Nullable<System.Int32> |
limit |
The optional upper limit of element to retrieve from the network
otherwise the maximum available element set will be returned.
|
Returns
Type |
Description |
System.Collections.Generic.IEnumerable<ISpatialNode> |
Returns the nearest ISpatialNode in the graph or null if nothing was found.. |
|
Improve this Doc
View Source
NearestNodesByHops(ISpatialNode, Int32)
Retrieve all nodes within the range of x hops
Declaration
public List<ISpatialNode> NearestNodesByHops(ISpatialNode start, int hops)
Parameters
Type |
Name |
Description |
ISpatialNode |
start |
The node where the traversal starts |
System.Int32 |
hops |
The number of hops or depth |
Returns
Type |
Description |
System.Collections.Generic.List<ISpatialNode> |
Returns a list of nodes visited one by one ordered by their hop distance, starting with start |
|
Improve this Doc
View Source
Remove(ISpatialGraphEntity)
Remove an entity from the environment and updates their
PositionOnCurrentEdge
CurrentEdge
attributes accordingly.
Declaration
public bool Remove(ISpatialGraphEntity entity)
Parameters
Returns
Type |
Description |
System.Boolean |
True if agent could be removed (was in the spatial graph environment
false if the agent wasn't in the spatial graph environment.
|
|
Improve this Doc
View Source
RemoveEdge(ISpatialEdge)
Remove an edge and all references to it from the affected nodes
Declaration
public bool RemoveEdge(ISpatialEdge edge)
Parameters
Type |
Name |
Description |
ISpatialEdge |
edge |
the edge to be removed |
Returns
Type |
Description |
System.Boolean |
true if the edge could be removed
false if the removal failed
|
|
Improve this Doc
View Source
RemoveNode(ISpatialNode)
Remove a node and delete all edges which are affected by this change
Declaration
public bool RemoveNode(ISpatialNode node)
Parameters
Type |
Name |
Description |
ISpatialNode |
node |
the node to be deleted |
Returns
Type |
Description |
System.Boolean |
true if the node could be deleted
false if the node couldn't be deleted
|
|
Improve this Doc
View Source
Serialize(Stream)
The geometric graph environment for entities. Provides exploration and movement queries
to change the internal positioning of entities along edges and node.
In addition provides a routing component to find paths.
Declaration
public void Serialize(Stream stream)
Parameters
Type |
Name |
Description |
System.IO.Stream |
stream |
|
|
Improve this Doc
View Source
Traverse(ISpatialNode, Action<ISpatialNode>, Int32)
Walks through the graph by applying the iterative deepening search
in which the benefits of BFS by visiting all nodes ordered by their hop/edge count and
DFS in which the maximum space consumption is O(n * t), than O(n^t+1)
Declaration
public void Traverse(ISpatialNode start, Action<ISpatialNode> callback, int depth = -1)
Parameters
Type |
Name |
Description |
ISpatialNode |
start |
The starting node. |
System.Action<ISpatialNode> |
callback |
The callback function which is invoked when a new ISpatialNode is visited. |
System.Int32 |
depth |
The optional amount of hops or rather depth traverse into. Default is -1 for no restriction. |
Implements
Extension Methods