Haversine (exp)

De Wiki1000
(Différences entre les versions)
(Page créée avec « <source lang='delphi'>function haversine(geoloc:TGeolocation; lat,long:Double):Double;</source> Retourne la distance entre l'attribut Geolocation et un jeu de coordonnée... »)
 
Ligne 4 : Ligne 4 :
  
 
Exemple :
 
Exemple :
 +
 +
'''Utilisation d'arguments'''
  
 
<source lang="delphi">
 
<source lang="delphi">
 +
//Procedure TestGeolocation;
 +
var sel:TSelector; S:string; stag:string; inst:WFAddress; dd:double; lat,long:double;
 +
begin
 +
  // looks for address in 100 meters range from a point.
 +
  //
 +
  lat := 38.897147;
 +
  long := -77.043934;
 +
  sel := WFAddress.CreateSelector('haversine(geoloc,%2,%3) < %1','',true,[0.1,lat,long]);
 +
 +
  foreach inst in  sel.AsCursor do
 +
  begin
 +
    dd := inst.Geoloc.haversine(38.897147,-77.043934);
 +
    showMessage(Format('%s %0.4f',[inst.Address1,dd]));
 +
  end;
 +
end;
 +
</source>
 +
 +
'''Utilisation de constantes'''
 +
 +
<source lang="delphi">
 +
//Procedure TestGeolocation;
 +
var sel:TSelector; S:string; stag:string; inst:WFAddress; dd:double;
 +
begin
 +
  // looks for address in 100 meters range from a point.
 +
  //
 +
  sel := WFAddress.CreateSelector('haversine(geoloc,38.897147,-77.043934) < %1','',true,[0.1]);
 +
 +
  foreach inst in  sel.AsCursor do
 +
  begin
 +
    dd := inst.Geoloc.haversine(38.897147,-77.043934);
 +
    showMessage(Format('%s %0.4f',[inst.Address1,dd]));
 +
  end;
 +
end;
 
</source>
 
</source>
  

Version du 24 décembre 2013 à 11:45

function haversine(geoloc:TGeolocation; lat,long:Double):Double;

Retourne la distance entre l'attribut Geolocation et un jeu de coordonnées.

Exemple :

Utilisation d'arguments

//Procedure TestGeolocation;
var sel:TSelector; S:string; stag:string; inst:WFAddress; dd:double; lat,long:double;
begin
  // looks for address in 100 meters range from a point.
  //
  lat := 38.897147;
  long := -77.043934;
  sel := WFAddress.CreateSelector('haversine(geoloc,%2,%3) < %1','',true,[0.1,lat,long]);
 
  foreach inst in  sel.AsCursor do
   begin
     dd := inst.Geoloc.haversine(38.897147,-77.043934);
     showMessage(Format('%s %0.4f',[inst.Address1,dd]));
   end;
end;

Utilisation de constantes

//Procedure TestGeolocation;
var sel:TSelector; S:string; stag:string; inst:WFAddress; dd:double; 
begin
  // looks for address in 100 meters range from a point.
  //
  sel := WFAddress.CreateSelector('haversine(geoloc,38.897147,-77.043934) < %1','',true,[0.1]);
 
  foreach inst in  sel.AsCursor do
   begin
     dd := inst.Geoloc.haversine(38.897147,-77.043934);
     showMessage(Format('%s %0.4f',[inst.Address1,dd]));
   end;
end;

Voir aussi:


Expressions objets (code)Développement DSM

Outils personnels