diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index da382d34a1..3d40c410b2 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,5 +1,8 @@ 2010-04-28 Sancho Lerena + * util/gpx2pandora_agent_data.pl: Added support to process + gpx files with tracks, plus the RTE format. + * lib/PandoraFMS/Core.pm: Fixed call to group stats and now process all groups (included disabled) and group 1, because with 3.1 group id 1 is not "all" anymore. diff --git a/pandora_server/util/gpx2pandora_agent_data.pl b/pandora_server/util/gpx2pandora_agent_data.pl index a02f6e7695..2bc39431f6 100755 --- a/pandora_server/util/gpx2pandora_agent_data.pl +++ b/pandora_server/util/gpx2pandora_agent_data.pl @@ -1,5 +1,9 @@ #!/usr/bin/perl +# (c) Artica ST 2010, for Pandora FMS monitoring system +# See more at http://pandorafms.org +# Licensed under GPL2 license. + use strict; use warnings; @@ -16,6 +20,8 @@ use constant AGENT_VERSION => '3.1'; if ($#ARGV != 1) { print "Pandora FMS GIS tool to produce XML files from a standard GPX file\n"; + print "This tool will not work with waypoints. To convert Waypoints to Tracks\n"; + print "please use another software like GPSBabel \n"; print "This will put all the XML files in /var/spool/pandora/data_in directory \n"; print "\n"; print "Usage: $0 \n\n"; @@ -50,30 +56,37 @@ if ($@) { } # Debug, code commented -print "Printing XML DATA\n"; +# print "Printing XML DATA\n"; #print Dumper ($xml_data); #print "Finish Printing XML DATA\n"; -# 'rte' => [ -# { -# 'rtept' => [ -# { -# 'ele' => [ -# '728' -# ], -# 'speed' => [ -# '0' -# ], -# 'time' => [ -# '2010-02-19T10:45:08Z' -# ], -# 'lat' => '40.4327545166', -# 'lon' => '-3.7009150982' -# }, -# -my $posiciones = $xml_data->{'rte'}[0]; + +# Detect if Rte or Track format + +my $gpx_format = ""; + +if (defined($xml_data->{'rte'}[0])){ + $gpx_format = "RTE"; +} else { + $gpx_format = "TRK"; +} + +print "Detecting GPX in $gpx_format format \n"; + +my $posiciones; +my $track_segment; +my $foreach_pointer; + +if ($gpx_format eq "RTE"){ + $posiciones = $xml_data->{'rte'}[0]; + $foreach_pointer = $posiciones->{'rtept'} +} else { + $posiciones = $xml_data->{'trk'}[0]; + $track_segment = $posiciones->{"trkseg"}[0]; + $foreach_pointer = $track_segment->{'trkpt'} +} # Process positions -foreach my $position (@{$posiciones->{'rtept'}}) { +foreach my $position (@{$foreach_pointer}) { my $longitude= $position->{'lon'}; my $latitude= $position->{'lat'}; my $altitude= $position->{'ele'}[0];