KB10588 - How can I use the DK to calculate the distance in meters of a calculated optimal street/road route between two selected points on a vector map layer in the UTM48 geographic coordinate system?
For calculating distance, first setup the projection. Starting with the DK Geocoding sample (located in DK sample set #2), for example, change the code of that sample as follows:
procedure TForm1.FormCreate(Sender: TObject);
begin
; ;GIS.Open( GisSamplesDataDir + 'tiger_route.shp' );
; ;GIS.Units.Units := gisUnitsTypeDegreeDecimal ;
; ;layerSrc := TGIS_LayerVector( TGIS_LayerShp( GIS.Items[0] ) ) ;
; ;layerSrc.Projection := ProjectionList.FindEx('GED');
; ;layerSrc.Units.Units := gisUnitsTypeDegreeDecimal;
; ;GIS.Projection := ProjectionList.FindEx('UTM');
; ;GIS.Projection.SetUp(0,0,0,0,0,0,48,0,0,0,0,0,0,0,0) ;
.....
and next change the code in layerRoute as well :
layerRoute.Projection := ProjectionList.FindEx('UTM');
and in the procedure TForm1.btnRouteClick(Sender: TObject) add :
for i:=0 to rtrObj.ItemsCount -1 do begin
; ;shp := rtrObj.Items[i].Layer.GetShape( rtrObj.Items[i].Uid ) ;
; ;if not Assigned( shp ) then continue ;
; ;layerRoute.AddShape( shp ) ;
; ;Length.Text := FloatToStr(StrToFloat(Length.Text) + shp.Length);
; ;if i = 0 then
; ; ;layerRoute.Extent := shp.Extent ;
end ;
Created: 2004-12-17, Modified: 2005-09-14