afstand-berekenen-met-gps
Gesponsorde koppelingen
PHP script bestanden
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
// Radius van de aarde in kilometers
DEFINE (R, 6367);
//coördinaten1
$lat1 = 52.3826;
$lon1 = 4.637;
// coördinaten2
$lat2 = 50.9235;
$lon2 = 5.7812;
// omzetten van graden naar radialen.
$lat1 = ($lat1 * pi() ) / 180;
$lon1 = ($lon1 * pi() ) / 180;
$lat2 = ($lat2 * pi() ) / 180;
$lon2 = ($lon2 * pi() ) / 180;
// formule
$dlon = $lon2 - $lon1;
$dlat = $lat2 - $lat1;
$a = pow(sin($dlat/2), 2) + cos($lat1) * cos($lat2) * pow(sin($dlon/2), 2);
$intermediate_result = 2 * asin(min(1,sqrt($a)));
$distance = R * $intermediate_result;
echo $distance;
?>
// Radius van de aarde in kilometers
DEFINE (R, 6367);
//coördinaten1
$lat1 = 52.3826;
$lon1 = 4.637;
// coördinaten2
$lat2 = 50.9235;
$lon2 = 5.7812;
// omzetten van graden naar radialen.
$lat1 = ($lat1 * pi() ) / 180;
$lon1 = ($lon1 * pi() ) / 180;
$lat2 = ($lat2 * pi() ) / 180;
$lon2 = ($lon2 * pi() ) / 180;
// formule
$dlon = $lon2 - $lon1;
$dlat = $lat2 - $lat1;
$a = pow(sin($dlat/2), 2) + cos($lat1) * cos($lat2) * pow(sin($dlon/2), 2);
$intermediate_result = 2 * asin(min(1,sqrt($a)));
$distance = R * $intermediate_result;
echo $distance;
?>