Haversine (exp)
De Wiki1000
(Différences entre les versions)
(2 révisions intermédiaires par un utilisateur sont masquées) | |||
Ligne 1 : | Ligne 1 : | ||
− | {{ | + | {{Version700}} |
<source lang='delphi'>function haversine(geoloc:TGeolocation; lat,long:Double):Double;</source> | <source lang='delphi'>function haversine(geoloc:TGeolocation; lat,long:Double):Double;</source> | ||
Ligne 58 : | Ligne 58 : | ||
[[Category:Expressions]] | [[Category:Expressions]] | ||
[[Category:TGeolocation]] | [[Category:TGeolocation]] | ||
− | [[Category: | + | [[Category:Version700]] |
Version actuelle en date du 13 janvier 2015 à 10:49
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','-haversine(geoloc,%2,%3)',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;
Requête SQL générée par ces exemple:
select t0.* from dbo.WFADDRESS t0 where dbo.udf_haversine(t0.Geoloc_lat,t0.Geoloc_long,38.897147,-77.043934) < 1.000000000000000060E-001 order by t0.oid
Voir aussi: