Fixed the non numeric positions of agents in GIS. TICKET: #944
This commit is contained in:
parent
872eeb0d05
commit
6c715f3940
|
@ -100,8 +100,15 @@ B<< References (I<C implementation>): >>
|
||||||
=cut
|
=cut
|
||||||
##########################################################################
|
##########################################################################
|
||||||
sub distance_moved ($$$$$$$) {
|
sub distance_moved ($$$$$$$) {
|
||||||
my ($pa_config, $last_longitude, $last_latitude, $last_altitude, $longitude, $latitude, $altitude) = @_;
|
my ($pa_config, $last_longitude, $last_latitude, $last_altitude,
|
||||||
|
$longitude, $latitude, $altitude) = @_;
|
||||||
|
|
||||||
|
if (!is_numeric($last_longitude) &&
|
||||||
|
!is_numeric($longitude) &&
|
||||||
|
!is_numeric($last_latitude) &&
|
||||||
|
!is_numeric($latitude)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
my $long_difference = $last_longitude - $longitude;
|
my $long_difference = $last_longitude - $longitude;
|
||||||
my $lat_difference = $last_latitude - $latitude;
|
my $lat_difference = $last_latitude - $latitude;
|
||||||
|
@ -113,14 +120,18 @@ sub distance_moved ($$$$$$$) {
|
||||||
$long_aux *= $long_aux;
|
$long_aux *= $long_aux;
|
||||||
$lat_aux *= $lat_aux;
|
$lat_aux *= $lat_aux;
|
||||||
# Temporary value to make sorter the asin formula.
|
# Temporary value to make sorter the asin formula.
|
||||||
my $asinaux = sqrt($lat_aux + cos($last_latitude*$to_radians) * cos($latitude*$to_radians) * $long_aux );
|
my $asinaux = sqrt($lat_aux +
|
||||||
|
cos($last_latitude*$to_radians) * cos($latitude * $to_radians) * $long_aux );
|
||||||
# Assure the aux value is not greater than 1
|
# Assure the aux value is not greater than 1
|
||||||
if ($asinaux > 1) { $asinaux = 1; }
|
if ($asinaux > 1) {
|
||||||
|
$asinaux = 1;
|
||||||
|
}
|
||||||
# We use: asin(x) = atan2(x, sqrt(1-x*x))
|
# We use: asin(x) = atan2(x, sqrt(1-x*x))
|
||||||
my $dist_in_rad = 2.0 * atan2($asinaux, sqrt (1 - $asinaux * $asinaux));
|
my $dist_in_rad = 2.0 * atan2($asinaux, sqrt (1 - $asinaux * $asinaux));
|
||||||
my $dist_in_meters = $earth_radius_in_meters * $dist_in_rad;
|
my $dist_in_meters = $earth_radius_in_meters * $dist_in_rad;
|
||||||
|
|
||||||
logger($pa_config, "Distance moved:" . $dist_in_meters ." meters", 10);
|
logger($pa_config,
|
||||||
|
"Distance moved:" . $dist_in_meters ." meters", 10);
|
||||||
|
|
||||||
return $dist_in_meters;
|
return $dist_in_meters;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue