It's the 15th anniversary of Google Maps Platform - Check out the latest news and announcements

Google.Maps.Unity.Intersections.RoadLattice

A representation of a graph of nodes and connections representing the road network in an area. For example, a single map tile, or a loaded map region.

Summary

Properties

Nodes
IEnumerable< RoadLatticeNode >
The nodes in this lattice.

Public functions

FindNodeAt(ulong locationUID)
Find any node in the lattice at the supplied location UID.
GetEdgeSegments()
List< LineSegment2D >
Returns a list of LineSegment2D objects representing all the edges in this lattice.
GetLocationsOfNodes()
List< Vector2 >
Returns a list of positions of all of the nodes in this lattice.
GetNodes()
List< RoadLatticeNode >
Deprecated. Please use Nodes instead. Returns a list of all the nodes in this lattice.
RoadLatticeNodePredicate(RoadLatticeNode node)
delegate bool
A predicate on a RoadLatticeNode used for filtering. For example, ins RoadLattice.SnapToNode.
SnapToNode(Vector3 position, RoadLatticeNodePredicate predicate)
UncheckedSnapToNode(Vector3 position, RoadLatticeNodePredicate predicate)
Finds the nearest node in the RoadLattice to the supplied position.

Public static functions

FindPath(RoadLatticeNode start, RoadLatticeNode end, int searchLimit, PathOptions options)
List< RoadLatticeNode >
Finds a path between the supplied nodes, or throws a NoPathException when a path cannot be found between the supplied nodes.
UncheckedFindPath(RoadLatticeNode start, RoadLatticeNode end, int searchLimit, PathOptions options)
List< RoadLatticeNode >
Returns a list of RoadLatticeNodes on the (inclusive) path from start node to end node, or null if there is no path.

Classes

Google.Maps.Unity.Intersections.RoadLattice.NoNodesFoundException

Exception thrown by RoadLattice.SnapToNode when no nodes can be found. For example, when the lattice is currently empty.

Google.Maps.Unity.Intersections.RoadLattice.NoPathException

Exception thrown by RoadLattice.FindPath when a path cannot be found.

Google.Maps.Unity.Intersections.RoadLattice.PathOptions

Additional options provided to RoadLattice.FindPath and RoadLattice.UncheckedFindPath.

Structs

Google.Maps.Unity.Intersections.RoadLattice.LineSegment2D

Encapsulates an immutable, directed line segment that represents a connection between nodes in this lattice.

Properties

Nodes

IEnumerable< RoadLatticeNode > Nodes

The nodes in this lattice.

Public functions

FindNodeAt

RoadLatticeNode FindNodeAt(
  ulong locationUID
)

Find any node in the lattice at the supplied location UID.

See RoadLatticeNode.LocationUID for more information.

Details
Parameters
locationUID
The location UID at which to look for nodes.
Returns
Any node found at the supplied location UID, or null if none exists.

GetEdgeSegments

List< LineSegment2D > GetEdgeSegments()

Returns a list of LineSegment2D objects representing all the edges in this lattice.

This method is primarily intended for use in debugging methods, e.g., displaying a representation of the RoadLattice.

Details
Returns
All of the edges in this lattice.

GetLocationsOfNodes

List< Vector2 > GetLocationsOfNodes()

Returns a list of positions of all of the nodes in this lattice.

This method is primarily intended for use in debugging methods, e.g. display.

Details
Returns
List of positions of nodes.

GetNodes

List< RoadLatticeNode > GetNodes()

Deprecated. Please use Nodes instead. Returns a list of all the nodes in this lattice.

Details
Returns
The list of nodes.

RoadLatticeNodePredicate

delegate bool RoadLatticeNodePredicate(
  RoadLatticeNode node
)

A predicate on a RoadLatticeNode used for filtering. For example, ins RoadLattice.SnapToNode.

Details
Parameters
node
The node to test.

SnapToNode

RoadLatticeNode SnapToNode(
  Vector3 position,
  RoadLatticeNodePredicate predicate
)

Finds the nearest node in the RoadLattice to the supplied position.

This is a proof of concept brute force implementation. Performance is O(n), where n is lattice.GetNodes().Count.

Details
Parameters
position
The 3D position to snap.
predicate
An optional predicate used to select which nodes are available for snapping. If provided, only nodes for which this predicate returns true can be returned as the result of snapping.
Returns
The nearest node to the supplied position or null if the lattice has no nodes, or no nodes pass the supplied predicate.

UncheckedSnapToNode

RoadLatticeNode UncheckedSnapToNode(
  Vector3 position,
  RoadLatticeNodePredicate predicate
)

Finds the nearest node in the RoadLattice to the supplied position.

Details
Parameters
position
The 3D position to snap.
predicate
An optional predicate used to select which nodes are available for snapping. If provided, only nodes for which this predicate returns true can be returned as the result of snapping.
Returns
The nearest node to the supplied position, or null if the lattice has no nodes, or if no nodes pass the supplied predicate.

Public static functions

FindPath

List< RoadLatticeNode > FindPath(
  RoadLatticeNode start,
  RoadLatticeNode end,
  int searchLimit,
  PathOptions options
)

Finds a path between the supplied nodes, or throws a NoPathException when a path cannot be found between the supplied nodes.

Details
Parameters
start
The node that begins the path.
end
The node that ends the path.
searchLimit
The maximum number of search iterations. If a path is not found within this limit, then no path is returned.
options
Additional pathfinding options. If null, PathOptions.Default is used.
Exceptions
ArgumentException
If a path cannot be found.
Returns
An ordered list of nodes on the found path

UncheckedFindPath

List< RoadLatticeNode > UncheckedFindPath(
  RoadLatticeNode start,
  RoadLatticeNode end,
  int searchLimit,
  PathOptions options
)

Returns a list of RoadLatticeNodes on the (inclusive) path from start node to end node, or null if there is no path.

Details
Parameters
start
The node that starts the path.
end
The node that ends the path.
searchLimit
The maximum number of search iterations. If a path is not found within this limit, then null is returned.
options
Additional pathfinding options. If null, PathOptions.Default is used.
Returns
An ordered list of nodes on the found path, or null.