1 (edited by manixs2013 2019-06-21 02:24:09)

Topic: MAP AREA

Hello MVD!

Please help me on how to compute 2 or more areas within one map.. Also if possible together to the routes...

Right now, I can only show computation on per polygon and per polyline....

Thanks

Post's attachments

Attachment icon Capture.PNG 53.25 kb, 195 downloads since 2019-06-21 

Re: MAP AREA

Hello.


For polygons

procedure frmRegion_Button1_OnClick (Sender: TObject; var Cancel: boolean);
begin
    ShowMessage( GetPolygonsAreaSqMeters(frmRegion.MapRegion) );
end;

function GetPolygonsAreaSqMeters (Map: TdbMap): double;
var
    i: integer;
    s: string;
    d: double;
begin
    d := 0;
    for i := 0 to Map.Polygons.Count-1 do
    begin
        s := Map.GetPolygonAreaSqMeters(i);
        if not ValidFloat(s) then s := ReplaceStr(s, '.', ',');
        if ValidFloat(s) then d := d + StrToFloat(s);
    end;
    result := d;
end;

for polylines

procedure frmRoute_Button1_OnClick (Sender: TObject; var Cancel: boolean);
var
    km: double;
begin
    km := GetPolylinesLengthKMeters(frmRoute.MapRoute);
    ShowMessage(FloatToStr(km) + ' km');
end;

function GetPolylinesLengthKMeters (Map: TdbMap): double;
var
    i, iPath: integer;
    d: double;
begin
    d := 0;
    for i := 0 to Map.Polylines.Count-1 do
    begin
        for iPath := 1 to Map.Polylines[i].Polyline.Path.Count-1 do
        begin
            d := d +  Map.Distance( Map.Polylines[i].Polyline.Path[iPath].Latitude, Map.Polylines[i].Polyline.Path[iPath].Longitude, Map.Polylines[i].Polyline.Path[iPath-1].Latitude, Map.Polylines[i].Polyline.Path[iPath-1].Longitude);
        end;
    end;
    result := d;
end;
Dmitry.

Re: MAP AREA

THANKS SO MUCH DRIVESOFT!