DK11 for Delphi | GisShortestPath.TGIS_ShortestPath.Find | Constructors | Methods | Properties | Events
Find path between two existing nodes.
// Delphi public function Find( const _from : TGIS_Point; const _to : TGIS_Point ) : Boolean;
// C++ Builder public: bool Find( TGIS_Point* const _from, TGIS_Point* const _to );
Name | Type | Description |
---|---|---|
_from | TGIS_Point | start node |
_to | TGIS_Point | end node |
Type | Description |
---|---|
Boolean | True if a path has been found. |
var GIS: TGIS_ViewerWnd; layerRoute : TGIS_LayerVector ; rtrObj : TGIS_ShortestPath ; Highways, SmallRoads, res : Integer; AddrFrom, AddrTo, ang, clue : String; begin // modify cost values for roads type rtrObj.CostModifiers[0] := 1 - 1/11 * Highways; rtrObj.CostModifiers[1] := 1 - 1/11 * SmallRoads; // let's find a starting position res := geoObj.Parse( AddrFrom) ; if res > 0 then AddrFrom := geoObj.Query[0] else AddrFrom := AddrFrom + ' ???' ; if res <= 0 then exit ; pt_a := geoObj.Point[0] ; // let's find an ending position res := geoObj.Parse(AddrTo) ; if res > 0 then AddrTo := geoObj.Query[0] else AddrTo:= AddrTo + ' ???' ; if res <= 0 then exit ; pt_b := geoObj.Point[0] ; // update the layer data and set start, stop position rtrObj.UpdateTheData ; rtrObj.Find( layerRoute.Unproject( pt_a ), layerRoute.Unproject( pt_b ), ) for i:=0 to rtrObj.ItemsCount -1 do begin case rtrObj.Items[i].Compass of 0 : ang := 'FWD ' ; 1 : ang := 'RIGHT' ; 2 : ang := 'RIGHT' ; 3 : ang := 'RIGHT' ; 4 : ang := 'BACK ' ; -1 : ang := 'LEFT ' ; -2 : ang := 'LEFT ' ; -3 : ang := 'LEFT ' ; -4 : ang := 'BACK ' ; end ; clue:=Format( '%s, %s', [ clue, ang ] ) dosomething(); end; end;