--
function Is_in(Target : Gps_Coordonates_Type; item : Gps_Coordonates_Type; Distance : Float) return Boolean is
function Longitude (X : Longitude_Coordonate_Type) return Decimal_Longitude_Type is
begin
if X.Degr_Lon < 0.0 then
return -Decimal_Longitude_Type(abs(X.Degr_Lon) + (abs(X.Minu_Lon) / 60.0) + (abs(X.Seco_Lon) / 3600.0));
else
return Decimal_Longitude_Type(abs(X.Degr_Lon) + (abs(X.Minu_Lon) / 60.0) + (abs(X.Seco_Lon) / 3600.0));
end if;
end Longitude;
function latitude (Y : Latitude_Coordonate_Type) return Decimal_Latitude_Type is
begin
if Y.Degr_Lat < 0.0 then
return -Decimal_Latitude_Type(abs(Y.Degr_Lat) + (abs(Y.Minu_Lat) / 60.0) + (abs(Y.Seco_Lat) / 3600.0));
else
return Decimal_Latitude_Type(abs(Y.Degr_Lat) + (abs(Y.Minu_Lat) / 60.0) + (abs(Y.Seco_Lat) / 3600.0));
end if;
end Latitude;
-- Formule À Appliquer Pour Calculer Une Orthodromie : Cos P = (Sin LA . Sin LB) + (Cos LA . Cos LB . Cos G)
LA, LB, G: Float := 0.0;
P : Float := 0.0;
-- LA Correspond À La Latitude Du Point A.
-- LB Correspond À La Latitude Du Point B.
-- G Correspond À La Différence De Longitude Entre Le Point A Et Le Point B.
begin
La := Latitude(Target.Latitude);
Lb := Latitude(Item.Latitude);
G := (Longitude(item.Longitude)) - (Longitude(Target.Longitude));
P := arccos(Float'rounding(((Sin(La) * Sin(Lb)) + (Cos(La) * Cos(Lb) * Cos(G))) * 1000000.0) / 1000000.0);
-- Qui devrait être la suivante mais qui plante si je n'arrondis pas.
--P := arccos((Sin(La) * Sin(Lb)) + (Cos(La) * Cos(Lb) * Cos(G)));
P := P * 60.0;
if P - Distance > 0.0 then
--Text_Io.Put_Line("False" );
return False;
else
Text_Io.Put_Line("TRUE" );
Text_Io.Put_Line("P = " & Float'Image(P));
return True;
end if;
end Is_in;