Einzelnen Beitrag anzeigen

Benutzerbild von Mavarik
Mavarik

Registriert seit: 9. Feb 2006
Ort: Stolberg (Rhld)
4.143 Beiträge
 
Delphi 10.3 Rio
 
#3

AW: Entfernungsbrechnung von OpenStreetMap-Koordinaten

  Alt 2. Sep 2019, 18:41
hmm...

Versuche es mal mit:

Delphi-Quellcode:
function GetDistanceBetween(lat1,Long1,lat2,Long2 : Double) : Double;
var
  F,G,L : Double;
  SF, SG, SL,
  CF, CG, CL : Double;
  W1, W2 : Double;
  S, C : Double;
  O,R,D : Double;
  H1, H2 : Double;
  ff : Double;
begin
  try
    ff := 1 / 298.257;
    F := (lat1 + lat2) / 2;
    G := (lat1 - lat2) / 2;
    L := (long1 - long2) / 2;

    SF := Sin(F*Pi/180);
    SG := Sin(G*Pi/180);
    SL := Sin(L*Pi/180);
    CF := Cos(F*Pi/180);
    CG := Cos(G*Pi/180);
    CL := Cos(L*Pi/180);

    W1 := sqr(SG * CL);
    W2 := sqr(CF * SL);
    S := W1 + W2;

    W1 := sqr(CG * CL);
    W2 := sqr(SF * SL);

    C := W1 + W2;

    if C = 0.0 then
      exit(0.0);

    O := ArcTan(Sqrt(S/C));

    if O = 0.0 then
      exit(0.0);

    R := Sqrt(S*C) / O;
    D := 2 * O * 6378.14;

    H1 := (3*R-1) / (2*C);
    H2 := (3*R+1) / (2*S);

    W1 := sqr(SF * CG) * H1 * ff + 1;
    W2 := sqr(CF * SG) * H2 * ff;

    result := D * (W1 - W2) * 1000;
  except
    Result := 0;
  end;
end;
Mavarik
  Mit Zitat antworten Zitat