User Tools

Site Tools


api:dk11:net:tatukgis.ndk.tgis_shortestpath



TGIS_ShortestPath class

DK for .NET | TatukGIS.NDK.TGIS_ShortestPath | Classes | Constructors | Fields | Methods | Properties | Events

Encapsulates shortest path and routing functionality over a vector network.

Available also on: Delphi | Java | ActiveX | Python.

Syntax

// C#
public class TGIS_ShortestPath : TGIS_BaseObjectDisposable
{
}
' VisualBasic
Public Class TGIS_ShortestPath
  Inherits TGIS_BaseObjectDisposable
End Class
// Oxygene
type
  TGIS_ShortestPath = public class( TGIS_BaseObjectDisposable )
  end;

Inheritance

→ TGIS_BaseObjectDisposable

Constructors

Inherited Overrides Protected
Name Visibility Description
TGIS_ShortestPath() public Create an instance.

Fields

Inherited Protected
Name Visibility Description
FOnLinkCost protected Event fired when link cost is obtained while building the network.
FOnLinkDynamic protected Event fired when a link is traversed during path calculation.
FOnLinkLevel protected Event fired when the ending node levels of each link are obtained.
FOnLinkType protected Event fired when the type of each link is obtained while building the network.
FOnNodeHeuristicCost protected Event fired when heuristic cost is calculated for a node.
FOnPath protected Event fired for each link in the discovered shortest path.

Methods

Inherited Overrides Protected
Name Visibility Description
Find public Find a path between two geographic positions.
LoadTheData public Load network data from the layer and, on first use, create persistent storage files for the routing network.
Regenerate public Recreate network (including network storage files).
StartPos public Set a start position for the shortest path.
StopPos public Set a stop position for the shortest path and run path calculation.
UpdateTheData public Update the network with geocoded addresses from the geocoder.

Properties

Inherited Protected
Name Visibility Description
CompassBlocks public Compass divided into a number of blocks (4 by default).
CostModifiers public Cost modifier for a link type.
Extent public Minimum bounding rectangle (MBR) encompassing the entire computed path.
HeuristicCostModifier public Cost modifier for heuristic cost calculation.
HeuristicMode public Mode of heuristic operation used during path-cost estimation.
HeuristicThreshold public Threshold of the starting node search area.
Items public Items in the shortest path.
ItemsCount public Number of items in the shortest path.
Layer public Vector layer assigned as the routing network source.
Network public Network instance responsible for low-level network operations.
OSMRouting public If True, the local routing resource is ignored and requests are sent to the TatukGIS online routing service.
RoadLength public Field name used to calculate segment length.
RoadName public Name of the vector layer attribute field that supplies the road or feature name for each route segment.
StoragePath public Forced network storage path.
TotalCost public Total cost of the path.

Events

Inherited Protected
Name Visibility Description
LinkCostEvent public Event fired when link cost is obtained while building the network.
LinkDynamicEvent public Event which will be fired upon traversing link.
LinkLevelEvent public Event fired when the ending node levels of each link are obtained while building the network.
LinkTypeEvent public Event fired when the type of each link is obtained while building the network.
NodeHeuristicCostEvent public Event fired when heuristic cost is calculated for a node.
PathEvent public Event which will be fired on each link of the discovered shortest path.

Remarks

PURPOSE: Computes the shortest path between two geographic positions over a routable vector network (road, river, or utility network). Supports local routing via TGIS_Network and optional online routing through the TatukGIS OSM (OpenStreetMap) routing service. Results are exposed as an ordered list of TGIS_ShortestPathLink segments with cost, length, road name, course, and compass direction metadata.

BEHAVIOR: On first use, LoadTheData builds and serializes a persistent network from the supplied TGIS_LayerVector line features. Subsequent calls reload the persisted network without rebuilding. Find() locates start and end nodes, runs A* path search with optional heuristic cost, and populates Items with the ordered route segments. Cost and type customization events (LinkCostEvent, LinkTypeEvent, LinkDynamicEvent, LinkLevelEvent) are fired during network construction and traversal. When OSMRouting is True all local network operations are bypassed and requests are forwarded to the TatukGIS online routing service.

USAGE: Create a router, attach events, load network data, then find a path between two map positions.

rtrObj = TGIS_ShortestPath(GIS)
rtrObj.LinkTypeEvent := doLinkType
rtrObj.LoadTheData(layerSrc)
rtrObj.RoadName = 'FULLNAME'
if rtrObj.Find(ptFrom, ptTo) then
  for i = 0 to rtrObj.ItemsCount - 1 do
    process(rtrObj.Items[i])

CONSTRAINTS: LoadTheData must be called before Find. The viewer passed to Create is held as a weak reference. Not thread-safe; call from the main thread only.

Types of routing functionality supported by the DK are as follows:

  1. Link cost (for each direction separately)
  2. Link cost modifier to reflect personal preferences.

Typical examples are “time to traverse” and length/distance“ based. For a pipeline network, the cost might be based on volume throughput. The cost is reflected in the vector parameters/attributes.

  1. On demand link cost calculation. This would calculate the cost individually on each call for situations when parameters are changing dynamically. An example might be an electrical power network grid.
  2. Cost for traversing a node. An example might be to consider the economic cost of a toll bridge/road, or the vehicle maintenance cost associated with a particularly poorly maintained segment of road.

Basic geocoding delivers the estimated position of each street number based on the known first and last street addresses on each side of each block or each street. Locations can also be searched based on street crossings.

As is normal for GIS, all street address locations are referenced to a geographic coordinate space, so that the geocoding application can be combined with other GIS functionalities, such as GPS tracking, etc.

Data are loaded from a shape and nodes are constructed on-line. If you want to support unidirectional street routing then attach negative cost. Node cost traverse methodology is not supported. Node UID can be stored in a layer under the name NodeA, NodeB and must be an integer value greater than 0.

References

2026/10/31 23:06

Page Tools