From aab39c4e9ffd590f49ccd533f013c7d477eb5f4a Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=98yvind=20A=2E=20Holm?= Date: Mon, 10 May 2010 05:43:51 +0200 Subject: [PATCH] Removing gpst.gpsman-format/, have created a branch for it 5064d2be-5be6-11df-a511-90e6ba3022ac --- branches/gpst.gpsman-format/GPST.pm | 210 -- branches/gpst.gpsman-format/GPSTdate.pm | 75 - branches/gpst.gpsman-format/GPSTdebug.pm | 41 - branches/gpst.gpsman-format/GPSTgeo.pm | 116 -- branches/gpst.gpsman-format/GPSTxml.pm | 50 - .../gpst.gpsman-format/Patch/events+func.patch | 39 - branches/gpst.gpsman-format/Patch/files.patch | 49 - branches/gpst.gpsman-format/Patch/gpst-replace | 1414 ------------- branches/gpst.gpsman-format/Patch/gpst-u-integrate | 1411 ------------- branches/gpst.gpsman-format/Patch/gpst-xmlsimple | 1432 ------------- branches/gpst.gpsman-format/Patch/hvor.patch | 30 - .../gpst.gpsman-format/Patch/mayko-comments.patch | 40 - .../Patch/xgraph-fix_plus_more.patch | 101 - .../gpst.gpsman-format/Patch/ygraph-midnight.patch | 38 - branches/gpst.gpsman-format/doc/Makefile | 22 - branches/gpst.gpsman-format/doc/currpos.ods | Bin 8913 -> 0 bytes branches/gpst.gpsman-format/doc/distance.txt | 33 - branches/gpst.gpsman-format/doc/gpst.1 | 468 ----- branches/gpst.gpsman-format/doc/gpst.html | 137 -- branches/gpst.gpsman-format/doc/gpst.xml | 690 ------ branches/gpst.gpsman-format/doc/mayko.txt | 37 - branches/gpst.gpsman-format/doc/til_postgres.txt | 56 - branches/gpst.gpsman-format/gpslist | 14 - branches/gpst.gpsman-format/gpsman2gpx | 258 --- branches/gpst.gpsman-format/gpst | 1342 ------------ branches/gpst.gpsman-format/gpst-pic | 270 --- branches/gpst.gpsman-format/makemesh | 240 --- branches/gpst.gpsman-format/poisync | 16 - .../postgres/Patch/floatingpoint-testing.patch | 48 - .../postgres/Patch/wheretype.patch | 49 - branches/gpst.gpsman-format/postgres/allupdate.sql | 3 - .../gpst.gpsman-format/postgres/create_funcs.sql | 142 -- .../gpst.gpsman-format/postgres/create_index.sql | 32 - .../gpst.gpsman-format/postgres/create_table.sql | 52 - .../gpst.gpsman-format/postgres/create_views.sql | 145 -- .../gpst.gpsman-format/postgres/distupdate.sql | 30 - branches/gpst.gpsman-format/postgres/div.txt | 5 - branches/gpst.gpsman-format/postgres/init.sql | 7 - branches/gpst.gpsman-format/postgres/path.sql | 8 - .../gpst.gpsman-format/postgres/update_things.sql | 114 - branches/gpst.gpsman-format/run | 13 - branches/gpst.gpsman-format/tests/Makefile | 8 - .../tests/chronology-error.gpsml | 19 - branches/gpst.gpsman-format/tests/comments.mayko | 13 - branches/gpst.gpsman-format/tests/compact.gpx | 1 - branches/gpst.gpsman-format/tests/date_error.mayko | 6 - .../tests/different_dateformats.gpsml | 10 - branches/gpst.gpsman-format/tests/log.dos.gpstxt | 11 - branches/gpst.gpsman-format/tests/log.dos.mayko | 7 - branches/gpst.gpsman-format/tests/log.gpstxt | 18 - branches/gpst.gpsman-format/tests/log.mcsv | 47 - branches/gpst.gpsman-format/tests/log.unix.mcsv | 13 - branches/gpst.gpsman-format/tests/log/tests.log | 333 --- .../gpst.gpsman-format/tests/log/todo-tests.log | 225 -- branches/gpst.gpsman-format/tests/missing.gpsml | 20 - .../tests/multitrack-pause.gpsml | 28 - .../gpst.gpsman-format/tests/multitrack-pause.gpx | 44 - branches/gpst.gpsman-format/tests/multitrack.gpx | 81 - branches/gpst.gpsman-format/tests/no_signal.mayko | 10 - .../gpst.gpsman-format/tests/one_ele.dos.gpsml | 12 - branches/gpst.gpsman-format/tests/pause.gpx | 44 - branches/gpst.gpsman-format/tests/run-tests.pl | 2186 -------------------- branches/gpst.gpsman-format/tests/testcmd | 9 - branches/gpst.gpsman-format/tests/tracks.gpsman | 22 - .../gpst.gpsman-format/tests/two-digit_year.mcsv | 11 - branches/gpst.gpsman-format/tests/unify.pl | 8 - 66 files changed, 12463 deletions(-) delete mode 100644 branches/gpst.gpsman-format/GPST.pm delete mode 100644 branches/gpst.gpsman-format/GPSTdate.pm delete mode 100644 branches/gpst.gpsman-format/GPSTdebug.pm delete mode 100644 branches/gpst.gpsman-format/GPSTgeo.pm delete mode 100644 branches/gpst.gpsman-format/GPSTxml.pm delete mode 100644 branches/gpst.gpsman-format/Patch/events+func.patch delete mode 100644 branches/gpst.gpsman-format/Patch/files.patch delete mode 100755 branches/gpst.gpsman-format/Patch/gpst-replace delete mode 100755 branches/gpst.gpsman-format/Patch/gpst-u-integrate delete mode 100755 branches/gpst.gpsman-format/Patch/gpst-xmlsimple delete mode 100644 branches/gpst.gpsman-format/Patch/hvor.patch delete mode 100644 branches/gpst.gpsman-format/Patch/mayko-comments.patch delete mode 100644 branches/gpst.gpsman-format/Patch/xgraph-fix_plus_more.patch delete mode 100644 branches/gpst.gpsman-format/Patch/ygraph-midnight.patch delete mode 100644 branches/gpst.gpsman-format/doc/Makefile delete mode 100644 branches/gpst.gpsman-format/doc/currpos.ods delete mode 100644 branches/gpst.gpsman-format/doc/distance.txt delete mode 100644 branches/gpst.gpsman-format/doc/gpst.1 delete mode 100644 branches/gpst.gpsman-format/doc/gpst.html delete mode 100644 branches/gpst.gpsman-format/doc/gpst.xml delete mode 100644 branches/gpst.gpsman-format/doc/mayko.txt delete mode 100644 branches/gpst.gpsman-format/doc/til_postgres.txt delete mode 100755 branches/gpst.gpsman-format/gpslist delete mode 100755 branches/gpst.gpsman-format/gpsman2gpx delete mode 100755 branches/gpst.gpsman-format/gpst delete mode 100755 branches/gpst.gpsman-format/gpst-pic delete mode 100755 branches/gpst.gpsman-format/makemesh delete mode 100755 branches/gpst.gpsman-format/poisync delete mode 100644 branches/gpst.gpsman-format/postgres/Patch/floatingpoint-testing.patch delete mode 100644 branches/gpst.gpsman-format/postgres/Patch/wheretype.patch delete mode 100644 branches/gpst.gpsman-format/postgres/allupdate.sql delete mode 100644 branches/gpst.gpsman-format/postgres/create_funcs.sql delete mode 100644 branches/gpst.gpsman-format/postgres/create_index.sql delete mode 100644 branches/gpst.gpsman-format/postgres/create_table.sql delete mode 100644 branches/gpst.gpsman-format/postgres/create_views.sql delete mode 100644 branches/gpst.gpsman-format/postgres/distupdate.sql delete mode 100644 branches/gpst.gpsman-format/postgres/div.txt delete mode 100644 branches/gpst.gpsman-format/postgres/init.sql delete mode 100644 branches/gpst.gpsman-format/postgres/path.sql delete mode 100644 branches/gpst.gpsman-format/postgres/update_things.sql delete mode 100755 branches/gpst.gpsman-format/run delete mode 100644 branches/gpst.gpsman-format/tests/Makefile delete mode 100644 branches/gpst.gpsman-format/tests/chronology-error.gpsml delete mode 100644 branches/gpst.gpsman-format/tests/comments.mayko delete mode 100644 branches/gpst.gpsman-format/tests/compact.gpx delete mode 100644 branches/gpst.gpsman-format/tests/date_error.mayko delete mode 100644 branches/gpst.gpsman-format/tests/different_dateformats.gpsml delete mode 100644 branches/gpst.gpsman-format/tests/log.dos.gpstxt delete mode 100644 branches/gpst.gpsman-format/tests/log.dos.mayko delete mode 100644 branches/gpst.gpsman-format/tests/log.gpstxt delete mode 100644 branches/gpst.gpsman-format/tests/log.mcsv delete mode 100644 branches/gpst.gpsman-format/tests/log.unix.mcsv delete mode 100644 branches/gpst.gpsman-format/tests/log/tests.log delete mode 100644 branches/gpst.gpsman-format/tests/log/todo-tests.log delete mode 100644 branches/gpst.gpsman-format/tests/missing.gpsml delete mode 100644 branches/gpst.gpsman-format/tests/multitrack-pause.gpsml delete mode 100644 branches/gpst.gpsman-format/tests/multitrack-pause.gpx delete mode 100644 branches/gpst.gpsman-format/tests/multitrack.gpx delete mode 100644 branches/gpst.gpsman-format/tests/no_signal.mayko delete mode 100644 branches/gpst.gpsman-format/tests/one_ele.dos.gpsml delete mode 100644 branches/gpst.gpsman-format/tests/pause.gpx delete mode 100755 branches/gpst.gpsman-format/tests/run-tests.pl delete mode 100644 branches/gpst.gpsman-format/tests/testcmd delete mode 100644 branches/gpst.gpsman-format/tests/tracks.gpsman delete mode 100644 branches/gpst.gpsman-format/tests/two-digit_year.mcsv delete mode 100755 branches/gpst.gpsman-format/tests/unify.pl diff --git a/branches/gpst.gpsman-format/GPST.pm b/branches/gpst.gpsman-format/GPST.pm deleted file mode 100644 index b86dd9f..0000000 --- a/branches/gpst.gpsman-format/GPST.pm +++ /dev/null @@ -1,210 +0,0 @@ -package GPST; - -#======================================================================= -# $Id$ -# -# Character set: UTF-8 -# ©opyleft 2002– Øyvind A. Holm -# License: GNU General Public License, see end of file for legal stuff. -#======================================================================= - -use strict; -use warnings; - -use GPSTdebug; -use GPSTgeo; -use GPSTxml; - -BEGIN { - use Exporter (); - our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); - - my $rcs_id = '$Id$'; - push(@main::version_array, $rcs_id); - $VERSION = ($rcs_id =~ / (\d+) /, $1); - - @ISA = qw(Exporter); - @EXPORT = qw(&trackpoint &postgresql_copy_safe &num_expand); - %EXPORT_TAGS = (); -} -our @EXPORT_OK; - -our $Spc = " "; - -sub trackpoint { - # Receive a hash and return a trackpoint as a string {{{ - my %Dat = @_; - - defined($Dat{'type'}) || return(undef); - defined($Dat{'format'}) || return(undef); - defined($Dat{'error'}) || return(undef); - - defined($Dat{'year'}) || ($Dat{'year'} = 0); - defined($Dat{'month'}) || ($Dat{'month'} = 0); - defined($Dat{'day'}) || ($Dat{'day'} = 0); - defined($Dat{'hour'}) || ($Dat{'hour'} = ""); - defined($Dat{'min'}) || ($Dat{'min'} = ""); - defined($Dat{'sec'}) || ($Dat{'sec'} = ""); - my $print_time = ( - !$Dat{'year'} || - !$Dat{'month'} || - !$Dat{'day'} || - !length($Dat{'hour'}) || - !length($Dat{'min'}) || - !length($Dat{'sec'}) - ) ? 0 : 1; - - if ( - ("$Dat{'year'}$Dat{'month'}$Dat{'day'}$Dat{'hour'}$Dat{'min'}" =~ - /[^\d]/) || ($Dat{'sec'} =~ /[^\d\.]/) - ) { - ($print_time = 0); - } - "$Dat{'lat'}$Dat{'lon'}" =~ /[^\d\.\-\+]/ && return(undef); - - defined($Dat{'lat'}) || ($Dat{'lat'} = ""); - defined($Dat{'lon'}) || ($Dat{'lon'} = ""); - defined($Dat{'ele'}) || ($Dat{'ele'} = ""); - defined($Dat{'desc'}) || ($Dat{'desc'} = ""); - - my $Retval = ""; - - if ($Dat{'type'} eq "tp") { - my $err_str = length($Dat{'error'}) ? $Dat{'error'} : ""; - if ($Dat{'format'} eq "gpsml") { - # {{{ - my $Elem = length($err_str) ? "etp" : "tp"; - $Retval .= join("", - $print_time - ? sprintf(" ", - $Dat{'year'}, $Dat{'month'}, $Dat{'day'}, - $Dat{'hour'}, $Dat{'min'}, $Dat{'sec'}*1.0 - ) - : "", - (length($Dat{'lat'})) - ? "" . $Dat{'lat'}*1.0 . " " - : "", - (length($Dat{'lon'})) - ? "" . $Dat{'lon'}*1.0 . " " - : "", - (length($Dat{'ele'})) - ? "" . $Dat{'ele'}*1.0 . " " - : "", - (length($Dat{'desc'})) - ? sprintf("%s ", - $Dat{'desc'}) - : "" - ); - length($Retval) && - ($Retval = sprintf("<%s%s> %s\n", - $Elem, - length($err_str) ? " err=\"$err_str\"" : "", - $Retval, - $Elem) - ); - # }}} - } elsif($Dat{'format'} eq "gpx") { - # {{{ - my $lat_str = length($Dat{'lat'}) ? " lat=\"$Dat{'lat'}\"" : ""; - my $lon_str = length($Dat{'lon'}) ? " lon=\"$Dat{'lon'}\"" : ""; - my ($estr_begin, $estr_ext, $estr_end) = - ( "", "", ""); - if (length($err_str)) { - $estr_begin = ""; - } - if (length("$lat_str$lon_str$Dat{'ele'}")) { - $Retval .= - join("", - "$Spc$Spc$Spc$Spc$Spc$Spc", - $estr_begin, - "", - "$Spc", - length($Dat{'ele'}) - ? "$Dat{'ele'}$Spc" - : "", - $print_time - ? "$Spc" - : "", - $estr_ext, - "$estr_end\n" - ); - } - # }}} - } elsif($Dat{'format'} eq "clean") { - $Retval .= "$Dat{'lon'}\t$Dat{'lat'}\t$Dat{'ele'}\n"; - } elsif($Dat{'format'} eq "xgraph") { - if (length($Dat{'lat'}) && length($Dat{'lon'})) { - $Retval .= "$Dat{'lon'} $Dat{'lat'}\n"; - } - } elsif ($Dat{'format'} eq "pgtab") { - $Retval .= join("\t", - $Dat{'year'} - ? "$Dat{'year'}-$Dat{'month'}-$Dat{'day'}T" . - "$Dat{'hour'}:$Dat{'min'}:$Dat{'sec'}Z" - : '\N', # date - (length($Dat{'lat'}) && length($Dat{'lon'})) - ? "($Dat{'lat'},$Dat{'lon'})" - : '\N', # coor - length($Dat{'ele'}) ? $Dat{'ele'} : '\N', # ele - '\N', # sted - '\N', # dist - '\N', # description - '\N' # avst - ) . "\n"; - } elsif ($Dat{'format'} eq "gpstrans") { - # {{{ - my ($gpt_lat, $gpt_lon) = - (ddd_to_dms($Dat{'lat'}), ddd_to_dms($Dat{'lon'})); - if ($print_time) { - $Retval .= "T\t$Dat{'month'}/$Dat{'day'}/$Dat{'year'} " . - "$Dat{'hour'}:$Dat{'min'}:$Dat{'sec'}\t" . - "$gpt_lat\t$gpt_lon\n"; - } else { - $Retval .= "T\t00/00/00 00:00:00\t$gpt_lat\t$gpt_lon\n"; - } - # }}} - } else { - $Retval = undef; - } - } elsif ($Dat{'type'} eq 'title') { - if ($Dat{'format'} eq "gpsml") { - $Retval = sprintf("%s ", txt_to_xml($Dat{'title'})); - } - } else { - $Retval = undef; - } - return $Retval; - # }}} -} - -sub postgresql_copy_safe { - # {{{ - my $Str = shift; - $Str =~ s/\\/\\\\/gs; - $Str =~ s/\n/\\n/gs; - $Str =~ s/\r/\\r/gs; - $Str =~ s/\t/\\t/gs; - return($Str); - # }}} -} - -sub num_expand { - # {{{ - my $n = shift; - my $Retval; - return $n unless $n =~ /^(.*)e([-+]?)(.*)$/; - my ($num, $sign, $exp) = ($1, $2, $3); - my $sig = $sign eq '-' ? "." . ($exp - 1 + length $num) : ''; - $Retval = sprintf("%${sig}f", $n); - D("num_expand('$n') returns '$Retval'"); - return($Retval); - # }}} -} - -1; diff --git a/branches/gpst.gpsman-format/GPSTdate.pm b/branches/gpst.gpsman-format/GPSTdate.pm deleted file mode 100644 index a837efd..0000000 --- a/branches/gpst.gpsman-format/GPSTdate.pm +++ /dev/null @@ -1,75 +0,0 @@ -package GPSTdate; - -#======================================================================= -# $Id$ -# -# Character set: UTF-8 -# ©opyleft 2002– Øyvind A. Holm -# License: GNU General Public License, see end of file for legal stuff. -#======================================================================= - -use strict; -use warnings; - -BEGIN { - use Exporter (); - our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); - - my $rcs_id = '$Id$'; - push(@main::version_array, $rcs_id); - $VERSION = ($rcs_id =~ / (\d+) /, $1); - - @ISA = qw(Exporter); - @EXPORT = qw(&sec_to_string &sec_to_readable); - %EXPORT_TAGS = (); -} -our @EXPORT_OK; - -sub sec_to_string { - # Convert seconds since 1970 to "yyyy-mm-dd hh:mm:ss" with optional - # separator - # {{{ - my ($Seconds, $Sep) = @_; - length($Seconds) || return(undef); - ($Seconds =~ /^(\d*)(\.\d+)?$/) || return(undef); - my $Secfrac = ($Seconds =~ /^([\-\d]*)(\.\d+)$/) ? 1.0*$2 : ""; - $Secfrac =~ s/^0//; - - defined($Sep) || ($Sep = " "); - my @TA = gmtime($Seconds); - my($DateString) = sprintf("%04u-%02u-%02u%s%02u:%02u:%02u%s", - $TA[5]+1900, $TA[4]+1, $TA[3], $Sep, - $TA[2], $TA[1], $TA[0], $Secfrac); - return($DateString); - # }}} -} - -sub sec_to_readable { - # Convert seconds since 1970 to human-readable format (d:hh:mm:ss) - # {{{ - my $Seconds = shift; - my ($Day, $Hour, $Min, $Sec) = - ( 0, 0, 0, 0); - - length($Seconds) || ($Seconds = 0); - ($Seconds =~ /^(\d*)(\.\d+)?$/) || return(undef); - my $Secfrac = ($Seconds =~ /^(\d*)(\.\d+)$/) ? 1.0*$2 : ""; - $Secfrac =~ s/^0//; - - $Day = int($Seconds/86400); - $Seconds -= $Day * 86400; - - $Hour = int($Seconds/3600); - $Seconds -= $Hour * 3600; - - $Min = int($Seconds/60); - $Seconds -= $Min * 60; - - $Sec = $Seconds; - - return(sprintf("%u:%02u:%02u:%02u%s", - $Day, $Hour, $Min, $Sec, $Secfrac)); - # }}} -} - -1; diff --git a/branches/gpst.gpsman-format/GPSTdebug.pm b/branches/gpst.gpsman-format/GPSTdebug.pm deleted file mode 100644 index 472fc2c..0000000 --- a/branches/gpst.gpsman-format/GPSTdebug.pm +++ /dev/null @@ -1,41 +0,0 @@ -package GPSTdebug; - -#======================================================================= -# $Id$ -# -# Character set: UTF-8 -# ©opyleft 2002– Øyvind A. Holm -# License: GNU General Public License, see end of file for legal stuff. -#======================================================================= - -use strict; -use warnings; - -BEGIN { - use Exporter (); - our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); - - my $rcs_id = '$Id$'; - push(@main::version_array, $rcs_id); - $VERSION = ($rcs_id =~ / (\d+) /, $1); - - @ISA = qw(Exporter); - @EXPORT = qw(&D); - %EXPORT_TAGS = (); -} -our @EXPORT_OK; - -sub D { - # Print a debugging message {{{ - $main::Debug || return; - my @call_info = caller; - chomp(my $Txt = shift); - my $File = $call_info[1]; - $File =~ s#\\#/#g; - $File =~ s#^.*/(.*?)$#$1#; - print(STDERR "$File:$call_info[2] $$ $Txt\n"); - return(""); - # }}} -} # D() - -1; diff --git a/branches/gpst.gpsman-format/GPSTgeo.pm b/branches/gpst.gpsman-format/GPSTgeo.pm deleted file mode 100644 index cf42411..0000000 --- a/branches/gpst.gpsman-format/GPSTgeo.pm +++ /dev/null @@ -1,116 +0,0 @@ -package GPSTgeo; - -#======================================================================= -# $Id$ -# -# Character set: UTF-8 -# ©opyleft 2002– Øyvind A. Holm -# License: GNU General Public License, see end of file for legal stuff. -#======================================================================= - -use strict; -use warnings; - -BEGIN { - use Exporter (); - our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); - - my $rcs_id = '$Id$'; - push(@main::version_array, $rcs_id); - $VERSION = ($rcs_id =~ / (\d+) /, $1); - - @ISA = qw(Exporter); - @EXPORT = qw(&list_nearest_waypoints &ddd_to_dms &dms_to_ddd); - %EXPORT_TAGS = (); -} -our @EXPORT_OK; - -sub list_nearest_waypoints { - # {{{ - my ($Lat, $Lon, $Count) = @_; - - # FIXME: Hardcoding - my $waypoint_file = "/home/sunny/gps/waypoints.gpx"; - - # FIXME: Incredible unfinished and kludgy. - if (open(WaypFP, "$main::Cmd{'gpsbabel'} -i gpx -f $waypoint_file " . - "-x radius,lat=$Lat,lon=$Lon,distance=1000 " . - "-o gpx -F - |") - ) { - my $Str = join("", ); - $Str =~ s{ - ^.*?.*?(.+?).*?.*? - .*?.*?(.+?).*?.*? - .*?.*?(.+?).*?.*$ - }{ - "($1, $2, $3)"; - }sex; - return($Str); - } else { - die("$main::progname: Cannot open $main::Cmd{'gpsbabel'} pipe: $!\n"); - } - # }}} -} - -sub ddd_to_dms { - # Convert floating-point degrees into D°M'S.S" (ISO-8859-1). - # Necessary for import into GPSman. Based on toDMS() from - # gpstrans-0.39 to ensure compatibility. - # {{{ - my $ddd = shift; - my $Neg = 0; - my ($Hour, $Min, $Sec) = - ( 0, 0, 0); - my $Retval = ""; - - ($ddd =~ /^\-?(\d*)(\.\d+)?$/) || return(undef); - length($ddd) || ($ddd = 0); - - if ($ddd < 0.0) { - $ddd = 0 - $ddd; - $Neg = 1; - } - $Hour = int($ddd); - $ddd = ($ddd - $Hour) * 60.0; - $Min = int($ddd); - $Sec = ($ddd - $Min) * 60.0; - - if ($Sec > 59.5) { - $Sec = 0.0; - $Min += 1.0; - } - if ($Min > 59.5) { - $Min = 0.0; - $Hour += 1.0; - } - $Retval = sprintf("%s%.0f\xB0%02.0f'%04.1f\"", - $Neg - ? "-" - : "", - $Hour, $Min, $Sec); - return $Retval; - # }}} -} - -sub dms_to_ddd { - # {{{ - my ($Deg, $Min, $Sec) = @_; - - defined($Deg) || ($Deg = 0); - defined($Min) || ($Min = 0); - defined($Sec) || ($Sec = 0); - - length($Deg) || ($Deg = 0); - length($Min) || ($Min = 0); - length($Sec) || ($Sec = 0); - - if ("$Deg$Min$Sec" =~ /[^\d\.]/) { - return(undef); - } - # Limit at 16 decimals, due to float restriction. YAGNI. - my $Retval = 1.0 * sprintf("%.16f", $Deg + 1.0*$Min/60 + 1.0*$Sec/3600); - return(GPST::num_expand($Retval)); - # }}} -} - -1; diff --git a/branches/gpst.gpsman-format/GPSTxml.pm b/branches/gpst.gpsman-format/GPSTxml.pm deleted file mode 100644 index 1b789b4..0000000 --- a/branches/gpst.gpsman-format/GPSTxml.pm +++ /dev/null @@ -1,50 +0,0 @@ -package GPSTxml; - -#======================================================================= -# $Id$ -# -# Character set: UTF-8 -# ©opyleft 2002– Øyvind A. Holm -# License: GNU General Public License, see end of file for legal stuff. -#======================================================================= - -use strict; -use warnings; - -BEGIN { - use Exporter (); - our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); - - my $rcs_id = '$Id$'; - push(@main::version_array, $rcs_id); - $VERSION = ($rcs_id =~ / (\d+) /, $1); - - @ISA = qw(Exporter); - @EXPORT = qw(&txt_to_xml &xml_to_txt); - %EXPORT_TAGS = (); -} -our @EXPORT_OK; - -sub txt_to_xml { - # Convert plain text to XML {{{ - my $Txt = shift; - $Txt =~ s/&/&/gs; - $Txt =~ s//>/gs; - return($Txt); - # }}} -} - -sub xml_to_txt { - # Convert XML data to plain text {{{ - my $Txt = shift; - $Txt =~ s/<//gs; - $Txt =~ s/&/&/gs; - $Txt =~ s/"/"/gs; - $Txt =~ s/'/'/gs; - return($Txt); - # }}} -} - -1; diff --git a/branches/gpst.gpsman-format/Patch/events+func.patch b/branches/gpst.gpsman-format/Patch/events+func.patch deleted file mode 100644 index e8718f8..0000000 --- a/branches/gpst.gpsman-format/Patch/events+func.patch +++ /dev/null @@ -1,39 +0,0 @@ -Index: postgres/create_funcs.sql -=================================================================== ---- postgres/create_funcs.sql (revisjon 2218) -+++ postgres/create_funcs.sql (arbeidskopi) -@@ -124,7 +124,8 @@ - currlon = currpos[1]; - currsted = clname(currpos); - currdist = cldist(currpos); -- RETURN(currtime || ' - ' || currlat::text || ' ' || currlon::text || ' - ' || currsted || ' - ' || currdist); -+ RAISE NOTICE 'time = %, lat = %, lon = %, sted = %, dist = %', currtime::text, currlat::text, currlon::text, currsted::text, currdist::text; -+ RETURN(currtime::text || ' - ' || currlat::text || ' ' || currlon::text || ' - ' || currsted::text || ' - ' || currdist::text); - END; - $$ LANGUAGE plpgsql; - -Index: postgres/update_things.sql -=================================================================== ---- postgres/update_things.sql (revisjon 2218) -+++ postgres/update_things.sql (arbeidskopi) -@@ -71,6 +71,20 @@ - FROM wayp; - - \echo -+\echo ================ Oppdater koordinater for events ================ -+ -+UPDATE events SET coor = findpos(date) -+ WHERE coor IS NULL; -+ -+\echo -+\echo ================ Rund av events til fem desimaler ================ -+ -+UPDATE events SET coor = point( -+ round(coor[0]::numeric, 5), -+ round(coor[1]::numeric, 5) -+); -+ -+\echo - \echo ================ Fjern duplikater i events ================ - - SELECT count(*) diff --git a/branches/gpst.gpsman-format/Patch/files.patch b/branches/gpst.gpsman-format/Patch/files.patch deleted file mode 100644 index 8733a71..0000000 --- a/branches/gpst.gpsman-format/Patch/files.patch +++ /dev/null @@ -1,49 +0,0 @@ -Index: postgres/create_table.sql -=================================================================== ---- postgres/create_table.sql (revisjon 2229) -+++ postgres/create_table.sql (arbeidskopi) -@@ -46,6 +46,17 @@ - author text - ); - -+CREATE TABLE files ( -+ mtime timestamptz, -+ coor point, -+ filename text, -+ descr text, -+ size bigint, -+ sha1 varchar(40), -+ md5 varchar(40), -+ path text -+); -+ - CREATE TABLE stat ( - lastupdate timestamptz, - laststed timestamptz -Index: postgres/create_views.sql -=================================================================== ---- postgres/create_views.sql (revisjon 2229) -+++ postgres/create_views.sql (arbeidskopi) -@@ -133,6 +133,22 @@ - ) AS u - ORDER BY date; - -+CREATE OR REPLACE VIEW evfiles AS -+ SELECT * FROM ( -+ SELECT 'gps' AS flag, date, coor, sted || ' (' || dist || ')' AS sted, ele::numeric(8,1), NULL AS descr, avst -+ FROM logg -+ UNION ALL -+ SELECT 'event' AS flag, date, coor, NULL, NULL, descr AS descr, NULL -+ FROM events -+ UNION ALL -+ SELECT 'pic' AS flag, date, coor, filename, NULL, NULL, NULL -+ FROM pictures -+ UNION ALL -+ SELECT 'file' AS flag, mtime, coor, filename, NULL, path, NULL -+ FROM files -+ ) AS u -+ ORDER BY date; -+ - CREATE OR REPLACE VIEW wp AS - SELECT - coor AS coor, diff --git a/branches/gpst.gpsman-format/Patch/gpst-replace b/branches/gpst.gpsman-format/Patch/gpst-replace deleted file mode 100755 index 634570d..0000000 --- a/branches/gpst.gpsman-format/Patch/gpst-replace +++ /dev/null @@ -1,1414 +0,0 @@ -#!/usr/bin/perl -w - -#======================================================================= -# $Id$ -# Converts between various GPS formats -# -# Character set: UTF-8 -# ©opyleft 2002– Øyvind A. Holm -# License: GNU General Public License, see end of file for legal stuff. -#======================================================================= - -use strict; -use Getopt::Long; -use Time::Local qw { timegm_nocheck }; - -$| = 1; - -our $Debug = 0; - -our %Opt = ( - # Initial values for command line arguments {{{ - 'chronology' => 0, - 'comment-out-dups' => 0, - 'create-breaks' => 0, - 'debug' => 0, - 'double-y-scale' => 0, - 'epoch' => 0, - 'fix' => 0, - 'help' => 0, - 'inside' => 0, - 'near' => "", - 'output-format' => "gpsml", - 'outside' => 0, - 'pos1' => "", - 'pos2' => "", - 'print-comments' => 0, - 'replace' => "", - 'require' => "", - 'save-to-file' => "\n", # \n = undefined, it’s banned in filenames anyway. - 'short-date' => 0, - 'skip-dups' => 0, - 'strip-whitespace' => 0, - 'undefined' => "", - 'use-comma' => 0, - 'version' => 0, - # }}} -); - -our $progname = $0; -$progname =~ s#^.*/(.*?)$#$1#; - -my $rcs_id = '$Id$'; -my $id_date = $rcs_id; -$id_date =~ s/^.*?\d+ (\d\d\d\d-.*?\d\d:\d\d:\d\d\S+).*/$1/; - -Getopt::Long::Configure("bundling"); -GetOptions( - # Command line options {{{ - "chronology" => \$Opt{'chronology'}, - "comment-out-dups|u" => \$Opt{'comment-out-dups'}, - "create-breaks|t" => \$Opt{'create-breaks'}, - "debug" => \$Opt{'debug'}, - "double-y-scale|y" => \$Opt{'double-y-scale'}, - "epoch|e" => \$Opt{'epoch'}, - "fix" => \$Opt{'fix'}, - "help|h" => \$Opt{'help'}, - "inside" => \$Opt{'inside'}, - "near" => \$Opt{'near'}, - "output-format|o=s" => \$Opt{'output-format'}, - "outside" => \$Opt{'outside'}, - "pos1=s" => \$Opt{'pos1'}, - "pos2=s" => \$Opt{'pos2'}, - "print-comments|C" => \$Opt{'print-comments'}, - "replace" => \$Opt{'replace'}, - "require|r=s" => \$Opt{'require'}, - "save-to-file|S=s" => \$Opt{'save-to-file'}, - "short-date|s" => \$Opt{'short-date'}, - "skip-dups|d" => \$Opt{'skip-dups'}, - "strip-whitespace|w" => \$Opt{'strip-whitespace'}, - "undefined|n=s" => \$Opt{'undefined'}, - "use-comma|c" => \$Opt{'use-comma'}, - "verbose|v" => \$Opt{'verbose'}, - "version" => \$Opt{'version'}, - # }}} -) || die("$progname: Option error. Use -h for help.\n"); - -my %Dat; - -my $PAUSE_LIMIT = 2 * 60; # Antall sekunder mellom to punkter det må til før en move legges inn. -my $Des = $Opt{'use-comma'} ? "," : "."; -my $Udef = "?"; -my $DIGIT = '[0-9\.\-\+]'; # Used in regexps -my $Spc = $Opt{'strip-whitespace'} ? "" : " "; -my $in_dupskip = 0; # Er 1 hvis vi holder på med ignorering av duplikater -my $found_move = 0; # Settes til 1 hvis en /^# move$/ blir funnet. -my $first_time = 0; -my $last_time = 0; -my ($last_lon, $last_lat, $last_ele, $last_line) = - ( 1000, 1000, 100000, ""); # Vi kan jo teoretisk sett være i Greenwich eller på ekvator -my ($lat1, $lon1, $lat2, $lon2) = - (-1000, -1000, 1000, 1000); - -my %Poscount = (); - -my %Req = ( - 'altitude' => ($Opt{'require'} =~ /a/) ? 1 : 0, - 'time' => ($Opt{'require'} =~ /t/) ? 1 : 0 -); -$Opt{'require'} =~ /[^at]/ && die("$0: Unknown flag in --require (-r) value\n"); - -$Opt{'debug'} && ($Debug = 1); -$Opt{'help'} && usage(0); -$Opt{'version'} && print_version(); - -if ($Opt{'pos1'} =~ /^($DIGIT+),($DIGIT+)$/) { - $lat1 = $1; - $lon1 = $2; -} -if ($Opt{'pos2'} =~ /^($DIGIT+),($DIGIT+)$/) { - $lat2 = $1; - $lon2 = $2; -} -if ($lat1 > $lat2) { - my $Tmp = $lat1; - $lat1 = $lat2; - $lat2 = $Tmp; -} -if ($lon1 > $lon2) { - my $Tmp = $lon1; - $lon1 = $lon2; - $lon2 = $Tmp; -} - -if ($Opt{'inside'} && $Opt{'outside'}) { - die("$progname: Cannot mix the --inside and --outside options\n"); -} - -my $waypoint_file = "/home/sunny/gps/waypoints.gpx"; - -# To avoid printing out extra "/> at the start of svg output: -my $svg_start_thing = ""; - -length($Opt{'undefined'}) && ($Udef = $Opt{'undefined'}); -# Kunne vært et eget script på grunn av at det gjør sine helt egne -# greier, men like greit å samle det på en plass. -# FIXME: Fjerner ikke første duplikatentryen. -# FIXME: Se om det går å få flytta den inn i print_entry() så man -# slipper å ha to gptrans_conv’er i pipen. -# FIXME: Legg inn alle formatene. -if ($Opt{'comment-out-dups'}) { - # Comment out areas without reception {{{ - my ($start_date, $end_date, $found_dup) = ("", "", 0); - my @Dup = (); - while (<>) { - if (m#^1 (\S+) (\S+) (\S+) (\S+) (\d\d)/(\d\d)/(\d\d\d\d) (\d\d):(\d\d):(\d\d)#) { - # {{{ - my ($lat_val, $lon_val, $Speed, $Unkn, $Month, $Day, $Year, $Hour, $Min, $Sec) = - ( $1, $2, $3, $4, $5, $6, $7, $8, $9, $10); - if (($lat_val eq $last_lat) && ($lon_val eq $last_lon)) { - unless ($found_dup) { - $start_date = "$Year$Month${Day}T$Hour$Min$Sec"; - @Dup = (); - $found_dup = 1; - } - push(@Dup, "# $_"); - $end_date = "$Year$Month${Day}T$Hour$Min$Sec"; - } else { - if ($found_dup) { - print("# $start_date-$end_date: CO: No signal \x7B\x7B\x7B\n"); - for (@Dup) { - print($_); - } - print("# $start_date-$end_date: CO: No signal \x7D\x7D\x7D\n# move\n$_"); - $found_dup = 0; - } else { - print($_); - } - } - $last_lat = $lat_val; - $last_lon = $lon_val; - # }}} - } else { - if ($found_dup) { - push(@Dup, $_); - } else { - print($_); - } - } - } - if ($found_dup) { - print("# $start_date-$end_date: CO: No signal \x7B\x7B\x7B\n"); - for (@Dup) { - print($_); - } - print("# $start_date-$end_date: CO: No signal \x7D\x7D\x7D\n# move\n"); - $found_dup = 0; - } - exit(0); - # }}} -} - -$Opt{'save-to-file'} eq "\n" && print_header(*STDOUT); - -my @first_lines; -my $xml_data; -my $data_line = ""; -my $curr_file = ""; - -my $from_stdin = scalar(@ARGV) ? 0 : 1; - -$from_stdin && push(@ARGV, "-"); - -for $curr_file (@ARGV) { - # Scan through stdin or specified files and send every GPS entry to - # print_entry() - # {{{ - D("Opening \"$curr_file\" for read"); - if (open(CurrFP, "<$curr_file")) { - # {{{ - while () { - $data_line = $_; - %Dat = ( - 'year' => '', 'month' => '', 'day' => '', - 'hour' => '', 'min' => '', 'sec' => '', - 'lat' => '', 'lon' => '', - 'ele' => '', - 'desc' => '', - 'error' => 0, - 'type' => 'tp', - ); - - if ($Opt{'save-to-file'} ne "\n") { - push(@first_lines, $_); - $_ =~ s/^# ?//; # Also read commented-out lines. - } - $xml_data = ""; - if (m#^<(e?tp)\b.*?>(.*?)$#) { - # gpsml — The main storage format {{{ - my ($Elem, $Data) = - ( $1, $2); - $Elem eq "etp" && ($Dat{'error'} = 1); - my $Time = ""; - $Data =~ m## && ($Time = $1); - $Time =~ s{ - (\d\d\d\d)-?(\d\d)-?(\d\d)T(\d\d):?(\d\d):?([\d\.]+?)Z - } { - ($Dat{'year'}, $Dat{'month'}, $Dat{'day'}, - $Dat{'hour'}, $Dat{'min'}, $Dat{'sec'}) = - ( $1, $2, $3, - $4, $5, $6); - ""; - }ex; - $Data =~ m#($DIGIT*?)# && ($Dat{'lat'} = $1); - $Data =~ m#($DIGIT*?)# && ($Dat{'lon'} = $1); - $Data =~ m#($DIGIT*?)# && ($Dat{'ele'} = $1); - $Data =~ m#(.*?)# && ($Dat{'desc'} = xml_to_txt($1)); - print_entry(%Dat); - # }}} - } elsif (m#^#) { - $found_move = 1; - } elsif (m#^<(desc|title|pause)\b.*?>(.*?)#) { - $Dat{'type'} = $1; - $Dat{$1} = xml_to_txt($2); - print_entry(%Dat); - } elsif (/^); - if (!length($Opt{'output-format'})) { - $Opt{'output-format'} = "gpx"; - print_header(*STDOUT); - } - read_xmlfile($xml_data); - last; - } elsif (/^# Pause: /) { - $Opt{'print-comments'} && print; - } elsif (/^# move$/) { - $found_move = 1; - } elsif (/^#/) { - $Opt{'print-comments'} && print; - } elsif (m#^(\d+)\t($DIGIT+)\t($DIGIT+)\t($DIGIT)#) { - # CSV format, epoch style {{{ - my ($ep_time, $lon_val, $lat_val, $Alt) = - ( $1, $2, $3, $4); - ($Dat{'sec'}, $Dat{'min'}, $Dat{'hour'}, - $Dat{'day'}, $Dat{'month'}, $Dat{'year'}, - $Dat{'wday'}, $Dat{'yday'}) = gmtime($ep_time); - $Dat{'month'}++; # Urgh Ⅰ - $Dat{'year'} += 1900; # Urgh Ⅱ - print_entry(%Dat); - # }}} - } elsif (m#^(\d\d\d\d)-?(\d\d)-?(\d\d)[T ](\d\d):?(\d\d):?(\d\d)Z?\t($DIGIT+)\t($DIGIT+)\t($DIGIT)#) { - # CSV format, human-readable date format {{{ - ($Dat{'year'}, $Dat{'month'}, $Dat{'day'}, - $Dat{'hour'}, $Dat{'min'}, $Dat{'sec'}, - $Dat{'lon'}, $Dat{'lat'}, $Dat{'ele'}) = - ($1, $2, $3, - $4, $5, $6, - $7, $8, $9); - print_entry(%Dat); - # }}} - } elsif (/^Trackpoint\t/) { - # Trackpoint\tN60.41630 E5.31675\t09.02.2006 20:24:37 (UTC)\t13.6 m\t\t93.9 m\t00:00:06\t56 kph\t123° true {{{ - # - # Trackpoint\t - # N60.41630 E5.31675\t - # 09.02.2006 20:24:37 (UTC)\t - # 13.6 m\t - # \t - # 93.9 m\t - # 00:00:06\t - # 56 kph\t - # 123° true - my $Orig = $_; - $Orig =~ s/[\r\n]+$//; - my ($Marker_f, $Position_f, $Time_f, $Alt_f, $Depth_f, - $Leglength_f, $Legtime_f, $Legspeed_f, $Legcourse_f) = - split(/\t/, $Orig . - # Nødløsning for å unngå at variabler blir - # udefinert. - "\t\t\t\t\t\t\t\t\t\t" - ); - D(join("", - "Position_f=\"$Position_f\" \x7B\x7B\x7B\n", - "Time_f=\"$Time_f\"\n", - "Alt_f=\"$Alt_f\"\n", - "Depth_f=\"$Depth_f\"\n", - "Leglength_f=\"$Leglength_f\"\n", - "Legtime_f=\"$Legtime_f\"\n", - "Legspeed_f=\"$Legspeed_f\"\n", - "Legcourse_f=\"$Legcourse_f\" \x7D\x7D\x7D\n", - )); - my ($NS, $WE, - $Alt_unit, - $Leglength, - $Legtime_hour, $Legtime_min, $Legtime_sec, - $Legspeed, $Legspeed_unit, - $Legcourse - ) = ("", "", "", "", "", "", "", "", "", "", "", "", "", "", "", - "", "", "", "", "", "", "", ""); - ($Position_f =~ /^(N|S)([\d\.]+) (W|E)([\d\.]+)/) && - ($NS = $1, $Dat{'lat'} = $2, $WE = $3, $Dat{'lon'} = $4); - ($Time_f =~ /^(\d+)\.(\d+)\.(\d+) (\d+):(\d+):(\d+) \((.+?)\)/) && - ($Dat{'day'} = $1, $Dat{'month'} = $2, $Dat{'year'} = $3, - $Dat{'hour'} = $4, $Dat{'min'} = $5, $Dat{'sec'} = $6); - ($Alt_f =~ /^([\d+\.]+) (.*?)/) && - ($Dat{'ele'} = $1, $Alt_unit = $2); - D("ele = \"$Dat{'ele'}\""); - ($NS eq "S") && ($Dat{'lat'} = 0-$Dat{'lat'}); - ($WE eq "W") && ($Dat{'lon'} = 0-$Dat{'lon'}); - # MapSource in win xp writes YYYY, but YY in win98se. - (defined($Dat{'year'}) && $Dat{'year'} =~ /\d/ && $Dat{'year'} < 1900) && ($Dat{'year'} += 2000); - print_entry(%Dat); - # }}} - } elsif (m#^T\t(\d\d)/(\d\d)/(\d\d\d\d) (\d\d):(\d\d):(\d\d)\t(.+)\xB0(.+)'(.+)"\t(.+)\xB0(.+)'(.+)"#) { - # T 09/01/2002 11:51:26 60°23'36.3" 5°19'35.9" {{{ - my ($lat_d, $lat_m, $lat_s, $lon_d, $lon_m, $lon_s); - ($Dat{'month'}, $Dat{'day'}, $Dat{'year'}, - $Dat{'hour'}, $Dat{'min'}, $Dat{'sec'}, $lat_d, - $lat_m, $lat_s, $lon_d, - $lon_m, $lon_s) = - ( $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12); - $Dat{'lat'} = sprintf("%.5f", 1*($lat_d+($lat_m/60)+($lat_s/3600))); - $Dat{'lon'} = sprintf("%.5f", $lon_d+($lon_m/60)+($lon_s/3600)); - print_entry(%Dat); - # }}} - } elsif (m#^1 (\S+) (\S+) (\S+) (\S+) (\d\d)/(\d\d)/(\d\d\d\d) (\d\d):(\d\d):(\d\d)#) { - # 1 60.3938222 5.3238754 17.3 0 09/01/2002 14:18:23 {{{ - ($Dat{'lat'}, $Dat{'lon'}, $Dat{'speed'}, - $Dat{'unkn'}, - $Dat{'month'}, $Dat{'day'}, $Dat{'year'}, - $Dat{'hour'}, $Dat{'min'}, $Dat{'sec'}) = - ( $1, $2, $3, $4, $5, $6, $7, $8, $9, $10); - print_entry(%Dat); - # }}} - } elsif (/^ - # @020721221336N6048353E00701826S015-00001E4859N1673U0000 {{{ - # Regexp {{{ - (@) # @ - (\d\d) # Year - (\d\d) # Month - (\d\d) # Day - (\d\d) # Hours - (\d\d) # Minutes - (\d\d) # Seconds - ([NS]) # N|S - (\d\d) # Latitude degree - (\d\d) # Latitude minute - (\d\d\d) # Latitude minute decimals - ([EW]) # E|W - (\d\d\d) # Longitude degree - (\d\d) # Longitude minute - (\d\d\d) # Longitude minute degree - (....) # Accurancy - (......) # Altitude - (...............) - $ - # }}} - /x) { - my ($NS, $EW, $lat_deg, $lat_degmin, $lat_mindec, $lon_deg, - $lon_degmin, $lon_mindec); - ($Dat{'year'}, $Dat{'month'}, $Dat{'day'}, $Dat{'hour'}, - $Dat{'min'}, $Dat{'sec'}, $NS, $lat_deg, - $lat_degmin, $lat_mindec, $EW, - $lon_deg, $lon_degmin, $lon_mindec, - $Dat{'accur'}, $Dat{'ele'}, $Dat{'unknown'}) = - ($2+2000, $3, $4, $5, $6, $7, $8, $9, $10, $11, - $12, $13, $14, $15, $16, $17, $18); - my $ep_time = timegm_nocheck($Dat{'sec'}, $Dat{'min'}, $Dat{'hour'}, $Dat{'day'}, $Dat{'month'}-1, $Dat{'year'}); - $last_time = $ep_time; - my $tmp_lon = sprintf("%.5f", $lon_deg + $lon_degmin/60 + $lon_mindec/60000); - my $tmp_lat = sprintf("%.5f", $lat_deg + $lat_degmin/60 + $lat_mindec/60000); - $tmp_lon =~ s/\./$Des/; - $tmp_lat =~ s/\./$Des/; - ($NS eq "S") && ($tmp_lat = 0-$tmp_lat); - ($EW eq "W") && ($tmp_lon = 0-$tmp_lon); - $Dat{'lat'} = $tmp_lat; - $Dat{'lon'} = $tmp_lon; - print_entry(%Dat); - # }}} - } elsif (/^(@)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(__________________________________________)/) { - # @020721221336__________________________________________ {{{ - my ($Alfa, $Year, $Month, $Day, $Hour, $Min, $Sec, $Rest) = - ( $1, $2+2000, $3, $4, $5, $6, $7, $8); - $Opt{'output-format'} eq "csv" && print("\n"); - $found_move = 1; - # }}} - } elsif (/^xmaplog /) { - ($Opt{'output-format'} eq "csv") && ($Opt{'save-to-file'} eq "\n") && print("\n"); - } elsif (/^$/) { - ($Opt{'output-format'} eq "csv") && ($Opt{'save-to-file'} eq "\n") && print("\n"); - } else { - if ($Opt{'print-comments'}) { - print("# $_"); - chomp; - } - $Opt{'verbose'} && warn("Line $.: Unknown: \"$_\"\n"); - } - } - # }}} - } else { - warn("$progname: $curr_file: Cannot open file for read: $!\n"); - } - # }}} -} - -print_footer(*STDOUT); - -exit(0); - -sub read_xmlfile { - # {{{ - my $Txt = join("", @_); - # FIXME: The sequential stuff here is probably bad, but easy. - $Txt =~ s#(.*?)#print_gpx($1)#gse; - $Txt =~ s#(.*?)#print_xml_gps($1)#gse; - # }}} -} - -sub print_gpx { - # {{{ - my $Orig = shift; - my $Str = $Orig; - D("print_xml_gps(\"$Orig\")\n"); - $Str =~ - s{ - (.*?) - } - { - my $el_trk = $2; - $el_trk =~ - s{ - (.*?) - } - { - my $el_trkseg = $2; - $el_trkseg =~ - s{ - (.*?) - } - { - my ($attr_trkpt, $el_trkpt) = - ( $1, $2); - ($attr_trkpt =~ /\blon="(.*?)"/) && ($Dat{'lon'} = $1); - ($attr_trkpt =~ /\blat="(.*?)"/) && ($Dat{'lat'} = $1); - ($el_trkpt =~ m#(.*?)#) && ($Dat{'ele'} = $1); - if ($el_trkpt =~ m##) { - ($Dat{'year'}, $Dat{'month'}, $Dat{'day'}, - $Dat{'hour'}, $Dat{'min'}, $Dat{'sec'}, $Dat{'secfrac'}) = - ($1, $2, $3, $4, $5, $6, $7); - } - print_entry(%Dat); - ""; - }gsex; - $found_move = 1; - }gsex; - $found_move = 1; - }gsex; - # }}} -} - -sub print_xml_gps { - # {{{ - my $Orig = shift; - my $Str = $Orig; - D("print_xml_gps(\"$Orig\")\n"); - if ($Str =~ m#(\d\d\d\d)-?(\d\d)-?(\d\d)T(\d\d):?(\d\d):?(\d\d)\.?(\d*?)Z#) { - ($Dat{'year'}, $Dat{'mon'}, $Dat{'day'}, $Dat{'hour'}, $Dat{'min'}, $Dat{'sec'}, $Dat{'secfrac'}) = - ( $1, $2, $3, $4, $5, $6, $7); - } - if ($Str =~ m#(.*?)#s) { - my $Txt = $1; - ($Txt =~ m#(.*?)#) && ($Dat{'lon'} = $1); - ($Txt =~ m#(.*?)#) && ($Dat{'lat'} = $1); - ($Txt =~ m#(.*?)#) && ($Dat{'ele'} = $1); - } - defined($Dat{'lon'}) || ($Dat{'lon'} = ""); - defined($Dat{'lat'}) || ($Dat{'lat'} = ""); - defined($Dat{'ele'}) || ($Dat{'ele'} = ""); - print_entry(%Dat); - # }}} -} - -sub print_header { - # {{{ - local *OutFP = shift; - if ($Opt{'output-format'} eq "gpsml") { - print(OutFP join("", - "\n", - "\n", - "\n", - )); - } elsif ($Opt{'output-format'} eq "gpstrans") { - print(OutFP "Format: DMS UTC Offset: 0.00 hrs Datum[100]: WGS 84\n"); - } elsif ($Opt{'output-format'} eq "gpx") { - print(OutFP join("", - "\n", - "\n", - "$Spc$Spc\n", - "$Spc$Spc$Spc$Spc\n", - )); - } elsif ($Opt{'output-format'} eq "ps") { - print(OutFP ps_header(532, 6034, 533, 6040)); - print(OutFP "*u\n"); - } elsif ($Opt{'output-format'} eq "xml") { - print(OutFP join("", - "\n", - "\n", - )); - } elsif ($Opt{'output-format'} eq "svg") { - print(OutFP join("", - "\n", - "\n", - "\n", - "$Spc$Spc\n", - "$Spc$Spc\n", - )); - } - # }}} -} - -sub print_footer { - # Print footer {{{ - local *OutFP = shift; - if ($Opt{'output-format'} eq "gpsml") { - print(OutFP join("", - "\n", - "\n", - )); - } elsif ($Opt{'output-format'} eq "gpx") { - print(OutFP join("", - "$Spc$Spc$Spc$Spc\n", - "$Spc$Spc\n", - "\n", - )); - } elsif ($Opt{'output-format'} eq "poscount") { - while (my ($l_name, $l_val) = each %Poscount) { - $l_name =~ /^(.+?),(.+?)$/ && print(OutFP "$1\t$2\t$l_val\n"); - } - } elsif ($Opt{'output-format'} eq "ps") { - print(OutFP join("", - "*U\n", - "%%Trailer\n", - "%%EOF\n", - )); - } elsif ($Opt{'output-format'} eq "svg") { - print(OutFP "\"/>\n\n"); - } elsif ($Opt{'output-format'} eq "xml") { - print(OutFP "\n"); - } - # }}} -} - -sub print_entry { - # Print a GPS entry with time, latitude, longitude and altitude in - # various formats - # {{{ - my %Dat = @_; - my $print_time = length($Dat{'year'}) ? 1 : 0; - my $print_ele = length($Dat{'ele'}) ? 1 : 0; - my $print_desc = length($Dat{'desc'}) ? 1 : 0; - my $Line = ""; - D("print_entry(\"" . join("\", \"", @_) . "\");"); - my $ep_time; - - if ($Opt{'near'}) { - $Line .= sprintf("%s ", list_nearest_waypoints($Dat{'lat'}, $Dat{'lon'})); - } - - if ($Opt{'output-format'} eq "poscount") { - my ($Lat_str, $Lon_str) = - ( "", ""); - $Dat{'lon'} =~ /^(\d+\.\d\d)/ && ($Lon_str = $1); - $Dat{'lat'} =~ /^(\d+\.\d\d)/ && ($Lat_str = $1); - my $Name = "${Lon_str},${Lat_str}"; - defined($Poscount{$Name}) || ($Poscount{$Name} = 0); - $Poscount{$Name}++; - return; - } - - if ($print_time) { - $ep_time = timegm_nocheck($Dat{'sec'}, $Dat{'min'}, $Dat{'hour'}, $Dat{'day'}, $Dat{'month'} - 1, $Dat{'year'}); - $Dat{'year'} = sprintf("%04u", $Dat{'year'}); - $Dat{'month'} = sprintf("%02u", $Dat{'month'}); - $Dat{'day'} = sprintf("%02u", $Dat{'day'}); - $Dat{'hour'} = sprintf("%02u", $Dat{'hour'}); - $Dat{'min'} = sprintf("%02u", $Dat{'min'}); - $Dat{'sec'} = sprintf("%02u", $Dat{'sec'}); - if ($Opt{'chronology'}) { - if ($last_time > $ep_time) { - warn(sprintf( - "%s: \"%sZ\": Next date is %s in the past (%sZ)\n", - $progname, sec_to_string($last_time, "T"), - sec_to_readable($last_time-$ep_time), - sec_to_string($ep_time, "T") - )); - # FIXME: Make --fix work with gpx and xml. - if ($Opt{'fix'} && ($Opt{'output-format'} !~ /^(gpx|xml)$/)) { - ($Line .= "# error "); - } - } - } - } else { - $Req{'time'} && return; - $ep_time = 0; - $Dat{'year'} = 0; - $Dat{'month'} = 0; - $Dat{'day'} = 0; - $Dat{'hour'} = 0; - $Dat{'min'} = 0; - $Dat{'sec'} = 0; - } - - if ($Opt{'save-to-file'} ne "\n") { - # {{{ - my $base_name = "$Dat{'year'}$Dat{'month'}$Dat{'day'}T$Dat{'hour'}$Dat{'min'}$Dat{'sec'}Z$Opt{'save-to-file'}"; - my $file_name = $base_name; - if (-e $file_name) { - for (my $a = 1; (-e $file_name) && ($a < 1000); $a++) { - $file_name = "$base_name.dup_$a"; - } - if (-e $file_name) { - die("$progname: $base_name: File already exists, and ran " . - "out of attempts to create unique file name\n"); - } - if ($Opt{'verbose'}) { - warn("$progname: $base_name: File already exists, using " . - "unique name \"$file_name\" instead\n"); - } - } - if (open(ToFP, ">", $file_name)) { - print_header(*ToFP); - print(ToFP ($from_stdin ? @first_lines : ()), (length($xml_data) ? $xml_data : <>)) || - die("$progname: $file_name: Cannot write to file: $!\n"); - print_footer(*ToFP); - close(ToFP); - if ($Opt{'output-format'} eq "gpsml") { - printf("%s\n", - txt_to_xml($file_name)); - } elsif ($Opt{'output-format'} eq "gpx") { - printf("\n", - txt_to_xml($file_name)); - } else { - print("$progname: Saved unconverted data to \"$file_name\"\n"); - } - exit 0; - } else { - die("$progname: $file_name: Cannot create file: $!\n"); - } - # }}} - } - - my $pause_len = 0; - my $do_print = 1; - ($Req{'altitude'} && !$print_ele) && return; - - if ($Opt{'inside'} || $Opt{'outside'}) { - if ( - ($Dat{'lat'} < $lat1) || - ($Dat{'lat'} > $lat2) || - ($Dat{'lon'} < $lon1) || - ($Dat{'lon'} > $lon2) - ) { - $Opt{'inside'} && return; - } else { - $Opt{'outside'} && return; - } - } - - if ($Opt{'output-format'} eq "ps") { - $Dat{'lon'} *= 100; - $Dat{'lat'} *= 100; - } - if ($Opt{'skip-dups'} && ($Dat{'lon'} eq $last_lon) && ($Dat{'lat'} eq $last_lat) && ($Dat{'ele'} eq $last_ele)) { - if ($in_dupskip) { - $do_print = 0; - } else { - $do_print = 1; - } - $in_dupskip = 1; - } else { - $do_print = 1; - $in_dupskip && ($Line .= $last_line); - $in_dupskip = 0; - } - - if ($Opt{'create-breaks'} && $ep_time-$last_time > $PAUSE_LIMIT && $last_time) { - $pause_len = $ep_time-$last_time; - D("pause_len set to '$pause_len'"); - } - - if ($pause_len) { - if ($Opt{'output-format'} eq "gpsml") { - $Line .= sprintf("%s\n", - sec_to_readable($ep_time-$last_time)); - } elsif ($Opt{'output-format'} eq "csv") { - $Line .= sprintf("# Pause: %s\n# move\n", - sec_to_readable($ep_time-$last_time)); - } - } - - if ($do_print) { - # Valid data was found, send to stdout {{{ - unless ($first_time) { - $first_time = $ep_time; - } - if ($Opt{'double-y-scale'}) { - $Dat{'lat'} *= 2; - } - if ($Opt{'output-format'} eq "gpsml") { - if ($Dat{'type'} eq "tp") { - my $Elem = $Dat{'error'} ? "etp" : "tp"; - $Line .= join("", - "<$Elem> ", - $print_time - ? " " - : "", - (length($Dat{'lat'})) - ? "" . $Dat{'lat'}*1.0 . " " - : "", - (length($Dat{'lon'})) - ? "" . $Dat{'lon'}*1.0 . " " - : "", - ($print_ele) - ? "" . $Dat{'ele'}*1.0 . " " - : "", - ($print_desc) - ? sprintf("%s ", - txt_to_xml($Dat{'desc'})) - : "", - "\n" - ); - } elsif ($Dat{'type'} =~ /^(pause|desc|title)$/) { - $Line .= sprintf("<%s>%s\n", - $1, - txt_to_xml($Dat{$1}), - $1); - } - } elsif ($Opt{'output-format'} eq "xgraph") { - $pause_len && ($Line .= "move "); - ($Line .= "$Dat{'lon'} $Dat{'lat'}\n"); - } elsif($Opt{'output-format'} eq "gpstrans") { - my ($gpt_lat, $gpt_lon) = (ddd_to_dms($Dat{'lat'}), ddd_to_dms($Dat{'lon'})); - if ($print_time) { - $Line .= "T\t$Dat{'month'}/$Dat{'day'}/$Dat{'year'} $Dat{'hour'}:$Dat{'min'}:$Dat{'sec'}\t$gpt_lat\t$gpt_lon\n"; - } else { - $Line .= "T\t00/00/00 00:00:00\t$gpt_lat\t$gpt_lon\n"; - } - } elsif($Opt{'output-format'} eq "gpx") { - $Line .= join("", - "$Spc$Spc$Spc$Spc$Spc$Spc$Spc", - $print_time - ? "$Spc" - : "", - $print_ele - ? "$Dat{'ele'}$Spc" - : "", - "\n" - ); - } elsif ($Opt{'output-format'} eq "clean") { - $pause_len && ($Line .= "\n"); - ($Line .= "$Dat{'lon'}\t$Dat{'lat'}" . ($print_ele ? "\t$Dat{'ele'}" : "") . "\n"); - } elsif ($Opt{'output-format'} eq "ps") { - $Line .= ($pause_len ? "f\n$Dat{'lon'} $Dat{'lat'} m\n" : "$Dat{'lon'} $Dat{'lat'} l\n"); - } elsif ($Opt{'output-format'} eq "svg") { - $Line .= ( - ($last_lon == 1000) || $pause_len - ? join("", - "$svg_start_thing$Spc", - $print_time - ? "$Dat{'year'}-$Dat{'month'}-$Dat{'day'}T$Dat{'hour'}:$Dat{'min'}:$Dat{'sec'}Z$Spc" - : "", - "$Spc", - (length($Dat{'lon'})) ? "$Dat{'lon'}$Spc" : "", - (length($Dat{'lat'})) ? "$Dat{'lat'}$Spc" : "", - ($print_ele) ? "$Dat{'ele'}$Spc" : "", - "$Spc", - "\n" - ); - } elsif ($Opt{'output-format'} eq "ygraph") { - my $Time = $print_time ? ($ep_time - $first_time) * 1 : 0; - $Line .= "\"Time = $Time.0\n$Dat{'lon'} $Dat{'lat'}\n\n"; - } elsif ($Opt{'output-format'} eq "csv") { - # {{{ - $Dat{'lon'} =~ s/\./$Des/; - $Dat{'lat'} =~ s/\./$Des/; - # $do_print || print("skipping "); - $Line .= join("\t", - $print_time - ? $Opt{'epoch'} - ? $ep_time - : $Opt{'short-date'} - ? "$Dat{'year'}$Dat{'month'}$Dat{'day'}T$Dat{'hour'}$Dat{'min'}$Dat{'sec'}Z" - : "$Dat{'year'}-$Dat{'month'}-$Dat{'day'} $Dat{'hour'}:$Dat{'min'}:$Dat{'sec'}" - : "", - $Dat{'lon'}, - $Dat{'lat'}, - $print_ele ? $Dat{'ele'} : "", # Elevation - "\n" - ); - # }}} - } else { - die("$progname: \"$Opt{'output-format'}\": Unknown output format\n"); - } - # }}} - } - - if (!$last_time && $Opt{'output-format'} eq "ps") { - $Line .= "$Dat{'lon'} $Dat{'lat'} m\n"; - } - - if ($do_print) { - if ($found_move) { - if ($Opt{'output-format'} eq "gpsml") { - $Line = "\n$Line"; - } - (!$pause_len && ($Opt{'output-format'} eq "xgraph")) && ($Line .= "move $Line"); - ($Opt{'output-format'} eq "clean") && ($Line .= "\n"); - if ($Opt{'output-format'} eq "gpx") { - $Line .= "$Spc$Spc$Spc$Spc\n$Spc$Spc$Spc$Spc\n"; - } - $found_move = 0; - } - print($Line); - } - $last_time = $ep_time; - $last_lon = $Dat{'lon'}; - $last_lat = $Dat{'lat'}; - $last_ele = $Dat{'ele'}; - $last_line = $data_line; - $svg_start_thing = "\"/>\n"; - # }}} -} - -sub list_nearest_waypoints { - # {{{ - my ($Lat, $Lon, $Count) = @_; - # FIXME: Incredible unfinished and kludgy. - if (open(WaypFP, "gpsbabel -i gpx -f $waypoint_file -x radius,lat=$Lat,lon=$Lon,distance=1000 -o gpx -F - |")) { - my $Str = join("", ); - $Str =~ s{ - ^.*?.*?(.+?).*?.*? - .*?.*?(.+?).*?.*? - .*?.*?(.+?).*?.*$ - }{ - "($1, $2, $3)"; - }sex; - return($Str); - } else { - die("$progname: Cannot open gpsbabel pipe: $!\n"); - } - # }}} -} - -sub sec_to_string { - # Convert seconds since 1970 to "yyyy-mm-dd hh:mm:ss" with optional - # separator - # {{{ - my ($Seconds, $Sep) = @_; - defined($Sep) || ($Sep = " "); - my @TA = gmtime($Seconds); - my($DateString) = sprintf("%04u-%02u-%02u%s%02u:%02u:%02u", $TA[5]+1900, $TA[4]+1, $TA[3], $Sep, $TA[2], $TA[1], $TA[0]); - return($DateString); - # }}} -} - -sub sec_to_readable { - # Convert seconds since 1970 to human-readable format (d:hh:mm:ss) - # {{{ - my $secs = shift; - D("sec_to_readable(\"$secs\")\n"); - my ($Day, $Hour, $Min, $Sec) = - ( 0, 0, 0, 0); - - $Day = int($secs/86400); - $secs -= $Day * 86400; - - $Hour = int($secs/3600); - $secs -= $Hour * 3600; - - $Min = int($secs/60); - $secs -= $Min * 60; - - $Sec = $secs; - - return(sprintf("%u:%02u:%02u:%02u", $Day, $Hour, $Min, $Sec)); - # }}} -} - -sub ps_header { - # Send a Postscript header to stdout {{{ - my ($bl_lon, $bl_lat, $br_lon, $br_lat) = @_; - my $Date = sec_to_string(time); - return(join("", - "%!PS-Adobe-3.0 EPSF-3.0\n", - "%%Creator: $rcs_id\n", - "%%Title:\n", - "%%CreationDate: $Date\n", - "%%BoundingBox: $bl_lon $bl_lat $br_lon $br_lat\n", - "%%DocumentData: Clean7Bit\n", - "%%EndComments\n", - "%%BeginProlog\n", - "/bd { bind def } bind def\n", - "/incompound false def\n", - "/m { moveto } bd\n", - "/l { lineto } bd\n", - "/c { curveto } bd\n", - "/F { incompound not {fill} if } bd\n", - "/f { closepath F } bd\n", - "/S { stroke } bd\n", - "/*u { /incompound true def } bd\n", - "/*U { /incompound false def f} bd\n", - "/k { setcmykcolor } bd\n", - "/K { k } bd\n", - "%%EndProlog\n", - "%%BeginSetup\n", - "%%EndSetup\n", - )); - # }}} -} - -sub ddd_to_dms { - # Convert floating-point degrees into D°M'S.S" (ISO-8859-1). - # Necessary for import into GPSman. Based on toDMS() from - # gpstrans-0.39 to ensure compatibility. - # {{{ - my $ddd = shift; - my $Neg = 0; - my ($Hour, $Min, $Sec) = - ( 0, 0, 0); - my $Retval = ""; - - if ($ddd < 0.0) { - $ddd = 0 - $ddd; - $Neg = 1; - } - $Hour = int($ddd); - $ddd = ($ddd - $Hour) * 60.0; - $Min = int($ddd); - $Sec = ($ddd - $Min) * 60.0; - - if ($Sec > 59.5) { - $Sec = 0.0; - $Min += 1.0; - } - if ($Min > 59.5) { - $Min = 0.0; - $Hour += 1.0; - } - if ($Neg) { - $Hour = 0 - $Hour; - } - D("Neg = $Neg , D = $Hour , M = $Min , S = $Sec\n"); - $Retval = sprintf("%s%.0f\xB0%02.0f'%04.1f\"", $Neg ? "-" : "", $Hour, $Min, $Sec); - return $Retval; - # }}} -} - -sub txt_to_xml { - # Convert plain text to XML {{{ - my $Txt = shift; - $Txt =~ s/&/&/gs; - $Txt =~ s//>/gs; - return($Txt); - # }}} -} - -sub xml_to_txt { - # Convert XML data to plain text {{{ - my $Txt = shift; - $Txt =~ s/<//gs; - $Txt =~ s/&/&/gs; - return($Txt); - # }}} -} - -sub print_version { - # Print program version {{{ - print("$rcs_id\n"); - exit(0); - # }}} -} # print_version() - -sub usage { - # Send the help message to stdout {{{ - my $Retval = shift; - - print(< [options] [file [files [...]]] - -B -S [options] [file [files [...]]] - -B -u [options] [file [files [...]]] - -=head1 DESCRIPTION - -Converts between various GPS formats. - -=head1 OPTIONS - -=over 4 - -=item B<-c>, B<--comment-out-dups> - -Use comma instead of period as decimal point (For Gnumeric etc). - -=item B<-C>, B<--print-comments> - -Print existing comment lines (starting with "#") and prefix unknown -lines with "# ". - -=item B<--chronology> - -Check for broken chronology, warn about entries with an old timestamp. - -=item B<-d>, B<--skip-dups> - -Skip duplicated coordinates, only print first and last. - -=item B<-e>, B<--epoch> - -Use seconds since 1970-01-01 00:00:00 GMT as date format. - -item B<--fix> - -Comment out entries which is obviously wrong. Use together with ---chronology to fix those kind of errors. Does not work with GPX or XML -output yet. - -=item B<-h>, B<--help> - -Show this help. - -=item B<--inside> - -Print only trackpoints inside a rectangle specified by --pos1 and ---pos2. - -=item B<--near> - -Add names of the three closest waypoints to the trackpoint. Unfinished -and experimental, needs gpsbabel. - -=item B<-n x>, B<--undefined x> - -Use x as undefined value. - -=item B<-o x>, B<--output-format x> - -Use output format x: - -=over 4 - -=over 4 - -=item clean - -=item csv - -=item gpsml (Default) - -This is the format which is meant to be used when storing the track -logs. -It is line-based XML which makes it easy to edit and grep. Probably not -finished yet. - -=item gpstrans - -=item gpx (Not complete) - -=item poscount (Experimental) - -Creates a 3D plot where areas with many trackpoints are higher than -areas with less track points. - -=item ps (Unfinished) - -=item svg (Unfinished) - -=item xgraph - -=item xml - -=item ygraph - -=back - -=back - -Z<> - -=item B<--outside> - -Print only trackpoints outside a rectangle specified by --pos1 and ---pos2. - -=item B<--pos1 x>, B<--pos2 x> - -Specifies corners of an area rectangle used by the --inside and ---outside options. The x value is in "lat,lon" format (decimal degrees, -negative for west or south) . - -=item B<-r x>, B<--require x> - -Specify requirements for trackpoints to be written. x is a string with -the following flags: - -=over 4 - -=over 4 - -=item a - -=over 4 - -=item Print only waypoints which have an altitude. - -=back - -=back - -=over 4 - -=item t - -=over 4 - -=item Print only waypoints which have a timestamp. - -=back - -=back - -=back - -Z<> - -=item B<-s>, B<--short-date> - -Use short date format. - -=item B<-S x>, B<--save-to-file x> - -Save the unconverted data to a file with a filename starting with the -timestamp of the first trackpoint. The parameter string x is added at -the end of the filename. For the time being this option will ignore all -other options. - -Note: If several files are specified on the command line, all data will -be saved into only one file. This behaviour may change in the future. - -=item B<-t>, B<--create-breaks> - -Create breaks in track between points with a difference more than the -number of seconds specified by the C<$PAUSE_LIMIT> variable. - -=item B<-u>, B<--comment-out-dups> - -Comment out following data with identical position values, only print -first entry. - -=item B<-v>, B<--verbose> - -Verbose, warn about unknown lines. - -=item B<-w>, B<--strip-whitespace> - -Strip all unnecessary whitespace. - -=item B<-x>, B<--xml> - -Create XML output. - -=item B<-y>, B<--double-y-scale> - -Double Y scale (latitude) to get it right in gnuplot. - -=item B<-h>, B<--help> - -Print a brief help summary. - -=item B<--version> - -Print version information. - -=item B<--debug> - -Print debugging messages. - -=back - -=head1 BUGS - -Pretty incomplete in some areas. Some of the source formats are -undocumented and thus incomplete. Some functionality is not working -properly, for example the Postscript output. - -=head1 AUTHOR - -Made by Øyvind A. Holm Ssunny@sunbase.orgE>. - -=head1 COPYRIGHT - -Copyleft © Øyvind A. Holm <sunny@sunbase.org> -This is free software; see the file F for legalese stuff. - -=head1 LICENCE - -This program is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2 of the License, or (at your -option) any later version. - -This program is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along -with this program; if not, write to the Free Software Foundation, Inc., -59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -=head1 SEE ALSO - -gpsbabel(1) - -=cut - -# }}} - -# vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w : -# End of file $Id$ diff --git a/branches/gpst.gpsman-format/Patch/gpst-u-integrate b/branches/gpst.gpsman-format/Patch/gpst-u-integrate deleted file mode 100755 index 6b14beb..0000000 --- a/branches/gpst.gpsman-format/Patch/gpst-u-integrate +++ /dev/null @@ -1,1411 +0,0 @@ -#!/usr/bin/perl -w - -#======================================================================= -# $Id$ -# Converts between various GPS formats -# -# Character set: UTF-8 -# ©opyleft 2002– Øyvind A. Holm -# License: GNU General Public License, see end of file for legal stuff. -#======================================================================= - -use strict; -use Getopt::Long; -use Time::Local qw { timegm_nocheck }; - -$| = 1; - -our $Debug = 0; - -our %Opt = ( - # Initial values for command line arguments {{{ - 'chronology' => 0, - 'comment-out-dups' => 0, - 'create-breaks' => 0, - 'debug' => 0, - 'double-y-scale' => 0, - 'epoch' => 0, - 'fix' => 0, - 'help' => 0, - 'inside' => 0, - 'near' => "", - 'output-format' => "gpsml", - 'outside' => 0, - 'pos1' => "", - 'pos2' => "", - 'print-comments' => 0, - 'require' => "", - 'save-to-file' => "\n", # \n = undefined, it’s banned in filenames anyway. - 'short-date' => 0, - 'skip-dups' => 0, - 'strip-whitespace' => 0, - 'undefined' => "", - 'use-comma' => 0, - 'version' => 0, - # }}} -); - -our $progname = $0; -$progname =~ s#^.*/(.*?)$#$1#; - -my $rcs_id = '$Id$'; -my $id_date = $rcs_id; -$id_date =~ s/^.*?\d+ (\d\d\d\d-.*?\d\d:\d\d:\d\d\S+).*/$1/; - -Getopt::Long::Configure("bundling"); -GetOptions( - # Command line options {{{ - "chronology" => \$Opt{'chronology'}, - "comment-out-dups|u" => \$Opt{'comment-out-dups'}, - "create-breaks|t" => \$Opt{'create-breaks'}, - "debug" => \$Opt{'debug'}, - "double-y-scale|y" => \$Opt{'double-y-scale'}, - "epoch|e" => \$Opt{'epoch'}, - "fix" => \$Opt{'fix'}, - "help|h" => \$Opt{'help'}, - "inside" => \$Opt{'inside'}, - "near" => \$Opt{'near'}, - "output-format|o=s" => \$Opt{'output-format'}, - "outside" => \$Opt{'outside'}, - "pos1=s" => \$Opt{'pos1'}, - "pos2=s" => \$Opt{'pos2'}, - "print-comments|C" => \$Opt{'print-comments'}, - "require|r=s" => \$Opt{'require'}, - "save-to-file|S=s" => \$Opt{'save-to-file'}, - "short-date|s" => \$Opt{'short-date'}, - "skip-dups|d" => \$Opt{'skip-dups'}, - "strip-whitespace|w" => \$Opt{'strip-whitespace'}, - "undefined|n=s" => \$Opt{'undefined'}, - "use-comma|c" => \$Opt{'use-comma'}, - "verbose|v" => \$Opt{'verbose'}, - "version" => \$Opt{'version'}, - # }}} -) || die("$progname: Option error. Use -h for help.\n"); - -my %Dat; - -my $PAUSE_LIMIT = 2 * 60; # Antall sekunder mellom to punkter det må til før en move legges inn. -my $Des = $Opt{'use-comma'} ? "," : "."; -my $Udef = "?"; -my $DIGIT = '[0-9\.\-\+]'; # Used in regexps -my $Spc = $Opt{'strip-whitespace'} ? "" : " "; -my $in_dupskip = 0; # Er 1 hvis vi holder på med ignorering av duplikater -my $found_move = 0; # Settes til 1 hvis en /^# move$/ blir funnet. -my $first_time = 0; -my $last_time = 0; -my ($last_lon, $last_lat, $last_ele, $last_line) = - ( 1000, 1000, 100000, ""); # Vi kan jo teoretisk sett være i Greenwich eller på ekvator -my ($lat1, $lon1, $lat2, $lon2) = - (-1000, -1000, 1000, 1000); -my ($start_date, $end_date, $found_dup) = - ( "", "", 0); -my @Dup = (); - -my %Poscount = (); - -my %Req = ( - 'altitude' => ($Opt{'require'} =~ /a/) ? 1 : 0, - 'time' => ($Opt{'require'} =~ /t/) ? 1 : 0 -); -$Opt{'require'} =~ /[^at]/ && die("$0: Unknown flag in --require (-r) value\n"); - -$Opt{'debug'} && ($Debug = 1); -$Opt{'help'} && usage(0); -$Opt{'version'} && print_version(); - -if ($Opt{'pos1'} =~ /^($DIGIT+),($DIGIT+)$/) { - $lat1 = $1; - $lon1 = $2; -} -if ($Opt{'pos2'} =~ /^($DIGIT+),($DIGIT+)$/) { - $lat2 = $1; - $lon2 = $2; -} -if ($lat1 > $lat2) { - my $Tmp = $lat1; - $lat1 = $lat2; - $lat2 = $Tmp; -} -if ($lon1 > $lon2) { - my $Tmp = $lon1; - $lon1 = $lon2; - $lon2 = $Tmp; -} - -if ($Opt{'inside'} && $Opt{'outside'}) { - die("$progname: Cannot mix the --inside and --outside options\n"); -} - -my $waypoint_file = "/home/sunny/gps/waypoints.gpx"; - -# To avoid printing out extra "/> at the start of svg output: -my $svg_start_thing = ""; - -length($Opt{'undefined'}) && ($Udef = $Opt{'undefined'}); -# Kunne vært et eget script på grunn av at det gjør sine helt egne -# greier, men like greit å samle det på en plass. -# FIXME: Fjerner ikke første duplikatentryen. -# FIXME: Se om det går å få flytta den inn i print_entry() så man -# slipper å ha to gptrans_conv’er i pipen. -# FIXME: Legg inn alle formatene. -if (0 && $Opt{'comment-out-dups'}) { - # Comment out areas without reception {{{ - while (<>) { - if (m#^1 (\S+) (\S+) (\S+) (\S+) (\d\d)/(\d\d)/(\d\d\d\d) (\d\d):(\d\d):(\d\d)#) { - # {{{ - my ($lat_val, $lon_val, $Speed, $Unkn, $Month, $Day, $Year, $Hour, $Min, $Sec) = - ( $1, $2, $3, $4, $5, $6, $7, $8, $9, $10); - # }}} - } else { - if ($found_dup) { - push(@Dup, $_); - } else { - print($_); - } - } - } - if ($found_dup) { - print("# $start_date-$end_date: CO: No signal \x7B\x7B\x7B\n"); - for (@Dup) { - print($_); - } - print("# $start_date-$end_date: CO: No signal \x7D\x7D\x7D\n# move\n"); - $found_dup = 0; - } - exit(0); - # }}} -} - -$Opt{'save-to-file'} eq "\n" && print_header(*STDOUT); - -my @first_lines; -my $xml_data; -my $data_line = ""; -my $curr_file = ""; - -my $from_stdin = scalar(@ARGV) ? 0 : 1; - -$from_stdin && push(@ARGV, "-"); - -for $curr_file (@ARGV) { - # Scan through stdin or specified files and send every GPS entry to - # print_entry() - # {{{ - D("Opening \"$curr_file\" for read"); - if (open(CurrFP, "<$curr_file")) { - # {{{ - while () { - $data_line = $_; - %Dat = ( - 'year' => '', 'month' => '', 'day' => '', - 'hour' => '', 'min' => '', 'sec' => '', - 'lat' => '', 'lon' => '', - 'ele' => '', - 'desc' => '', - 'error' => 0, - 'type' => 'tp', - ); - - if ($Opt{'save-to-file'} ne "\n") { - push(@first_lines, $_); - $_ =~ s/^# ?//; # Also read commented-out lines. - } - $xml_data = ""; - if (m#^<(e?tp)\b.*?>(.*?)$#) { - # gpsml — The main storage format {{{ - my ($Elem, $Data) = - ( $1, $2); - $Elem eq "etp" && ($Dat{'error'} = 1); - my $Time = ""; - $Data =~ m## && ($Time = $1); - $Time =~ s{ - (\d\d\d\d)-?(\d\d)-?(\d\d)T(\d\d):?(\d\d):?([\d\.]+?)Z - } { - ($Dat{'year'}, $Dat{'month'}, $Dat{'day'}, - $Dat{'hour'}, $Dat{'min'}, $Dat{'sec'}) = - ( $1, $2, $3, - $4, $5, $6); - ""; - }ex; - $Data =~ m#($DIGIT*?)# && ($Dat{'lat'} = $1); - $Data =~ m#($DIGIT*?)# && ($Dat{'lon'} = $1); - $Data =~ m#($DIGIT*?)# && ($Dat{'ele'} = $1); - $Data =~ m#(.*?)# && ($Dat{'desc'} = xml_to_txt($1)); - print_entry(%Dat); - # }}} - } elsif (m#^#) { - $found_move = 1; - } elsif (m#^<(desc|title|pause)\b.*?>(.*?)#) { - $Dat{'type'} = $1; - $Dat{$1} = xml_to_txt($2); - print_entry(%Dat); - } elsif (/^); - if (!length($Opt{'output-format'})) { - $Opt{'output-format'} = "gpx"; - print_header(*STDOUT); - } - read_xmlfile($xml_data); - last; - } elsif (/^# Pause: /) { - $Opt{'print-comments'} && print; - } elsif (/^# move$/) { - $found_move = 1; - } elsif (/^#/) { - $Opt{'print-comments'} && print; - } elsif (m#^(\d+)\t($DIGIT+)\t($DIGIT+)\t($DIGIT)#) { - # CSV format, epoch style {{{ - my ($ep_time, $lon_val, $lat_val, $Alt) = - ( $1, $2, $3, $4); - ($Dat{'sec'}, $Dat{'min'}, $Dat{'hour'}, - $Dat{'day'}, $Dat{'month'}, $Dat{'year'}, - $Dat{'wday'}, $Dat{'yday'}) = gmtime($ep_time); - $Dat{'month'}++; # Urgh Ⅰ - $Dat{'year'} += 1900; # Urgh Ⅱ - print_entry(%Dat); - # }}} - } elsif (m#^(\d\d\d\d)-?(\d\d)-?(\d\d)[T ](\d\d):?(\d\d):?(\d\d)Z?\t($DIGIT+)\t($DIGIT+)\t($DIGIT)#) { - # CSV format, human-readable date format {{{ - ($Dat{'year'}, $Dat{'month'}, $Dat{'day'}, - $Dat{'hour'}, $Dat{'min'}, $Dat{'sec'}, - $Dat{'lon'}, $Dat{'lat'}, $Dat{'ele'}) = - ($1, $2, $3, - $4, $5, $6, - $7, $8, $9); - print_entry(%Dat); - # }}} - } elsif (/^Trackpoint\t/) { - # Trackpoint\tN60.41630 E5.31675\t09.02.2006 20:24:37 (UTC)\t13.6 m\t\t93.9 m\t00:00:06\t56 kph\t123° true {{{ - # - # Trackpoint\t - # N60.41630 E5.31675\t - # 09.02.2006 20:24:37 (UTC)\t - # 13.6 m\t - # \t - # 93.9 m\t - # 00:00:06\t - # 56 kph\t - # 123° true - my $Orig = $_; - $Orig =~ s/[\r\n]+$//; - my ($Marker_f, $Position_f, $Time_f, $Alt_f, $Depth_f, - $Leglength_f, $Legtime_f, $Legspeed_f, $Legcourse_f) = - split(/\t/, $Orig . - # Nødløsning for å unngå at variabler blir - # udefinert. - "\t\t\t\t\t\t\t\t\t\t" - ); - D(join("", - "Position_f=\"$Position_f\" \x7B\x7B\x7B\n", - "Time_f=\"$Time_f\"\n", - "Alt_f=\"$Alt_f\"\n", - "Depth_f=\"$Depth_f\"\n", - "Leglength_f=\"$Leglength_f\"\n", - "Legtime_f=\"$Legtime_f\"\n", - "Legspeed_f=\"$Legspeed_f\"\n", - "Legcourse_f=\"$Legcourse_f\" \x7D\x7D\x7D\n", - )); - my ($NS, $WE, - $Alt_unit, - $Leglength, - $Legtime_hour, $Legtime_min, $Legtime_sec, - $Legspeed, $Legspeed_unit, - $Legcourse - ) = ("", "", "", "", "", "", "", "", "", "", "", "", "", "", "", - "", "", "", "", "", "", "", ""); - ($Position_f =~ /^(N|S)([\d\.]+) (W|E)([\d\.]+)/) && - ($NS = $1, $Dat{'lat'} = $2, $WE = $3, $Dat{'lon'} = $4); - ($Time_f =~ /^(\d+)\.(\d+)\.(\d+) (\d+):(\d+):(\d+) \((.+?)\)/) && - ($Dat{'day'} = $1, $Dat{'month'} = $2, $Dat{'year'} = $3, - $Dat{'hour'} = $4, $Dat{'min'} = $5, $Dat{'sec'} = $6); - ($Alt_f =~ /^([\d+\.]+) (.*?)/) && - ($Dat{'ele'} = $1, $Alt_unit = $2); - D("ele = \"$Dat{'ele'}\""); - ($NS eq "S") && ($Dat{'lat'} = 0-$Dat{'lat'}); - ($WE eq "W") && ($Dat{'lon'} = 0-$Dat{'lon'}); - # MapSource in win xp writes YYYY, but YY in win98se. - (defined($Dat{'year'}) && $Dat{'year'} =~ /\d/ && $Dat{'year'} < 1900) && ($Dat{'year'} += 2000); - print_entry(%Dat); - # }}} - } elsif (m#^T\t(\d\d)/(\d\d)/(\d\d\d\d) (\d\d):(\d\d):(\d\d)\t(.+)\xB0(.+)'(.+)"\t(.+)\xB0(.+)'(.+)"#) { - # T 09/01/2002 11:51:26 60°23'36.3" 5°19'35.9" {{{ - my ($lat_d, $lat_m, $lat_s, $lon_d, $lon_m, $lon_s); - ($Dat{'month'}, $Dat{'day'}, $Dat{'year'}, - $Dat{'hour'}, $Dat{'min'}, $Dat{'sec'}, $lat_d, - $lat_m, $lat_s, $lon_d, - $lon_m, $lon_s) = - ( $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12); - $Dat{'lat'} = sprintf("%.5f", 1*($lat_d+($lat_m/60)+($lat_s/3600))); - $Dat{'lon'} = sprintf("%.5f", $lon_d+($lon_m/60)+($lon_s/3600)); - print_entry(%Dat); - # }}} - } elsif (m#^1 (\S+) (\S+) (\S+) (\S+) (\d\d)/(\d\d)/(\d\d\d\d) (\d\d):(\d\d):(\d\d)#) { - # 1 60.3938222 5.3238754 17.3 0 09/01/2002 14:18:23 {{{ - ($Dat{'lat'}, $Dat{'lon'}, $Dat{'speed'}, - $Dat{'unkn'}, - $Dat{'month'}, $Dat{'day'}, $Dat{'year'}, - $Dat{'hour'}, $Dat{'min'}, $Dat{'sec'}) = - ( $1, $2, $3, $4, $5, $6, $7, $8, $9, $10); - print_entry(%Dat); - # }}} - } elsif (/^ - # @020721221336N6048353E00701826S015-00001E4859N1673U0000 {{{ - # Regexp {{{ - (@) # @ - (\d\d) # Year - (\d\d) # Month - (\d\d) # Day - (\d\d) # Hours - (\d\d) # Minutes - (\d\d) # Seconds - ([NS]) # N|S - (\d\d) # Latitude degree - (\d\d) # Latitude minute - (\d\d\d) # Latitude minute decimals - ([EW]) # E|W - (\d\d\d) # Longitude degree - (\d\d) # Longitude minute - (\d\d\d) # Longitude minute degree - (....) # Accurancy - (......) # Altitude - (...............) - $ - # }}} - /x) { - my ($NS, $EW, $lat_deg, $lat_degmin, $lat_mindec, $lon_deg, - $lon_degmin, $lon_mindec); - ($Dat{'year'}, $Dat{'month'}, $Dat{'day'}, $Dat{'hour'}, - $Dat{'min'}, $Dat{'sec'}, $NS, $lat_deg, - $lat_degmin, $lat_mindec, $EW, - $lon_deg, $lon_degmin, $lon_mindec, - $Dat{'accur'}, $Dat{'ele'}, $Dat{'unknown'}) = - ($2+2000, $3, $4, $5, $6, $7, $8, $9, $10, $11, - $12, $13, $14, $15, $16, $17, $18); - my $ep_time = timegm_nocheck($Dat{'sec'}, $Dat{'min'}, $Dat{'hour'}, $Dat{'day'}, $Dat{'month'}-1, $Dat{'year'}); - $last_time = $ep_time; - my $tmp_lon = sprintf("%.5f", $lon_deg + $lon_degmin/60 + $lon_mindec/60000); - my $tmp_lat = sprintf("%.5f", $lat_deg + $lat_degmin/60 + $lat_mindec/60000); - $tmp_lon =~ s/\./$Des/; - $tmp_lat =~ s/\./$Des/; - ($NS eq "S") && ($tmp_lat = 0-$tmp_lat); - ($EW eq "W") && ($tmp_lon = 0-$tmp_lon); - $Dat{'lat'} = $tmp_lat; - $Dat{'lon'} = $tmp_lon; - print_entry(%Dat); - # }}} - } elsif (/^(@)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(__________________________________________)/) { - # @020721221336__________________________________________ {{{ - my ($Alfa, $Year, $Month, $Day, $Hour, $Min, $Sec, $Rest) = - ( $1, $2+2000, $3, $4, $5, $6, $7, $8); - $Opt{'output-format'} eq "csv" && print("\n"); - $found_move = 1; - # }}} - } elsif (/^xmaplog /) { - ($Opt{'output-format'} eq "csv") && ($Opt{'save-to-file'} eq "\n") && print("\n"); - } elsif (/^$/) { - ($Opt{'output-format'} eq "csv") && ($Opt{'save-to-file'} eq "\n") && print("\n"); - } else { - if ($Opt{'print-comments'}) { - print("# $_"); - chomp; - } - $Opt{'verbose'} && warn("Line $.: Unknown: \"$_\"\n"); - } - } - # }}} - } else { - warn("$progname: $curr_file: Cannot open file for read: $!\n"); - } - # }}} -} - -print_footer(*STDOUT); - -exit(0); - -sub read_xmlfile { - # {{{ - my $Txt = join("", @_); - # FIXME: The sequential stuff here is probably bad, but easy. - $Txt =~ s#(.*?)#print_gpx($1)#gse; - $Txt =~ s#(.*?)#print_xml_gps($1)#gse; - # }}} -} - -sub print_gpx { - # {{{ - my $Orig = shift; - my $Str = $Orig; - D("print_xml_gps(\"$Orig\")\n"); - $Str =~ - s{ - (.*?) - } - { - my $el_trk = $2; - $el_trk =~ - s{ - (.*?) - } - { - my $el_trkseg = $2; - $el_trkseg =~ - s{ - (.*?) - } - { - my ($attr_trkpt, $el_trkpt) = - ( $1, $2); - ($attr_trkpt =~ /\blon="(.*?)"/) && ($Dat{'lon'} = $1); - ($attr_trkpt =~ /\blat="(.*?)"/) && ($Dat{'lat'} = $1); - ($el_trkpt =~ m#(.*?)#) && ($Dat{'ele'} = $1); - if ($el_trkpt =~ m##) { - ($Dat{'year'}, $Dat{'month'}, $Dat{'day'}, - $Dat{'hour'}, $Dat{'min'}, $Dat{'sec'}, $Dat{'secfrac'}) = - ($1, $2, $3, $4, $5, $6, $7); - } - print_entry(%Dat); - ""; - }gsex; - $found_move = 1; - }gsex; - $found_move = 1; - }gsex; - # }}} -} - -sub print_xml_gps { - # {{{ - my $Orig = shift; - my $Str = $Orig; - D("print_xml_gps(\"$Orig\")\n"); - if ($Str =~ m#(\d\d\d\d)-?(\d\d)-?(\d\d)T(\d\d):?(\d\d):?(\d\d)\.?(\d*?)Z#) { - ($Dat{'year'}, $Dat{'mon'}, $Dat{'day'}, $Dat{'hour'}, $Dat{'min'}, $Dat{'sec'}, $Dat{'secfrac'}) = - ( $1, $2, $3, $4, $5, $6, $7); - } - if ($Str =~ m#(.*?)#s) { - my $Txt = $1; - ($Txt =~ m#(.*?)#) && ($Dat{'lon'} = $1); - ($Txt =~ m#(.*?)#) && ($Dat{'lat'} = $1); - ($Txt =~ m#(.*?)#) && ($Dat{'ele'} = $1); - } - defined($Dat{'lon'}) || ($Dat{'lon'} = ""); - defined($Dat{'lat'}) || ($Dat{'lat'} = ""); - defined($Dat{'ele'}) || ($Dat{'ele'} = ""); - print_entry(%Dat); - # }}} -} - -sub print_header { - # {{{ - local *OutFP = shift; - if ($Opt{'output-format'} eq "gpsml") { - print(OutFP join("", - "\n", - "\n", - "\n", - )); - } elsif ($Opt{'output-format'} eq "gpstrans") { - print(OutFP "Format: DMS UTC Offset: 0.00 hrs Datum[100]: WGS 84\n"); - } elsif ($Opt{'output-format'} eq "gpx") { - print(OutFP join("", - "\n", - "\n", - "$Spc$Spc\n", - "$Spc$Spc$Spc$Spc\n", - )); - } elsif ($Opt{'output-format'} eq "ps") { - print(OutFP ps_header(532, 6034, 533, 6040)); - print(OutFP "*u\n"); - } elsif ($Opt{'output-format'} eq "xml") { - print(OutFP join("", - "\n", - "\n", - )); - } elsif ($Opt{'output-format'} eq "svg") { - print(OutFP join("", - "\n", - "\n", - "\n", - "$Spc$Spc\n", - "$Spc$Spc\n", - )); - } - # }}} -} - -sub print_footer { - # Print footer {{{ - local *OutFP = shift; - if ($Opt{'output-format'} eq "gpsml") { - print(OutFP join("", - "\n", - "\n", - )); - } elsif ($Opt{'output-format'} eq "gpx") { - print(OutFP join("", - "$Spc$Spc$Spc$Spc\n", - "$Spc$Spc\n", - "\n", - )); - } elsif ($Opt{'output-format'} eq "poscount") { - while (my ($l_name, $l_val) = each %Poscount) { - $l_name =~ /^(.+?),(.+?)$/ && print(OutFP "$1\t$2\t$l_val\n"); - } - } elsif ($Opt{'output-format'} eq "ps") { - print(OutFP join("", - "*U\n", - "%%Trailer\n", - "%%EOF\n", - )); - } elsif ($Opt{'output-format'} eq "svg") { - print(OutFP "\"/>\n\n"); - } elsif ($Opt{'output-format'} eq "xml") { - print(OutFP "\n"); - } - # }}} -} - -sub print_entry { - # Print a GPS entry with time, latitude, longitude and altitude in - # various formats - # {{{ - my %Dat = @_; - my $print_time = length($Dat{'year'}) ? 1 : 0; - my $print_ele = length($Dat{'ele'}) ? 1 : 0; - my $print_desc = length($Dat{'desc'}) ? 1 : 0; - my $Line = ""; - D("print_entry(\"" . join("\", \"", @_) . "\");"); - my $ep_time; - - if ($Opt{'near'}) { - $Line .= sprintf("%s ", list_nearest_waypoints($Dat{'lat'}, $Dat{'lon'})); - } - - if ($Opt{'output-format'} eq "poscount") { - my ($Lat_str, $Lon_str) = - ( "", ""); - $Dat{'lon'} =~ /^(\d+\.\d\d)/ && ($Lon_str = $1); - $Dat{'lat'} =~ /^(\d+\.\d\d)/ && ($Lat_str = $1); - my $Name = "${Lon_str},${Lat_str}"; - defined($Poscount{$Name}) || ($Poscount{$Name} = 0); - $Poscount{$Name}++; - return; - } - - if ($print_time) { - $ep_time = timegm_nocheck($Dat{'sec'}, $Dat{'min'}, $Dat{'hour'}, $Dat{'day'}, $Dat{'month'} - 1, $Dat{'year'}); - $Dat{'year'} = sprintf("%04u", $Dat{'year'}); - $Dat{'month'} = sprintf("%02u", $Dat{'month'}); - $Dat{'day'} = sprintf("%02u", $Dat{'day'}); - $Dat{'hour'} = sprintf("%02u", $Dat{'hour'}); - $Dat{'min'} = sprintf("%02u", $Dat{'min'}); - $Dat{'sec'} = sprintf("%02u", $Dat{'sec'}); - if ($Opt{'chronology'}) { - if ($last_time > $ep_time) { - warn(sprintf( - "%s: \"%sZ\": Next date is %s in the past (%sZ)\n", - $progname, sec_to_string($last_time, "T"), - sec_to_readable($last_time-$ep_time), - sec_to_string($ep_time, "T") - )); - # FIXME: Make --fix work with gpx and xml. - if ($Opt{'fix'} && ($Opt{'output-format'} !~ /^(gpx|xml)$/)) { - ($Line .= "# error "); - } - } - } - } else { - $Req{'time'} && return; - $ep_time = 0; - $Dat{'year'} = 0; - $Dat{'month'} = 0; - $Dat{'day'} = 0; - $Dat{'hour'} = 0; - $Dat{'min'} = 0; - $Dat{'sec'} = 0; - } - - if ($Opt{'save-to-file'} ne "\n") { - # {{{ - my $base_name = "$Dat{'year'}$Dat{'month'}$Dat{'day'}T$Dat{'hour'}$Dat{'min'}$Dat{'sec'}Z$Opt{'save-to-file'}"; - my $file_name = $base_name; - if (-e $file_name) { - for (my $a = 1; (-e $file_name) && ($a < 1000); $a++) { - $file_name = "$base_name.dup_$a"; - } - if (-e $file_name) { - die("$progname: $base_name: File already exists, and ran " . - "out of attempts to create unique file name\n"); - } - if ($Opt{'verbose'}) { - warn("$progname: $base_name: File already exists, using " . - "unique name \"$file_name\" instead\n"); - } - } - if (open(ToFP, ">", $file_name)) { - print_header(*ToFP); - print(ToFP ($from_stdin ? @first_lines : ()), (length($xml_data) ? $xml_data : <>)) || - die("$progname: $file_name: Cannot write to file: $!\n"); - print_footer(*ToFP); - close(ToFP); - if ($Opt{'output-format'} eq "gpsml") { - printf("%s\n", - txt_to_xml($file_name)); - } elsif ($Opt{'output-format'} eq "gpx") { - printf("\n", - txt_to_xml($file_name)); - } else { - print("$progname: Saved unconverted data to \"$file_name\"\n"); - } - exit 0; - } else { - die("$progname: $file_name: Cannot create file: $!\n"); - } - # }}} - } - - my $pause_len = 0; - my $do_print = 1; - ($Req{'altitude'} && !$print_ele) && return; - - if ($Opt{'inside'} || $Opt{'outside'}) { - if ( - ($Dat{'lat'} < $lat1) || - ($Dat{'lat'} > $lat2) || - ($Dat{'lon'} < $lon1) || - ($Dat{'lon'} > $lon2) - ) { - $Opt{'inside'} && return; - } else { - $Opt{'outside'} && return; - } - } - - if ($Opt{'comment-out-dups'}) { - if (($Dat{'lat'} eq $last_lat) && ($Dat{'lon'} eq $last_lon)) { - unless ($found_dup) { - $start_date = "$Dat{'year'}$Dat{'month'}$Dat{'day'}T$Dat{'hour'}$Dat{'min'}$Dat{'sec'}"; - @Dup = (); - $found_dup = 1; - } - push(@Dup, "# $_"); - $end_date = "$Dat{'year'}$Dat{'month'}$Dat{'day'}T$Dat{'hour'}$Dat{'min'}$Dat{'sec'}"; - $do_print = 0; - } else { - if ($found_dup) { - print("# $start_date-$end_date: CO: No signal \x7B\x7B\x7B\n"); - for (@Dup) { - print($_); - } - print("# $start_date-$end_date: CO: No signal \x7D\x7D\x7D\n# move\n$_"); - $found_dup = 0; - } else { - $Line = $_; - $do_print = 1; - } - } - } - if ($Opt{'output-format'} eq "ps") { - $Dat{'lon'} *= 100; - $Dat{'lat'} *= 100; - } - # FIXME: $Opt{'skip_dups'} ble bytta ut med $Opt{'comment-out-dups'} - # i r583. Lurer på hva det gikk i der. - if ($Opt{'skip-dups'} && ($Dat{'lon'} eq $last_lon) && ($Dat{'lat'} eq $last_lat) && ($Dat{'ele'} eq $last_ele)) { - if ($in_dupskip) { - $do_print = 0; - } else { - $do_print = 1; - } - $in_dupskip = 1; - } else { - $do_print = 1; - $in_dupskip && ($Line .= $last_line); - $in_dupskip = 0; - } - - if ($Opt{'create-breaks'} && $ep_time-$last_time > $PAUSE_LIMIT && $last_time) { - $pause_len = $ep_time-$last_time; - D("pause_len set to '$pause_len'"); - } - - if ($pause_len) { - if ($Opt{'output-format'} eq "gpsml") { - $Line .= sprintf("%s\n", - sec_to_readable($ep_time-$last_time)); - } elsif ($Opt{'output-format'} eq "csv") { - $Line .= sprintf("# Pause: %s\n# move\n", - sec_to_readable($ep_time-$last_time)); - } - } - - if ($do_print) { - # Valid data was found, send to stdout {{{ - if ($Opt{'double-y-scale'}) { - $Dat{'lat'} *= 2; - } - if ($Opt{'output-format'} eq "gpsml") { - if ($Dat{'type'} eq "tp") { - my $Elem = $Dat{'error'} ? "etp" : "tp"; - $Line .= join("", - "<$Elem> ", - $print_time - ? " " - : "", - (length($Dat{'lat'})) - ? "" . $Dat{'lat'}*1.0 . " " - : "", - (length($Dat{'lon'})) - ? "" . $Dat{'lon'}*1.0 . " " - : "", - ($print_ele) - ? "" . $Dat{'ele'}*1.0 . " " - : "", - ($print_desc) - ? sprintf("%s ", - txt_to_xml($Dat{'desc'})) - : "", - "\n" - ); - } elsif ($Dat{'type'} =~ /^(pause|desc|title)$/) { - $Line .= sprintf("<%s>%s\n", - $1, - txt_to_xml($Dat{$1}), - $1); - } - } elsif ($Opt{'output-format'} eq "xgraph") { - $pause_len && ($Line .= "move "); - ($Line .= "$Dat{'lon'} $Dat{'lat'}\n"); - } elsif($Opt{'output-format'} eq "gpstrans") { - my ($gpt_lat, $gpt_lon) = (ddd_to_dms($Dat{'lat'}), ddd_to_dms($Dat{'lon'})); - if ($print_time) { - $Line .= "T\t$Dat{'month'}/$Dat{'day'}/$Dat{'year'} $Dat{'hour'}:$Dat{'min'}:$Dat{'sec'}\t$gpt_lat\t$gpt_lon\n"; - } else { - $Line .= "T\t00/00/00 00:00:00\t$gpt_lat\t$gpt_lon\n"; - } - } elsif($Opt{'output-format'} eq "gpx") { - $Line .= join("", - "$Spc$Spc$Spc$Spc$Spc$Spc$Spc", - $print_time - ? "$Spc" - : "", - $print_ele - ? "$Dat{'ele'}$Spc" - : "", - "\n" - ); - } elsif ($Opt{'output-format'} eq "clean") { - $pause_len && ($Line .= "\n"); - ($Line .= "$Dat{'lon'}\t$Dat{'lat'}" . ($print_ele ? "\t$Dat{'ele'}" : "") . "\n"); - } elsif ($Opt{'output-format'} eq "ps") { - $Line .= ($pause_len ? "f\n$Dat{'lon'} $Dat{'lat'} m\n" : "$Dat{'lon'} $Dat{'lat'} l\n"); - } elsif ($Opt{'output-format'} eq "svg") { - $Line .= ( - ($last_lon == 1000) || $pause_len - ? join("", - "$svg_start_thing$Spc", - $print_time - ? "$Dat{'year'}-$Dat{'month'}-$Dat{'day'}T$Dat{'hour'}:$Dat{'min'}:$Dat{'sec'}Z$Spc" - : "", - "$Spc", - (length($Dat{'lon'})) ? "$Dat{'lon'}$Spc" : "", - (length($Dat{'lat'})) ? "$Dat{'lat'}$Spc" : "", - ($print_ele) ? "$Dat{'ele'}$Spc" : "", - "$Spc", - "\n" - ); - } elsif ($Opt{'output-format'} eq "ygraph") { - my $Time = $print_time ? ($ep_time - $first_time) * 1 : 0; - $Line .= "\"Time = $Time.0\n$Dat{'lon'} $Dat{'lat'}\n\n"; - } elsif ($Opt{'output-format'} eq "csv") { - # {{{ - $Dat{'lon'} =~ s/\./$Des/; - $Dat{'lat'} =~ s/\./$Des/; - # $do_print || print("skipping "); - $Line .= join("\t", - $print_time - ? $Opt{'epoch'} - ? $ep_time - : $Opt{'short-date'} - ? "$Dat{'year'}$Dat{'month'}$Dat{'day'}T$Dat{'hour'}$Dat{'min'}$Dat{'sec'}Z" - : "$Dat{'year'}-$Dat{'month'}-$Dat{'day'} $Dat{'hour'}:$Dat{'min'}:$Dat{'sec'}" - : "", - $Dat{'lon'}, - $Dat{'lat'}, - $print_ele ? $Dat{'ele'} : "", # Elevation - "\n" - ); - # }}} - } else { - die("$progname: \"$Opt{'output-format'}\": Unknown output format\n"); - } - # }}} - } - - if (!$last_time && $Opt{'output-format'} eq "ps") { - $Line .= "$Dat{'lon'} $Dat{'lat'} m\n"; - } - - if ($do_print) { - if ($found_move) { - if ($Opt{'output-format'} eq "gpsml") { - $Line = "\n$Line"; - } - (!$pause_len && ($Opt{'output-format'} eq "xgraph")) && ($Line .= "move $Line"); - ($Opt{'output-format'} eq "clean") && ($Line .= "\n"); - if ($Opt{'output-format'} eq "gpx") { - $Line .= "$Spc$Spc$Spc$Spc\n$Spc$Spc$Spc$Spc\n"; - } - $found_move = 0; - } - print($Line); - } - $last_time = $ep_time; - $last_lon = $Dat{'lon'}; - $last_lat = $Dat{'lat'}; - $last_ele = $Dat{'ele'}; - $last_line = $data_line; - $svg_start_thing = "\"/>\n"; - # }}} -} - -sub list_nearest_waypoints { - # {{{ - my ($Lat, $Lon, $Count) = @_; - # FIXME: Incredible unfinished and kludgy. - if (open(WaypFP, "gpsbabel -i gpx -f $waypoint_file -x radius,lat=$Lat,lon=$Lon,distance=1000 -o gpx -F - |")) { - my $Str = join("", ); - $Str =~ s{ - ^.*?.*?(.+?).*?.*? - .*?.*?(.+?).*?.*? - .*?.*?(.+?).*?.*$ - }{ - "($1, $2, $3)"; - }sex; - return($Str); - } else { - die("$progname: Cannot open gpsbabel pipe: $!\n"); - } - # }}} -} - -sub sec_to_string { - # Convert seconds since 1970 to "yyyy-mm-dd hh:mm:ss" with optional - # separator - # {{{ - my ($Seconds, $Sep) = @_; - defined($Sep) || ($Sep = " "); - my @TA = gmtime($Seconds); - my($DateString) = sprintf("%04u-%02u-%02u%s%02u:%02u:%02u", $TA[5]+1900, $TA[4]+1, $TA[3], $Sep, $TA[2], $TA[1], $TA[0]); - return($DateString); - # }}} -} - -sub sec_to_readable { - # Convert seconds since 1970 to human-readable format (d:hh:mm:ss) - # {{{ - my $secs = shift; - D("sec_to_readable(\"$secs\")\n"); - my ($Day, $Hour, $Min, $Sec) = - ( 0, 0, 0, 0); - - $Day = int($secs/86400); - $secs -= $Day * 86400; - - $Hour = int($secs/3600); - $secs -= $Hour * 3600; - - $Min = int($secs/60); - $secs -= $Min * 60; - - $Sec = $secs; - - return(sprintf("%u:%02u:%02u:%02u", $Day, $Hour, $Min, $Sec)); - # }}} -} - -sub ps_header { - # Send a Postscript header to stdout {{{ - my ($bl_lon, $bl_lat, $br_lon, $br_lat) = @_; - my $Date = sec_to_string(time); - return(join("", - "%!PS-Adobe-3.0 EPSF-3.0\n", - "%%Creator: $rcs_id\n", - "%%Title:\n", - "%%CreationDate: $Date\n", - "%%BoundingBox: $bl_lon $bl_lat $br_lon $br_lat\n", - "%%DocumentData: Clean7Bit\n", - "%%EndComments\n", - "%%BeginProlog\n", - "/bd { bind def } bind def\n", - "/incompound false def\n", - "/m { moveto } bd\n", - "/l { lineto } bd\n", - "/c { curveto } bd\n", - "/F { incompound not {fill} if } bd\n", - "/f { closepath F } bd\n", - "/S { stroke } bd\n", - "/*u { /incompound true def } bd\n", - "/*U { /incompound false def f} bd\n", - "/k { setcmykcolor } bd\n", - "/K { k } bd\n", - "%%EndProlog\n", - "%%BeginSetup\n", - "%%EndSetup\n", - )); - # }}} -} - -sub ddd_to_dms { - # Convert floating-point degrees into D°M'S.S" (ISO-8859-1). - # Necessary for import into GPSman. Based on toDMS() from - # gpstrans-0.39 to ensure compatibility. - # {{{ - my $ddd = shift; - my $Neg = 0; - my ($Hour, $Min, $Sec) = - ( 0, 0, 0); - my $Retval = ""; - - if ($ddd < 0.0) { - $ddd = 0 - $ddd; - $Neg = 1; - } - $Hour = int($ddd); - $ddd = ($ddd - $Hour) * 60.0; - $Min = int($ddd); - $Sec = ($ddd - $Min) * 60.0; - - if ($Sec > 59.5) { - $Sec = 0.0; - $Min += 1.0; - } - if ($Min > 59.5) { - $Min = 0.0; - $Hour += 1.0; - } - if ($Neg) { - $Hour = 0 - $Hour; - } - D("Neg = $Neg , D = $Hour , M = $Min , S = $Sec\n"); - $Retval = sprintf("%s%.0f\xB0%02.0f'%04.1f\"", $Neg ? "-" : "", $Hour, $Min, $Sec); - return $Retval; - # }}} -} - -sub txt_to_xml { - # Convert plain text to XML {{{ - my $Txt = shift; - $Txt =~ s/&/&/gs; - $Txt =~ s//>/gs; - return($Txt); - # }}} -} - -sub xml_to_txt { - # Convert XML data to plain text {{{ - my $Txt = shift; - $Txt =~ s/<//gs; - $Txt =~ s/&/&/gs; - return($Txt); - # }}} -} - -sub print_version { - # Print program version {{{ - print("$rcs_id\n"); - exit(0); - # }}} -} # print_version() - -sub usage { - # Send the help message to stdout {{{ - my $Retval = shift; - - print(< [options] [file [files [...]]] - -B -S [options] [file [files [...]]] - -B -u [options] [file [files [...]]] - -=head1 DESCRIPTION - -Converts between various GPS formats. - -=head1 OPTIONS - -=over 4 - -=item B<-c>, B<--comment-out-dups> - -Use comma instead of period as decimal point (For Gnumeric etc). - -=item B<-C>, B<--print-comments> - -Print existing comment lines (starting with "#") and prefix unknown -lines with "# ". - -=item B<--chronology> - -Check for broken chronology, warn about entries with an old timestamp. - -=item B<-d>, B<--skip-dups> - -Skip duplicated coordinates, only print first and last. - -=item B<-e>, B<--epoch> - -Use seconds since 1970-01-01 00:00:00 GMT as date format. - -item B<--fix> - -Comment out entries which is obviously wrong. Use together with ---chronology to fix those kind of errors. Does not work with GPX or XML -output yet. - -=item B<-h>, B<--help> - -Show this help. - -=item B<--inside> - -Print only trackpoints inside a rectangle specified by --pos1 and ---pos2. - -=item B<--near> - -Add names of the three closest waypoints to the trackpoint. Unfinished -and experimental, needs gpsbabel. - -=item B<-n x>, B<--undefined x> - -Use x as undefined value. - -=item B<-o x>, B<--output-format x> - -Use output format x: - -=over 4 - -=over 4 - -=item clean - -=item csv - -=item gpsml (Default) - -This is the format which is meant to be used when storing the track -logs. -It is line-based XML which makes it easy to edit and grep. Probably not -finished yet. - -=item gpstrans - -=item gpx (Not complete) - -=item poscount (Experimental) - -Creates a 3D plot where areas with many trackpoints are higher than -areas with less track points. - -=item ps (Unfinished) - -=item svg (Unfinished) - -=item xgraph - -=item xml - -=item ygraph - -=back - -=back - -Z<> - -=item B<--outside> - -Print only trackpoints outside a rectangle specified by --pos1 and ---pos2. - -=item B<--pos1 x>, B<--pos2 x> - -Specifies corners of an area rectangle used by the --inside and ---outside options. The x value is in "lat,lon" format (decimal degrees, -negative for west or south) . - -=item B<-r x>, B<--require x> - -Specify requirements for trackpoints to be written. x is a string with -the following flags: - -=over 4 - -=over 4 - -=item a - -=over 4 - -=item Print only waypoints which have an altitude. - -=back - -=back - -=over 4 - -=item t - -=over 4 - -=item Print only waypoints which have a timestamp. - -=back - -=back - -=back - -Z<> - -=item B<-s>, B<--short-date> - -Use short date format. - -=item B<-S x>, B<--save-to-file x> - -Save the unconverted data to a file with a filename starting with the -timestamp of the first trackpoint. The parameter string x is added at -the end of the filename. For the time being this option will ignore all -other options. - -Note: If several files are specified on the command line, all data will -be saved into only one file. This behaviour may change in the future. - -=item B<-t>, B<--create-breaks> - -Create breaks in track between points with a difference more than the -number of seconds specified by the C<$PAUSE_LIMIT> variable. - -=item B<-u>, B<--comment-out-dups> - -Comment out following data with identical position values, only print -first entry. - -=item B<-v>, B<--verbose> - -Verbose, warn about unknown lines. - -=item B<-w>, B<--strip-whitespace> - -Strip all unnecessary whitespace. - -=item B<-x>, B<--xml> - -Create XML output. - -=item B<-y>, B<--double-y-scale> - -Double Y scale (latitude) to get it right in gnuplot. - -=item B<-h>, B<--help> - -Print a brief help summary. - -=item B<--version> - -Print version information. - -=item B<--debug> - -Print debugging messages. - -=back - -=head1 BUGS - -Pretty incomplete in some areas. Some of the source formats are -undocumented and thus incomplete. Some functionality is not working -properly, for example the Postscript output. - -=head1 AUTHOR - -Made by Øyvind A. Holm Ssunny@sunbase.orgE>. - -=head1 COPYRIGHT - -Copyleft © Øyvind A. Holm <sunny@sunbase.org> -This is free software; see the file F for legalese stuff. - -=head1 LICENCE - -This program is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2 of the License, or (at your -option) any later version. - -This program is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along -with this program; if not, write to the Free Software Foundation, Inc., -59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -=head1 SEE ALSO - -gpsbabel(1) - -=cut - -# }}} - -# vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w : -# End of file $Id$ diff --git a/branches/gpst.gpsman-format/Patch/gpst-xmlsimple b/branches/gpst.gpsman-format/Patch/gpst-xmlsimple deleted file mode 100755 index 1014755..0000000 --- a/branches/gpst.gpsman-format/Patch/gpst-xmlsimple +++ /dev/null @@ -1,1432 +0,0 @@ -#!/usr/bin/perl -w - -#======================================================================= -# $Id$ -# Converts between various GPS formats -# -# Character set: UTF-8 -# ©opyleft 2002– Øyvind A. Holm -# License: GNU General Public License, see end of file for legal stuff. -#======================================================================= - -use strict; -use Getopt::Long; -use Time::Local qw { timegm_nocheck }; -use XML::Simple; -use Data::Dumper; - -$| = 1; - -our $Debug = 0; - -our %Opt = ( - # Initial values for command line arguments {{{ - 'chronology' => 0, - 'comment-out-dups' => 0, - 'create-breaks' => 0, - 'debug' => 0, - 'double-y-scale' => 0, - 'epoch' => 0, - 'fix' => 0, - 'help' => 0, - 'inside' => 0, - 'near' => "", - 'output-format' => "gpsml", - 'outside' => 0, - 'pos1' => "", - 'pos2' => "", - 'print-comments' => 0, - 'require' => "", - 'save-to-file' => "\n", # \n = undefined, it’s banned in filenames anyway. - 'short-date' => 0, - 'skip-dups' => 0, - 'strip-whitespace' => 0, - 'undefined' => "", - 'use-comma' => 0, - 'version' => 0, - # }}} -); - -our $progname = $0; -$progname =~ s#^.*/(.*?)$#$1#; - -my $rcs_id = '$Id$'; -my $id_date = $rcs_id; -$id_date =~ s/^.*?\d+ (\d\d\d\d-.*?\d\d:\d\d:\d\d\S+).*/$1/; - -Getopt::Long::Configure("bundling"); -GetOptions( - # Command line options {{{ - "chronology" => \$Opt{'chronology'}, - "comment-out-dups|u" => \$Opt{'comment-out-dups'}, - "create-breaks|t" => \$Opt{'create-breaks'}, - "debug" => \$Opt{'debug'}, - "double-y-scale|y" => \$Opt{'double-y-scale'}, - "epoch|e" => \$Opt{'epoch'}, - "fix" => \$Opt{'fix'}, - "help|h" => \$Opt{'help'}, - "inside" => \$Opt{'inside'}, - "near" => \$Opt{'near'}, - "output-format|o=s" => \$Opt{'output-format'}, - "outside" => \$Opt{'outside'}, - "pos1=s" => \$Opt{'pos1'}, - "pos2=s" => \$Opt{'pos2'}, - "print-comments|C" => \$Opt{'print-comments'}, - "require|r=s" => \$Opt{'require'}, - "save-to-file|S=s" => \$Opt{'save-to-file'}, - "short-date|s" => \$Opt{'short-date'}, - "skip-dups|d" => \$Opt{'skip-dups'}, - "strip-whitespace|w" => \$Opt{'strip-whitespace'}, - "undefined|n=s" => \$Opt{'undefined'}, - "use-comma|c" => \$Opt{'use-comma'}, - "verbose|v" => \$Opt{'verbose'}, - "version" => \$Opt{'version'}, - # }}} -) || die("$progname: Option error. Use -h for help.\n"); - -my %Dat; - -my $PAUSE_LIMIT = 2 * 60; # Antall sekunder mellom to punkter det må til før en move legges inn. -my $Des = $Opt{'use-comma'} ? "," : "."; -my $Udef = "?"; -my $DIGIT = '[0-9\.\-\+]'; # Used in regexps -my $Spc = $Opt{'strip-whitespace'} ? "" : " "; -my $in_dupskip = 0; # Er 1 hvis vi holder på med ignorering av duplikater -my $found_move = 0; # Settes til 1 hvis en /^# move$/ blir funnet. -my $first_time = 0; -my $last_time = 0; -my ($last_lon, $last_lat, $last_ele, $last_line) = - ( 1000, 1000, 100000, ""); # Vi kan jo teoretisk sett være i Greenwich eller på ekvator -my ($lat1, $lon1, $lat2, $lon2) = - (-1000, -1000, 1000, 1000); - -my %Poscount = (); - -my %Req = ( - 'altitude' => ($Opt{'require'} =~ /a/) ? 1 : 0, - 'time' => ($Opt{'require'} =~ /t/) ? 1 : 0 -); -$Opt{'require'} =~ /[^at]/ && die("$0: Unknown flag in --require (-r) value\n"); - -$Opt{'debug'} && ($Debug = 1); -$Opt{'help'} && usage(0); -$Opt{'version'} && print_version(); - -if ($Opt{'pos1'} =~ /^($DIGIT+),($DIGIT+)$/) { - $lat1 = $1; - $lon1 = $2; -} -if ($Opt{'pos2'} =~ /^($DIGIT+),($DIGIT+)$/) { - $lat2 = $1; - $lon2 = $2; -} -if ($lat1 > $lat2) { - my $Tmp = $lat1; - $lat1 = $lat2; - $lat2 = $Tmp; -} -if ($lon1 > $lon2) { - my $Tmp = $lon1; - $lon1 = $lon2; - $lon2 = $Tmp; -} - -if ($Opt{'inside'} && $Opt{'outside'}) { - die("$progname: Cannot mix the --inside and --outside options\n"); -} - -my $waypoint_file = "/home/sunny/gps/waypoints.gpx"; - -# To avoid printing out extra "/> at the start of svg output: -my $svg_start_thing = ""; - -length($Opt{'undefined'}) && ($Udef = $Opt{'undefined'}); -# Kunne vært et eget script på grunn av at det gjør sine helt egne -# greier, men like greit å samle det på en plass. -# FIXME: Fjerner ikke første duplikatentryen. -# FIXME: Se om det går å få flytta den inn i print_entry() så man -# slipper å ha to gptrans_conv’er i pipen. -# FIXME: Legg inn alle formatene. -if ($Opt{'comment-out-dups'}) { - # Comment out areas without reception {{{ - my ($start_date, $end_date, $found_dup) = ("", "", 0); - my @Dup = (); - while (<>) { - if (m#^1 (\S+) (\S+) (\S+) (\S+) (\d\d)/(\d\d)/(\d\d\d\d) (\d\d):(\d\d):(\d\d)#) { - # {{{ - my ($lat_val, $lon_val, $Speed, $Unkn, $Month, $Day, $Year, $Hour, $Min, $Sec) = - ( $1, $2, $3, $4, $5, $6, $7, $8, $9, $10); - if (($lat_val eq $last_lat) && ($lon_val eq $last_lon)) { - unless ($found_dup) { - $start_date = "$Year$Month${Day}T$Hour$Min$Sec"; - @Dup = (); - $found_dup = 1; - } - push(@Dup, "# $_"); - $end_date = "$Year$Month${Day}T$Hour$Min$Sec"; - } else { - if ($found_dup) { - print("# $start_date-$end_date: CO: No signal \x7B\x7B\x7B\n"); - for (@Dup) { - print($_); - } - print("# $start_date-$end_date: CO: No signal \x7D\x7D\x7D\n# move\n$_"); - $found_dup = 0; - } else { - print($_); - } - } - $last_lat = $lat_val; - $last_lon = $lon_val; - # }}} - } else { - if ($found_dup) { - push(@Dup, $_); - } else { - print($_); - } - } - } - if ($found_dup) { - print("# $start_date-$end_date: CO: No signal \x7B\x7B\x7B\n"); - for (@Dup) { - print($_); - } - print("# $start_date-$end_date: CO: No signal \x7D\x7D\x7D\n# move\n"); - $found_dup = 0; - } - exit(0); - # }}} -} - -$Opt{'save-to-file'} eq "\n" && print_header(*STDOUT); - -my @first_lines; -my $xml_data; -my $data_line = ""; -my $curr_file = ""; - -my $from_stdin = scalar(@ARGV) ? 0 : 1; - -$from_stdin && push(@ARGV, "-"); - -for $curr_file (@ARGV) { - # Scan through stdin or specified files and send every GPS entry to - # print_entry() - # {{{ - D("Opening \"$curr_file\" for read"); - if (open(CurrFP, "<$curr_file")) { - # {{{ - while () { - $data_line = $_; - %Dat = ( - 'year' => '', 'month' => '', 'day' => '', - 'hour' => '', 'min' => '', 'sec' => '', - 'lat' => '', 'lon' => '', - 'ele' => '', - 'desc' => '', - 'error' => 0, - 'type' => 'tp', - ); - - if ($Opt{'save-to-file'} ne "\n") { - push(@first_lines, $_); - $_ =~ s/^# ?//; # Also read commented-out lines. - } - $xml_data = ""; - if (m#^<(e?tp)\b.*?>(.*?)$#) { - # gpsml — The main storage format {{{ - my ($Elem, $Data) = - ( $1, $2); - $Elem eq "etp" && ($Dat{'error'} = 1); - my $Time = ""; - $Data =~ m## && ($Time = $1); - $Time =~ s{ - (\d\d\d\d)-?(\d\d)-?(\d\d)T(\d\d):?(\d\d):?([\d\.]+?)Z - } { - ($Dat{'year'}, $Dat{'month'}, $Dat{'day'}, - $Dat{'hour'}, $Dat{'min'}, $Dat{'sec'}) = - ( $1, $2, $3, - $4, $5, $6); - ""; - }ex; - $Data =~ m#($DIGIT*?)# && ($Dat{'lat'} = $1); - $Data =~ m#($DIGIT*?)# && ($Dat{'lon'} = $1); - $Data =~ m#($DIGIT*?)# && ($Dat{'ele'} = $1); - $Data =~ m#(.*?)# && ($Dat{'desc'} = xml_to_txt($1)); - print_entry(%Dat); - # }}} - } elsif (m#^#) { - $found_move = 1; - } elsif (m#^<(desc|title|pause)\b.*?>(.*?)#) { - $Dat{'type'} = $1; - $Dat{$1} = xml_to_txt($2); - print_entry(%Dat); - } elsif (/^); - if (!length($Opt{'output-format'})) { - $Opt{'output-format'} = "gpx"; - print_header(*STDOUT); - } - read_xmlfile($xml_data); - last; - } elsif (/^# Pause: /) { - $Opt{'print-comments'} && print; - } elsif (/^# move$/) { - $found_move = 1; - } elsif (/^#/) { - $Opt{'print-comments'} && print; - } elsif (m#^(\d+)\t($DIGIT+)\t($DIGIT+)\t($DIGIT)#) { - # CSV format, epoch style {{{ - my ($ep_time, $lon_val, $lat_val, $Alt) = - ( $1, $2, $3, $4); - ($Dat{'sec'}, $Dat{'min'}, $Dat{'hour'}, - $Dat{'day'}, $Dat{'month'}, $Dat{'year'}, - $Dat{'wday'}, $Dat{'yday'}) = gmtime($ep_time); - $Dat{'month'}++; # Urgh Ⅰ - $Dat{'year'} += 1900; # Urgh Ⅱ - print_entry(%Dat); - # }}} - } elsif (m#^(\d\d\d\d)-?(\d\d)-?(\d\d)[T ](\d\d):?(\d\d):?(\d\d)Z?\t($DIGIT+)\t($DIGIT+)\t($DIGIT)#) { - # CSV format, human-readable date format {{{ - ($Dat{'year'}, $Dat{'month'}, $Dat{'day'}, - $Dat{'hour'}, $Dat{'min'}, $Dat{'sec'}, - $Dat{'lon'}, $Dat{'lat'}, $Dat{'ele'}) = - ($1, $2, $3, - $4, $5, $6, - $7, $8, $9); - print_entry(%Dat); - # }}} - } elsif (/^Trackpoint\t/) { - # Trackpoint\tN60.41630 E5.31675\t09.02.2006 20:24:37 (UTC)\t13.6 m\t\t93.9 m\t00:00:06\t56 kph\t123° true {{{ - # - # Trackpoint\t - # N60.41630 E5.31675\t - # 09.02.2006 20:24:37 (UTC)\t - # 13.6 m\t - # \t - # 93.9 m\t - # 00:00:06\t - # 56 kph\t - # 123° true - my $Orig = $_; - $Orig =~ s/[\r\n]+$//; - my ($Marker_f, $Position_f, $Time_f, $Alt_f, $Depth_f, - $Leglength_f, $Legtime_f, $Legspeed_f, $Legcourse_f) = - split(/\t/, $Orig . - # Nødløsning for å unngå at variabler blir - # udefinert. - "\t\t\t\t\t\t\t\t\t\t" - ); - D(join("", - "Position_f=\"$Position_f\" \x7B\x7B\x7B\n", - "Time_f=\"$Time_f\"\n", - "Alt_f=\"$Alt_f\"\n", - "Depth_f=\"$Depth_f\"\n", - "Leglength_f=\"$Leglength_f\"\n", - "Legtime_f=\"$Legtime_f\"\n", - "Legspeed_f=\"$Legspeed_f\"\n", - "Legcourse_f=\"$Legcourse_f\" \x7D\x7D\x7D\n", - )); - my ($NS, $WE, - $Alt_unit, - $Leglength, - $Legtime_hour, $Legtime_min, $Legtime_sec, - $Legspeed, $Legspeed_unit, - $Legcourse - ) = ("", "", "", "", "", "", "", "", "", "", "", "", "", "", "", - "", "", "", "", "", "", "", ""); - ($Position_f =~ /^(N|S)([\d\.]+) (W|E)([\d\.]+)/) && - ($NS = $1, $Dat{'lat'} = $2, $WE = $3, $Dat{'lon'} = $4); - ($Time_f =~ /^(\d+)\.(\d+)\.(\d+) (\d+):(\d+):(\d+) \((.+?)\)/) && - ($Dat{'day'} = $1, $Dat{'month'} = $2, $Dat{'year'} = $3, - $Dat{'hour'} = $4, $Dat{'min'} = $5, $Dat{'sec'} = $6); - ($Alt_f =~ /^([\d+\.]+) (.*?)/) && - ($Dat{'ele'} = $1, $Alt_unit = $2); - D("ele = \"$Dat{'ele'}\""); - ($NS eq "S") && ($Dat{'lat'} = 0-$Dat{'lat'}); - ($WE eq "W") && ($Dat{'lon'} = 0-$Dat{'lon'}); - # MapSource in win xp writes YYYY, but YY in win98se. - (defined($Dat{'year'}) && $Dat{'year'} =~ /\d/ && $Dat{'year'} < 1900) && ($Dat{'year'} += 2000); - print_entry(%Dat); - # }}} - } elsif (m#^T\t(\d\d)/(\d\d)/(\d\d\d\d) (\d\d):(\d\d):(\d\d)\t(.+)\xB0(.+)'(.+)"\t(.+)\xB0(.+)'(.+)"#) { - # T 09/01/2002 11:51:26 60°23'36.3" 5°19'35.9" {{{ - my ($lat_d, $lat_m, $lat_s, $lon_d, $lon_m, $lon_s); - ($Dat{'month'}, $Dat{'day'}, $Dat{'year'}, - $Dat{'hour'}, $Dat{'min'}, $Dat{'sec'}, $lat_d, - $lat_m, $lat_s, $lon_d, - $lon_m, $lon_s) = - ( $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12); - $Dat{'lat'} = sprintf("%.5f", 1*($lat_d+($lat_m/60)+($lat_s/3600))); - $Dat{'lon'} = sprintf("%.5f", $lon_d+($lon_m/60)+($lon_s/3600)); - print_entry(%Dat); - # }}} - } elsif (m#^1 (\S+) (\S+) (\S+) (\S+) (\d\d)/(\d\d)/(\d\d\d\d) (\d\d):(\d\d):(\d\d)#) { - # 1 60.3938222 5.3238754 17.3 0 09/01/2002 14:18:23 {{{ - ($Dat{'lat'}, $Dat{'lon'}, $Dat{'speed'}, - $Dat{'unkn'}, - $Dat{'month'}, $Dat{'day'}, $Dat{'year'}, - $Dat{'hour'}, $Dat{'min'}, $Dat{'sec'}) = - ( $1, $2, $3, $4, $5, $6, $7, $8, $9, $10); - print_entry(%Dat); - # }}} - } elsif (/^ - # @020721221336N6048353E00701826S015-00001E4859N1673U0000 {{{ - # Regexp {{{ - (@) # @ - (\d\d) # Year - (\d\d) # Month - (\d\d) # Day - (\d\d) # Hours - (\d\d) # Minutes - (\d\d) # Seconds - ([NS]) # N|S - (\d\d) # Latitude degree - (\d\d) # Latitude minute - (\d\d\d) # Latitude minute decimals - ([EW]) # E|W - (\d\d\d) # Longitude degree - (\d\d) # Longitude minute - (\d\d\d) # Longitude minute degree - (....) # Accurancy - (......) # Altitude - (...............) - $ - # }}} - /x) { - my ($NS, $EW, $lat_deg, $lat_degmin, $lat_mindec, $lon_deg, - $lon_degmin, $lon_mindec); - ($Dat{'year'}, $Dat{'month'}, $Dat{'day'}, $Dat{'hour'}, - $Dat{'min'}, $Dat{'sec'}, $NS, $lat_deg, - $lat_degmin, $lat_mindec, $EW, - $lon_deg, $lon_degmin, $lon_mindec, - $Dat{'accur'}, $Dat{'ele'}, $Dat{'unknown'}) = - ($2+2000, $3, $4, $5, $6, $7, $8, $9, $10, $11, - $12, $13, $14, $15, $16, $17, $18); - my $ep_time = timegm_nocheck($Dat{'sec'}, $Dat{'min'}, $Dat{'hour'}, $Dat{'day'}, $Dat{'month'}-1, $Dat{'year'}); - $last_time = $ep_time; - my $tmp_lon = sprintf("%.5f", $lon_deg + $lon_degmin/60 + $lon_mindec/60000); - my $tmp_lat = sprintf("%.5f", $lat_deg + $lat_degmin/60 + $lat_mindec/60000); - $tmp_lon =~ s/\./$Des/; - $tmp_lat =~ s/\./$Des/; - ($NS eq "S") && ($tmp_lat = 0-$tmp_lat); - ($EW eq "W") && ($tmp_lon = 0-$tmp_lon); - $Dat{'lat'} = $tmp_lat; - $Dat{'lon'} = $tmp_lon; - print_entry(%Dat); - # }}} - } elsif (/^(@)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(__________________________________________)/) { - # @020721221336__________________________________________ {{{ - my ($Alfa, $Year, $Month, $Day, $Hour, $Min, $Sec, $Rest) = - ( $1, $2+2000, $3, $4, $5, $6, $7, $8); - $Opt{'output-format'} eq "csv" && print("\n"); - $found_move = 1; - # }}} - } elsif (/^xmaplog /) { - ($Opt{'output-format'} eq "csv") && ($Opt{'save-to-file'} eq "\n") && print("\n"); - } elsif (/^$/) { - ($Opt{'output-format'} eq "csv") && ($Opt{'save-to-file'} eq "\n") && print("\n"); - } else { - if ($Opt{'print-comments'}) { - print("# $_"); - chomp; - } - $Opt{'verbose'} && warn("Line $.: Unknown: \"$_\"\n"); - } - } - # }}} - } else { - warn("$progname: $curr_file: Cannot open file for read: $!\n"); - } - # }}} -} - -print_footer(*STDOUT); - -exit(0); - -sub read_xmlfile { - # {{{ - D("Inn i read_xmlfile()"); - my $Txt = XMLin(@_); - D("Etter XMLin()"); - # print(Dumper($Txt->{trk}->{trkseg}->{trkpt}->[0]->{time})); - D(Dumper($Txt)); - D("Etter Dumper"); - my $Loop = 1; - for (my $a = 0; $Loop; $a++) { - D("a = $a"); - my $Date = $Txt->{trk}->{trkseg}->{trkpt}->[$a]->{time}; - $Dat{'lat'} = $Txt->{trk}->{trkseg}->{trkpt}->[$a]->{lat}; - $Dat{'lon'} = $Txt->{trk}->{trkseg}->{trkpt}->[$a]->{lon}; - $Dat{'ele'} = $Txt->{trk}->{trkseg}->{trkpt}->[$a]->{ele}; - if ($Date =~ m#(\d\d\d\d)-?(\d\d)-?(\d\d)T(\d\d):?(\d\d):?(\d\d)\.?(\d*?)Z#) { - ($Dat{'year'}, $Dat{'mon'}, $Dat{'day'}, - $Dat{'hour'}, $Dat{'min'}, $Dat{'sec'}, $Dat{'secfrac'}) = - ( $1, $2, $3, - $4, $5, $6, $7); - } - print_entry(%Dat); - # print($Txt->{trk}->{trkseg}->{trkpt}->{time}->[$a]); - } - # FIXME: The sequential stuff here is probably bad, but easy. - # $Txt =~ s#(.*?)#print_gpx($1)#gse; - # $Txt =~ s#(.*?)#print_xml_gps($1)#gse; - # }}} -} - -sub print_gpx { - # {{{ - my $Orig = shift; - my $Str = $Orig; - D("print_xml_gps(\"$Orig\")\n"); - $Str =~ - s{ - (.*?) - } - { - my $el_trk = $2; - $el_trk =~ - s{ - (.*?) - } - { - my $el_trkseg = $2; - $el_trkseg =~ - s{ - (.*?) - } - { - my ($attr_trkpt, $el_trkpt) = - ( $1, $2); - ($attr_trkpt =~ /\blon="(.*?)"/) && ($Dat{'lon'} = $1); - ($attr_trkpt =~ /\blat="(.*?)"/) && ($Dat{'lat'} = $1); - ($el_trkpt =~ m#(.*?)#) && ($Dat{'ele'} = $1); - if ($el_trkpt =~ m##) { - ($Dat{'year'}, $Dat{'month'}, $Dat{'day'}, - $Dat{'hour'}, $Dat{'min'}, $Dat{'sec'}, $Dat{'secfrac'}) = - ($1, $2, $3, $4, $5, $6, $7); - } - print_entry(%Dat); - ""; - }gsex; - $found_move = 1; - }gsex; - $found_move = 1; - }gsex; - # }}} -} - -sub print_xml_gps { - # {{{ - my $Orig = shift; - my $Str = $Orig; - D("print_xml_gps(\"$Orig\")\n"); - if ($Str =~ m#(\d\d\d\d)-?(\d\d)-?(\d\d)T(\d\d):?(\d\d):?(\d\d)\.?(\d*?)Z#) { - ($Dat{'year'}, $Dat{'mon'}, $Dat{'day'}, $Dat{'hour'}, $Dat{'min'}, $Dat{'sec'}, $Dat{'secfrac'}) = - ( $1, $2, $3, $4, $5, $6, $7); - } - if ($Str =~ m#(.*?)#s) { - my $Txt = $1; - ($Txt =~ m#(.*?)#) && ($Dat{'lon'} = $1); - ($Txt =~ m#(.*?)#) && ($Dat{'lat'} = $1); - ($Txt =~ m#(.*?)#) && ($Dat{'ele'} = $1); - } - defined($Dat{'lon'}) || ($Dat{'lon'} = ""); - defined($Dat{'lat'}) || ($Dat{'lat'} = ""); - defined($Dat{'ele'}) || ($Dat{'ele'} = ""); - print_entry(%Dat); - # }}} -} - -sub print_header { - # {{{ - local *OutFP = shift; - if ($Opt{'output-format'} eq "gpsml") { - print(OutFP join("", - "\n", - "\n", - "\n", - )); - } elsif ($Opt{'output-format'} eq "gpstrans") { - print(OutFP "Format: DMS UTC Offset: 0.00 hrs Datum[100]: WGS 84\n"); - } elsif ($Opt{'output-format'} eq "gpx") { - print(OutFP join("", - "\n", - "\n", - "$Spc$Spc\n", - "$Spc$Spc$Spc$Spc\n", - )); - } elsif ($Opt{'output-format'} eq "ps") { - print(OutFP ps_header(532, 6034, 533, 6040)); - print(OutFP "*u\n"); - } elsif ($Opt{'output-format'} eq "xml") { - print(OutFP join("", - "\n", - "\n", - )); - } elsif ($Opt{'output-format'} eq "svg") { - print(OutFP join("", - "\n", - "\n", - "\n", - "$Spc$Spc\n", - "$Spc$Spc\n", - )); - } - # }}} -} - -sub print_footer { - # Print footer {{{ - local *OutFP = shift; - if ($Opt{'output-format'} eq "gpsml") { - print(OutFP join("", - "\n", - "\n", - )); - } elsif ($Opt{'output-format'} eq "gpx") { - print(OutFP join("", - "$Spc$Spc$Spc$Spc\n", - "$Spc$Spc\n", - "\n", - )); - } elsif ($Opt{'output-format'} eq "poscount") { - while (my ($l_name, $l_val) = each %Poscount) { - $l_name =~ /^(.+?),(.+?)$/ && print(OutFP "$1\t$2\t$l_val\n"); - } - } elsif ($Opt{'output-format'} eq "ps") { - print(OutFP join("", - "*U\n", - "%%Trailer\n", - "%%EOF\n", - )); - } elsif ($Opt{'output-format'} eq "svg") { - print(OutFP "\"/>\n\n"); - } elsif ($Opt{'output-format'} eq "xml") { - print(OutFP "\n"); - } - # }}} -} - -sub print_entry { - # Print a GPS entry with time, latitude, longitude and altitude in - # various formats - # {{{ - my %Dat = @_; - my $print_time = length($Dat{'year'}) ? 1 : 0; - my $print_ele = length($Dat{'ele'}) ? 1 : 0; - my $print_desc = length($Dat{'desc'}) ? 1 : 0; - my $Line = ""; - D("print_entry(\"" . join("\", \"", @_) . "\");"); - my $ep_time; - - if ($Opt{'near'}) { - $Line .= sprintf("%s ", list_nearest_waypoints($Dat{'lat'}, $Dat{'lon'})); - } - - if ($Opt{'output-format'} eq "poscount") { - my ($Lat_str, $Lon_str) = - ( "", ""); - $Dat{'lon'} =~ /^(\d+\.\d\d)/ && ($Lon_str = $1); - $Dat{'lat'} =~ /^(\d+\.\d\d)/ && ($Lat_str = $1); - my $Name = "${Lon_str},${Lat_str}"; - defined($Poscount{$Name}) || ($Poscount{$Name} = 0); - $Poscount{$Name}++; - return; - } - - if ($print_time) { - $ep_time = timegm_nocheck($Dat{'sec'}, $Dat{'min'}, $Dat{'hour'}, $Dat{'day'}, $Dat{'month'} - 1, $Dat{'year'}); - $Dat{'year'} = sprintf("%04u", $Dat{'year'}); - $Dat{'month'} = sprintf("%02u", $Dat{'month'}); - $Dat{'day'} = sprintf("%02u", $Dat{'day'}); - $Dat{'hour'} = sprintf("%02u", $Dat{'hour'}); - $Dat{'min'} = sprintf("%02u", $Dat{'min'}); - $Dat{'sec'} = sprintf("%02u", $Dat{'sec'}); - if ($Opt{'chronology'}) { - if ($last_time > $ep_time) { - warn(sprintf( - "%s: \"%sZ\": Next date is %s in the past (%sZ)\n", - $progname, sec_to_string($last_time, "T"), - sec_to_readable($last_time-$ep_time), - sec_to_string($ep_time, "T") - )); - # FIXME: Make --fix work with gpx and xml. - if ($Opt{'fix'} && ($Opt{'output-format'} !~ /^(gpx|xml)$/)) { - ($Line .= "# error "); - } - } - } - } else { - $Req{'time'} && return; - $ep_time = 0; - $Dat{'year'} = 0; - $Dat{'month'} = 0; - $Dat{'day'} = 0; - $Dat{'hour'} = 0; - $Dat{'min'} = 0; - $Dat{'sec'} = 0; - } - - if ($Opt{'save-to-file'} ne "\n") { - # {{{ - my $base_name = "$Dat{'year'}$Dat{'month'}$Dat{'day'}T$Dat{'hour'}$Dat{'min'}$Dat{'sec'}Z$Opt{'save-to-file'}"; - my $file_name = $base_name; - if (-e $file_name) { - for (my $a = 1; (-e $file_name) && ($a < 1000); $a++) { - $file_name = "$base_name.dup_$a"; - } - if (-e $file_name) { - die("$progname: $base_name: File already exists, and ran " . - "out of attempts to create unique file name\n"); - } - if ($Opt{'verbose'}) { - warn("$progname: $base_name: File already exists, using " . - "unique name \"$file_name\" instead\n"); - } - } - if (open(ToFP, ">", $file_name)) { - print_header(*ToFP); - print(ToFP ($from_stdin ? @first_lines : ()), (length($xml_data) ? $xml_data : <>)) || - die("$progname: $file_name: Cannot write to file: $!\n"); - print_footer(*ToFP); - close(ToFP); - if ($Opt{'output-format'} eq "gpsml") { - printf("%s\n", - txt_to_xml($file_name)); - } elsif ($Opt{'output-format'} eq "gpx") { - printf("\n", - txt_to_xml($file_name)); - } else { - print("$progname: Saved unconverted data to \"$file_name\"\n"); - } - exit 0; - } else { - die("$progname: $file_name: Cannot create file: $!\n"); - } - # }}} - } - - my $pause_len = 0; - my $do_print = 1; - ($Req{'altitude'} && !$print_ele) && return; - - if ($Opt{'inside'} || $Opt{'outside'}) { - if ( - ($Dat{'lat'} < $lat1) || - ($Dat{'lat'} > $lat2) || - ($Dat{'lon'} < $lon1) || - ($Dat{'lon'} > $lon2) - ) { - $Opt{'inside'} && return; - } else { - $Opt{'outside'} && return; - } - } - - if ($Opt{'output-format'} eq "ps") { - $Dat{'lon'} *= 100; - $Dat{'lat'} *= 100; - } - if ($Opt{'skip-dups'} && ($Dat{'lon'} eq $last_lon) && ($Dat{'lat'} eq $last_lat) && ($Dat{'ele'} eq $last_ele)) { - if ($in_dupskip) { - $do_print = 0; - } else { - $do_print = 1; - } - $in_dupskip = 1; - } else { - $do_print = 1; - $in_dupskip && ($Line .= $last_line); - $in_dupskip = 0; - } - - if ($Opt{'create-breaks'} && $ep_time-$last_time > $PAUSE_LIMIT && $last_time) { - $pause_len = $ep_time-$last_time; - D("pause_len set to '$pause_len'"); - } - - if ($pause_len) { - if ($Opt{'output-format'} eq "gpsml") { - $Line .= sprintf("%s\n", - sec_to_readable($ep_time-$last_time)); - } elsif ($Opt{'output-format'} eq "csv") { - $Line .= sprintf("# Pause: %s\n# move\n", - sec_to_readable($ep_time-$last_time)); - } - } - - if ($do_print) { - # Valid data was found, send to stdout {{{ - unless ($first_time) { - $first_time = $ep_time; - } - if ($Opt{'double-y-scale'}) { - $Dat{'lat'} *= 2; - } - if ($Opt{'output-format'} eq "gpsml") { - if ($Dat{'type'} eq "tp") { - my $Elem = $Dat{'error'} ? "etp" : "tp"; - $Line .= join("", - "<$Elem> ", - $print_time - ? " " - : "", - (length($Dat{'lat'})) - ? "" . $Dat{'lat'}*1.0 . " " - : "", - (length($Dat{'lon'})) - ? "" . $Dat{'lon'}*1.0 . " " - : "", - ($print_ele) - ? "" . $Dat{'ele'}*1.0 . " " - : "", - ($print_desc) - ? sprintf("%s ", - txt_to_xml($Dat{'desc'})) - : "", - "\n" - ); - } elsif ($Dat{'type'} =~ /^(pause|desc|title)$/) { - $Line .= sprintf("<%s>%s\n", - $1, - txt_to_xml($Dat{$1}), - $1); - } - } elsif ($Opt{'output-format'} eq "xgraph") { - $pause_len && ($Line .= "move "); - ($Line .= "$Dat{'lon'} $Dat{'lat'}\n"); - } elsif($Opt{'output-format'} eq "gpstrans") { - my ($gpt_lat, $gpt_lon) = (ddd_to_dms($Dat{'lat'}), ddd_to_dms($Dat{'lon'})); - if ($print_time) { - $Line .= "T\t$Dat{'month'}/$Dat{'day'}/$Dat{'year'} $Dat{'hour'}:$Dat{'min'}:$Dat{'sec'}\t$gpt_lat\t$gpt_lon\n"; - } else { - $Line .= "T\t00/00/00 00:00:00\t$gpt_lat\t$gpt_lon\n"; - } - } elsif($Opt{'output-format'} eq "gpx") { - $Line .= join("", - "$Spc$Spc$Spc$Spc$Spc$Spc$Spc", - $print_time - ? "$Spc" - : "", - $print_ele - ? "$Dat{'ele'}$Spc" - : "", - "\n" - ); - } elsif ($Opt{'output-format'} eq "clean") { - $pause_len && ($Line .= "\n"); - ($Line .= "$Dat{'lon'}\t$Dat{'lat'}" . ($print_ele ? "\t$Dat{'ele'}" : "") . "\n"); - } elsif ($Opt{'output-format'} eq "ps") { - $Line .= ($pause_len ? "f\n$Dat{'lon'} $Dat{'lat'} m\n" : "$Dat{'lon'} $Dat{'lat'} l\n"); - } elsif ($Opt{'output-format'} eq "svg") { - $Line .= ( - ($last_lon == 1000) || $pause_len - ? join("", - "$svg_start_thing$Spc", - $print_time - ? "$Dat{'year'}-$Dat{'month'}-$Dat{'day'}T$Dat{'hour'}:$Dat{'min'}:$Dat{'sec'}Z$Spc" - : "", - "$Spc", - (length($Dat{'lon'})) ? "$Dat{'lon'}$Spc" : "", - (length($Dat{'lat'})) ? "$Dat{'lat'}$Spc" : "", - ($print_ele) ? "$Dat{'ele'}$Spc" : "", - "$Spc", - "\n" - ); - } elsif ($Opt{'output-format'} eq "ygraph") { - my $Time = $print_time ? ($ep_time - $first_time) * 1 : 0; - $Line .= "\"Time = $Time.0\n$Dat{'lon'} $Dat{'lat'}\n\n"; - } elsif ($Opt{'output-format'} eq "csv") { - # {{{ - $Dat{'lon'} =~ s/\./$Des/; - $Dat{'lat'} =~ s/\./$Des/; - # $do_print || print("skipping "); - $Line .= join("\t", - $print_time - ? $Opt{'epoch'} - ? $ep_time - : $Opt{'short-date'} - ? "$Dat{'year'}$Dat{'month'}$Dat{'day'}T$Dat{'hour'}$Dat{'min'}$Dat{'sec'}Z" - : "$Dat{'year'}-$Dat{'month'}-$Dat{'day'} $Dat{'hour'}:$Dat{'min'}:$Dat{'sec'}" - : "", - $Dat{'lon'}, - $Dat{'lat'}, - $print_ele ? $Dat{'ele'} : "", # Elevation - "\n" - ); - # }}} - } else { - die("$progname: \"$Opt{'output-format'}\": Unknown output format\n"); - } - # }}} - } - - if (!$last_time && $Opt{'output-format'} eq "ps") { - $Line .= "$Dat{'lon'} $Dat{'lat'} m\n"; - } - - if ($do_print) { - if ($found_move) { - if ($Opt{'output-format'} eq "gpsml") { - $Line = "\n$Line"; - } - (!$pause_len && ($Opt{'output-format'} eq "xgraph")) && ($Line .= "move $Line"); - ($Opt{'output-format'} eq "clean") && ($Line .= "\n"); - if ($Opt{'output-format'} eq "gpx") { - $Line .= "$Spc$Spc$Spc$Spc\n$Spc$Spc$Spc$Spc\n"; - } - $found_move = 0; - } - print($Line); - } - $last_time = $ep_time; - $last_lon = $Dat{'lon'}; - $last_lat = $Dat{'lat'}; - $last_ele = $Dat{'ele'}; - $last_line = $data_line; - $svg_start_thing = "\"/>\n"; - # }}} -} - -sub list_nearest_waypoints { - # {{{ - my ($Lat, $Lon, $Count) = @_; - # FIXME: Incredible unfinished and kludgy. - if (open(WaypFP, "gpsbabel -i gpx -f $waypoint_file -x radius,lat=$Lat,lon=$Lon,distance=1000 -o gpx -F - |")) { - my $Str = join("", ); - $Str =~ s{ - ^.*?.*?(.+?).*?.*? - .*?.*?(.+?).*?.*? - .*?.*?(.+?).*?.*$ - }{ - "($1, $2, $3)"; - }sex; - return($Str); - } else { - die("$progname: Cannot open gpsbabel pipe: $!\n"); - } - # }}} -} - -sub sec_to_string { - # Convert seconds since 1970 to "yyyy-mm-dd hh:mm:ss" with optional - # separator - # {{{ - my ($Seconds, $Sep) = @_; - defined($Sep) || ($Sep = " "); - my @TA = gmtime($Seconds); - my($DateString) = sprintf("%04u-%02u-%02u%s%02u:%02u:%02u", $TA[5]+1900, $TA[4]+1, $TA[3], $Sep, $TA[2], $TA[1], $TA[0]); - return($DateString); - # }}} -} - -sub sec_to_readable { - # Convert seconds since 1970 to human-readable format (d:hh:mm:ss) - # {{{ - my $secs = shift; - D("sec_to_readable(\"$secs\")\n"); - my ($Day, $Hour, $Min, $Sec) = - ( 0, 0, 0, 0); - - $Day = int($secs/86400); - $secs -= $Day * 86400; - - $Hour = int($secs/3600); - $secs -= $Hour * 3600; - - $Min = int($secs/60); - $secs -= $Min * 60; - - $Sec = $secs; - - return(sprintf("%u:%02u:%02u:%02u", $Day, $Hour, $Min, $Sec)); - # }}} -} - -sub ps_header { - # Send a Postscript header to stdout {{{ - my ($bl_lon, $bl_lat, $br_lon, $br_lat) = @_; - my $Date = sec_to_string(time); - return(join("", - "%!PS-Adobe-3.0 EPSF-3.0\n", - "%%Creator: $rcs_id\n", - "%%Title:\n", - "%%CreationDate: $Date\n", - "%%BoundingBox: $bl_lon $bl_lat $br_lon $br_lat\n", - "%%DocumentData: Clean7Bit\n", - "%%EndComments\n", - "%%BeginProlog\n", - "/bd { bind def } bind def\n", - "/incompound false def\n", - "/m { moveto } bd\n", - "/l { lineto } bd\n", - "/c { curveto } bd\n", - "/F { incompound not {fill} if } bd\n", - "/f { closepath F } bd\n", - "/S { stroke } bd\n", - "/*u { /incompound true def } bd\n", - "/*U { /incompound false def f} bd\n", - "/k { setcmykcolor } bd\n", - "/K { k } bd\n", - "%%EndProlog\n", - "%%BeginSetup\n", - "%%EndSetup\n", - )); - # }}} -} - -sub ddd_to_dms { - # Convert floating-point degrees into D°M'S.S" (ISO-8859-1). - # Necessary for import into GPSman. Based on toDMS() from - # gpstrans-0.39 to ensure compatibility. - # {{{ - my $ddd = shift; - my $Neg = 0; - my ($Hour, $Min, $Sec) = - ( 0, 0, 0); - my $Retval = ""; - - if ($ddd < 0.0) { - $ddd = 0 - $ddd; - $Neg = 1; - } - $Hour = int($ddd); - $ddd = ($ddd - $Hour) * 60.0; - $Min = int($ddd); - $Sec = ($ddd - $Min) * 60.0; - - if ($Sec > 59.5) { - $Sec = 0.0; - $Min += 1.0; - } - if ($Min > 59.5) { - $Min = 0.0; - $Hour += 1.0; - } - if ($Neg) { - $Hour = 0 - $Hour; - } - D("Neg = $Neg , D = $Hour , M = $Min , S = $Sec\n"); - $Retval = sprintf("%s%.0f\xB0%02.0f'%04.1f\"", $Neg ? "-" : "", $Hour, $Min, $Sec); - return $Retval; - # }}} -} - -sub txt_to_xml { - # Convert plain text to XML {{{ - my $Txt = shift; - $Txt =~ s/&/&/gs; - $Txt =~ s//>/gs; - return($Txt); - # }}} -} - -sub xml_to_txt { - # Convert XML data to plain text {{{ - my $Txt = shift; - $Txt =~ s/<//gs; - $Txt =~ s/&/&/gs; - return($Txt); - # }}} -} - -sub print_version { - # Print program version {{{ - print("$rcs_id\n"); - exit(0); - # }}} -} # print_version() - -sub usage { - # Send the help message to stdout {{{ - my $Retval = shift; - - print(< [options] [file [files [...]]] - -B -S [options] [file [files [...]]] - -B -u [options] [file [files [...]]] - -=head1 DESCRIPTION - -Converts between various GPS formats. - -=head1 OPTIONS - -=over 4 - -=item B<-c>, B<--comment-out-dups> - -Use comma instead of period as decimal point (For Gnumeric etc). - -=item B<-C>, B<--print-comments> - -Print existing comment lines (starting with "#") and prefix unknown -lines with "# ". - -=item B<--chronology> - -Check for broken chronology, warn about entries with an old timestamp. - -=item B<-d>, B<--skip-dups> - -Skip duplicated coordinates, only print first and last. - -=item B<-e>, B<--epoch> - -Use seconds since 1970-01-01 00:00:00 GMT as date format. - -item B<--fix> - -Comment out entries which is obviously wrong. Use together with ---chronology to fix those kind of errors. Does not work with GPX or XML -output yet. - -=item B<-h>, B<--help> - -Show this help. - -=item B<--inside> - -Print only trackpoints inside a rectangle specified by --pos1 and ---pos2. - -=item B<--near> - -Add names of the three closest waypoints to the trackpoint. Unfinished -and experimental, needs gpsbabel. - -=item B<-n x>, B<--undefined x> - -Use x as undefined value. - -=item B<-o x>, B<--output-format x> - -Use output format x: - -=over 4 - -=over 4 - -=item clean - -=item csv - -=item gpsml (Default) - -This is the format which is meant to be used when storing the track -logs. -It is line-based XML which makes it easy to edit and grep. Probably not -finished yet. - -=item gpstrans - -=item gpx (Not complete) - -=item poscount (Experimental) - -Creates a 3D plot where areas with many trackpoints are higher than -areas with less track points. - -=item ps (Unfinished) - -=item svg (Unfinished) - -=item xgraph - -=item xml - -=item ygraph - -=back - -=back - -Z<> - -=item B<--outside> - -Print only trackpoints outside a rectangle specified by --pos1 and ---pos2. - -=item B<--pos1 x>, B<--pos2 x> - -Specifies corners of an area rectangle used by the --inside and ---outside options. The x value is in "lat,lon" format (decimal degrees, -negative for west or south) . - -=item B<-r x>, B<--require x> - -Specify requirements for trackpoints to be written. x is a string with -the following flags: - -=over 4 - -=over 4 - -=item a - -=over 4 - -=item Print only waypoints which have an altitude. - -=back - -=back - -=over 4 - -=item t - -=over 4 - -=item Print only waypoints which have a timestamp. - -=back - -=back - -=back - -Z<> - -=item B<-s>, B<--short-date> - -Use short date format. - -=item B<-S x>, B<--save-to-file x> - -Save the unconverted data to a file with a filename starting with the -timestamp of the first trackpoint. The parameter string x is added at -the end of the filename. For the time being this option will ignore all -other options. - -Note: If several files are specified on the command line, all data will -be saved into only one file. This behaviour may change in the future. - -=item B<-t>, B<--create-breaks> - -Create breaks in track between points with a difference more than the -number of seconds specified by the C<$PAUSE_LIMIT> variable. - -=item B<-u>, B<--comment-out-dups> - -Comment out following data with identical position values, only print -first entry. - -=item B<-v>, B<--verbose> - -Verbose, warn about unknown lines. - -=item B<-w>, B<--strip-whitespace> - -Strip all unnecessary whitespace. - -=item B<-x>, B<--xml> - -Create XML output. - -=item B<-y>, B<--double-y-scale> - -Double Y scale (latitude) to get it right in gnuplot. - -=item B<-h>, B<--help> - -Print a brief help summary. - -=item B<--version> - -Print version information. - -=item B<--debug> - -Print debugging messages. - -=back - -=head1 BUGS - -Pretty incomplete in some areas. Some of the source formats are -undocumented and thus incomplete. Some functionality is not working -properly, for example the Postscript output. - -=head1 AUTHOR - -Made by Øyvind A. Holm Ssunny@sunbase.orgE>. - -=head1 COPYRIGHT - -Copyleft © Øyvind A. Holm <sunny@sunbase.org> -This is free software; see the file F for legalese stuff. - -=head1 LICENCE - -This program is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2 of the License, or (at your -option) any later version. - -This program is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along -with this program; if not, write to the Free Software Foundation, Inc., -59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -=head1 SEE ALSO - -gpsbabel(1) - -=cut - -# }}} - -# vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w : -# End of file $Id$ diff --git a/branches/gpst.gpsman-format/Patch/hvor.patch b/branches/gpst.gpsman-format/Patch/hvor.patch deleted file mode 100644 index 0f6df87..0000000 --- a/branches/gpst.gpsman-format/Patch/hvor.patch +++ /dev/null @@ -1,30 +0,0 @@ -Index: postgres/create_funcs.sql -=================================================================== ---- postgres/create_funcs.sql (revisjon 2238) -+++ postgres/create_funcs.sql (arbeidskopi) -@@ -120,6 +120,25 @@ - END; - $$ LANGUAGE plpgsql; - -+DROP FUNCTION hvor(timestamptz); -+CREATE OR REPLACE FUNCTION hvor(currtime timestamptz) RETURNS SETOF timestamptz AS $$ -+DECLARE -+ currpos point; -+ currsted text; -+ currdist numeric; -+ currlat numeric(9, 6); -+ currlon numeric(9, 6); -+BEGIN -+ currpos = findpos(currtime); -+ currlat = currpos[0]; -+ currlon = currpos[1]; -+ currsted = clname(currpos); -+ currdist = cldist(currpos); -+ SELECT currtime, currlat::text, currlon::text, currsted, currdist; -+ RETURN; -+END; -+$$ LANGUAGE plpgsql; -+ - DROP FUNCTION wherepos(timestamptz); - CREATE OR REPLACE FUNCTION wherepos(currtime timestamptz) RETURNS text AS $$ - DECLARE diff --git a/branches/gpst.gpsman-format/Patch/mayko-comments.patch b/branches/gpst.gpsman-format/Patch/mayko-comments.patch deleted file mode 100644 index 0db9110..0000000 --- a/branches/gpst.gpsman-format/Patch/mayko-comments.patch +++ /dev/null @@ -1,40 +0,0 @@ -Index: tests/run-tests.pl -=================================================================== ---- tests/run-tests.pl (revision 2020) -+++ tests/run-tests.pl (working copy) -@@ -488,9 +488,11 @@ - - - -+ - - - -+ - - - -@@ -512,9 +514,11 @@ - - - -+ - - - -+ - - - -Index: gpst -=================================================================== ---- gpst (revision 2020) -+++ gpst (working copy) -@@ -273,6 +273,7 @@ - push(@first_lines, $_); - } - s/^# error // && ($Dat{'error'} = "error"); -+ s/^# (.+)// && ($Dat{'error'} = $1); - s/^# ?// && ($Dat{'error'} = "desc"); - $xml_data = ""; - if (m#^<(e?tp)\b(.*?)>(.*?)\s*$#) { diff --git a/branches/gpst.gpsman-format/Patch/xgraph-fix_plus_more.patch b/branches/gpst.gpsman-format/Patch/xgraph-fix_plus_more.patch deleted file mode 100644 index 71db8fa..0000000 --- a/branches/gpst.gpsman-format/Patch/xgraph-fix_plus_more.patch +++ /dev/null @@ -1,101 +0,0 @@ -Index: tests/run-tests.pl -=================================================================== ---- tests/run-tests.pl (revision 1817) -+++ tests/run-tests.pl (working copy) -@@ -56,6 +56,29 @@ - $Opt{'help'} && usage(0); - $Opt{'version'} && print_version(); - -+testcmd("../gpst -o xgraph multitrack.gpx", # {{{ -+ <%s\n", - sec_to_readable($ep_time-$last_time)); - } elsif ($Opt{'output-format'} eq "csv") { -- $Line .= sprintf("# Pause: %s\n# move\n", -+ $Line .= sprintf("# Pause: %s\n", - sec_to_readable($ep_time-$last_time)); - } - } -@@ -896,8 +890,10 @@ - $1); - } - } elsif ($Opt{'output-format'} eq "xgraph") { -- $pause_len && ($Line .= "move "); -- ($Line .= "$Dat{'lon'} $Dat{'lat'}\n"); -+ if ($print_pos) { -+ $pause_len && ($Line .= "move "); -+ ($Line .= "$Dat{'lon'} $Dat{'lat'}\n"); -+ } - } elsif($Opt{'output-format'} eq "gpstrans") { - my ($gpt_lat, $gpt_lon) = - (ddd_to_dms($Dat{'lat'}), ddd_to_dms($Dat{'lon'})); -@@ -976,8 +972,8 @@ - if ($Opt{'output-format'} eq "gpsml") { - $Line = "\n$Line"; - } -- (!$pause_len && ($Opt{'output-format'} eq "xgraph")) -- && ($Line .= "move $Line"); -+ # (!$pause_len && ($Opt{'output-format'} eq "xgraph")) -+ # && ($Line .= "move $Line"); - ($Opt{'output-format'} eq "clean") && ($Line .= "\n"); - if ($Opt{'output-format'} eq "gpx") { - $Line .= "$Spc$Spc$Spc$Spc\n" . diff --git a/branches/gpst.gpsman-format/Patch/ygraph-midnight.patch b/branches/gpst.gpsman-format/Patch/ygraph-midnight.patch deleted file mode 100644 index 1936b6e..0000000 --- a/branches/gpst.gpsman-format/Patch/ygraph-midnight.patch +++ /dev/null @@ -1,38 +0,0 @@ -Index: tests/run-tests.pl -=================================================================== ---- tests/run-tests.pl (revision 2148) -+++ tests/run-tests.pl (working copy) -@@ -1655,16 +1655,16 @@ - # }}} - testcmd("../gpst -o ygraph date_error.mayko", # {{{ - <-~wJ_dfUA&E(mgIp@qfJG(RU&a0`4jYElXc5u{Xi2B3Df&r)3X9@o_ z*}`n0NOuP)*uen~gMg7Rdpn?uoh85?jDR5k_6|@xOM8g3Ez}MPKsY!-!Ip@7P$*LK zoF>LE2kmK+v$wN?Svxy@S3?K@5lAr78DRl-0{-CPpPs+-*#E!-Lm*H%^z_!=2?%j^ zaym1@%@&T0p{a^@W;+JfU*vx_hx!k)R&aYT68h7aKe7JQ2nTxyXNS}0;QTKA^+-& z6(b}2(HoQx(M5cI=1POTHNzXW#UWsY5DZ(h8e$LbdqK~tzu-O#PWHZO%4*;Q4{?G6 z?Y5>HXT|0vVj}`53&!e96u|SCJ3u(jZl5}|5GetMizL6U)yPr&^4~G>f zfR3g3%|unoU0=~8L*a|^-5Oz`@1t-)YV7=>WXXK4&oVdwW!H5VgWiK!qNSdUd;wME zb$<+Ar4cay{^ahUP_1zWZCfOyIv)-5hie;w_=%lBME z4N-0E5?f~{i}i^UZa+O_fmuyvOV@uTm zm>+%9V9K76_%(7(`~yf%wYuc2ll|?DkTgpu<~#yXm1Twu$(Pl&*^(0G z9(_n;Ur!Ht6fpL*XO(ilb1M7*5G*P@k?uW(Hkc<2b>~Q0^uO!(t~GZ

tfiNI{X9 zIytzVQZN>=fq99CHV(Xs_boZZ-zY73BQGxw6Em2+skRLn#OXz{ZB5rL$ThRzIYwiv zZlhX@R}EdwQaUkPUew(k2RFOL3QX!-~e{qH8{s=?GmaRj5?M}c;mwMt4v6UMiVe_L4#`QZjE~Djq(ldtCWz$zt z10KpHV-BGaI&~mz3kM&E*XA$odEI`r<|_IUpOy0+IgyNRVkFVxVfUm->A{mDfq`ebd5`4{GK0$9e4@viZ_v^eRE;j0{1L zn@Y6Vt~gJ0%5xdXOib!&MqHuxK)15(jXXXL&0zC={ElpMCGOjV;l$WjpPF$O2Nkn% zZ&G&FC_cpz#bw%5Xfi6mD!b1oxQ81S!)^B0VgPua>Qm!rtbqzLZvtDZ_ar*? zO>iI9rOc;tPSso~rPVp2#!(SHQGr7$;`{D2WR)ekwi%it*{#7jRdkQQPcS^xs@*%> zItg(eS4F5{ZMO)|yk@vI#1XVyrLd4+*6iUguvIevyEhtxZSow z#(Ym&!!{-C@d8rA+`2X0oM>lxs_FsZMc>w0U4s)D0w{_^JkYj%Dc*;}uYl_GIwvGB2B$ao5!2Cg~x?9T9@g+*<%%tW8rPn611433bPtJ ze3h>EFu>M9Sg)&2uXc~iv^1SGxN@B}x~v3JrH$0P#8?r;K6SjHK8tp}pTf@X8^@4; z1^>Y``gMm0YxlLbW)JUjk%M5FogT9d+buH;>l4hg>AvXeF$EO&bm9{IIo$l&7qR97)j-!xIfc@ zzGnh>=TJGy>rzA|`x)%%>Pj^-J_sJ0?obg3QE^nF=5NuV22Otj6Tav*J|U`Dx>OV_ z99fzxLreT3uVQ~Wboetx|0MCVQpCH*hf`k3J)~<(W!y%Lb@74iwqG%CtVEEmkybN? zR96sH+`jz0EXk{jc07hkwycoW=isrSEAZt4SAMF*!npER4UoDeUih82{1#PEV@gN{ zCV&K!{Aq!*Hu}DbQW2c3P!WptMf(ZgMbP7TmDQy&o7lPoltbAjI`ZbnwU|8`M@_<@ zS@R3fJKQH1xcncCHuV$M4`~^I!kGGvSaWkpAG(c9l43wuvc?|h_b=m!P052MHCJ*# zW)=r5yn`_%^Xn6LQYr#y#nwv42(m3cD&_K*&@V>>o9=cER@GgPM zMb7KO{)4kRU_-`Xb90@7Z=Kl6Y|l7ibH<1=Z?RBQL7##$$wlgTO^r=wrWtL;+ciI? z*hjCZ@z6}W`#TNK+<)^(p}E{o&g&cMrXE?Ng5oz(8QzvfM>2q@qeoarae=RmHV+Ld zRd3>POaGpT`lH*-v13DCX)wGxhZ}V9_eZhayR~K9Z&hCxYs(bMrnR6ll4B7!x>oh< zQdVp>zqTWCM|HNR_%czAKkUd*?>&Rox=#KD#Kbns{OjZewuq9QWu@D%MlIE*%lQsP zAASY*rDQd)dZDZE&Fg#i@xh zB~1a@8ueW%4zBgwVIH#Aw;f3@u_Q*x0C_(I*c^~F_a^2VAwByN1=*8p&B~k7H(YnT z_Oe5eqP*XNaz2%q8s&`Yho{-^$v+-(8mcwW45Mz=NWGvh$#%&KGR>#Lm!NUWMM!vt zF0U-^me5cWZF$3C0jY%S7ICQc(|lOAP71i<`uwKB@^+B$%nswcM)Mr|hOR58m3Q5kU&dfG|Gc z1KkS+q(=zhhe5;|bBWm%trum-cL^Cc3Mk~h_6oVA)X+ZkVc9C0%l3U_l@KM9MbvX} zQz`R=3o=h3k(96Bt>~lkO7@zS(3^Wg$+YG*uHd_$ZPubZ4mmAQ-->Sd^-s=DO-)Hl zn!@!uSV+QU?cXjO2is;l2W5>yWwlB6zL^5G3iuIm|TypWyOy01+27Bg%< z?nqvR>CPn&F~&jX4%WJrt0%F=t8H10p zB)+{1QJ@^h?G^SsR7Tc4vM=p(13zltOF>ZAMoiD?)`r>}X1A7Puc7r-If2VqD{l;) zT!$_U-ai3-@t<*(qB{{(*rYlevR{nUWqMq|!1zr4yN7n!Mrfk|8w2AkeRo2kNbuQ! zEqU|wkI@C{ggEs|q?q{ue9VkcJBYm{%+6YhSyxAqSCsjtG=ZeOl@$yE760j(@}BV- zPpNhY@gGG}%+5}B;@^E(aXYXr6d{g;i2v%$ivNlh|6b9L95*=3?!FZBJtWdW90+uE zbp^Nz0_>fvf&5}(V!-dEKcSY8zi|%EPVnz2O9=4PWj(6_0pthp1Ak)AEc~xVone19 z$==@n?~2agKaBofod6%75b(!6Gvi;4IrsRae?F@-QEAEV($-MBA5OLOol~_tzo-HD zSk+*5&Tfq73(QV^SQ{t=3A`c7XDiGq>kNZi@`~~C^GgDM6Z}yD#0mP{ujI8n^|Pf< zZ4~9@|cp>hP)3t!K$X^xymVF*;`Ik2=t*IlVBp|9TAguix z?Qg^nqB8>O#A^w)g4sbW8NcV8^{N!JvYnMZBR@0nzrY0k8%*%O!G!*X{rzd2?Y+Pd zNEqY?7zwt3LwOFx$jN-pI2dL+Y&nWoNX=a zz%V!hi2Qj8aImu;(Df3cAfPl0ucZd^nC(21yLU%UnoBW}KGRg1ixiwiB^O-+pIYA0 zgx%rnbn8qQcwr$e0NamyMsb5-tJkVPttHN~BE2Om``B$BDL#L6vMRPWfv(<5@i?h6 z`#RZpg!|y?4hF`fCQNTM%PZQtj(%tHSC_6!(UM{;P%^CVTok)=>>$yI#sN=gC0J5@ zQR2X%l^HHiW*WJ1AW>*|+c;OGzv1i1$(4_mzVR>VyM;PCPLQ+MtEx71@|J?#UJb+=PycW+0I{T@4g%DTMi!zh_r@E}|2ES zAC$9G8V(E(<3mES&2(vD8Q_d@fptfah6YJ`)o}gw8t5$@D1-c>4kvqOT-SQ!XXI6_ zCI4xv>LpbNcX#(-RHbH&)&514;0hyQCA_sraV+E0qJx=-heuDa6;0*0c!sNyOs`}r zt`JXu=KXi^J0Lg>on?35a^{v^d7BD$wD8bXd?wbUEi4r#qdMlhVa7C<~ALLibBmD ziiY?K3NBbaX-PehR-3lo=2!kNzOokIRZG*PlVQ{}3BDI$WBQ=?KKmj)mtQg<`}inxDsv`gn!+3pZ&I|t zrxFfPq|_D@;YVGbz*NivoF;)Rve5KHR40k?q8&WBHv(vmcqr*hsfbV z!w_2Oia{zttxx<(F;HcSL8Fvzx_!Rj3!#;z)52o^HE!&*ikh;H<0Dik20}fo!-*7<8*e&Eh1`i+Sg&%oh*i~r%0tIsm z17Rv9MbbA}&r6(61@=HAOR$CsAu0UhVR18ge>M~f-(SJlY39B7I!d9F0UAk!%c3i8 zz7$yw zgR)1{sq^J+2@M#%7_&jUv#%XYw3nYu#W(HlzGH+>`mh3K zvEi%9zqjg-$q_03;58kww`k*BOEli2rpaq!4Os(2pO*rpdHhW#bJuu2?ky*&H5?0{ zE(SH1bx?I4Q?y~Y1O0?2QV+30FDj%+8h~4}MS%u&wr_EDS&VokbQ5CVuYUXHIo#%p zLK$GELnur2xcU~^x6rk{LkrTXd`GMG->4{?O*C+pQbVSV$93tvX7PQ9ns<+JxVR9X zQ~ayK<)Lo7+I6Zg--V1!UW<71;bmsfK60&(oE-5^TFxqxAn5tyx!RuMI3<*$$YjI# z;Ygb+mW!M+=|+&hB&D?k_nmMG>E|))l)>Un)4|sf4hc*S{PqFv3Ita&efQj@*xqz- zaSa~~1a{5ww+V{Y`BH~Qpb-v`MyoBTS3IVe7Xqyi2HATJJFfn4n>~Lvfn-T zm3SjWo;c+r^oJq`H>pp-!-*QsqU`eOd2eN6+1Npp92QZgD7g#{knQ)*-yiNLIsb(9qRFgjj z$kRD;_$|NXb`qWHF00P;3l-v=3>3Mz&SX!Jt&FX7<6VNihlu{$J_*&(w%SZLS)6Vg z;ouiDISr#o!%3~kcHq6bB@w86Z zZ6QfqtOO2W^`)|~rlk&NmDDHa41zM+K4Ud4#12H)IX9Q@5Xx3$jX%B7;xtzrl2W;cSnV29ow)e&deTy$(w9sL514K|%sE{sm6 z(+-o*S9$p>%TYe-*yg=x{Dn4Zi8cN>O90JrG>8aOYXpdaxNF*lBT&iWHUKV{hgg)F9^S=1S zlKB4Hf_Q1@jd{&B3v9#Uo0)M&d{;?!ncp)rE@)FYV3rcrMMT9sUi&JpFCB+N;Z!~0 zpPRmI$0ntDB{h*@HMsI^Zpf8Ds=NkvxB5+JrAF{jY@iXpqom@+2mWkyTJ6T>CLD9F zPX|_ZcN`wDSTY(+exPhIbDZ(MB0^6VPl`o_f7e(eh8MR%wohN_fI#^q?CEwSs}yBF z#_+{r z4n)ZX>egh2@CdoR!EoXRrcvAd6U7Vf6o*SC2m|6a+yZsq zc^isWQcD!&%}O2#(gPfeyss&@TS(ThKa*e}^-a(gX_oI;*l|9-C*S)n=GZG=_-on2 zo2jAVTvebMcBw!*+aMG4=Mr?{t}@>sE^+%e{;C^AS%xoOxk}N;r}#)r$d?|PQ%=tB zmvdzga#e5mVzgqDpe~b{pIk++V_=7mMd9vXP zDbm7sX>oey5SKU`U#g z>uerrs8>L`@Sy0KLhH)V{)(lcv<}sJ8u6gJg`^G@%`UBtG|n=PpLrQpk9$Y*QsT>3 z)p|md%(8ck-y+5e@Kf&?yZ^5sj3Bq$?LRja5<-Zeu z-5?`4N9@D@HIDJS^}lbQ{qOK6`QK*R@3sB95 -.\" Date: $Id$ -.\" Manual: -.\" Source: -.\" -.TH "GPST" "1" "$Id$" "" "" -.\" disable hyphenation -.nh -.\" disable justification (adjust text to left margin only) -.ad l -.SH "NAME" -gpst \- Converts between various GPS formats. -.SH "SYNOPSIS" -.HP 5 -\fBgpst\fR [\fIoptions\fR] [\fIfile\fR...] -.HP 5 -\fBgpst\fR {\-S} [\fIoptions\fR] [\fIfile\fR...] -.HP 5 -\fBgpst\fR {\-u} [\fIoptions\fR] [\fIfile\fR...] -.SH "DESCRIPTION" -.PP -\fB\-\-chronology\fR -.RS 4 -Check for broken chronology, warn about entries with an old timestamp. -.RE -.PP -\fB\-d\fR, \fB\-\-skip\-dups\fR -.RS 4 -If succeeding identical coordinates are found, print only the first one and ignore the rest. -.RE -.PP -\fB\-e\fR, \fB\-\-epoch\fR -.RS 4 -Use seconds since 1970\-01\-01 00:00:00 GMT as date format. -.RE -.PP -\fB\-\-fix\fR -.RS 4 -Comment out entries which is obviously wrong. Use together with -\fB\-\-chronology\fR -to fix those kind of errors. Does not work with GPX output yet. -.RE -.PP -\fB\-\-from\-date \fR\fB\fIx\fR\fR -.RS 4 -Used by the -pgwupd -format. Specifies from which date waypoints should be updated. No checks for valid date format here, let -PostgreSQL -take care of that. All variants it understands can be used here. -.RE -.PP -\fB\-h\fR, \fB\-\-help\fR -.RS 4 -Send a brief help summary to stdout. -.RE -.PP -\fB\-\-inside\fR -.RS 4 -Print only trackpoints inside a rectangle specified by -\fB\-\-pos1\fR -and -\fB\-\-pos2\fR. -.RE -.PP -\fB\-n\fR, \fB\-\-undefined \fR\fB\fIx\fR\fR -.RS 4 -Use -\fIx\fR -as undefined value. -.RE -.PP -\fB\-\-near\fR -.RS 4 -Add names of the three closest waypoints to the trackpoint. Unfinished and experimental, needs -\fBgpsbabel\fR(1), which is called from the program as -\fB/usr/local/bin/gpsbabel\fR. -.RE -.PP -\fB\-o\fR, \fB\-\-output\-format \fR\fB\fIx\fR\fR -.RS 4 -Use output format -\fIx\fR: -.RS 4 -.PP -\fBclean\fR -.RS 4 -TAB\-separated format with longitude, latitude and altitude. -.RE -.PP -\fBcsv\fR -.RS 4 -TAB\-separated format: -.RS 4 -.PP -date -.RS 4 -Date of trackpoint. Format: -\fIyyyy\fR\-\fImm\fR\-\fIdd\fRT\fIhh\fR:\fImm\fR:\fIss\fRZ -unless the -\fB\-\-epoch\fR -option is specified. If so, it\(cqs represented as number of seconds since 1970\-01\-01 00:00:00 UTC. -.RE -.PP -longitude -.RS 4 -Longitude, decimal degrees. -.RE -.PP -latitude -.RS 4 -Latitude, decimal degrees. -.RE -.PP -altitude -.RS 4 -Altitude in metres above sea level. Optional. If not present, the corresponding TAB is also printed, to keep the number of columns intact. -.RE -.RE -.RE -.PP -\fBgpsml\fR (Default) -.RS 4 -Line\-based XML which makes it easy to edit and grep. In the past, there was this big plan about making this the default storage format, so it was declared as The Honourable Default Output Format. But using GPX is the way to go, so this will probably change in the future. It\(cqs way too -de facto -and widely used, so storing GPS data in anything else is sheer waste of work. Probably not finished yet. -.RE -.PP -\fBgpstrans\fR -.RS 4 -The format generated by -\fBgpstrans\fR(1). -.RE -.PP -\fBgpx\fR -.RS 4 -Not complete yet, but good enough in most cases. -.RE -.PP -\fBpgtab\fR -.RS 4 -TAB\-separated format for import into -PostgreSQL. Undefined values are written as -\\N -if the -\fB\-\-undefined\fR -option is not specified. -.RS 4 -.PP -date -.RS 4 -Format: -\fIyyyy\fR\-\fImm\fR\-\fIdd\fRT\fIhh\fR:\fImm\fR:\fIss\fRZ -.RE -.PP -coor -.RS 4 -Format: -(\fIlat\fR,\fIlon\fR) -.RE -.PP -ele -.RS 4 -Altitude in metres above sea level. -.RE -.PP -sted -.RS 4 -Short name of closest waypoint. Calculated in -PostgreSQL, so this value is always -\\N. -.RE -.PP -dist -.RS 4 -Distance in decimal degrees to closest waypoint. Calculated in -PostgreSQL, so this value is always -\\N. -.RE -.PP -description -.RS 4 -Description of waypoint. Calculated in -PostgreSQL, so this value is always -\\N. -.RE -.PP -avst -.RS 4 -Distance to trackpoint in decimal degrees from a defined -\(lqhome\(rq -position. This is calculated in -PostgreSQL, so the field value is always -\\N. -.RE -.RE -.RE -.PP -\fBpgwtab\fR -.RS 4 -Output waypoints on a TAB\-separated format: -.RS 4 -.PP -coor -.RS 4 -Format: -(\fIlat\fR,\fIlon\fR) -.RE -.PP -name -.RS 4 -Title of waypoint. -.RE -.PP -ele -.RS 4 -Elevation in metres above sea level. -.RE -.PP -type -.RS 4 -Type of waypoint, same as the GPX - -element. -.RE -.PP -time -.RS 4 -Timestamp of waypoint. -.RE -.PP -cmt -.RS 4 -Short waypoint description, used by the GPS as a comment. Same as the GPX - -element. -.RE -.PP -descr -.RS 4 -Long description, not used by the GPS. Same as the GPX - -element. -.RE -.PP -src -.RS 4 -Source of data, same as the - -GPX element. -.RE -.PP -sym -.RS 4 -GPS symbol name. Same as the - -GPX element. -.RE -.RE -.RE -.PP -\fBpgwupd\fR -.RS 4 -Output waypoints as SQL transactions which updates the -sted -and -dist -columns. -.RE -.PP -\fBposcount\fR -.RS 4 -Creates a 3D plot where areas with many trackpoints are higher than areas with less track points. -.RE -.PP -\fBps\fR -.RS 4 -Postscript. Unfinished. -.RE -.PP -\fBsvg\fR -.RS 4 -Unfinished. -.RE -.PP -\fBxgraph\fR -.RS 4 -Input format for -\fBxgraph\fR(1). -.RE -.PP -\fBygraph\fR -.RS 4 -Input format for -\fBygraph\fR(1). -.RE -.RE -.RE -.PP -\fB\-\-outside\fR -.RS 4 -Print only trackpoints outside a rectangle specified by -\fB\-\-pos1\fR -and -\fB\-\-pos2\fR. -.RE -.PP -\fB\-\-pos1 \fR\fB\fIx1\fR\fR\fB,\fR\fB\fIy1\fR\fR, \fB\-\-pos2 \fR\fB\fIx2\fR\fR\fB,\fR\fB\fIy2\fR\fR -.RS 4 -Specifies corners of an area rectangle used by the -\fB\-\-inside\fR -and -\fB\-\-outside\fR -options. The -\fIx\fR -and -\fIy\fR -values are specified as decimal degrees, negative for west or south. -.RE -.PP -\fB\-r\fR, \fB\-\-require \fR\fB\fIx\fR\fR -.RS 4 -Specify requirements for trackpoints to be written. -\fIx\fR -is a string with the following flags: -.RS 4 -.PP -\fBe\fR -.RS 4 -Print only waypoints which have an elevation. -.RE -.PP -\fBp\fR -.RS 4 -Print only waypoints which have a position. -.RE -.PP -\fBt\fR -.RS 4 -Print only waypoints which have a timestamp. -.RE -.RE -.RE -.PP -\fB\-R\fR, \fB\-\-round \fR\fB\fIx\fR\fR\fB=\fR\fB\fIy\fR\fR\fB[,\fIx2\fR=\fIy2\fR[...]]\fR -.RS 4 -Round trackpoint element -\fIx\fR -to -\fIy\fR -decimals. -.sp -Example: -\fB\-\-round lat=4,lon=5,ele=1\fR -.RE -.PP -\fB\-s\fR, \fB\-\-short\-date\fR -.RS 4 -Use short date format. -.RE -.PP -\fB\-S\fR, \fB\-\-save\-to\-file \fR\fB\fIx\fR\fR -.RS 4 -Save the unconverted data to a file with a filename starting with the timestamp of the first trackpoint. The parameter string -\fIx\fR -is added at the end of the filename. For the time being this option will ignore all other options. -.sp -.it 1 an-trap -.nr an-no-space-flag 1 -.nr an-break-flag 1 -.br -\fBNote\fR -If several files are specified on the command line, all data will be saved into only one file. This behaviour may change in the future. -.RE -.PP -\fB\-t\fR, \fB\-\-create\-breaks\fR -.RS 4 -Create breaks in track between points with a difference more than the number of seconds specified by the -\fBPAUSE_LIMIT\fR -variable. -.RE -.PP -\fB\-u\fR, \fB\-\-comment\-out\-dups\fR -.RS 4 -Comment out following data with identical position values, only print first entry. -.RE -.PP -\fB\-v\fR, \fB\-\-verbose\fR -.RS 4 -Verbose output, can be repeated. -.RE -.PP -\fB\-\-version\fR -.RS 4 -Print program version information. -.RE -.PP -\fB\-w\fR, \fB\-\-strip\-whitespace\fR -.RS 4 -Strip all unnecessary whitespace. -.RE -.PP -\fB\-y\fR, \fB\-\-double\-y\-scale\fR -.RS 4 -Double Y scale (latitude). -.RE -.PP -\fB\-\-debug\fR -.RS 4 -Print debugging messages. -.RE -.SH "BUGS AND THINGS THAT NEED TO BE DONE" -.TP 4 -\(bu -Pretty incomplete in some areas. Some of the source formats are undocumented and thus incomplete. Some functionality is not working properly, for example the Postscript output. -.TP 4 -\(bu -Remove hardcodings, for example the -\(lqhome\(rq -position used to calculate the -avst -database column. -.TP 4 -\(bu -Translate database column names to English. -.TP 4 -\(bu -Add more tests to cover all command\-line options. -.SH "AUTHOR" -.PP -Made by -Øyvind A. Holm -. -.SH "COPYRIGHT" -.PP -Copyleft \(co -Øyvind A. Holm -. This is free software; see the file -\fICOPYING\fR -for legalese stuff. -.SH "LICENSE" -.PP -This program is free software; you can redistribute it and/or modify it under the terms of the -GNU General Public License -as published by the -Free Software Foundation; either version 2 of the License, or (at your option) any later version. -.PP -This program is distributed in the hope that it will be useful, but -\fIWITHOUT ANY WARRANTY\fR; without even the implied warranty of -\fIMERCHANTABILITY\fR -or -\fIFITNESS FOR A PARTICULAR PURPOSE\fR. See the GNU General Public License for more details. -.PP -You should have received a copy of the GNU General Public License along with this program; if not, write to -.sp -.RS 4 -.nf -The Free Software Foundation, Inc. -59 Temple Place, Suite 330 -Boston, MA 02111\-1307 -USA -.fi -.RE -.SH "SEE ALSO" -.PP -\fBgpsbabel\fR(1) diff --git a/branches/gpst.gpsman-format/doc/gpst.html b/branches/gpst.gpsman-format/doc/gpst.html deleted file mode 100644 index e14d2af..0000000 --- a/branches/gpst.gpsman-format/doc/gpst.html +++ /dev/null @@ -1,137 +0,0 @@ - - -gpst

Name

gpst — Converts between various GPS formats.

Synopsis

gpst [ - options - ] [ - file - ...]

gpst {-S} [ - options - ] [ - file - ...]

gpst {-u} [ - options - ] [ - file - ...]

Description

--chronology

Check for broken chronology, warn about entries with an - old timestamp.

-d, --skip-dups

If succeeding identical coordinates are found, print - only the first one and ignore the rest.

-e, --epoch

Use seconds since 1970-01-01 00:00:00 GMT as date - format.

--fix

Comment out entries which is obviously wrong. - Use together with --chronology to fix those - kind of errors. - Does not work with GPX output yet.

--from-date - x

Used by the pgwupd format. - Specifies from which date waypoints should be updated. - No checks for valid date format here, let - PostgreSQL take care of that. - All variants it understands can be used here.

-h, --help

Send a brief help summary to stdout.

--inside

Print only trackpoints inside a rectangle specified by - --pos1 and --pos2.

-n, --undefined - x

Use x as undefined - value.

--near

Add names of the three closest waypoints to the - trackpoint. - Unfinished and experimental, needs gpsbabel(1), which is called from - the program as - /usr/local/bin/gpsbabel.

-o, --output-format - x

Use output format x:

clean

TAB-separated format with longitude, latitude and - altitude.

csv

TAB-separated format: -

date

Date of trackpoint. - Format: - yyyy-mm-ddThh:mm:ssZ - unless the --epoch option is - specified. - If so, it’s represented as number of seconds since - 1970-01-01 00:00:00 UTC.

longitude

Longitude, decimal degrees.

latitude

Latitude, decimal degrees.

altitude

Altitude in metres above sea level. - Optional. - If not present, the corresponding TAB is also - printed, to keep the number of columns - intact.

gpsml (Default)

Line-based XML which makes it easy to edit and - grep. - In the past, there was this big plan about making this - the default storage format, so it was declared as The - Honourable Default Output Format. - But using GPX is the way to go, so this will probably - change in the future. - It’s way too de facto and - widely used, so storing GPS data in anything else is - sheer waste of work. - Probably not finished yet.

gpstrans

The format generated by gpstrans(1).

gpx

Not complete yet, but good enough in most - cases.

pgtab

TAB-separated format for import into - PostgreSQL. - Undefined values are written as \N if - the --undefined option is not - specified.

date

Format: - yyyy-mm-ddThh:mm:ssZ

coor

Format: - (lat,lon)

ele

Altitude in metres above sea level.

sted

Short name of closest waypoint. - Calculated in - PostgreSQL, so this - value is always \N.

dist

Distance in decimal degrees to closest - waypoint. - Calculated in - PostgreSQL, so this - value is always \N.

description

Description of waypoint. - Calculated in - PostgreSQL, so this - value is always \N.

avst

Distance to trackpoint in decimal degrees - from a defined “home” position. - This is calculated in - PostgreSQL, so the - field value is always - \N.

pgwtab

Output waypoints on a TAB-separated format:

coor

Format: - (lat,lon)

name

Title of waypoint.

ele

Elevation in metres above sea level.

type

Type of waypoint, same as the GPX <type> element.

time

Timestamp of waypoint.

cmt

Short waypoint description, used by the GPS - as a comment. - Same as the GPX <cmt> element.

descr

Long description, not used by the GPS. - Same as the GPX <desc> element.

src

Source of data, same as the <src> GPX element.

sym

GPS symbol name. - Same as the <sym> GPX element.

pgwupd

Output waypoints as SQL transactions which updates - the sted and - dist columns.

poscount

Creates a 3D plot where areas with many - trackpoints are higher than areas with less track - points.

ps

Postscript. Unfinished.

svg

Unfinished.

xgraph

Input format for xgraph(1).

ygraph

Input format for ygraph(1).

--outside

Print only trackpoints outside a rectangle specified by - --pos1 and --pos2.

--pos1 - x1,y1, --pos2 - x2,y2

Specifies corners of an area rectangle used by the - --inside and --outside - options. - The x and - y values are specified as decimal - degrees, negative for west or south.

-r, --require - x

Specify requirements for trackpoints to be written. - x is a string with the following - flags:

e

Print only waypoints which have an - elevation.

p

Print only waypoints which have a position.

t

Print only waypoints which have a - timestamp.

-R, --round - x=y[,x2=y2[...]]

Round trackpoint element x to - y decimals.

Example:

--round lat=4,lon=5,ele=1

-s, --short-date

Use short date format.

-S, --save-to-file - x

Save the unconverted data to a file with a filename - starting with the timestamp of the first trackpoint. - The parameter string x is added at - the end of the filename. - For the time being this option will ignore all other - options.

Note

If several files are specified on the command line, - all data will be saved into only one file. - This behaviour may change in the future.

-t, - --create-breaks

Create breaks in track between points with a difference - more than the number of seconds specified by the - PAUSE_LIMIT variable.

-u, - --comment-out-dups

Comment out following data with identical position - values, only print first entry.

-v, --verbose

Verbose output, can be repeated.

--version

Print program version information.

-w, - --strip-whitespace

Strip all unnecessary whitespace.

-y, - --double-y-scale

Double Y scale (latitude).

--debug

Print debugging messages.

Bugs and things that need to be done

  • Pretty incomplete in some areas. - Some of the source formats are undocumented and thus incomplete. - Some functionality is not working properly, for example the - Postscript output.

  • Remove hardcodings, for example the “home” - position used to calculate the avst database column.

  • Translate database column names to English.

  • Add more tests to cover all command-line options.

Author

Made by Øyvind A. Holm - .

Copyright

Copyleft © Øyvind A. Holm - . - This is free software; see the file COPYING for - legalese stuff.

License

This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public - License as published by the Free Software Foundation; either version - 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details.

You should have received a copy of the GNU General Public - License along with this program; if not, write to -

The Free Software Foundation, Inc.
-59 Temple PlaceSuite 330
-BostonMA 02111-1307
-USA

See also

gpsbabel(1)

diff --git a/branches/gpst.gpsman-format/doc/gpst.xml b/branches/gpst.gpsman-format/doc/gpst.xml deleted file mode 100644 index ab04ec4..0000000 --- a/branches/gpst.gpsman-format/doc/gpst.xml +++ /dev/null @@ -1,690 +0,0 @@ - - - - - - - - gpst - 1 - - - gpst - Converts between various GPS formats. - - - - - gpst - - options - - - file - - - - - gpst - -S - - options - - - file - - - - - gpst - -u - - options - - - file - - - - - - Description - - - - - - - Check for broken chronology, warn about entries with an - old timestamp. - - - - - , - - If succeeding identical coordinates are found, print - only the first one and ignore the rest. - - - - - , - - Use seconds since 1970-01-01 00:00:00 GMT as date - format. - - - - - - - Comment out entries which is obviously wrong. - Use together with to fix those - kind of errors. - Does not work with GPX output yet. - - - - - - - Used by the pgwupd format. - Specifies from which date waypoints should be updated. - No checks for valid date format here, let - PostgreSQL take care of that. - All variants it understands can be used here. - - - - - , - - Send a brief help summary to stdout. - - - - - - - Print only trackpoints inside a rectangle specified by - and . - - - - - , - - Use x as undefined - value. - - - - - - - Add names of the three closest waypoints to the - trackpoint. - Unfinished and experimental, needs - gpsbabel - 1 , which is called from - the program as - /usr/local/bin/gpsbabel. - - - - - , - - Use output format x: - - - - - - TAB-separated format with longitude, latitude and - altitude. - - - - - - - TAB-separated format: - - - - date - - Date of trackpoint. - Format: - yyyy-mm-ddThh:mm:ssZ - unless the option is - specified. - If so, it’s represented as number of seconds since - 1970-01-01 00:00:00 UTC. - - - - - longitude - - Longitude, decimal degrees. - - - - - latitude - - Latitude, decimal degrees. - - - - - altitude - - Altitude in metres above sea level. - Optional. - If not present, the corresponding TAB is also - printed, to keep the number of columns - intact. - - - - - - - - - (Default) - - Line-based XML which makes it easy to edit and - grep. - In the past, there was this big plan about making this - the default storage format, so it was declared as The - Honourable Default Output Format. - But using GPX is the way to go, so this will probably - change in the future. - It’s way too de facto and - widely used, so storing GPS data in anything else is - sheer waste of work. - Probably not finished yet. - - - - - - - The format generated by - gpstrans - 1 . - - - - - - - Not complete yet, but good enough in most - cases. - - - - - - - TAB-separated format for import into - PostgreSQL. - Undefined values are written as \N if - the option is not - specified. - - - - date - - Format: - yyyy-mm-ddThh:mm:ssZ - - - - - coor - - Format: - (lat,lon) - - - - - ele - - Altitude in metres above sea level. - - - - - sted - - Short name of closest waypoint. - Calculated in - PostgreSQL, so this - value is always \N. - - - - - dist - - Distance in decimal degrees to closest - waypoint. - Calculated in - PostgreSQL, so this - value is always \N. - - - - - description - - Description of waypoint. - Calculated in - PostgreSQL, so this - value is always \N. - - - - - avst - - Distance to trackpoint in decimal degrees - from a defined home position. - This is calculated in - PostgreSQL, so the - field value is always - \N. - - - - - - - - - - - Output waypoints on a TAB-separated format: - - - - coor - - Format: - (lat,lon) - - - - - name - - Title of waypoint. - - - - - ele - - Elevation in metres above sea level. - - - - - type - - Type of waypoint, same as the GPX type element. - - - - - time - - Timestamp of waypoint. - - - - - cmt - - Short waypoint description, used by the GPS - as a comment. - Same as the GPX cmt element. - - - - - descr - - Long description, not used by the GPS. - Same as the GPX desc element. - - - - - src - - Source of data, same as the src GPX element. - - - - - sym - - GPS symbol name. - Same as the sym GPX element. - - - - - - - - - - - Output waypoints as SQL transactions which updates - the sted and - dist columns. - - - - - - - Creates a 3D plot where areas with many - trackpoints are higher than areas with less track - points. - - - - - - - Postscript. Unfinished. - - - - - - - Unfinished. - - - - - - - Input format for - xgraph - 1 . - - - - - - - Input format for - ygraph - 1 . - - - - - - - - - - - Print only trackpoints outside a rectangle specified by - and . - - - - - - - - Specifies corners of an area rectangle used by the - and - options. - The x and - y values are specified as decimal - degrees, negative for west or south. - - - - - , - - Specify requirements for trackpoints to be written. - x is a string with the following - flags: - - - - - - Print only waypoints which have an - elevation. - - - - - - - Print only waypoints which have a position. - - - - - - - Print only waypoints which have a - timestamp. - - - - - - - - - , - - Round trackpoint element x to - y decimals. - Example: -
- -
-
-
- - - , - - Use short date format. - - - - - , - - Save the unconverted data to a file with a filename - starting with the timestamp of the first trackpoint. - The parameter string x is added at - the end of the filename. - For the time being this option will ignore all other - options. - - If several files are specified on the command line, - all data will be saved into only one file. - This behaviour may change in the future. - - - - - - , - - - Create breaks in track between points with a difference - more than the number of seconds specified by the - PAUSE_LIMIT variable. - - - - - , - - - Comment out following data with identical position - values, only print first entry. - - - - - , - - Verbose output, can be repeated. - - - - - - - Print program version information. - - - - - , - - - Strip all unnecessary whitespace. - - - - - , - - - Double Y scale (latitude). - - - - - - - Print debugging messages. - - - -
- -
- - Bugs and things that need to be done - - - - - Pretty incomplete in some areas. - Some of the source formats are undocumented and thus incomplete. - Some functionality is not working properly, for example the - Postscript output. - - - - Remove hardcodings, for example the home - position used to calculate the avst database column. - - - - Translate database column names to English. - - - - Add more tests to cover all command-line options. - - - - - - - Author - - Made by Øyvind - A. Holm - sunny@sunbase.org. - - - - Copyright - - Copyleft © Øyvind - A. Holm - sunny@sunbase.org. - This is free software; see the file COPYING for - legalese stuff. - - - - License - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public - License as published by the Free Software Foundation; either version - 2 of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public - License along with this program; if not, write to -
The Free Software Foundation, Inc. -59 Temple Place, Suite 330 -Boston, MA 02111-1307 -USA
- -
- - See also - - - gpsbabel - 1 - - - - -
diff --git a/branches/gpst.gpsman-format/doc/mayko.txt b/branches/gpst.gpsman-format/doc/mayko.txt deleted file mode 100644 index 36bc443..0000000 --- a/branches/gpst.gpsman-format/doc/mayko.txt +++ /dev/null @@ -1,37 +0,0 @@ -$Id$ - -Description of the “Mayko Xmap” format written by gpstrans(1). From the -C source. - -======== CUT ======== -xmaplog 1.0 Fri Nov 1 17:49:13 2002 -1 60.3907135 5.3303821 8.4 0 10/30/2002 15:13:21 -1 60.3906397 5.3304033 8.1 0 10/30/2002 15:13:23 -1 60.3902955 5.3304494 8.3 0 10/30/2002 15:13:32 -======== CUT ======== - - - -
xmaplog 1.0
- - Fri Nov 1 17:49:13 2002 -
- - - -
1
- 60.3907135 5.3303821 - - 8.4 - - 0 - - - -
- -
diff --git a/branches/gpst.gpsman-format/doc/til_postgres.txt b/branches/gpst.gpsman-format/doc/til_postgres.txt deleted file mode 100644 index 6345f5c..0000000 --- a/branches/gpst.gpsman-format/doc/til_postgres.txt +++ /dev/null @@ -1,56 +0,0 @@ -$Id$ - -Opprettelse av "gps"-databasen: - - $ cd ~/bin/src/gpstools/postgres - $ createdb gps - $ psql gps - gps=# \i create_table.sql - gps=# \i create_funcs.sql - gps=# \i create_views.sql - -For å kopiere ting fra nye tracklogger inn i PostgreSQL: - - 1: cd til der de nye filene er. - 1: Kjør svn update og slett de filene som allerede er lagt inn. - 1: gpst -o pgtab -d -rpt *.gpx | psql -a -c "COPY logg FROM stdin" gps - - 2: cd ~/gps/div/postgres - 2: psql gps - 2: \i update_things.sql - - Så kommer turen til stedsnavnene: - - 1: cd ~/gps/poi/trans - 1: svn update osv - 1: gpst -o pgwupd *.gpx | psql -a gps - 1: cd ~/gps/unit - 1: svn update osv - 1: gpst -o pgwupd wpdata.gpx | psql -a gps - -For å legge til nye veipunkter: - -Kjør - - gpst -o pgwtab *.gpx | psql -a -c "COPY wayp FROM stdin" gps - -For å renske opp i veipunktene: - -cd ~/bin/src/gpstools/postgres -psql gps -\i cleanup.sql - -For å synkronisere waypoints og POI: - -Her trengs Postgres. Må ha en database som heter "gps" og en tabell som -heter "tmpwayp". Ordnes med ../postgres/create_table.sql . Deretter er -det bare å kjøre ../poisync og redigere .gpx-filene. - -En grei makro som kan brukes i vimdiff når wpdata.gpx er i venstre vindu -og den som veipunktet skal legges inn i er i høyre, er: - -:map yGP?Y/p - -(Marker veipunktet i venstre vindu med Shift-V og trykk F1.) - -vim: set ts=2 sts=2 sw=2 et : diff --git a/branches/gpst.gpsman-format/gpslist b/branches/gpst.gpsman-format/gpslist deleted file mode 100755 index 21e1719..0000000 --- a/branches/gpst.gpsman-format/gpslist +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -#======================================================================= -# $Id$ -# Read GPS data from stdin or file names at the command line and send a -# PostgreSQL table to stdout. Needs a database called "tmpgps" with the -# usual tables. -#======================================================================= - -cat "$@" | gpst -o pgtab | psql -c "TRUNCATE logg; COPY logg FROM stdin;" tmpgps >/dev/null 2>&1 -cd ~/bin/src/gpstools/postgres -psql -f "$HOME/bin/src/gpstools/postgres/allupdate.sql" tmpgps >/dev/null 2>&1 -psql -f "$HOME/bin/src/gpstools/postgres/distupdate.sql" tmpgps >/dev/null 2>&1 -psql -c "SELECT date as date, coor, sted, dist, avst FROM logg ORDER BY date;" tmpgps diff --git a/branches/gpst.gpsman-format/gpsman2gpx b/branches/gpst.gpsman-format/gpsman2gpx deleted file mode 100755 index 679c444..0000000 --- a/branches/gpst.gpsman-format/gpsman2gpx +++ /dev/null @@ -1,258 +0,0 @@ -#!/usr/bin/perl -w - -#======================================================================= -# $Id$ -# Quick & dirty script for converting gpsman(1) sdata files to GPX. -# -# Character set: UTF-8 -# ©opyleft 2006– Øyvind A. Holm -# License: GNU General Public License version 2 or later, see end of -# file for legal stuff. -#======================================================================= - -BEGIN { - push(@INC, "$ENV{'HOME'}/bin/src/gpstools"); -} - -BEGIN { - our @version_array; -} - -use strict; -use Getopt::Long; - -use GPSTxml; - -$| = 1; - -our $Debug = 0; - -our %Opt = ( - 'debug' => 0, - 'help' => 0, - 'verbose' => 0, - 'version' => 0, -); - -our $progname = $0; -$progname =~ s/^.*\/(.*?)$/$1/; - -my $rcs_id = '$Id$'; -my $id_date = $rcs_id; -$id_date =~ s/^.*?\d+ (\d\d\d\d-.*?\d\d:\d\d:\d\d\S+).*/$1/; - -push(@main::version_array, $rcs_id); - -Getopt::Long::Configure("bundling"); -GetOptions( - "debug" => \$Opt{'debug'}, - "help|h" => \$Opt{'help'}, - "verbose|v+" => \$Opt{'verbose'}, - "version" => \$Opt{'version'}, -) || die("$progname: Option error. Use -h for help.\n"); - -$Opt{'debug'} && ($Debug = 1); -$Opt{'help'} && usage(0); -$Opt{'version'} && print_version(); - -print(< - - -END - -while (<>) { - my $Line = $_; - if ( - $Line =~ /^ - (.*?)\t # name - (.*?)\t # cmt - (.*?)\t # some kind of worthless date - ([NS].+?)\t # lat - ([WE].+?)\t # lon - (.*) # lots of uninteresting stuff but with altitude - $ - /x - ) { - my ($Name, $Cmt, $wl_date, $Lat, $Lon, $Rest) = - ( $1, $2, $3, $4, $5, $6); - my $Ele = ""; - - $Name = txt_to_xml($Name); - $Cmt = txt_to_xml($Cmt); - $Lat = conv_pos($Lat); - $Lon = conv_pos($Lon); - if ($Rest =~ /ele=([\d\.]+)\D/) { - $Ele = 1.0 * $1; - } - print(" \n"); - print(" $Ele\n") if length($Ele); - print(" $Name\n") if length($Name); - print(" $Cmt\n") if length($Cmt); - print(" \n"); - } -} - -print("\n"); - -sub conv_pos { - # {{{ - my $Retval = shift; - - if ($Retval =~ /^([NSWE])([0-9\.]+)$/) { - my ($Pref, $Deg) = ($1, $2); - $Retval = ($Pref =~ /[SW]/) - ? 0-$Deg - : $Deg; - } else { - warn("\"$Retval\": Invalid coordinate\n"); - } - return $Retval; - # }}} -} - -sub print_version { - # Print program version {{{ - for (@main::version_array) { - print("$_\n"); - } - exit(0); - # }}} -} # print_version() - -sub usage { - # Send the help message to stdout {{{ - my $Retval = shift; - - print(<= $verbose_level) { - print(STDERR "$progname: $Txt\n"); - } - # }}} -} # msg() - -sub D { - # Print a debugging message {{{ - $Debug || return; - my @call_info = caller; - chomp(my $Txt = shift); - my $File = $call_info[1]; - $File =~ s#\\#/#g; - $File =~ s#^.*/(.*?)$#$1#; - print(STDERR "$File:$call_info[2] $$ $Txt\n"); - return(""); - # }}} -} # D() - -__END__ - -# Plain Old Documentation (POD) {{{ - -=pod - -=head1 NAME - - - -=head1 REVISION - -$Id$ - -=head1 SYNOPSIS - - [options] [file [files [...]]] - -=head1 DESCRIPTION - - - -=head1 OPTIONS - -=over 4 - -=item B<-h>, B<--help> - -Print a brief help summary. - -=item B<-v>, B<--verbose> - -Increase level of verbosity. Can be repeated. - -=item B<--version> - -Print version information. - -=item B<--debug> - -Print debugging messages. - -=back - -=head1 BUGS - - - -=head1 AUTHOR - -Made by Øyvind A. Holm Ssunny@sunbase.orgE>. - -=head1 COPYRIGHT - -Copyleft © Øyvind A. Holm Esunny@sunbase.orgE -This is free software; see the file F for legalese stuff. - -=head1 LICENCE - -This program is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2 of the License, or (at your -option) any later version. - -This program is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along -with this program; if not, write to the Free Software Foundation, Inc., -59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -=head1 SEE ALSO - -=cut - -# }}} - -# vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w : -# End of file $Id$ diff --git a/branches/gpst.gpsman-format/gpst b/branches/gpst.gpsman-format/gpst deleted file mode 100755 index 18c4774..0000000 --- a/branches/gpst.gpsman-format/gpst +++ /dev/null @@ -1,1342 +0,0 @@ -#!/usr/bin/perl -w - -#======================================================================= -# $Id$ -# Converts between various GPS formats -# -# Character set: UTF-8 -# ©opyleft 2002– Øyvind A. Holm -# License: GNU General Public License version 2 or later, see end of -# file for legal stuff. -#======================================================================= - -BEGIN { - our @version_array; -} - -use strict; -use Getopt::Long; -use Time::Local qw { timegm_nocheck }; - -BEGIN { - push(@INC, "$ENV{'HOME'}/bin/src/gpstools"); - our @version_array; -} - -use GPST; -use GPSTdate; -use GPSTdebug; -use GPSTgeo; -use GPSTxml; - -$| = 1; - -our $Debug = 0; - -our %Opt = ( - # Initial values for command line arguments {{{ - 'chronology' => 0, - 'comment-out-dups' => 0, - 'create-breaks' => 0, - 'debug' => 0, - 'double-y-scale' => 0, - 'epoch' => 0, - 'fix' => 0, - 'from-date' => "", - 'help' => 0, - 'inside' => 0, - 'near' => "", - 'output-format' => "gpsml", - 'outside' => 0, - 'pos1' => "", - 'pos2' => "", - 'require' => "", - 'round' => "", - 'save-to-file' => "\n", # \n = undefined, it’s banned in filenames anyway. - 'short-date' => 0, - 'skip-dups' => 0, - 'strip-whitespace' => 0, - 'undefined' => "", - 'verbose' => 0, - 'version' => 0, - # }}} -); - -our $progname = $0; -$progname =~ s/^.*\/(.*?)$/$1/; - -my $rcs_id = '$Id$'; -my $id_date = $rcs_id; -$id_date =~ s/^.*?\d+ (\d\d\d\d-.*?\d\d:\d\d:\d\d\S+).*/$1/; - -push(@main::version_array, $rcs_id); - -Getopt::Long::Configure("bundling"); -GetOptions( - # Command line options {{{ - "chronology" => \$Opt{'chronology'}, - "comment-out-dups|u" => \$Opt{'comment-out-dups'}, - "create-breaks|t" => \$Opt{'create-breaks'}, - "debug" => \$Opt{'debug'}, - "double-y-scale|y" => \$Opt{'double-y-scale'}, - "epoch|e" => \$Opt{'epoch'}, - "fix" => \$Opt{'fix'}, - "from-date=s" => \$Opt{'from-date'}, - "help|h" => \$Opt{'help'}, - "inside" => \$Opt{'inside'}, - "near" => \$Opt{'near'}, - "output-format|o=s" => \$Opt{'output-format'}, - "outside" => \$Opt{'outside'}, - "pos1=s" => \$Opt{'pos1'}, - "pos2=s" => \$Opt{'pos2'}, - "require|r=s" => \$Opt{'require'}, - "round|R=s" => \$Opt{'round'}, - "save-to-file|S=s" => \$Opt{'save-to-file'}, - "short-date|s" => \$Opt{'short-date'}, - "skip-dups|d" => \$Opt{'skip-dups'}, - "strip-whitespace|w" => \$Opt{'strip-whitespace'}, - "undefined|n=s" => \$Opt{'undefined'}, - "verbose|v+" => \$Opt{'verbose'}, - "version" => \$Opt{'version'}, - # }}} -) || die("$progname: Option error. Use -h for help.\n"); - -my %Dat; - -my $PAUSE_LIMIT = 2 * 60; # Antall sekunder mellom to punkter det må til før en move legges inn. -my $Udef = "?"; -my $DIGIT = '[0-9\.\-\+]'; # Used in regexps -$GPST::Spc = $Opt{'strip-whitespace'} ? "" : " "; -my $Spc = $GPST::Spc; # FIXME -my $found_move = 0; # Settes til 1 hvis en /^# move$/ blir funnet. -my $first_time = 0; -my $last_time = 0; -my ($last_lon, $last_lat, $last_line) = - ( 1000, 1000, ""); # Vi kan jo teoretisk sett være i Greenwich eller på ekvator -my ($lat1, $lon1, $lat2, $lon2) = - (-1000, -1000, 1000, 1000); - -our %Cmd = ( - 'gpsbabel' => '/usr/local/bin/gpsbabel', -); - -my %Poscount = (); - -if ($Opt{'output-format'} eq "pgtab") { - $Opt{'require'} .= "p"; -} -my %Req = ( - 'ele' => ($Opt{'require'} =~ /e/) ? 1 : 0, - 'position' => ($Opt{'require'} =~ /p/) ? 1 : 0, - 'time' => ($Opt{'require'} =~ /t/) ? 1 : 0, -); -$Opt{'require'} =~ /[^ept]/ - && die("$0: Unknown flag in --require (-r) value\n"); - -$Opt{'debug'} && ($Debug = 1); -$Opt{'help'} && usage(0); -$Opt{'version'} && print_version(); - -if ($Opt{'pos1'} =~ /^($DIGIT+),($DIGIT+)$/) { - $lat1 = $1; - $lon1 = $2; -} -if ($Opt{'pos2'} =~ /^($DIGIT+),($DIGIT+)$/) { - $lat2 = $1; - $lon2 = $2; -} -if ($lat1 > $lat2) { - my $Tmp = $lat1; - $lat1 = $lat2; - $lat2 = $Tmp; -} -if ($lon1 > $lon2) { - my $Tmp = $lon1; - $lon1 = $lon2; - $lon2 = $Tmp; -} - -if ($Opt{'epoch'} && $Opt{'short-date'}) { - die("$progname: Cannot mix the --epoch (-e) and --short-date (-s) options\n"); -} - -if ($Opt{'inside'} && $Opt{'outside'}) { - die("$progname: Cannot mix the --inside and --outside options\n"); -} - -# To avoid printing out extra "/> at the start of svg output: -my $svg_start_thing = ""; - -my %Round = (); - -if (defined($Opt{'round'})) { - my $R = $Opt{'round'}; - $R =~ s/([a-z]+)=(\d+)/($Round{$1}=$2, "")/eg; -} - -length($Opt{'undefined'}) && ($Udef = $Opt{'undefined'}); -# Kunne vært et eget script på grunn av at det gjør sine helt egne -# greier, men like greit å samle det på en plass. -# FIXME: Fjerner ikke første duplikatentryen. -# FIXME: Se om det går å få flytta den inn i print_entry() så man -# slipper å ha to gptrans_conv’er i pipen. -# FIXME: Legg inn alle formatene. -if ($Opt{'comment-out-dups'}) { - # Comment out areas without reception {{{ - my ($start_date, $end_date, $found_dup) = ("", "", 0); - my @Dup = (); - while (<>) { - if ( - m{^ - 1\x20 - (\S+)\x20 # Lat - (\S+)\x20 # Lon - (\S+)\x20 # Speed - (\S+)\x20 # Unknown - (\d\d)/(\d\d)/(\d\d\d\d)\x20 # Month/Day/Year — urgh - (\d\d):(\d\d):(\d\d) # Hour:Min:Sec - }x - ) { - # {{{ - my ($lat_val, $lon_val, $Speed, $Unkn, - $Month, $Day, $Year, $Hour, $Min, $Sec) = - ($1, $2, $3, $4, - $5, $6, $7, $8, $9, $10); - if (($lat_val eq $last_lat) && ($lon_val eq $last_lon)) { - unless ($found_dup) { - $start_date = "$Year$Month${Day}T$Hour$Min$Sec"; - @Dup = (); - $found_dup = 1; - } - push(@Dup, "# $_"); - $end_date = "$Year$Month${Day}T$Hour$Min$Sec"; - } else { - if ($found_dup) { - print("# $start_date-$end_date: " . - "CO: No signal \x7B\x7B\x7B\n"); - for (@Dup) { - print($_); - } - print("# $start_date-$end_date: " . - "CO: No signal \x7D\x7D\x7D\n# move\n$_"); - $found_dup = 0; - } else { - print($_); - } - } - $last_lat = $lat_val; - $last_lon = $lon_val; - # }}} - } else { - if ($found_dup) { - push(@Dup, $_); - } else { - print($_); - } - } - } - if ($found_dup) { - print("# $start_date-$end_date: " . - "CO: No signal \x7B\x7B\x7B\n"); - for (@Dup) { - print($_); - } - print("# $start_date-$end_date: " . - "CO: No signal \x7D\x7D\x7D\n# move\n"); - $found_dup = 0; - } - exit(0); - # }}} -} - -$Opt{'save-to-file'} eq "\n" && print_header(*STDOUT); - -my @first_lines; -my $xml_data; -my $data_line = ""; -our $curr_file = ""; - -my $from_stdin = scalar(@ARGV) ? 0 : 1; - -$from_stdin && push(@ARGV, "-"); - -for $curr_file (@ARGV) { - # Scan through stdin or specified files and send every GPS entry to - # print_entry() - # {{{ - print(STDERR "$progname: Opening \"$curr_file\" for read\n") if $Opt{'verbose'}; - if (open(CurrFP, "<$curr_file")) { - # {{{ - while () { - $data_line = $_; - %Dat = ( - 'year' => '', 'month' => '', 'day' => '', - 'hour' => '', 'min' => '', 'sec' => '', - 'epoch' => '', - 'date-format' => '', - 'lat' => '', 'lon' => '', - 'ele' => '', - 'desc' => '', - 'error' => "", - 'type' => 'tp', - ); - - $Opt{'epoch'} && ($Dat{'date-format'} = "epoch"); - $Opt{'short-date'} && ($Dat{'date-format'} = "short"); - - if ($Opt{'save-to-file'} ne "\n") { - push(@first_lines, $_); - } - s/^# error // && ($Dat{'error'} = "error"); - s/^# ?// && ($Dat{'error'} = "desc"); - $xml_data = ""; - if (m#^<(e?tp)\b(.*?)>(.*?)\s*$#) { - # gpsml — The main storage format {{{ - my ($Elem, $Props, $Data) = - ( $1, $2, $3); - my $err_str = ($Props =~ /\berr="(.*?)"/) ? $1 : "error"; - $Elem eq "etp" && ($Dat{'error'} = $err_str); - my $Time = ""; - $Data =~ m## && ($Time = $1); - $Time =~ s{ - (\d\d\d\d)-?(\d\d)-?(\d\d)[T ](\d\d):?(\d\d):?([\d\.]+?)Z - } { - ($Dat{'year'}, $Dat{'month'}, $Dat{'day'}, - $Dat{'hour'}, $Dat{'min'}, $Dat{'sec'}) = - ( $1, $2, $3, - $4, $5, $6); - ""; - }ex; - $Data =~ m#($DIGIT*?)# && ($Dat{'lat'} = $1); - $Data =~ m#($DIGIT*?)# && ($Dat{'lon'} = $1); - $Data =~ m#($DIGIT*?)# && ($Dat{'ele'} = $1); - $Data =~ m#(.*?)# && ($Dat{'desc'} = $1); - print_entry(%Dat); - # }}} - } elsif (m#^#) { - $found_move = 1; - } elsif (m#^<(title|pause)\b.*?>(.*?)#) { - $Dat{'type'} = $1; - $Dat{$1} = $2; - print_entry(%Dat); - } elsif (m#^(.*$)#s) { - $Dat{'type'} = "desc"; - my $Txt = $1; - until ($Txt =~ m##s) { - $Txt .= ; - } - $Txt =~ s#^(.*)(.*$)#$1#s; - $Dat{'desc'} = $Txt; - print_entry(%Dat); - } elsif (/); - if (!length($Opt{'output-format'})) { - $Opt{'output-format'} = "gpx"; - print_header(*STDOUT); - } - read_xmlfile($xml_data); - last; - } elsif (/^move$/) { - $found_move = 1; - } elsif (m#^(\d+)\t($DIGIT+)\t($DIGIT+)\t($DIGIT)#) { - # CSV format, epoch style {{{ - my ($ep_time, $lon_val, $lat_val, $Alt) = - ( $1, $2, $3, $4); - $Dat{'epoch'} = $ep_time; - ($Dat{'sec'}, $Dat{'min'}, $Dat{'hour'}, - $Dat{'day'}, $Dat{'month'}, $Dat{'year'}, - $Dat{'wday'}, $Dat{'yday'}) = gmtime($ep_time); - $Dat{'month'}++; # Urgh Ⅰ - $Dat{'year'} += 1900; # Urgh Ⅱ - print_entry(%Dat); - # }}} - } elsif ( - m{^ - (\d\d\d\d)-?(\d\d)-?(\d\d)[T\ ](\d\d):?(\d\d):?(\d\d)Z?\t - ($DIGIT+)\t($DIGIT+)\t($DIGIT) - }x - ) { - # CSV format, human-readable date format {{{ - ($Dat{'year'}, $Dat{'month'}, $Dat{'day'}, - $Dat{'hour'}, $Dat{'min'}, $Dat{'sec'}, - $Dat{'lon'}, $Dat{'lat'}, $Dat{'ele'}) = - ($1, $2, $3, - $4, $5, $6, - $7, $8, $9); - print_entry(%Dat); - # }}} - } elsif (/^Trackpoint\t/) { - # Trackpoint\tN60.41630 E5.31675\t09.02.2006 20:24:37 (UTC)\t13.6 m\t\t93.9 m\t00:00:06\t56 kph\t123° true {{{ - # - # Trackpoint\t - # N60.41630 E5.31675\t - # 09.02.2006 20:24:37 (UTC)\t - # 13.6 m\t - # \t - # 93.9 m\t - # 00:00:06\t - # 56 kph\t - # 123° true - my $Orig = $_; - $Orig =~ s/[\r\n]+$//; - my ($Marker_f, $Position_f, $Time_f, $Alt_f, $Depth_f, - $Leglength_f, $Legtime_f, $Legspeed_f, $Legcourse_f) = - split(/\t/, $Orig . - # Nødløsning for å unngå at variabler - # blir udefinert. - "\t\t\t\t\t\t\t\t\t\t" - ); - D(join("", - "Position_f=\"$Position_f\" \x7B\x7B\x7B\n", - "Time_f=\"$Time_f\"\n", - "Alt_f=\"$Alt_f\"\n", - "Depth_f=\"$Depth_f\"\n", - "Leglength_f=\"$Leglength_f\"\n", - "Legtime_f=\"$Legtime_f\"\n", - "Legspeed_f=\"$Legspeed_f\"\n", - "Legcourse_f=\"$Legcourse_f\" \x7D\x7D\x7D\n", - )); - my ($NS, $WE, - $Alt_unit, - $Leglength, - $Legtime_hour, $Legtime_min, $Legtime_sec, - $Legspeed, $Legspeed_unit, - $Legcourse - ) = ("", "", "", "", "", "", "", "", "", "", "", "", "", - "", "", "", "", "", "", "", "", "", ""); - ($Position_f =~ /^(N|S)([\d\.]+) (W|E)([\d\.]+)/) && - ($NS = $1, $Dat{'lat'} = $2, $WE = $3, $Dat{'lon'} = $4); - ($Time_f =~ /^(\d+)\.(\d+)\.(\d+) (\d+):(\d+):(\d+) \((.+?)\)/) && - ($Dat{'day'} = $1, $Dat{'month'} = $2, $Dat{'year'} = $3, - $Dat{'hour'} = $4, $Dat{'min'} = $5, $Dat{'sec'} = $6); - ($Alt_f =~ /^($DIGIT+) (.*?)/) && - ($Dat{'ele'} = $1, $Alt_unit = $2); - D("ele = \"$Dat{'ele'}\""); - ($NS eq "S") && ($Dat{'lat'} = 0-$Dat{'lat'}); - ($WE eq "W") && ($Dat{'lon'} = 0-$Dat{'lon'}); - # MapSource in win xp writes YYYY, but YY in win98se. - ( - defined($Dat{'year'}) - && $Dat{'year'} =~ /\d/ - && $Dat{'year'} < 1900 - ) && ($Dat{'year'} += 2000); - print_entry(%Dat); - # }}} - } elsif (/^Track\t(.*?)\t/) { - $Dat{'title'} = txt_to_xml($1); - $Dat{'type'} = "title"; - $found_move = 1; - print_entry(%Dat); - } elsif ( - m{^ - T\t - (\d\d)/(\d\d)/(\d\d\d\d)\ (\d\d):(\d\d):(\d\d)\t - (.+)\xB0(.+)'(.+)"\t - (.+)\xB0(.+)'(.+)" - }x - ) { - # T 09/01/2002 11:51:26 60°23'36.3" 5°19'35.9" {{{ - my ($lat_d, $lat_m, $lat_s, $lon_d, $lon_m, $lon_s); - ($Dat{'month'}, $Dat{'day'}, $Dat{'year'}, - $Dat{'hour'}, $Dat{'min'}, $Dat{'sec'}, - $lat_d, $lat_m, $lat_s, - $lon_d, $lon_m, $lon_s) = - ($1, $2, $3, - $4, $5, $6, - $7, $8, $9, - $10, $11, $12); - my $Flat = defined($Round{'lat'}) ? ".$Round{'lat'}" : ""; - my $Flon = defined($Round{'lon'}) ? ".$Round{'lon'}" : ""; - $Dat{'lat'} = sprintf("%${Flat}f", - 1.0*($lat_d+($lat_m/60)+($lat_s/3600))); - $Dat{'lon'} = sprintf("%${Flon}f", - 1.0*$lon_d+($lon_m/60)+($lon_s/3600)); - print_entry(%Dat); - # }}} - } elsif ( - m{^ - 1\ (\S+)\ (\S+)\ (\S+)\ (\S+)\x20 - (\d\d)/(\d\d)/(\d\d\d\d)\ (\d\d):(\d\d):(\d\d) - }x - ) { - # 1 60.3938222 5.3238754 17.3 0 09/01/2002 14:18:23 {{{ - ($Dat{'lat'}, $Dat{'lon'}, $Dat{'speed'}, - $Dat{'unkn'}, - $Dat{'month'}, $Dat{'day'}, $Dat{'year'}, - $Dat{'hour'}, $Dat{'min'}, $Dat{'sec'}) = - ($1, $2, $3, - $4, - $5, $6, $7, - $8, $9, $10); - print_entry(%Dat); - # }}} - } elsif (/^ - # @020721221336N6048353E00701826S015-00001E4859N1673U0000 {{{ - # Regexp {{{ - (@) # @ - (\d\d) # Year - (\d\d) # Month - (\d\d) # Day - (\d\d) # Hours - (\d\d) # Minutes - (\d\d) # Seconds - ([NS]) # N|S - (\d\d) # Latitude degree - (\d\d) # Latitude minute - (\d\d\d) # Latitude minute decimals - ([EW]) # E|W - (\d\d\d) # Longitude degree - (\d\d) # Longitude minute - (\d\d\d) # Longitude minute degree - (....) # Accurancy - (......) # Elevation - (...............) - # }}} - /x) { - my ($NS, $EW, $lat_deg, $lat_degmin, $lat_mindec, $lon_deg, - $lon_degmin, $lon_mindec); - ($Dat{'year'}, $Dat{'month'}, $Dat{'day'}, $Dat{'hour'}, - $Dat{'min'}, $Dat{'sec'}, $NS, $lat_deg, - $lat_degmin, $lat_mindec, $EW, - $lon_deg, $lon_degmin, $lon_mindec, - $Dat{'accur'}, $Dat{'ele'}, $Dat{'unknown'}) = - ($2+2000, $3, $4, $5, - $6, $7, $8, $9, - $10, $11, $12, - $13, $14, $15, - $16, $17, $18); - my $ep_time = timegm_nocheck( - $Dat{'sec'}, $Dat{'min'}, $Dat{'hour'}, - $Dat{'day'}, $Dat{'month'}-1, $Dat{'year'} - ); - $last_time = $ep_time; - my $Flat = defined($Round{'lat'}) ? ".$Round{'lat'}" : ""; - my $Flon = defined($Round{'lon'}) ? ".$Round{'lon'}" : ""; - my $tmp_lon = sprintf( - "%${Flon}f", - $lon_deg + - $lon_degmin/60 + - $lon_mindec/60000); - my $tmp_lat = sprintf("%${Flat}f", - $lat_deg + - $lat_degmin/60 + - $lat_mindec/60000); - ($NS eq "S") && ($tmp_lat = 0-$tmp_lat); - ($EW eq "W") && ($tmp_lon = 0-$tmp_lon); - $Dat{'lat'} = $tmp_lat; - $Dat{'lon'} = $tmp_lon; - print_entry(%Dat); - # }}} - } elsif (/^(@)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(_{42})/) { - # @020721221336__________________________________________ {{{ - ($Dat{'year'}, $Dat{'month'}, $Dat{'day'}, - $Dat{'hour'}, $Dat{'min'}, $Dat{'sec'}, $Dat{'rest'}) = - ($2+2000, $3, $4, - $5, $6, $7, $8); - $Dat{'error'} = "nosignal"; - print_entry(%Dat); - # }}} - } elsif ( - # \t2003-12-02 10:06:17\tN50 05 31.2\tE14 26 10.4\t165.003417969 - # (GPSMan) - # {{{ - /^ - \t - (\d\d\d\d)-(\d\d)-(\d\d)\ (\d\d):(\d\d):(\d\d) - \t - (N|S)(\d+)\ (\d\d)\ (\d\d\.\d) - \t - (W|E)(\d+)\ (\d\d)\ (\d\d\.\d) - \t - ($DIGIT+) - $ - /x) { - ($Dat{'year'}, $Dat{'month'}, $Dat{'day'}, - $Dat{'hour'}, $Dat{'min'}, $Dat{'sec'}) = - ($1, $2, $3, $4, $5, $6); - my $NS = $7; - $Dat{'lat'} = dms_to_ddd($8, $9, $10); - my $WE = $11; - $Dat{'lon'} = dms_to_ddd($12, $13, $14); - $Dat{'ele'} = $15; - $NS eq "S" && ($Dat{'lat'} = 0 - $Dat{'lat'}); - $WE eq "W" && ($Dat{'lon'} = 0 - $Dat{'lon'}); - print_entry(%Dat); - # }}} - } elsif (/^!TS:$/) { - $found_move = 1; - print_entry(%Dat); - } elsif (/^!T:\t(.*?)\t/) { - $Dat{'title'} = $1; - $Dat{'type'} = "title"; - print_entry(%Dat); - } elsif (/^xmaplog /) { - # NOP - } elsif (/^$/) { - ($Opt{'output-format'} eq "csv") - && ($Opt{'save-to-file'} eq "\n") - && print("\n"); - } elsif (/^Pause: /) { - # NOP, is here to cope with old files I’ve lying around. - } elsif ($Dat{'error'} eq "desc") { - my $Comment = $_; - if (defined($Comment)) { - $Comment =~ s/^\s*(.*?)\s*$/$1/; - if ($Opt{'output-format'} eq "gpsml") { - $Dat{'desc'} = txt_to_xml($Comment); - $Dat{'type'} = "desc"; - print_entry(%Dat); - } - } - } else { - $Opt{'verbose'} && warn("Line $.: Unknown: \"$_\"\n"); - } - } - # }}} - } else { - warn("$progname: $curr_file: Cannot open file for read: $!\n"); - } - # }}} -} - -print_footer(*STDOUT); - -exit(0); - -sub read_xmlfile { - # {{{ - my $Txt = join("", @_); - $Txt =~ s///gs; - $Txt =~ s#(.*?)#print_gpx($1)#gse; - # }}} -} - -sub print_gpx { - # {{{ - my $Orig = shift; - my $Str = $Orig; - # D("print_xml_gps(\"$Orig\")\n"); - $Str =~ s///gs; - my $fromdate_str = ""; - if ($Opt{'from-date'}) { - $fromdate_str = "date >= '$Opt{'from-date'}' AND "; - } - if ($Opt{'output-format'} =~ /^(pgwtab|pgwupd)$/) { - # {{{ - $Str =~ - s{ - (.*?) - } - { - my $attr_wpt = $1; - my $el_wpt = $2; - my ($Lat, $Lon, $Name, $Ele, $Type, $Time, $Cmt, $Desc, $Src, $Sym) = - ('\N', '\N', '\N', '\N', '\N', '\N', '\N', '\N', '\N', '\N'); - - $attr_wpt =~ /.*lat="($DIGIT+?)"/s && - ($Lat = postgresql_copy_safe($1)); - $attr_wpt =~ /.*lon="($DIGIT+?)"/s && - ($Lon = postgresql_copy_safe($1)); - $el_wpt =~ /.*(.*?)<\/name>/s && - ($Name = postgresql_copy_safe(xml_to_txt($2))); - $el_wpt =~ /.*(.*?)<\/ele>/s && - ($Ele = postgresql_copy_safe(xml_to_txt($2))); - $el_wpt =~ /.*(.*?)<\/type>/s && - ($Type = postgresql_copy_safe(xml_to_txt($2))); - $el_wpt =~ /.*(.*?)<\/time>/s && - ($Time = postgresql_copy_safe(xml_to_txt($2))); - $el_wpt =~ /.*(.*?)<\/cmt>/s && - ($Cmt = postgresql_copy_safe(xml_to_txt($2))); - $el_wpt =~ /.*(.*?)<\/desc>/s && - ($Desc = postgresql_copy_safe(xml_to_txt($2))); - $el_wpt =~ /.*(.*?)<\/src>/s && - ($Src = postgresql_copy_safe(xml_to_txt($2))); - $el_wpt =~ /.*(.*?)<\/sym>/s && - ($Sym = postgresql_copy_safe(xml_to_txt($2))); - - if ($Opt{'output-format'} eq "pgwtab") { - print( - join("\t", - "($Lat,$Lon)", - $Name, - $Ele, - $Type, - $Time, - $Cmt, - $Desc, - $Src, - $Sym - ) . "\n" - ); - } elsif ($Opt{'output-format'} eq "pgwupd") { - $Name =~ s/'/''/gs; - print(join("\n", - "BEGIN;", - " UPDATE logg SET sted = clname(coor) " . - "WHERE $fromdate_str(point($Lat,$Lon) <-> coor) < 0.05;", - " UPDATE logg SET dist = cldist(coor) " . - "WHERE $fromdate_str(point($Lat,$Lon) <-> coor) < 0.05;", - "COMMIT;" - ) . "\n"); - } - ""; - }gsex; - # }}} - } else { - # {{{ - $Str =~ - s{ - (.*?) - } - { - my $el_trk = $2; - $el_trk =~ - s{ - (.*?) - }{ - my %tmp_dat = (); - $tmp_dat{'title'} = $2; - $tmp_dat{'type'} = "title"; - $tmp_dat{'error'} = ""; - print_entry(%tmp_dat); - ""; - }sex; - $el_trk =~ - s{ - (.*?) - } - { - my $el_trkseg = $2; - $el_trkseg =~ - s{ - (.*?) - } - { - my ($attr_trkpt, $el_trkpt) = - ( $1, $2); - %Dat = ( - 'year' => '', 'month' => '', 'day' => '', - 'hour' => '', 'min' => '', 'sec' => '', - 'epoch' => '', - 'date-format' => '', - 'lat' => '', 'lon' => '', - 'ele' => '', - 'desc' => '', - 'error' => "", - 'type' => 'tp', - ); - ($attr_trkpt =~ /\blon="(.*?)"/) && ($Dat{'lon'} = $1); - ($attr_trkpt =~ /\blat="(.*?)"/) && ($Dat{'lat'} = $1); - ($el_trkpt =~ m#(.*?)#) && ($Dat{'ele'} = $1); - if ( - $el_trkpt =~ - m{ - - }x - ) { - ($Dat{'year'}, $Dat{'month'}, $Dat{'day'}, - $Dat{'hour'}, $Dat{'min'}, $Dat{'sec'}) = - ($1, $2, $3, $4, $5, $6); - } - print_entry(%Dat); - ""; - }gsex; - $found_move = 1; - }gsex; - $found_move = 1; - }gsex; - # }}} - } - # }}} -} - -sub print_header { - # {{{ - local *OutFP = shift; - if ($Opt{'output-format'} eq "gpsml") { - print(OutFP join("", - "\n", - "\n", - "\n", - )); - } elsif ($Opt{'output-format'} eq "gpstrans") { - print(OutFP "Format: DMS UTC Offset: 0.00 hrs " . - "Datum[100]: WGS 84\n"); - } elsif ($Opt{'output-format'} eq "gpx") { - print(OutFP join("", - qq{\n}, - qq{\n}, - qq{$Spc$Spc\n}, - qq{$Spc$Spc$Spc$Spc\n}, - )); - } elsif ($Opt{'output-format'} eq "ps") { - print(OutFP ps_header(532, 6034, 533, 6040)); - print(OutFP "*u\n"); - } elsif ($Opt{'output-format'} eq "svg") { - print(OutFP join("", - "\n", - "\n", - "\n", - "$Spc$Spc\n", - "$Spc$Spc\n", - )); - } - # }}} -} - -sub print_footer { - # Print footer {{{ - local *OutFP = shift; - if ($Opt{'output-format'} eq "gpsml") { - print(OutFP join("", - "\n", - "\n", - )); - } elsif ($Opt{'output-format'} eq "gpx") { - print(OutFP join("", - "$Spc$Spc$Spc$Spc\n", - "$Spc$Spc\n", - "\n", - )); - } elsif ($Opt{'output-format'} eq "poscount") { - while (my ($l_name, $l_val) = each %Poscount) { - $l_name =~ /^(.+?),(.+?)$/ - && print(OutFP "$1\t$2\t$l_val\n"); - } - } elsif ($Opt{'output-format'} eq "ps") { - print(OutFP join("", - "*U\n", - "%%Trailer\n", - "%%EOF\n", - )); - } elsif ($Opt{'output-format'} eq "svg") { - print(OutFP "\"/>\n\n"); - } - # }}} -} - -sub print_entry { - # Print a GPS entry with time, latitude, longitude and elevation in - # various formats - # {{{ - my %Dat = @_; - defined($Dat{'desc'}) || ($Dat{'desc'} = ""); - defined($Dat{'ele'}) || ($Dat{'ele'} = ""); - defined($Dat{'lat'}) || ($Dat{'lat'} = ""); - defined($Dat{'lon'}) || ($Dat{'lon'} = ""); - defined($Dat{'year'}) || ($Dat{'year'} = ""); - my $print_time = length($Dat{'year'}) ? 1 : 0; - my $print_pos = (length($Dat{'lat'}) && length($Dat{'lon'})) ? 1 : 0; - if (!$print_pos) { - $Dat{'lat'} = $Dat{'lon'} = ""; - } - my $print_ele = length($Dat{'ele'}) ? 1 : 0; - my $print_desc = length($Dat{'desc'}) ? 1 : 0; - my $Line = ""; - D("print_entry(\"" . join("\", \"", @_) . "\");"); - my $ep_time; - - if ($Opt{'near'} && $print_pos) { - $Line .= sprintf("%s ", - list_nearest_waypoints($Dat{'lat'}, $Dat{'lon'})); - } - - if (length($Opt{'round'})) { - for my $Tmp (qw{ lat lon ele }) { - if (defined($Round{$Tmp}) && length($Dat{$Tmp})) { - D("Tmp = '$Tmp'"); - ($Dat{$Tmp} = 1.0 * sprintf("%.$Round{$Tmp}f", $Dat{$Tmp})); - } - } - } - - if ($Opt{'output-format'} eq "poscount") { - if (!length($Dat{'error'})) { - my $Name = "$Dat{'lon'},$Dat{'lat'}"; - defined($Poscount{$Name}) || ($Poscount{$Name} = 0); - $Poscount{$Name}++; - } - return; - } - - if ($print_time) { - $ep_time = timegm_nocheck( - $Dat{'sec'}, $Dat{'min'}, $Dat{'hour'}, - $Dat{'day'}, $Dat{'month'} - 1, $Dat{'year'} - ); - $Dat{'epoch'} = $ep_time; - $Dat{'year'} = sprintf("%04u", $Dat{'year'}); - $Dat{'month'} = sprintf("%02u", $Dat{'month'}); - $Dat{'day'} = sprintf("%02u", $Dat{'day'}); - $Dat{'hour'} = sprintf("%02u", $Dat{'hour'}); - $Dat{'min'} = sprintf("%02u", $Dat{'min'}); - $Dat{'sec'} = sprintf("%02u", $Dat{'sec'}); - if ($Opt{'chronology'}) { - if ($last_time > $ep_time && !length($Dat{'error'})) { - warn(sprintf( - "%s: $curr_file: \"%sZ\": Next date is %s in the past (%sZ)\n", - $progname, sec_to_string($last_time, "T"), - sec_to_readable($last_time-$ep_time), - sec_to_string($ep_time, "T") - )); - # FIXME: Make --fix work with gpx. - if ($Opt{'fix'} && ($Opt{'output-format'} !~ /^gpx$/)) { - $Dat{'error'} = "chrono"; - } - } elsif ($last_time == $ep_time && !length($Dat{'error'})) { - warn(sprintf( - "%s: $curr_file: \"%sZ\": Duplicated time\n", - $progname, sec_to_string($last_time, "T") - )); - # FIXME: Make --fix work with gpx. - if ($Opt{'fix'} && ($Opt{'output-format'} !~ /^gpx$/)) { - $Dat{'error'} = "duptime"; - } - } - } - } else { - $ep_time = 0; - $Dat{'year'} = 0; - $Dat{'month'} = 0; - $Dat{'day'} = 0; - $Dat{'hour'} = 0; - $Dat{'min'} = 0; - $Dat{'sec'} = 0; - } - - if ($Opt{'save-to-file'} ne "\n") { - # {{{ - $print_time || return; - my $base_name = "$Dat{'year'}$Dat{'month'}$Dat{'day'}T" . - "$Dat{'hour'}$Dat{'min'}$Dat{'sec'}Z" . - "$Opt{'save-to-file'}"; - my $file_name = $base_name; - if (-e $file_name) { - for (my $a = 1; (-e $file_name) && ($a < 1000); $a++) { - $file_name = "$base_name.dup_$a"; - } - if (-e $file_name) { - die("$progname: $base_name: File already exists, and ran " . - "out of attempts to create unique file name\n"); - } - if ($Opt{'verbose'}) { - warn("$progname: $base_name: File already exists, using " . - "unique name \"$file_name\" instead\n"); - } - } - if (open(ToFP, ">", $file_name)) { - print_header(*ToFP); - print(ToFP ( - $from_stdin - ? @first_lines - : ()), - (length($xml_data) - ? $xml_data - : <>) - ) || die("$progname: $file_name: Cannot write to file: $!\n"); - print_footer(*ToFP); - close(ToFP); - if ($Opt{'output-format'} eq "gpsml") { - printf("%s\n", - txt_to_xml($file_name)); - } elsif ($Opt{'output-format'} eq "gpx") { - printf("\n", - txt_to_xml($file_name)); - } else { - print("$progname: Saved unconverted data to \"$file_name\"\n"); - } - exit 0; - } else { - die("$progname: $file_name: Cannot create file: $!\n"); - } - # }}} - } - - my $pause_len = 0; - my $do_print = 1; - - if ($Dat{'type'} eq "tp") { - # {{{ - if ($Opt{'require'}) { - $Req{'time'} && !$print_time && return; - $Req{'position'} && !$print_pos && return; - $Req{'ele'} && !$print_ele && return; - } - - if ($Opt{'inside'} || $Opt{'outside'}) { - if ( - ($Dat{'lat'} < $lat1) || - ($Dat{'lat'} > $lat2) || - ($Dat{'lon'} < $lon1) || - ($Dat{'lon'} > $lon2) - ) { - $Opt{'inside'} && return; - } else { - $Opt{'outside'} && return; - } - } - - if ($Opt{'output-format'} eq "ps") { - $Dat{'lon'} *= 100; - $Dat{'lat'} *= 100; - } - - if ( - $Opt{'skip-dups'} - && ($Dat{'lon'} eq $last_lon) - && ($Dat{'lat'} eq $last_lat) - ) { - if ($Opt{'output-format'} eq 'gpsml') { - $Dat{'error'} = "dup"; - } else { - $do_print = 0; - } - } else { - $do_print = 1; - } - - if ( - $Opt{'create-breaks'} - && $ep_time-$last_time > $PAUSE_LIMIT - && $last_time - ) { - $pause_len = $ep_time-$last_time; - D("pause_len set to '$pause_len'"); - } - - if ($pause_len) { - if ($Opt{'output-format'} eq "gpsml") { - $Line .= sprintf("%s\n", - sec_to_readable($ep_time-$last_time)); - } elsif ($Opt{'output-format'} eq "clean") { - $pause_len && ($Line .= "\n"); - } elsif ($Opt{'output-format'} eq "csv") { - $Line .= sprintf("# Pause: %s\n# move\n", - sec_to_readable($ep_time-$last_time)); - } elsif ($Opt{'output-format'} eq "xgraph") { - $pause_len && ($Line .= "move "); - } - } - # }}} - } - - if ($do_print) { - # Valid data was found, send to stdout {{{ - unless ($first_time) { - $first_time = $ep_time; - } - if ($Opt{'double-y-scale'} && length($Dat{'lat'})) { - $Dat{'lat'} *= 2; - } - if ($Opt{'output-format'} eq "gpsml") { - if ($Dat{'type'} eq "tp") { - $Dat{'format'} = "gpsml"; - $Line .= trackpoint(%Dat); - } elsif ($Dat{'type'} =~ /^(pause|desc|title)$/) { - $Line .= sprintf("<%s>%s\n", - $1, - $Dat{$1}, - $1); - } - } elsif ($Opt{'output-format'} eq "pgtab") { - if ($Dat{'type'} eq "tp" && !length($Dat{'error'})) { - $Dat{'format'} = "pgtab"; - $Line .= trackpoint(%Dat); - } - } elsif ($Opt{'output-format'} eq "xgraph") { - if ($print_pos && !length($Dat{'error'})) { - $Dat{'format'} = "xgraph"; - $Line .= trackpoint(%Dat); - } - } elsif($Opt{'output-format'} eq "gpstrans") { - if ($print_pos && !length($Dat{'error'})) { - $Dat{'format'} = "gpstrans"; - $Line .= trackpoint(%Dat); - } - } elsif($Opt{'output-format'} eq "gpx") { - $Dat{'format'} = "gpx"; - if ($Dat{'type'} =~ /^(tp|title)$/) { - $Line .= trackpoint(%Dat); - } - } elsif ($Opt{'output-format'} eq "clean") { - if ($Dat{'type'} eq "tp" && !length($Dat{'error'})) { - $Dat{'format'} = "clean"; - $Line .= trackpoint(%Dat); - } - } elsif ($Opt{'output-format'} eq "ps") { - $Line .= ( - $pause_len - ? "f\n$Dat{'lon'} $Dat{'lat'} m\n" - : "$Dat{'lon'} $Dat{'lat'} l\n" - ); - } elsif ($Opt{'output-format'} eq "svg") { - $Line .= ( - ($last_lon == 1000) || $pause_len - ? join("", - "$svg_start_thing\n"; - } - $found_move = 0; - } - print($Line); - } - $print_time && ($last_time = $ep_time); - if ($print_pos) { - $last_lon = $Dat{'lon'}; - $last_lat = $Dat{'lat'}; - } - $last_line = $data_line; - $svg_start_thing = "\"/>\n"; - # }}} -} - -sub ps_header { - # Send a Postscript header to stdout {{{ - my ($bl_lon, $bl_lat, $br_lon, $br_lat) = @_; - my $Date = sec_to_string(time); - return(join("", - "%!PS-Adobe-3.0 EPSF-3.0\n", - "%%Creator: $rcs_id\n", - "%%Title:\n", - "%%CreationDate: $Date\n", - "%%BoundingBox: $bl_lon $bl_lat $br_lon $br_lat\n", - "%%DocumentData: Clean7Bit\n", - "%%EndComments\n", - "%%BeginProlog\n", - "/bd { bind def } bind def\n", - "/incompound false def\n", - "/m { moveto } bd\n", - "/l { lineto } bd\n", - "/c { curveto } bd\n", - "/F { incompound not {fill} if } bd\n", - "/f { closepath F } bd\n", - "/S { stroke } bd\n", - "/*u { /incompound true def } bd\n", - "/*U { /incompound false def f} bd\n", - "/k { setcmykcolor } bd\n", - "/K { k } bd\n", - "%%EndProlog\n", - "%%BeginSetup\n", - "%%EndSetup\n", - )); - # }}} -} - -sub print_version { - # Print program version {{{ - for (@main::version_array) { - print("$_\n"); - } - exit(0); - # }}} -} # print_version() - -sub usage { - # Send the help message to stdout {{{ - my $Retval = shift; - - print(<= $verbose_level) { - print(STDERR "$progname: $Txt\n"); - } - # }}} -} # msg() - -__END__ - -# Law talk {{{ -# Copyleft © Øyvind A. Holm -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA -# }}} - -# vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w : -# End of file $Id$ diff --git a/branches/gpst.gpsman-format/gpst-pic b/branches/gpst.gpsman-format/gpst-pic deleted file mode 100755 index d9172a9..0000000 --- a/branches/gpst.gpsman-format/gpst-pic +++ /dev/null @@ -1,270 +0,0 @@ -#!/usr/bin/perl -w - -#======================================================================= -# $Id$ -# Extract EXIF data from pictures for use with COPY in Postgres -# -# Character set: UTF-8 -# ©opyleft 2008– Øyvind A. Holm -# License: GNU General Public License version 2 or later, see end of -# file for legal stuff. -#======================================================================= - -BEGIN { - our @version_array; -} - -use strict; -use Getopt::Long; - -BEGIN { - push(@INC, "$ENV{'HOME'}/bin/src/gpstools"); - our @version_array; -} - -use GPST; - -$| = 1; - -our $Debug = 0; -our $NA = '\N'; - -our %Opt = ( - 'author' => '', - 'debug' => 0, - 'description' => '', - 'help' => 0, - 'verbose' => 0, - 'version' => 0, -); - -our $progname = $0; -$progname =~ s/^.*\/(.*?)$/$1/; - -my $rcs_id = '$Id$'; -my $id_date = $rcs_id; -$id_date =~ s/^.*?\d+ (\d\d\d\d-.*?\d\d:\d\d:\d\d\S+).*/$1/; - -push(@main::version_array, $rcs_id); - -Getopt::Long::Configure("bundling"); -GetOptions( - "author|a=s" => \$Opt{'author'}, - "debug" => \$Opt{'debug'}, - "description|d=s" => \$Opt{'description'}, - "help|h" => \$Opt{'help'}, - "verbose|v+" => \$Opt{'verbose'}, - "version" => \$Opt{'version'}, -) || die("$progname: Option error. Use -h for help.\n"); - -$Opt{'debug'} && ($Debug = 1); -$Opt{'help'} && usage(0); -$Opt{'version'} && print_version(); - -if ($#ARGV < 0) { - while (<>) { - chomp(); - print_entry($_); - } -} else { - for my $fname (@ARGV) { - print_entry($fname); - } -} - -sub print_entry { - # {{{ - my $filename = shift; - my $Retval = 0; - my ($date, $coor) = - ( '', ''); - my @Dates = (); - local *PicFP; - D("filename = '$filename'"); - if (open(PicFP, "exifprobe -L \"$filename\" |")) { # FIXME: Quick & Dirty™ - while () { - if (/DateTime/) { - s/^.*'(.*?)'.*$/$1/; - chomp($date = $_); - $date =~ s/^(\d\d\d\d)(.)(\d\d)(.)(\d\d)(.)(\d\d:\d\d:\d\d)(.*)/$1-$3-$5 $7$8/; - D("date = '$date'"); - push(@Dates, $date); - } - } - close(PicFP); - @Dates = reverse sort @Dates; - $date = $Dates[0]; - defined($date) || ($date = ''); - D("final date = '$date'"); - if ($date =~ /^\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d$/) { - $filename =~ s/^.*\/(.*?)$/$1/; - my $Output = join("\t", - postgresql_copy_safe($date), - length($coor) ? postgresql_copy_safe($coor) : $NA, - length($Opt{'description'}) ? postgresql_copy_safe($Opt{'description'}) : $NA, - length($filename) ? postgresql_copy_safe($filename) : $NA, - length($Opt{'author'}) ? postgresql_copy_safe($Opt{'author'}) : $NA - ) . "\n"; - print($Output); - $Opt{'verbose'} && print(STDERR $Output); - } else { - if (length($date)) { - warn("$filename: $date: Invalid date format"); - $Retval = 2; - } - } - } else { - warn("$filename: Cannot open exifprobe(1) pipe: $!"); - $Retval = 1; - } - return($Retval); - # }}} -} # print_entry() - -sub print_version { - # Print program version {{{ - for (@main::version_array) { - print("$_\n"); - } - exit(0); - # }}} -} # print_version() - -sub usage { - # Send the help message to stdout {{{ - my $Retval = shift; - - print(<= $verbose_level) { - print(STDERR "$progname: $Txt\n"); - } - # }}} -} # msg() - -sub D { - # Print a debugging message {{{ - $Debug || return; - my @call_info = caller; - chomp(my $Txt = shift); - my $File = $call_info[1]; - $File =~ s#\\#/#g; - $File =~ s#^.*/(.*?)$#$1#; - print(STDERR "$File:$call_info[2] $$ $Txt\n"); - return(""); - # }}} -} # D() - -__END__ - -# Plain Old Documentation (POD) {{{ - -=pod - -=head1 NAME - - - -=head1 REVISION - -$Id$ - -=head1 SYNOPSIS - - [options] [file [files [...]]] - -=head1 DESCRIPTION - - - -=head1 OPTIONS - -=over 4 - -=item B<-h>, B<--help> - -Print a brief help summary. - -=item B<-v>, B<--verbose> - -Increase level of verbosity. Can be repeated. - -=item B<--version> - -Print version information. - -=item B<--debug> - -Print debugging messages. - -=back - -=head1 BUGS - - - -=head1 AUTHOR - -Made by Øyvind A. Holm Ssunny@sunbase.orgE>. - -=head1 COPYRIGHT - -Copyleft © Øyvind A. Holm Esunny@sunbase.orgE -This is free software; see the file F for legalese stuff. - -=head1 LICENCE - -This program is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2 of the License, or (at your -option) any later version. - -This program is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along -with this program; if not, write to the Free Software Foundation, Inc., -59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -=head1 SEE ALSO - -=cut - -# }}} - -# vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w : -# End of file $Id$ diff --git a/branches/gpst.gpsman-format/makemesh b/branches/gpst.gpsman-format/makemesh deleted file mode 100755 index 93d9e29..0000000 --- a/branches/gpst.gpsman-format/makemesh +++ /dev/null @@ -1,240 +0,0 @@ -#!/usr/bin/perl -w - -#======================================================================= -# $Id$ -# Create random 3D surface for use in plotting programs. -# -# Character set: UTF-8 -# ©opyleft 2007– Øyvind A. Holm -# License: GNU General Public License version 2 or later, see end of -# file for legal stuff. -#======================================================================= - -BEGIN { - our @version_array; -} - -use strict; -use Getopt::Long; - -$| = 1; - -our $Debug = 0; - -our %Opt = ( - 'debug' => 0, - 'help' => 0, - 'max' => 1000, - 'min' => 0, - 'verbose' => 0, - 'version' => 0, -); - -our $progname = $0; -$progname =~ s/^.*\/(.*?)$/$1/; - -my $rcs_id = '$Id$'; -my $id_date = $rcs_id; -$id_date =~ s/^.*?\d+ (\d\d\d\d-.*?\d\d:\d\d:\d\d\S+).*/$1/; - -push(@main::version_array, $rcs_id); - -Getopt::Long::Configure("bundling"); -GetOptions( - "debug" => \$Opt{'debug'}, - "help|h" => \$Opt{'help'}, - "max=f" => \$Opt{'max'}, - "min=f" => \$Opt{'min'}, - "verbose|v+" => \$Opt{'verbose'}, - "version" => \$Opt{'version'}, -) || die("$progname: Option error. Use -h for help.\n"); - -$Opt{'debug'} && ($Debug = 1); -$Opt{'help'} && usage(0); -$Opt{'version'} && print_version(); - -my ($Lat, $Lon) = - ( 0, 0); - -my @Ele = (); - -my $Size = 20; - -while (1) { - D("Lon = '$Lon'"); - for $Lon (0..$Size) { - my $Left = defined($Ele[$Lat][$Lon-1]) ? $Ele[$Lat][$Lon-1] : rand(1); - my $Right = defined($Ele[$Lat][$Lon+1]) ? $Ele[$Lat][$Lon+1] : rand(1); - my $Over = defined($Ele[$Lat+1][$Lon]) ? $Ele[$Lat+1][$Lon] : rand(1); - my $Under = defined($Ele[$Lat-1][$Lon]) ? $Ele[$Lat-1][$Lon] : rand(1); - my $Curr = ($Left+$Right+$Over+$Under)/4; - $Curr += rand(1) >= 0.5 ? rand(1) : 0-rand(1); - # until ($Curr >= $Opt{'min'}) { - # D("Curr >= Min"); - # $Curr += rand(1) * 1.0; - # } - # until ($Curr <= $Opt{'max'}) { - # D("Curr <= Max"); - # $Curr -= rand(1) * 1.0; - # } - if ($Lat > 0 && $Lat < $Size && $Lon > 0 && $Lon < $Size) { - # print("$Lat\t$Lon\t$Curr\n"); - # print($Lat . "\t" . $Lon-1 . "\t" . $Left . "\n"); - print($Lat . "\t" . $Lon . "\t" . $Curr . "\n"); - # print("\n"); - print($Lat+1 . "\t" . $Lon . "\t" . $Over . "\n"); - print($Lat . "\t" . $Lon . "\t" . $Curr . "\n"); - # print("\n"); - # print($Lat . "\t" . $Lon+1 . "\t" . $Right . "\n"); - print($Lat . "\t" . $Lon . "\t" . $Curr . "\n"); - # print("\n"); - print($Lat-1 . "\t" . $Lon . "\t" . $Under . "\n"); - print($Lat . "\t" . $Lon . "\t" . $Curr . "\n"); - # print("\n"); - } - $Ele[$Lat][$Lon] = $Curr; - print("\n"); - } - $Lat += 1; - last if ($Lat > $Size); -} - -sub print_version { - # Print program version {{{ - for (@main::version_array) { - print("$_\n"); - } - exit(0); - # }}} -} # print_version() - -sub usage { - # Send the help message to stdout {{{ - my $Retval = shift; - - print(<= $verbose_level) { - print(STDERR "$progname: $Txt\n"); - } - # }}} -} # msg() - -sub D { - # Print a debugging message {{{ - $Debug || return; - my @call_info = caller; - chomp(my $Txt = shift); - my $File = $call_info[1]; - $File =~ s#\\#/#g; - $File =~ s#^.*/(.*?)$#$1#; - print(STDERR "$File:$call_info[2] $$ $Txt\n"); - return(""); - # }}} -} # D() - -__END__ - -# Plain Old Documentation (POD) {{{ - -=pod - -=head1 NAME - - - -=head1 REVISION - -$Id$ - -=head1 SYNOPSIS - - [options] [file [files [...]]] - -=head1 DESCRIPTION - - - -=head1 OPTIONS - -=over 4 - -=item B<-h>, B<--help> - -Print a brief help summary. - -=item B<-v>, B<--verbose> - -Increase level of verbosity. Can be repeated. - -=item B<--version> - -Print version information. - -=item B<--debug> - -Print debugging messages. - -=back - -=head1 BUGS - - - -=head1 AUTHOR - -Made by Øyvind A. Holm Ssunny@sunbase.orgE>. - -=head1 COPYRIGHT - -Copyleft © Øyvind A. Holm Esunny@sunbase.orgE -This is free software; see the file F for legalese stuff. - -=head1 LICENCE - -This program is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2 of the License, or (at your -option) any later version. - -This program is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along -with this program; if not, write to the Free Software Foundation, Inc., -59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -=head1 SEE ALSO - -=cut - -# }}} - -# vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w : -# End of file $Id$ diff --git a/branches/gpst.gpsman-format/poisync b/branches/gpst.gpsman-format/poisync deleted file mode 100755 index 7f9b0cc..0000000 --- a/branches/gpst.gpsman-format/poisync +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash -#======================================================================= -# $Id$ -# For synkronisering av POI og waypoints fra uniten. -#======================================================================= - -gpst -o pgwtab ~/gps/unit/wpdata.gpx ~/gps/poi/trans/*.gpx | psql gps -a -c "TRUNCATE tmpwayp; COPY tmpwayp FROM STDIN;" -psql gps -a -c "UPDATE tmpwayp SET coor = point(round(coor[0]::numeric, 6), round(coor[1]::numeric, 6));" -psql gps -a -c "COPY (SELECT coor, name FROM tmpwayp WHERE type IS NULL ORDER BY coor[0] desc, coor[1]) TO '/tmp/un';" -psql gps -a -c "COPY (SELECT coor, name FROM tmpwayp WHERE type IS NOT NULL ORDER BY coor[0] desc, coor[1]) TO '/tmp/p';" - -if [ "$1" = "-d" ]; then - diff -u /tmp/un /tmp/p -else - vimdiff /tmp/un /tmp/p -fi diff --git a/branches/gpst.gpsman-format/postgres/Patch/floatingpoint-testing.patch b/branches/gpst.gpsman-format/postgres/Patch/floatingpoint-testing.patch deleted file mode 100644 index cd78c0d..0000000 --- a/branches/gpst.gpsman-format/postgres/Patch/floatingpoint-testing.patch +++ /dev/null @@ -1,48 +0,0 @@ -Index: create_views.sql -=================================================================== ---- create_views.sql (revisjon 2221) -+++ create_views.sql (arbeidskopi) -@@ -122,8 +122,20 @@ - -- Lister ut events sammen med loggen. - CREATE OR REPLACE VIEW ev AS - SELECT * FROM ( -+ SELECT 'gps' AS flag, date, (coor[0]::numeric || ',' || coor[1]::numeric)::point as coor, sted || ' (' || dist || ')' AS sted, ele::numeric(8,1), NULL AS descr, avst -+ FROM logg -+ -- UNION ALL -+ -- SELECT 'event' AS flag, date, coor[0] || ',' || coor[1], NULL, NULL, descr AS descr, NULL -+ -- FROM events -+ -- UNION ALL -+ -- SELECT 'pic' AS flag, date, coor[0] || ',' || coor[1], filename, NULL, NULL, NULL -+ -- FROM pictures -+ ) AS u -+ ORDER BY date; -+CREATE OR REPLACE VIEW flev AS -+ SELECT * FROM ( - SELECT 'gps' AS flag, date, coor, sted || ' (' || dist || ')' AS sted, ele::numeric(8,1), NULL AS descr, avst -- FROM logg -+ FROM rsflytting - UNION ALL - SELECT 'event' AS flag, date, coor, NULL, NULL, descr AS descr, NULL - FROM events -@@ -131,7 +143,21 @@ - SELECT 'pic' AS flag, date, coor, filename, NULL, NULL, NULL - FROM pictures - ) AS u -+ WHERE date between '2007-11-01' and '2007-12-01' - ORDER BY date; -+CREATE OR REPLACE VIEW evmer AS -+ SELECT * FROM ( -+ SELECT 'gps' AS flag, date, coor, sted || ' (' || dist || ')' AS sted, ele::numeric(8,1), NULL AS descr, avst -+ FROM rsmerete -+ UNION ALL -+ SELECT 'event' AS flag, date, coor, NULL, NULL, descr AS descr, NULL -+ FROM events -+ UNION ALL -+ SELECT 'pic' AS flag, date, coor, filename, NULL, NULL, NULL -+ FROM pictures -+ ) AS u -+ WHERE date between '2007-11-01' and '2007-12-01' -+ ORDER BY date; - - CREATE OR REPLACE VIEW wp AS - SELECT diff --git a/branches/gpst.gpsman-format/postgres/Patch/wheretype.patch b/branches/gpst.gpsman-format/postgres/Patch/wheretype.patch deleted file mode 100644 index e7f480f..0000000 --- a/branches/gpst.gpsman-format/postgres/Patch/wheretype.patch +++ /dev/null @@ -1,49 +0,0 @@ -Index: create_funcs.sql -=================================================================== ---- create_funcs.sql (revisjon 2216) -+++ create_funcs.sql (arbeidskopi) -@@ -110,6 +110,44 @@ - END; - $$ LANGUAGE plpgsql; - -+DROP TYPE wheretype; -+CREATE TYPE wheretype AS ( -+ date timestamptz, -+ lat numeric(8, 5), -+ lon numeric(8, 5), -+ sted text, -+ dist numeric -+); -+ -+DROP FUNCTION wherepos(timestamptz); -+CREATE OR REPLACE FUNCTION wherepos(currtime timestamptz) RETURNS wheretype AS $$ -+DECLARE -+ currpos point; -+ currsted text; -+ currdist numeric; -+ currlat numeric(8, 5); -+ currlon numeric(8, 5); -+BEGIN -+ currpos = findpos(currtime); -+ currlat = currpos[1]; -+ currlon = currpos[0]; -+ currsted = clname(currpos); -+ currdist = cldist(currpos); -+ RETURN(currtime, currlat, currlon, currsted, currdist); -+ -- RETURN(currtime || currlat || currlon || currplace || currdist); -+END; -+$$ LANGUAGE plpgsql; -+ -+-- Backup -+-- begin-base64 644 - -+-- H4sIABd7IEgCA11Q0WrCMBR971fch8JacLA9CGLxIatZEUocsX0SH0qNLpCm -+-- WRvZGH78kupMm0DC5Zx77jm5KcWowLClQPFHjlIM7yVJi82WwPcn65hq+6i+ -+-- dJ3mDQP79LpqlP6NTX9RUrIDzX40oB2EYbDGaY4oDsAcKzJiUC2XOnGQqGo2 -+-- aBx25L0GeWlYx2uHiuoBRosZzOMR1UqfesPZhkyMV3Di8jjOH0+Hr/5b96+H -+-- 6WzHvBz86IYTsmpYdG+JvX9Y3hYef9uWW+X1Ck/wbK4p7oGWy2GVA+PwVo7x -+-- keIWx0ettbHEZJ0EYQg5IlmJMgxKqHP/JZLgD2CFKF3xAQAA -+-- ==== -+ - -- Returnerer antall sekunder sia midnatt for en dato. - DROP FUNCTION secmidnight(timestamptz); - CREATE OR REPLACE FUNCTION secmidnight(timestamptz) RETURNS double precision diff --git a/branches/gpst.gpsman-format/postgres/allupdate.sql b/branches/gpst.gpsman-format/postgres/allupdate.sql deleted file mode 100644 index f0d5d86..0000000 --- a/branches/gpst.gpsman-format/postgres/allupdate.sql +++ /dev/null @@ -1,3 +0,0 @@ --- $Id$ - -INSERT INTO stat (lastupdate, laststed) VALUES (now(), '1900-01-01'); diff --git a/branches/gpst.gpsman-format/postgres/create_funcs.sql b/branches/gpst.gpsman-format/postgres/create_funcs.sql deleted file mode 100644 index 9bcf6e9..0000000 --- a/branches/gpst.gpsman-format/postgres/create_funcs.sql +++ /dev/null @@ -1,142 +0,0 @@ --- $Id$ - --- Returnerer navnet på det nærmeste veipunktet i wayp. -CREATE OR REPLACE FUNCTION clname(point) RETURNS text -AS $$ -SELECT name FROM ( - SELECT - name, - ($1 <-> coor) - AS avs - FROM wayp - WHERE ($1 <-> coor) < 0.05 - ORDER BY avs - LIMIT 1 - ) AS s; -$$ LANGUAGE SQL; - --- Returnerer avstanden (i grader) til det nærmeste veipunktet i wayp. -CREATE OR REPLACE FUNCTION cldist(point) RETURNS numeric -AS $$ -SELECT round(avs::numeric, 5) FROM ( - SELECT - ($1 <-> coor) - AS avs - FROM wayp - WHERE ($1 <-> coor) < 0.05 - ORDER BY avs - LIMIT 1 - ) AS s; -$$ LANGUAGE SQL; - --- Beregn koordinater for et tidspunkt som ligger mellom to --- trackpunkter. -CREATE OR REPLACE FUNCTION findpos(currtime timestamptz) RETURNS point AS $$ -DECLARE - firstdate timestamptz; - lastdate timestamptz; - firsttime timestamptz; - firstcoor point; - lasttime timestamptz; - lastcoor point; - currlat numeric; - currlon numeric; -BEGIN - -- RAISE NOTICE '-----------------------------------'; - SELECT INTO firstdate date - FROM logg - ORDER BY date - LIMIT 1; - SELECT INTO lastdate date - FROM logg - ORDER BY date DESC - LIMIT 1; - IF currtime < firstdate OR currtime > lastdate THEN - return(NULL); - END IF; - - SELECT INTO firsttime date - FROM logg - WHERE date <= currtime - ORDER BY date DESC - LIMIT 1; - SELECT INTO firstcoor coor - FROM logg - WHERE date <= currtime - ORDER BY date DESC - LIMIT 1; - SELECT INTO lasttime date - FROM logg - WHERE date >= currtime - ORDER BY date - LIMIT 1; - SELECT INTO lastcoor coor - FROM logg - WHERE date >= currtime - ORDER BY date - LIMIT 1; - -- RAISE NOTICE 'currtime = %', currtime; - -- RAISE NOTICE 'firsttime = %, firstcoor = %', firsttime, firstcoor; - -- RAISE NOTICE 'lasttime = %, lastcoor = %', lasttime, lastcoor; - - IF firsttime = lasttime THEN - RETURN(firstcoor); - END IF; - - currlat = firstcoor[0] + - ( - ( - lastcoor[0]-firstcoor[0] - ) * - ( - ( - EXTRACT(EPOCH FROM currtime)-EXTRACT(EPOCH FROM firsttime) - ) - / - ( - EXTRACT(EPOCH FROM lasttime)-EXTRACT(EPOCH FROM firsttime) - ) - ) - ); - currlon = firstcoor[1] + - ( - ( - lastcoor[1]-firstcoor[1] - ) * - ( - ( - EXTRACT(EPOCH FROM currtime)-EXTRACT(EPOCH FROM firsttime) - ) - / - ( - EXTRACT(EPOCH FROM lasttime)-EXTRACT(EPOCH FROM firsttime) - ) - ) - ); - -- RAISE NOTICE 'currcoor = (%,%)', currlat, currlon; - RETURN (currlat,currlon); -END; -$$ LANGUAGE plpgsql; - -CREATE OR REPLACE FUNCTION wherepos(currtime timestamptz) RETURNS text AS $$ -DECLARE - currpos point; - currsted text; - currdist numeric; - currlat numeric(9, 6); - currlon numeric(9, 6); -BEGIN - currpos = findpos(currtime); - currlat = currpos[0]; - currlon = currpos[1]; - currsted = clname(currpos); - currdist = cldist(currpos); - RETURN(currtime || ' - ' || currlat::text || ' ' || currlon::text || ' - ' || currsted || ' - ' || currdist); -END; -$$ LANGUAGE plpgsql; - --- Returnerer antall sekunder sia midnatt for en dato. -CREATE OR REPLACE FUNCTION secmidnight(timestamptz) RETURNS double precision -AS $$ -SELECT extract(hour from $1) * 3600 + extract(minute from $1) * 60 + extract(second from $1); -$$ LANGUAGE SQL; diff --git a/branches/gpst.gpsman-format/postgres/create_index.sql b/branches/gpst.gpsman-format/postgres/create_index.sql deleted file mode 100644 index 75f77dc..0000000 --- a/branches/gpst.gpsman-format/postgres/create_index.sql +++ /dev/null @@ -1,32 +0,0 @@ --- $Id$ - -CREATE INDEX log_date_idx on logg(date); -CREATE INDEX log_coor0_idx on logg((coor[0])); -CREATE INDEX log_coor1_idx on logg((coor[1])); -CREATE INDEX log_ele_idx on logg(ele); -CREATE INDEX log_sted_idx on logg(sted); -CREATE INDEX log_dist_idx on logg(dist); -CREATE INDEX log_avst_idx on logg(avst); - --- DROP INDEX begin_idx; --- DROP INDEX end_idx; --- DROP INDEX cabegin_idx; --- DROP INDEX caend_idx; --- DROP INDEX lat_idx; --- DROP INDEX lon_idx; --- DROP INDEX descr_idx; --- DROP INDEX flags_idx; --- DROP INDEX persons_idx; --- DROP INDEX data_idx; - -CREATE INDEX ev_date_idx ON events (date); -CREATE INDEX ev_begindate_idx ON events (begindate); -CREATE INDEX ev_enddate_idx ON events (enddate); -CREATE INDEX ev_cabegin_idx ON events (cabegin); -CREATE INDEX ev_caend_idx ON events (caend); -CREATE INDEX ev_coor0_idx ON events ((coor[0])); -CREATE INDEX ev_coor1_idx ON events ((coor[1])); -CREATE INDEX ev_descr_idx ON events (descr); -CREATE INDEX ev_flags_idx ON events (flags); -CREATE INDEX ev_persons_idx ON events (persons); -CREATE INDEX ev_data_idx ON events (data); diff --git a/branches/gpst.gpsman-format/postgres/create_table.sql b/branches/gpst.gpsman-format/postgres/create_table.sql deleted file mode 100644 index 7d3c930..0000000 --- a/branches/gpst.gpsman-format/postgres/create_table.sql +++ /dev/null @@ -1,52 +0,0 @@ --- $Id$ - -CREATE TABLE logg ( - date timestamptz, - coor point, - ele numeric, - sted text, - dist numeric(8, 5), - description text, - avst numeric(8, 5) -); - -CREATE TABLE wayp ( - coor point, - name text, - ele numeric(6, 1), - type text, - time timestamptz, - cmt text, -- GPS waypoint comment. Sent to the GPS as comment. - descr text, -- A text description. Additional info intended for the user, not the GPS. - src text, - sym text -); - -CREATE TABLE tmpwayp AS - SELECT * from wayp LIMIT 0; - -CREATE TABLE events ( - date timestamptz, - coor point, - descr text, - begindate timestamptz, -- Ganske eksakt tidspunt ved start - enddate timestamptz, -- Ganske eksakt tidspunkt ved slutt - cabegin interval, - caend interval, - flags text[], - persons text[], - data bytea -); - -CREATE TABLE pictures ( - date timestamptz, - coor point, - descr text, - filename text, - author text -); - -CREATE TABLE stat ( - lastupdate timestamptz, - laststed timestamptz -); diff --git a/branches/gpst.gpsman-format/postgres/create_views.sql b/branches/gpst.gpsman-format/postgres/create_views.sql deleted file mode 100644 index 74389eb..0000000 --- a/branches/gpst.gpsman-format/postgres/create_views.sql +++ /dev/null @@ -1,145 +0,0 @@ - -- $Id$ - -CREATE OR REPLACE VIEW siste_aar - AS SELECT * FROM ( - SELECT DISTINCT ON ( - sted, date_trunc('week', date) - ) * - FROM logg - WHERE date > now() + interval '1 year ago' - ) AS s - ORDER BY date; - -CREATE OR REPLACE VIEW siste_halvaar - AS SELECT * FROM ( - SELECT DISTINCT ON ( - sted, date_trunc('week', date) - ) * - FROM logg - WHERE date > now() + interval '0.5 year ago' - ) AS s - ORDER BY date; - -CREATE OR REPLACE VIEW siste_maaned - AS SELECT * FROM ( - SELECT DISTINCT ON ( - sted, date_trunc('hour', date) - ) * - FROM logg - WHERE date > now() + interval '1 month ago' - ) AS s - ORDER BY date; - -CREATE OR REPLACE VIEW siste_uke - AS SELECT * FROM ( - SELECT DISTINCT ON ( - sted, date_trunc('hour', date) - ) * - FROM logg - WHERE date > now()+interval '1 week ago' - ) AS s - ORDER BY date; - -CREATE OR REPLACE VIEW siste_dogn - AS SELECT * FROM ( - SELECT DISTINCT ON ( - sted, date_trunc('minute', date) - ) * - FROM logg - WHERE date > now()+interval '1 day ago' - ) AS s - ORDER BY date; - -/*** De 50.000 punktene med høyest fjernesthjemmefrahet. ***/ - -CREATE OR REPLACE VIEW fjernest - AS SELECT * FROM logg - ORDER BY avst DESC LIMIT 50000; - -CREATE OR REPLACE VIEW fjernest_siste_aar - AS SELECT * FROM logg - WHERE date > now()+interval '1 year ago' - ORDER BY avst DESC LIMIT 50000; - -CREATE OR REPLACE VIEW fjernest_siste_halvaar - AS SELECT * FROM logg - WHERE date > now()+interval '0.5 year ago' - ORDER BY avst DESC LIMIT 50000; - -CREATE OR REPLACE VIEW fjernest_siste_maaned - AS SELECT * FROM logg - WHERE date > now() + interval '1 month ago' - ORDER BY avst DESC LIMIT 50000; - -CREATE OR REPLACE VIEW fjernest_siste_uke - AS SELECT * FROM logg - WHERE date > now() + interval '1 week ago' - ORDER BY avst DESC LIMIT 50000; - -CREATE OR REPLACE VIEW fjernest_siste_dogn - AS SELECT * FROM logg - WHERE date > now() + interval '1 day ago' - ORDER BY avst DESC LIMIT 50000; - -/*** Intervaller ***/ - -CREATE OR REPLACE VIEW minutt - AS SELECT * FROM ( - SELECT DISTINCT ON ( - date_trunc('minute', date) - ) * - FROM logg - ) AS s - ORDER BY date DESC; - -/*** Formater ***/ - -CREATE OR REPLACE VIEW closest AS - SELECT * FROM ( - SELECT DISTINCT ON (sted) * FROM ( - SELECT * FROM LOGG - ORDER BY dist - ) AS b - WHERE sted IS NOT NULL - ) AS a - ORDER BY date; - -CREATE OR REPLACE VIEW gpx AS - SELECT ' ' || - '' || ele || ' ' || - ' ' || - '' - AS gpx, - date, coor, ele, sted, dist, description - FROM logg; - -CREATE OR REPLACE VIEW gpst AS - SELECT date, coor, ele, sted, dist, avst, - ' ' || coor[0] || ' ' || coor[1] || ' ' - AS gpst - FROM logg; - --- Lister ut events sammen med loggen. -CREATE OR REPLACE VIEW ev AS - SELECT * FROM ( - SELECT 'gps' AS flag, date, coor, sted || ' (' || dist || ')' AS sted, ele::numeric(8,1), NULL AS descr, avst - FROM logg - UNION ALL - SELECT 'event' AS flag, date, coor, NULL, NULL, descr AS descr, NULL - FROM events - UNION ALL - SELECT 'pic' AS flag, date, coor, filename, NULL, NULL, NULL - FROM pictures - ) AS u - ORDER BY date; - -CREATE OR REPLACE VIEW wp AS - SELECT - coor AS coor, - substr(name, 1, 20) AS name, - type AS type, - substr(cmt, 1, 20) AS cmt, - ele AS ele, - time AS time - FROM wayp - ORDER BY coor[0] desc, coor[1]; diff --git a/branches/gpst.gpsman-format/postgres/distupdate.sql b/branches/gpst.gpsman-format/postgres/distupdate.sql deleted file mode 100644 index 7b8036b..0000000 --- a/branches/gpst.gpsman-format/postgres/distupdate.sql +++ /dev/null @@ -1,30 +0,0 @@ --- $Id$ - -BEGIN ISOLATION LEVEL SERIALIZABLE; - \echo - \echo ================ Sett avstanden hjemmefra ================ - - UPDATE logg SET avst = '(60.42543,5.29959)'::point <-> coor - WHERE date > ( - SELECT laststed FROM stat - WHERE lastupdate IS NOT NULL - ORDER BY lastupdate DESC LIMIT 1 - ) - OR date IS NULL; - - \echo - \echo ================ Oppdater sted og dist ================ - - UPDATE logg SET sted = clname(coor), dist = cldist(coor) - WHERE date > ( - SELECT laststed FROM stat - WHERE lastupdate IS NOT NULL - ORDER BY lastupdate DESC LIMIT 1 - ) - OR date IS NULL; - - INSERT INTO stat (lastupdate, laststed) VALUES ( - now(), - (SELECT max(date) FROM logg) - ); -COMMIT; diff --git a/branches/gpst.gpsman-format/postgres/div.txt b/branches/gpst.gpsman-format/postgres/div.txt deleted file mode 100644 index dffcae8..0000000 --- a/branches/gpst.gpsman-format/postgres/div.txt +++ /dev/null @@ -1,5 +0,0 @@ -$Id$ - -For å liste ut de nærmeste trackpunktene for en posisjon: - -SELECT date, coor, sted, dist, (point(60.30738,5.34574) <-> coor)::numeric AS avs FROM logg ORDER BY avs LIMIT 100; diff --git a/branches/gpst.gpsman-format/postgres/init.sql b/branches/gpst.gpsman-format/postgres/init.sql deleted file mode 100644 index f8980ca..0000000 --- a/branches/gpst.gpsman-format/postgres/init.sql +++ /dev/null @@ -1,7 +0,0 @@ --- $Id$ - -CREATE LANGUAGE plpgsql; -\i create_table.sql -\i create_funcs.sql -\i create_views.sql -\i allupdate.sql diff --git a/branches/gpst.gpsman-format/postgres/path.sql b/branches/gpst.gpsman-format/postgres/path.sql deleted file mode 100644 index c7e5179..0000000 --- a/branches/gpst.gpsman-format/postgres/path.sql +++ /dev/null @@ -1,8 +0,0 @@ --- $Id$ - -SELECT * FROM logg - WHERE coor <@ polygon(path('( - (58.633, 3.149), - (52.395, 3.163), - (49.364, -6.437) - )')) ORDER BY date; diff --git a/branches/gpst.gpsman-format/postgres/update_things.sql b/branches/gpst.gpsman-format/postgres/update_things.sql deleted file mode 100644 index b2fdce8..0000000 --- a/branches/gpst.gpsman-format/postgres/update_things.sql +++ /dev/null @@ -1,114 +0,0 @@ --- $Id$ - -\echo -\echo ================ Rund av veipunkter til seks desimaler ================ - -UPDATE wayp SET coor = point( - round(coor[0]::numeric, 6), - round(coor[1]::numeric, 6) -); - -\echo -\echo ================ Fjern duplikater i wayp ================ - -SELECT count(*) - AS "Antall i wayp før rensking" - FROM wayp; - -BEGIN ISOLATION LEVEL SERIALIZABLE; - CREATE TEMPORARY TABLE dupfri - ON COMMIT DROP - AS ( - SELECT - DISTINCT ON ( - coor[0], coor[1], - name, - ele, - type, - time, - cmt, - descr, - src, - sym - ) * - FROM wayp - ); - TRUNCATE wayp; - INSERT INTO wayp ( - SELECT * - FROM dupfri - ORDER BY name - ); -COMMIT; - -SELECT count(*) - AS "Antall i wayp etter rensking" - FROM wayp; - -\echo -\echo ================ Fjern duplikater i events ================ - -SELECT count(*) - AS "Antall i events før rensking" - FROM events; - -BEGIN ISOLATION LEVEL SERIALIZABLE; - CREATE TEMPORARY TABLE dupfri - ON COMMIT DROP - AS ( - SELECT - DISTINCT ON (date, coor[0], coor[1], descr) * - FROM events - ); - TRUNCATE events; - INSERT INTO events ( - SELECT * - FROM dupfri - ORDER BY date - ); -COMMIT; - -SELECT count(*) - AS "Antall i events etter rensking" - FROM events; - -\echo -\echo ================ Oppdater koordinater for bilder ================ - -UPDATE pictures SET coor = findpos(date) - WHERE coor IS NULL; - -\echo ================ Rund av bildekoordinater ================ -UPDATE pictures SET coor = point( - round(coor[0]::numeric, 6), - round(coor[1]::numeric, 6) -); - -\echo -\echo ================ Fjern duplikater i pictures ================ - -SELECT count(*) - AS "Antall i pictures før rensking" - FROM pictures; - -BEGIN ISOLATION LEVEL SERIALIZABLE; - CREATE TEMPORARY TABLE dupfri - ON COMMIT DROP - AS ( - SELECT - DISTINCT ON (date, coor[0], coor[1], descr, filename, author) * - FROM pictures - ); - TRUNCATE pictures; - INSERT INTO pictures ( - SELECT * - FROM dupfri - ORDER BY date - ); -COMMIT; - -SELECT count(*) - AS "Antall i pictures etter rensking" - FROM pictures; - -\i distupdate.sql diff --git a/branches/gpst.gpsman-format/run b/branches/gpst.gpsman-format/run deleted file mode 100755 index 769e868..0000000 --- a/branches/gpst.gpsman-format/run +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/gnuplot - -# $Id$ - -!./makemesh >x -set pm3d -splot "x" w l, "x" w pm3d -pause -1 - -splot "x" w l -pause -1 -splot "x" w d -pause -1 diff --git a/branches/gpst.gpsman-format/tests/Makefile b/branches/gpst.gpsman-format/tests/Makefile deleted file mode 100644 index 4c5d694..0000000 --- a/branches/gpst.gpsman-format/tests/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/make - -# $Id$ -# gpstools/tests/Makefile - -all: - ./run-tests.pl 2>&1 | ./unify.pl >log/tests.log - ./run-tests.pl --todo 2>&1 | ./unify.pl >log/todo-tests.log diff --git a/branches/gpst.gpsman-format/tests/chronology-error.gpsml b/branches/gpst.gpsman-format/tests/chronology-error.gpsml deleted file mode 100644 index b8e59c4..0000000 --- a/branches/gpst.gpsman-format/tests/chronology-error.gpsml +++ /dev/null @@ -1,19 +0,0 @@ - - - -Chronology errors - 60.45369 5.31559 95 - 60.45353 5.31548 94 - 60.45353 5.31561 94 - - 60.45369 5.31597 Out of chronology - -0:00:37:54 - 60.45418 5.31517 92 - 60.45407 5.31542 91 - 60.45401 5.31543 98 - 60.45401 5.31543 98 - 60.45395 5.31544 103 - 60.45391 5.31545 107 - - diff --git a/branches/gpst.gpsman-format/tests/comments.mayko b/branches/gpst.gpsman-format/tests/comments.mayko deleted file mode 100644 index 917fc7b..0000000 --- a/branches/gpst.gpsman-format/tests/comments.mayko +++ /dev/null @@ -1,13 +0,0 @@ -xmaplog 1.0 Mon Dec 23 02:00:50 2002 -1 70.6800486 23.6746151 57.4 0 12/22/2002 21:42:24 -1 70.6799322 23.6740038 6.3 0 12/22/2002 21:42:32 -1 70.6796266 23.6723991 6.0 0 12/22/2002 21:42:54 -# 20021222T214351-20021222T214354: CO: No signal {{{ -# 1 70.6796266 23.6723991 0.0 0 12/22/2002 21:43:51 -# 1 70.6796266 23.6723991 0.0 0 12/22/2002 21:43:52 -# 1 70.6796266 23.6723991 0.0 0 12/22/2002 21:43:54 -# 20021222T214351-20021222T214354: CO: No signal }}} -# move -1 70.6800774 23.6757566 5.1 0 12/22/2002 21:44:45 -1 70.6801502 23.6753442 4.8 0 12/22/2002 21:44:52 -1 70.6801905 23.6757542 2.5 0 12/22/2002 21:45:04 diff --git a/branches/gpst.gpsman-format/tests/compact.gpx b/branches/gpst.gpsman-format/tests/compact.gpx deleted file mode 100644 index fca71c9..0000000 --- a/branches/gpst.gpsman-format/tests/compact.gpx +++ /dev/null @@ -1 +0,0 @@ -All whitespace stripped diff --git a/branches/gpst.gpsman-format/tests/date_error.mayko b/branches/gpst.gpsman-format/tests/date_error.mayko deleted file mode 100644 index 5a498ee..0000000 --- a/branches/gpst.gpsman-format/tests/date_error.mayko +++ /dev/null @@ -1,6 +0,0 @@ -xmaplog 1.0 Fri Jun 13 12:34:56 2003 -1 60.4280897 5.5794667 41.8 0 06/13/2003 09:12:36 -1 60.4281867 5.5802255 41.8 0 06/13/2003 09:12:38 -# error 1 103.4034054 129.7271053 0.0 0 06/25/2037 17:19:22 -1 60.4283320 5.5813636 -0.0 0 06/13/2003 09:12:41 -1 60.4283806 5.5817430 41.8 0 06/13/2003 09:12:42 diff --git a/branches/gpst.gpsman-format/tests/different_dateformats.gpsml b/branches/gpst.gpsman-format/tests/different_dateformats.gpsml deleted file mode 100644 index 5990ff9..0000000 --- a/branches/gpst.gpsman-format/tests/different_dateformats.gpsml +++ /dev/null @@ -1,10 +0,0 @@ - - - -Date format variations - 1 1 - 2 2 - 3 3 - 4 4 - - diff --git a/branches/gpst.gpsman-format/tests/log.dos.gpstxt b/branches/gpst.gpsman-format/tests/log.dos.gpstxt deleted file mode 100644 index 52519f4..0000000 --- a/branches/gpst.gpsman-format/tests/log.dos.gpstxt +++ /dev/null @@ -1,11 +0,0 @@ -@030105164711N6654490E01501379G012+11472W1017S2144U0029 -@030105164712N6654375E01501240G012+11472W1018S2144U0029 -@030105164713N6654259E01501101G012+11472W1018S2144U0029 -@030105164714N6654144E01500961G012+11473W1019S2145U0031 -@030105164715N6654029E01500822G012+11474W1018S2146U0032 -@030105164716N6653914E01500683G012+11474W1017S2146U0034 -@030105164717N6653798E01500544G013+11475W1019S2149U0034 -@030105164718N6653683E01500404G013+11475W1019S2149U0034 -@030105164719N6653568E01500265G012+11475W1018S2148U0033 -@030105164720N6653452E01500126G012+11475W1019S2151U0032 -@030105164721N6653337E01459987G012+11475W1018S2150U0027 diff --git a/branches/gpst.gpsman-format/tests/log.dos.mayko b/branches/gpst.gpsman-format/tests/log.dos.mayko deleted file mode 100644 index 7164576..0000000 --- a/branches/gpst.gpsman-format/tests/log.dos.mayko +++ /dev/null @@ -1,7 +0,0 @@ -xmaplog 1.0 Mon Jun 16 13:04:24 2003 -1 58.1818158 8.1225077 38.6 0 06/15/2003 10:27:45 -1 58.1818712 8.1253200 40.1 0 06/15/2003 10:27:53 -1 58.1816347 8.1266031 38.7 0 06/15/2003 10:27:57 -1 58.1812099 8.1284612 38.5 0 06/15/2003 10:28:03 -1 58.1810315 8.1293950 37.7 0 06/15/2003 10:28:06 -1 58.1809621 8.1307400 38.5 0 06/15/2003 10:28:10 diff --git a/branches/gpst.gpsman-format/tests/log.gpstxt b/branches/gpst.gpsman-format/tests/log.gpstxt deleted file mode 100644 index 2b34784..0000000 --- a/branches/gpst.gpsman-format/tests/log.gpstxt +++ /dev/null @@ -1,18 +0,0 @@ -@030613143609N5931291E00723512G005+00762E0154S0126D0020 -@030613143610N5931284E00723528G005+00762E0156S0126D0019 -@030613143611N5931278E00723545G005+00761E0156S0125D0021 -@030613143612N5931271E00723562G005+00761E0155S0124D0022 -@030613143613__________________________________________ -@030613143615N5931251E00723611G005+00760E0152S0122D0022 -@030613143616N5931244E00723627G005+00760E0151S0119D0022 -@030613143617N5931239E00723643G005+00760E0153S0092D0021 -@030613143618N5931235E00723660G005+00760E0160S0075D0020 -@030613143619N5931232E00723678G005+00759E0168S0062D0019 -@030613143620N5931229E00723695G005+00759E0178S0052D0019 -@030613143621N5931226E00723714G005+00759E0184S0052D0019 -@030613143622__________________________________________ -@030613143624N5931217E00723774G005+00758E0186S0057D0021 -@030613143625N5931214E00723793G005+00758E0186S0057D0020 -@030613143626N5931211E00723813G005+00757E0186S0055D0018 -@030613143627N5931208E00723833G005+00757E0187S0052D0016 -@030613143628N5931206E00723854G005+00757E0193S0042D0014 diff --git a/branches/gpst.gpsman-format/tests/log.mcsv b/branches/gpst.gpsman-format/tests/log.mcsv deleted file mode 100644 index e5c0d84..0000000 --- a/branches/gpst.gpsman-format/tests/log.mcsv +++ /dev/null @@ -1,47 +0,0 @@ -Track ACTIVE LOG 125 04.03.2006 11:12:30 (UTC) 00:04:55 695 m 8.5 kph - -Header Position Time Altitude Depth Leg Length Leg Time Leg Speed Leg Course - -Trackpoint N54.96883 W1.62439 04.03.2006 11:12:30 (UTC) 77.0 m -Trackpoint N54.96878 W1.62413 04.03.2006 11:12:47 (UTC) 77.0 m 17.5 m 00:00:17 3.7 kph 109° true -Trackpoint N54.96913 W1.62616 04.03.2006 11:12:55 (UTC) 77.0 m 135 m 00:00:08 61 kph 287° true -Trackpoint N54.96934 W1.62624 04.03.2006 11:13:04 (UTC) 77.5 m 23.5 m 00:00:09 9.4 kph 348° true -Trackpoint N54.96934 W1.62596 04.03.2006 11:13:33 (UTC) 78.0 m 17.9 m 00:00:29 2.2 kph 89° true -Trackpoint N54.96931 W1.62645 04.03.2006 11:13:48 (UTC) 78.0 m 31.7 m 00:00:15 7.6 kph 265° true -Trackpoint N54.96918 W1.62603 04.03.2006 11:14:05 (UTC) 79.0 m 30.8 m 00:00:17 6.5 kph 118° true -Trackpoint N54.96901 W1.62364 04.03.2006 11:14:33 (UTC) 76.1 m 153 m 00:00:28 20 kph 97° true -Trackpoint N54.96922 W1.62540 04.03.2006 11:15:02 (UTC) 76.1 m 115 m 00:00:29 14 kph 282° true -Trackpoint N54.96914 W1.62526 04.03.2006 11:15:27 (UTC) 75.1 m 13.1 m 00:00:25 1.9 kph 135° true -Trackpoint N54.96911 W1.62494 04.03.2006 11:15:50 (UTC) 75.1 m 20.4 m 00:00:23 3.2 kph 99° true -Trackpoint N54.96930 W1.62489 04.03.2006 11:16:03 (UTC) 75.1 m 20.8 m 00:00:13 5.8 kph 9° true -Trackpoint N54.96901 W1.62496 04.03.2006 11:16:19 (UTC) 75.1 m 32.6 m 00:00:16 7.3 kph 188° true -Trackpoint N54.96871 W1.62466 04.03.2006 11:16:52 (UTC) 74.6 m 38.4 m 00:00:33 4.2 kph 151° true -Trackpoint N54.96908 W1.62488 04.03.2006 11:17:25 (UTC) 72.7 m 44.4 m 00:00:33 4.8 kph 342° true - -Track ACTIVE LOG 126 04.03.2006 11:18:32 (UTC) 00:01:49 252 m 8.3 kph - -Header Position Time Altitude Depth Leg Length Leg Time Leg Speed Leg Course - -Trackpoint N54.96904 W1.62482 04.03.2006 11:18:32 (UTC) 72.7 m -Trackpoint N54.96913 W1.62499 04.03.2006 11:18:35 (UTC) 71.3 m 15.4 m 00:00:03 19 kph 314° true -Trackpoint N54.96904 W1.62497 04.03.2006 11:18:38 (UTC) 70.8 m 10.4 m 00:00:03 12 kph 173° true -Trackpoint N54.96913 W1.62496 04.03.2006 11:18:48 (UTC) 71.8 m 10.5 m 00:00:10 3.8 kph 6° true -Trackpoint N54.96924 W1.62501 04.03.2006 11:18:55 (UTC) 72.2 m 12.6 m 00:00:07 6.5 kph 345° true -Trackpoint N54.96940 W1.62521 04.03.2006 11:19:11 (UTC) 71.8 m 21.5 m 00:00:16 4.8 kph 324° true -Trackpoint N54.96916 W1.62515 04.03.2006 11:19:30 (UTC) 71.3 m 27.2 m 00:00:19 5.2 kph 172° true -Trackpoint N54.96921 W1.62500 04.03.2006 11:19:53 (UTC) 71.3 m 11.2 m 00:00:23 1.8 kph 59° true -Trackpoint N54.96801 W1.62417 04.03.2006 11:20:21 (UTC) 71.8 m 143 m 00:00:28 18 kph 158° true - -Track ACTIVE LOG 127 04.03.2006 11:21:16 (UTC) 00:01:44 76.4 m 2.6 kph - -Header Position Time Altitude Depth Leg Length Leg Time Leg Speed Leg Course - -Trackpoint N54.96887 W1.62504 04.03.2006 11:21:16 (UTC) 70.8 m -Trackpoint N54.96898 W1.62476 04.03.2006 11:21:18 (UTC) 69.8 m 21.5 m 00:00:02 39 kph 56° true -Trackpoint N54.96910 W1.62475 04.03.2006 11:21:29 (UTC) 69.4 m 13.7 m 00:00:11 4.5 kph 3° true -Trackpoint N54.96918 W1.62468 04.03.2006 11:21:46 (UTC) 70.3 m 9.79 m 00:00:17 2.1 kph 26° true -Trackpoint N54.96920 W1.62465 04.03.2006 11:22:39 (UTC) 69.4 m 2.60 m 00:00:53 0.18 kph 48° true -Trackpoint N54.96924 W1.62462 04.03.2006 11:22:43 (UTC) 71.8 m 5.39 m 00:00:04 4.9 kph 19° true -Trackpoint N54.96928 W1.62463 04.03.2006 11:22:45 (UTC) 71.8 m 3.98 m 00:00:02 7.2 kph 353° true -Trackpoint N54.96945 W1.62466 04.03.2006 11:23:00 (UTC) 69.4 m 19.5 m 00:00:15 4.7 kph 356° true - diff --git a/branches/gpst.gpsman-format/tests/log.unix.mcsv b/branches/gpst.gpsman-format/tests/log.unix.mcsv deleted file mode 100644 index ccc20e0..0000000 --- a/branches/gpst.gpsman-format/tests/log.unix.mcsv +++ /dev/null @@ -1,13 +0,0 @@ -Track ACTIVE LOG 058 21.02.2006 15:14:25 (UTC) 00:05:53 2.91 km 30 kph - -Header Position Time Altitude Depth Leg Length Leg Time Leg Speed Leg Course - -Trackpoint N60.36662 E5.24885 21.02.2006 15:14:25 (UTC) 31.9 m -Trackpoint N60.37057 E5.22956 21.02.2006 15:14:30 (UTC) 35.2 m 1.15 km 00:00:05 828 kph 293° true -Trackpoint N60.37019 E5.22817 21.02.2006 15:14:35 (UTC) 39.6 m 87.1 m 00:00:05 63 kph 241° true -Trackpoint N60.37012 E5.22790 21.02.2006 15:14:36 (UTC) 41.0 m 16.8 m 00:00:01 60 kph 245° true -Trackpoint N60.37009 E5.22682 21.02.2006 15:14:40 (UTC) 47.2 m 59.5 m 00:00:04 54 kph 267° true -Trackpoint N60.37011 E5.22641 21.02.2006 15:14:42 (UTC) 49.2 m 22.8 m 00:00:02 41 kph 276° true -Trackpoint N60.37011 E5.22607 21.02.2006 15:14:44 (UTC) 50.1 m 18.4 m 00:00:02 33 kph 267° true -Trackpoint N60.37002 E5.22568 21.02.2006 15:14:48 (UTC) 51.1 m 23.6 m 00:00:04 21 kph 247° true -Trackpoint N60.37010 E5.22548 21.02.2006 15:14:51 (UTC) 52.5 m 13.3 m 00:00:03 16 kph 306° true diff --git a/branches/gpst.gpsman-format/tests/log/tests.log b/branches/gpst.gpsman-format/tests/log/tests.log deleted file mode 100644 index d8ae01e..0000000 --- a/branches/gpst.gpsman-format/tests/log/tests.log +++ /dev/null @@ -1,333 +0,0 @@ -# Testing conversion routines... -ok - txt_to_xml("abc") -ok - txt_to_xml("<&>") -ok - txt_to_xml() with multiline string -ok - xml_to_txt("abc") -ok - xml_to_txt("<&>") -ok - xml_to_txt() with multiline string -ok - postgresql_copy_safe() with empty string -ok - postgresql_copy_safe("abcæøåÆØÅ") -ok - postgresql_copy_safe("abc\t'\r\n") -ok - postgresql_copy_safe() with multiline, nulls and stuff -# Testing date routines... -ok - sec_to_string() without separator -ok - sec_to_string() with separator -ok - sec_to_string(-5000) — negative numbers unsupported atm -ok - sec_to_string("") -ok - sec_to_string() with invalid string -ok - sec_to_string() with a bunch of leading zeros -ok - sec_to_string() with decimals -ok - sec_to_string() with decimals and prefixing zeros -ok - sec_to_string() with decimals and extra trailing zeros -ok - sec_to_string() with missing zero before decimal point -ok - sec_to_readable(0) -ok - sec_to_readable() with invalid string -ok - sec_to_readable(86400) -ok - sec_to_readable(86400*1000) -ok - sec_to_readable(86400+7200+180+4) -ok - sec_to_readable("3.14") -ok - sec_to_readable() rejects negative numbers -ok - sec_to_readable() rejects negative decimal -ok - sec_to_readable(), missing zero before decimal point -ok - sec_to_readable() with empty string -# Testing geo routines... -ok - ddd_to_dms("12.34567") -ok - ddd_to_dms("0") -ok - ddd_to_dms("0.00001") — Precision of DDD with five decimals -ok - ddd_to_dms("") -ok - ddd_to_dms("pH()rtY tW0") -ok - ddd_to_dms("-12.34567") -ok - ddd_to_dms("0.34567") -ok - ddd_to_dms(".34567") -ok - ddd_to_dms("-.34567") -ok - ddd_to_dms("-0.34567") -ok - ddd_to_dms("180") -ok - ddd_to_dms("-180") -ok - ddd_to_dms("-1") -ok - ddd_to_dms("2-3") -ok - dms_to_ddd() with no parameters -ok - dms_to_ddd(0, 0, 0) -ok - dms_to_ddd(12, 30, 45) -ok - dms_to_ddd() with invalid degrees -ok - dms_to_ddd() with invalid minutes -ok - dms_to_ddd() with invalid seconds -ok - dms_to_ddd() with empty degree string -ok - dms_to_ddd() with empty second string -ok - dms_to_ddd() doesn’t accept negative degrees atm -ok - dms_to_ddd() doesn’t accept negative minutes atm -ok - dms_to_ddd() doesn’t accept negative seconds atm -ok - dms_to_ddd(0, 0, 0.1) — Precision of DMS with one decimal -ok - dms_to_ddd(2, 30) -ok - dms_to_ddd(4) -ok - dms_to_ddd(4.3) -ok - dms_to_ddd(120.5, 0.3) -# Testing trackpoint()... -ok - trackpoint() receives empty hash -ok - trackpoint() (gpsml) -ok - trackpoint() (gpx) -ok - trackpoint(): {'format'} with invalid value ("2d") returns undef -ok - trackpoint(): {'lat'} with invalid value ("2d") returns undef -ok - trackpoint(): {'lon'} with invalid value ("2d") returns undef -ok - trackpoint(): {'type'} with invalid value ("2d") returns undef -ok - trackpoint(): {'year'} with empty value skips time -ok - trackpoint(): {'year'} with invalid value ("2d") skips time -ok - trackpoint(): Strip prefixing zeros from {'year'} -ok - trackpoint(): {'year'} is negative, skip time -ok - trackpoint(): Decimals in {'year'}, skip time -ok - trackpoint(): {'month'} with empty value skips time -ok - trackpoint(): {'month'} with invalid value ("2d") skips time -ok - trackpoint(): Strip prefixing zeros from {'month'} -ok - trackpoint(): {'month'} is negative, skip time -ok - trackpoint(): Decimals in {'month'}, skip time -ok - trackpoint(): {'day'} with empty value skips time -ok - trackpoint(): {'day'} with invalid value ("2d") skips time -ok - trackpoint(): Strip prefixing zeros from {'day'} -ok - trackpoint(): {'day'} is negative, skip time -ok - trackpoint(): Decimals in {'day'}, skip time -ok - trackpoint(): {'hour'} with empty value skips time -ok - trackpoint(): {'hour'} with invalid value ("2d") skips time -ok - trackpoint(): Strip prefixing zeros from {'hour'} -ok - trackpoint(): {'hour'} is negative, skip time -ok - trackpoint(): Decimals in {'hour'}, skip time -ok - trackpoint(): {'min'} with empty value skips time -ok - trackpoint(): {'min'} with invalid value ("2d") skips time -ok - trackpoint(): Strip prefixing zeros from {'min'} -ok - trackpoint(): {'min'} is negative, skip time -ok - trackpoint(): Decimals in {'min'}, skip time -ok - trackpoint(): {'sec'} with empty value skips time -ok - trackpoint(): {'sec'} with invalid value ("2d") skips time -ok - trackpoint(): Strip prefixing zeros from {'sec'} -ok - trackpoint(): {'sec'} is negative, skip time -ok - trackpoint(): Remove trailing zeros in {'sec'} decimals -ok - trackpoint(): Missing {'format'}, return undef -ok - trackpoint(): Missing {'type'}, return undef -ok - trackpoint(): Missing {'error'}, return undef -# Testing output from ../gpst -# Read empty input (/dev/null)... -ok - "../gpst ' | ../gpst" - Don’t print empty trackpoints -ok - "echo ' ' | ../gpst" - Don’t print empty trackpoints (stderr) -# Testing --chronology option... -ok - "../gpst --chronology chronology-error.gpsml" - Check for chronology errors and duplicated times -ok - "../gpst --chronology chronology-error.gpsml" - Check for chronology errors and duplicated times (stderr) -# Testing --skip-dups option... -ok - "../gpst -d no_signal.mayko" - Remove duplicated positions from gpsml -ok - "../gpst -d no_signal.mayko" - Remove duplicated positions from gpsml (stderr) -ok - "../gpst -d -o csv no_signal.mayko" - Remove duplicated positions from csv output format -ok - "../gpst -d -o csv no_signal.mayko" - Remove duplicated positions from csv output format (stderr) -ok - "../gpst -d -o clean no_signal.mayko" - Remove duplicated positions from clean output format -ok - "../gpst -d -o clean no_signal.mayko" - Remove duplicated positions from clean output format (stderr) -ok - "../gpst -d -o pgtab no_signal.mayko" - Remove duplicated positions from pgtab output format -ok - "../gpst -d -o pgtab no_signal.mayko" - Remove duplicated positions from pgtab output format (stderr) -# Testing --epoch option... -ok - "../gpst -e pause.gpx" - --epoch is ignored in gpsml output -ok - "../gpst -e pause.gpx" - --epoch is ignored in gpsml output (stderr) -ok - "../gpst -e -o gpx pause.gpx" - --epoch is ignored in gpx output -ok - "../gpst -e -o gpx pause.gpx" - --epoch is ignored in gpx output (stderr) -# Testing --fix option... -ok - "../gpst --fix --chronology chronology-error.gpsml" - Remove bad timestamps -ok - "../gpst --fix --chronology chronology-error.gpsml" - Remove bad timestamps (stderr) -# Testing --from-date option... -# Testing --help option... -ok - Check -h (--help) option -# Testing --inside option... -ok - "../gpst --pos1 2.11,2.12 --pos2 3.31,3.32 --inside multitrack-pause.gpx" - Check --inside option (gpx to gpst) -ok - "../gpst --pos1 2.11,2.12 --pos2 3.31,3.32 --inside multitrack-pause.gpx" - Check --inside option (gpx to gpst) (stderr) -# Testing --undefined option... -# Testing --near option... -# Testing --output option... -ok - "../gpst log.mcsv" - Read Mapsource TAB-separated format -ok - "../gpst log.mcsv" - Read Mapsource TAB-separated format (stderr) -ok - "../gpst two-digit_year.mcsv" - Read Mapsource TAB-separated format with two-digit year -ok - "../gpst two-digit_year.mcsv" - Read Mapsource TAB-separated format with two-digit year (stderr) -ok - "../gpst log.gpstxt" - Read Garmin serial text format -ok - "../gpst log.gpstxt" - Read Garmin serial text format (stderr) -ok - "../gpst log.dos.mayko" - Read DOS-formatted Mayko format -ok - "../gpst log.dos.mayko" - Read DOS-formatted Mayko format (stderr) -ok - "../gpst log.dos.gpstxt" - Read DOS-formatted Garmin serial text format -ok - "../gpst log.dos.gpstxt" - Read DOS-formatted Garmin serial text format (stderr) -ok - "../gpst log.unix.mcsv" - Read UNIX-formatted Garmin Mapsource TAB-separated format -ok - "../gpst log.unix.mcsv" - Read UNIX-formatted Garmin Mapsource TAB-separated format (stderr) -ok - "../gpst multitrack.gpx" - Read GPX file with multiple tracks -ok - "../gpst multitrack.gpx" - Read GPX file with multiple tracks (stderr) -ok - "../gpst compact.gpx" - Read GPX one-liner -ok - "../gpst compact.gpx" - Read GPX one-liner (stderr) -ok - "../gpst missing.gpsml" - Read gpsml with various data missing -ok - "../gpst missing.gpsml" - Read gpsml with various data missing (stderr) -ok - "../gpst different_dateformats.gpsml" - Read different date formats from gpsml file -ok - "../gpst different_dateformats.gpsml" - Read different date formats from gpsml file (stderr) -ok - "../gpst multitrack-pause.gpx" - Should be equal to multitrack-pause.gpsml -ok - "../gpst multitrack-pause.gpx" - Should be equal to multitrack-pause.gpsml (stderr) -ok - "../gpst -o gpx no_signal.mayko" - Output GPX from Mayko file with duplicates -ok - "../gpst -o gpx no_signal.mayko" - Output GPX from Mayko file with duplicates (stderr) -ok - "../gpst -o gpx comments.mayko" - Output GPX from Mayko file with commented-out lines -ok - "../gpst -o gpx comments.mayko" - Output GPX from Mayko file with commented-out lines (stderr) -ok - "../gpst -o gpx missing.gpsml" - Output GPX from gpsml with missing data -ok - "../gpst -o gpx missing.gpsml" - Output GPX from gpsml with missing data (stderr) -ok - "../gpst -o xgraph multitrack.gpx" - Output xgraph format from GPX -ok - "../gpst -o xgraph multitrack.gpx" - Output xgraph format from GPX (stderr) -ok - "../gpst -o pgtab compact.gpx" - Output pgtab from gpx format -ok - "../gpst -o pgtab compact.gpx" - Output pgtab from gpx format (stderr) -ok - "../gpst -o pgtab no_signal.mayko" - Output pgtab from mayko format -ok - "../gpst -o pgtab no_signal.mayko" - Output pgtab from mayko format (stderr) -ok - "../gpst -o pgtab missing.gpsml" - Output pgtab from missing.gpsml -ok - "../gpst -o pgtab missing.gpsml" - Output pgtab from missing.gpsml (stderr) -ok - "../gpst -o csv log.dos.mayko" - Output csv from DOS-formatted Mayko format -ok - "../gpst -o csv log.dos.mayko" - Output csv from DOS-formatted Mayko format (stderr) -ok - "../gpst -o pgwtab multitrack.gpx" - Test pgwtab format -ok - "../gpst -o pgwtab multitrack.gpx" - Test pgwtab format (stderr) -ok - "../gpst -o pgwupd multitrack.gpx" - Test pgwupd format -ok - "../gpst -o pgwupd multitrack.gpx" - Test pgwupd format (stderr) -ok - "../gpst -t -o clean pause.gpx" - Output clean format with time breaks -ok - "../gpst -t -o clean pause.gpx" - Output clean format with time breaks (stderr) -# Testing --outside option... -ok - "../gpst --pos1 2.11,2.12 --pos2 3.31,3.32 --outside multitrack-pause.gpx" - Check --outside option (gpx to gpst) -ok - "../gpst --pos1 2.11,2.12 --pos2 3.31,3.32 --outside multitrack-pause.gpx" - Check --outside option (gpx to gpst) (stderr) -# Testing --pos1 and --pos2 options... -# Testing --require option... -ok - "../gpst -re multitrack.gpx" - Require elevation from GPX data -ok - "../gpst -re multitrack.gpx" - Require elevation from GPX data (stderr) -ok - "../gpst tracks.gpsman" - Output gpsml format from gpsman -ok - "../gpst tracks.gpsman" - Output gpsml format from gpsman (stderr) -not ok - "../gpst -o gpx -R lat=7,lon=7,ele=2 tracks.gpsman" - Output GPX format from gpsman -# Failed test '"../gpst -o gpx -R lat=7,lon=7,ele=2 tracks.gpsman" - Output GPX format from gpsman' -# in ./run-tests.pl at line 2023. -# got: ' -# -# -# -# 54.45 -# 54.45 -# -# -# 1494.99 -# -# -# 1494.99 -# 1494.03 -# -# -# 183.27 -# 184.71 -# -# -# 180.38 -# 181.35 -# 182.31 -# -# -# -# ' -# expected: ' -# -# -# ACTIVE LOG -# -# 54.45 -# 54.45 -# -# -# 1494.99 -# -# -# 1494.99 -# 1494.03 -# -# -# 183.27 -# 184.71 -# -# -# 180.38 -# 181.35 -# 182.31 -# -# -# -# ' -ok - "../gpst -o gpx -R lat=7,lon=7,ele=2 tracks.gpsman" - Output GPX format from gpsman (stderr) -ok - "../gpst -re one_ele.dos.gpsml" - Require elevation from gpsml -ok - "../gpst -re one_ele.dos.gpsml" - Require elevation from gpsml (stderr) -ok - "../gpst -re missing.gpsml" - Require elevation # TODO Shall lat/lon be cleared if one is missing? -ok - "../gpst -re missing.gpsml" - Require elevation (stderr) # TODO Shall lat/lon be cleared if one is missing? -ok - "../gpst -rt missing.gpsml" - Require time # TODO Shall lat/lon be cleared if one is missing? -ok - "../gpst -rt missing.gpsml" - Require time (stderr) # TODO Shall lat/lon be cleared if one is missing? -ok - "../gpst -rp missing.gpsml" - Require position # TODO Shall lat/lon be cleared if one is missing? -ok - "../gpst -rp missing.gpsml" - Require position (stderr) # TODO Shall lat/lon be cleared if one is missing? -ok - "../gpst -ret missing.gpsml" - Require elevation and time # TODO Shall lat/lon be cleared if one is missing? -ok - "../gpst -ret missing.gpsml" - Require elevation and time (stderr) # TODO Shall lat/lon be cleared if one is missing? -ok - "../gpst -retp missing.gpsml" - Require elevation, time and position # TODO Shall lat/lon be cleared if one is missing? -ok - "../gpst -retp missing.gpsml" - Require elevation, time and position (stderr) # TODO Shall lat/lon be cleared if one is missing? -ok - "../gpst -rep missing.gpsml" - Require elevation and position # TODO Shall lat/lon be cleared if one is missing? -ok - "../gpst -rep missing.gpsml" - Require elevation and position (stderr) # TODO Shall lat/lon be cleared if one is missing? -# Testing --round option... -ok - "../gpst -R lat=4,lon=5,ele=1 pause.gpx" - --round works with lat, lon, ele from gpx -ok - "../gpst -R lat=4,lon=5,ele=1 pause.gpx" - --round works with lat, lon, ele from gpx (stderr) -# Testing --short-date option... -# Testing --save-to-file option... -# Testing --create-breaks option... -ok - "../gpst -t pause.gpx" - Output gpsml with elements from GPX files -ok - "../gpst -t pause.gpx" - Output gpsml with elements from GPX files (stderr) -ok - "../gpst -t multitrack-pause.gpx" - Insert between gpx tracks -ok - "../gpst -t multitrack-pause.gpx" - Insert between gpx tracks (stderr) -ok - "../gpst -t multitrack-pause.gpsml" - Insert between gpsml titles -ok - "../gpst -t multitrack-pause.gpsml" - Insert between gpsml titles (stderr) -# Testing --comment-out-dups option... -ok - "../gpst -u no_signal.mayko >nosignal.tmp" - Redirect stdout -ok - "../gpst -u no_signal.mayko >nosignal.tmp" - Redirect stdout (stderr) -ok - "../gpst nosignal.tmp" - Read output from 'gpst -u *.mayko' -ok - "../gpst nosignal.tmp" - Read output from 'gpst -u *.mayko' (stderr) -ok - "../gpst -u no_signal.mayko" - Read Mayko format with no signal, output old Mayko format -ok - "../gpst -u no_signal.mayko" - Read Mayko format with no signal, output old Mayko format (stderr) -# Testing --verbose option... -# Testing --version option... -ok - "../gpst --version" - The --version option outputs Id strings -# Testing --strip-whitespace option... -ok - "../gpst -w -o gpx pause.gpx" - Strip whitespace from GPX output -ok - "../gpst -w -o gpx pause.gpx" - Strip whitespace from GPX output (stderr) -ok - "../gpst -o gpx -w comments.mayko" - Output whitespace-stripped GPX from Mayko file with commented-out lines -ok - "../gpst -o gpx -w comments.mayko" - Output whitespace-stripped GPX from Mayko file with commented-out lines (stderr) -# Testing --double-y-scale option... -ok - "../gpst -y -o clean pause.gpx" - Double y scale, clean output from gpx format -ok - "../gpst -y -o clean pause.gpx" - Double y scale, clean output from gpx format (stderr) -ok - "../gpst -y -o clean log.dos.mayko" - Double y scale, clean output from mayko format -ok - "../gpst -y -o clean log.dos.mayko" - Double y scale, clean output from mayko format (stderr) -# Testing --debug option... -# Strip error from Mayko format... -ok - "../gpst -o csv date_error.mayko" - Strip error from mayko format in csv output -ok - "../gpst -o csv date_error.mayko" - Strip error from mayko format in csv output (stderr) -ok - "../gpst -o clean date_error.mayko" - Strip error from mayko format in clean output -ok - "../gpst -o clean date_error.mayko" - Strip error from mayko format in clean output (stderr) -ok - "../gpst -o gpsml date_error.mayko" - Strip error from mayko format in gpsml output -ok - "../gpst -o gpsml date_error.mayko" - Strip error from mayko format in gpsml output (stderr) -ok - "../gpst -o gpx date_error.mayko" - Strip error from mayko format in gpx output -ok - "../gpst -o gpx date_error.mayko" - Strip error from mayko format in gpx output (stderr) -ok - "../gpst -o gpstrans date_error.mayko" - Strip error from mayko format in gpstrans output -ok - "../gpst -o gpstrans date_error.mayko" - Strip error from mayko format in gpstrans output (stderr) -ok - "../gpst -o pgtab date_error.mayko" - Strip error from mayko format in pgtab output -ok - "../gpst -o pgtab date_error.mayko" - Strip error from mayko format in pgtab output (stderr) -ok - "../gpst -o poscount date_error.mayko" - Strip error from mayko format in poscount output -ok - "../gpst -o poscount date_error.mayko" - Strip error from mayko format in poscount output (stderr) -ok - "../gpst -o xgraph date_error.mayko" - Strip error from mayko format in xgraph output -ok - "../gpst -o xgraph date_error.mayko" - Strip error from mayko format in xgraph output (stderr) -ok - "../gpst -o ygraph date_error.mayko" - Strip error from mayko format in ygraph output -ok - "../gpst -o ygraph date_error.mayko" - Strip error from mayko format in ygraph output (stderr) -# Testing finished. -1..232 -# Looks like you failed 1 test of 232. diff --git a/branches/gpst.gpsman-format/tests/log/todo-tests.log b/branches/gpst.gpsman-format/tests/log/todo-tests.log deleted file mode 100644 index bcd9f5e..0000000 --- a/branches/gpst.gpsman-format/tests/log/todo-tests.log +++ /dev/null @@ -1,225 +0,0 @@ -# Running TODO tests... -not ok - "../gpst -o csv multitrack.gpx" - Output csv format from gpx # TODO Remove extra \n in the beginning -# Failed (TODO) test '"../gpst -o csv multitrack.gpx" - Output csv format from gpx' -# in ./run-tests.pl at line 2023. -# got: ' -# 2003-02-11T23:35:39Z -0.1448824 51.4968266 -# 2003-02-11T23:35:49Z -0.1449938 51.4968227 -# 2003-02-11T23:36:14Z -0.1453202 51.4969040 -# -# 2003-02-11T23:36:16Z -0.1453398 51.4969214 -# 2003-02-11T23:36:31Z -0.1455514 51.4969816 -# 2003-02-11T23:36:43Z -0.1457489 51.4970224 1000 -# 2003-02-11T23:36:50Z -0.1457804 51.4970452 -# -# 2003-02-11T23:37:05Z -0.1458608 51.4970680 -# 2003-02-11T23:37:22Z -0.1460047 51.4971658 -# 2003-02-11T23:37:36Z -0.1461614 51.4972469 -# -# 2003-02-11T23:37:43Z -0.1462394 51.4972731 -# 2003-02-11T23:38:04Z -0.1463232 51.4973437 -# 2003-02-11T23:38:28Z -0.1462949 51.4973337 -# 2003-02-11T23:38:34Z -0.1462825 51.4973218 -# 2003-02-11T23:38:35Z -0.1462732 51.4973145 -# ' -# expected: '2003-02-11T23:35:39Z -0.1448824 51.4968266 -# 2003-02-11T23:35:49Z -0.1449938 51.4968227 -# 2003-02-11T23:36:14Z -0.1453202 51.4969040 -# -# 2003-02-11T23:36:16Z -0.1453398 51.4969214 -# 2003-02-11T23:36:31Z -0.1455514 51.4969816 -# 2003-02-11T23:36:43Z -0.1457489 51.4970224 1000 -# 2003-02-11T23:36:50Z -0.1457804 51.4970452 -# -# 2003-02-11T23:37:05Z -0.1458608 51.4970680 -# 2003-02-11T23:37:22Z -0.1460047 51.4971658 -# 2003-02-11T23:37:36Z -0.1461614 51.4972469 -# -# 2003-02-11T23:37:43Z -0.1462394 51.4972731 -# 2003-02-11T23:38:04Z -0.1463232 51.4973437 -# 2003-02-11T23:38:28Z -0.1462949 51.4973337 -# 2003-02-11T23:38:34Z -0.1462825 51.4973218 -# 2003-02-11T23:38:35Z -0.1462732 51.4973145 -# ' -ok - "../gpst -o csv multitrack.gpx" - Output csv format from gpx (stderr) # TODO Remove extra \n in the beginning -not ok - "../gpst -o csv pause.gpx" - csv format from gpx # TODO Remove extra \n in the beginning -# Failed (TODO) test '"../gpst -o csv pause.gpx" - csv format from gpx' -# in ./run-tests.pl at line 2023. -# got: ' -# 2006-05-21T16:49:11Z 5.299534 60.425494 25.260 -# 2006-05-21T16:49:46Z 5.299610 60.425464 24.931 -# 2006-05-21T16:52:04Z 5.299694 60.425314 27.975 -# 2006-05-21T16:56:36Z 5.299741 60.425384 31.017 -# 2006-05-21T16:56:47Z 5.299958 60.425339 30.980 -# 2006-05-21T16:56:56Z 5.299640 60.425238 30.538 -# 2006-05-21T16:57:03Z 5.299686 60.425246 30.515 -# 2006-05-21T16:59:08Z 5.299773 60.425345 31.936 -# 2006-05-21T17:00:54Z 5.299419 60.425457 31.794 -# ' -# expected: '2006-05-21 16:49:11 5.299534 60.425494 25.260 -# 2006-05-21 16:49:46 5.299610 60.425464 24.931 -# 2006-05-21 16:52:04 5.299694 60.425314 27.975 -# 2006-05-21 16:56:36 5.299741 60.425384 31.017 -# 2006-05-21 16:56:47 5.299958 60.425339 30.980 -# 2006-05-21 16:56:56 5.299640 60.425238 30.538 -# 2006-05-21 16:57:03 5.299686 60.425246 30.515 -# 2006-05-21 16:59:08 5.299773 60.425345 31.936 -# 2006-05-21 17:00:54 5.299419 60.425457 31.794 -# ' -ok - "../gpst -o csv pause.gpx" - csv format from gpx (stderr) # TODO Remove extra \n in the beginning -not ok - "../gpst -e -o csv pause.gpx" - csv format with epoch seconds from gpx # TODO Remove extra \n in the beginning -# Failed (TODO) test '"../gpst -e -o csv pause.gpx" - csv format with epoch seconds from gpx' -# in ./run-tests.pl at line 2023. -# got: ' -# 1148230151 5.299534 60.425494 25.260 -# 1148230186 5.299610 60.425464 24.931 -# 1148230324 5.299694 60.425314 27.975 -# 1148230596 5.299741 60.425384 31.017 -# 1148230607 5.299958 60.425339 30.980 -# 1148230616 5.299640 60.425238 30.538 -# 1148230623 5.299686 60.425246 30.515 -# 1148230748 5.299773 60.425345 31.936 -# 1148230854 5.299419 60.425457 31.794 -# ' -# expected: '1148230151 5.299534 60.425494 25.260 -# 1148230186 5.299610 60.425464 24.931 -# 1148230324 5.299694 60.425314 27.975 -# 1148230596 5.299741 60.425384 31.017 -# 1148230607 5.299958 60.425339 30.980 -# 1148230616 5.299640 60.425238 30.538 -# 1148230623 5.299686 60.425246 30.515 -# 1148230748 5.299773 60.425345 31.936 -# 1148230854 5.299419 60.425457 31.794 -# ' -ok - "../gpst -e -o csv pause.gpx" - csv format with epoch seconds from gpx (stderr) # TODO Remove extra \n in the beginning -not ok - "../gpst -u no_signal.mayko" - Output gpsml from the -u option # TODO Use gpsml, this Mayko thing is obsolete. -# Failed (TODO) test '"../gpst -u no_signal.mayko" - Output gpsml from the -u option' -# in ./run-tests.pl at line 2023. -# got: 'xmaplog 1.0 Mon Dec 23 02:00:50 2002 -# 1 70.6800486 23.6746151 57.4 0 12/22/2002 21:42:24 -# 1 70.6799322 23.6740038 6.3 0 12/22/2002 21:42:32 -# 1 70.6796266 23.6723991 6.0 0 12/22/2002 21:42:54 -# # 20021222T214351-20021222T214354: CO: No signal {{{ -# # 1 70.6796266 23.6723991 0.0 0 12/22/2002 21:43:51 -# # 1 70.6796266 23.6723991 0.0 0 12/22/2002 21:43:52 -# # 1 70.6796266 23.6723991 0.0 0 12/22/2002 21:43:54 -# # 20021222T214351-20021222T214354: CO: No signal }}} -# # move -# 1 70.6800774 23.6757566 5.1 0 12/22/2002 21:44:45 -# 1 70.6801502 23.6753442 4.8 0 12/22/2002 21:44:52 -# 1 70.6801905 23.6757542 2.5 0 12/22/2002 21:45:04 -# ' -# expected: ' -# -# -# 70.6800486 23.6746151 -# 70.6799322 23.6740038 -# 70.6796266 23.6723991 -# 20021222T214351-20021222T214354: CO: No signal {{{ -# 70.6796266 23.6723991 -# 70.6796266 23.6723991 -# 70.6796266 23.6723991 -# 20021222T214351-20021222T214354: CO: No signal }}} -# -# 70.6800774 23.6757566 -# 70.6801502 23.6753442 -# 70.6801905 23.6757542 -# -# -# ' -ok - "../gpst -u no_signal.mayko" - Output gpsml from the -u option (stderr) # TODO Use gpsml, this Mayko thing is obsolete. -not ok - "../gpst -o gpx multitrack-pause.gpsml" - Should be equal to multitrack-pause.gpx # TODO Tweak output -# Failed (TODO) test '"../gpst -o gpx multitrack-pause.gpsml" - Should be equal to multitrack-pause.gpx' -# in ./run-tests.pl at line 2023. -# got: ' -# -# -# -# -# -# -# -# -# -# -# -# -# -# -# -# -# -# -# -# -# -# -# -# -# -# -# -# -# -# -# ' -# expected: ' -# -# -# track1 -# -# -# -# -# -# -# -# track2 -# -# -# -# -# -# -# -# -# -# -# -# track3 -# -# -# -# -# -# -# -# -# -# -# -# -# -# -# ' -ok - "../gpst -o gpx multitrack-pause.gpsml" - Should be equal to multitrack-pause.gpx (stderr) # TODO Tweak output -GPX: Cannot open file '/home/sunny/gps/waypoints.gpx'! -not ok - list_nearest_waypoints() # TODO Fix it. -# Failed (TODO) test 'list_nearest_waypoints()' -# in ./run-tests.pl at line 1995. -# '' -# doesn't match '(?-xism:^\(.*,.*,.*\)$)' -# Testing finished. -1..11 diff --git a/branches/gpst.gpsman-format/tests/missing.gpsml b/branches/gpst.gpsman-format/tests/missing.gpsml deleted file mode 100644 index 9956675..0000000 --- a/branches/gpst.gpsman-format/tests/missing.gpsml +++ /dev/null @@ -1,20 +0,0 @@ - - - -Missing various elements - - 60.42352 - 60.42353 5.34185 - 5.34187 483 - 485 - 60.42347 5.34212 486 - 5.34224 484 - 486 - Missing everything - - 60.42339 - 5.34262 - 60.42339 490 - 60.42338 5.34269 487 - - diff --git a/branches/gpst.gpsman-format/tests/multitrack-pause.gpsml b/branches/gpst.gpsman-format/tests/multitrack-pause.gpsml deleted file mode 100644 index 1133753..0000000 --- a/branches/gpst.gpsman-format/tests/multitrack-pause.gpsml +++ /dev/null @@ -1,28 +0,0 @@ - - - -track1 - 1.11 1.12 - 1.21 1.22 - 1.31 1.32 - -track2 - 2.11 2.12 - 2.21 2.22 - 2.31 2.32 - 2.41 2.42 - - 2.451 2.452 - -track3 - 3.11 3.12 - 3.21 3.22 - 3.31 3.32 - - 3.41 3.42 - 3.51 3.52 - 3.61 3.62 - 3.71 3.72 - 3.81 3.82 - - diff --git a/branches/gpst.gpsman-format/tests/multitrack-pause.gpx b/branches/gpst.gpsman-format/tests/multitrack-pause.gpx deleted file mode 100644 index df92af6..0000000 --- a/branches/gpst.gpsman-format/tests/multitrack-pause.gpx +++ /dev/null @@ -1,44 +0,0 @@ - - - - track1 - - - - - - - - track2 - - - - - - - - - - - - track3 - - - - - - - - - - - - - - diff --git a/branches/gpst.gpsman-format/tests/multitrack.gpx b/branches/gpst.gpsman-format/tests/multitrack.gpx deleted file mode 100644 index c4577af..0000000 --- a/branches/gpst.gpsman-format/tests/multitrack.gpx +++ /dev/null @@ -1,81 +0,0 @@ - - - - 0-Meridian - 11-FEB-03 15:46 - 11-FEB-03 15:46 - - - 34.492798 - Abbey Road - Det hellige gangfeltet der Beatles valsa over. - 26-FEB-06 17:29:46 - - - 2469.012939 - - Galdhøpiggen med ', &, < og >. ☺ - Her er det &, < og >. ☺ - Schwæra greie - http://www.example.org/ - Waypoint - mountain - - - Halfdan Griegs vei - 04-AUG-02 19:42 - 04-AUG-02 19:42 - - - Leicester Square - 11-FEB-03 18:00 - 11-FEB-03 18:00 - - - Leira camping - 03-OKT-02 21:58 - 03-OKT-02 21:58 - - - Track 1 - - - - - - - - - Track 2 - - - - 1000 - - - - - Track 3 - - - - - - - - Track 4 - - - - - - - - - diff --git a/branches/gpst.gpsman-format/tests/no_signal.mayko b/branches/gpst.gpsman-format/tests/no_signal.mayko deleted file mode 100644 index 21bb9c8..0000000 --- a/branches/gpst.gpsman-format/tests/no_signal.mayko +++ /dev/null @@ -1,10 +0,0 @@ -xmaplog 1.0 Mon Dec 23 02:00:50 2002 -1 70.6800486 23.6746151 57.4 0 12/22/2002 21:42:24 -1 70.6799322 23.6740038 6.3 0 12/22/2002 21:42:32 -1 70.6796266 23.6723991 6.0 0 12/22/2002 21:42:54 -1 70.6796266 23.6723991 0.0 0 12/22/2002 21:43:51 -1 70.6796266 23.6723991 0.0 0 12/22/2002 21:43:52 -1 70.6796266 23.6723991 0.0 0 12/22/2002 21:43:54 -1 70.6800774 23.6757566 5.1 0 12/22/2002 21:44:45 -1 70.6801502 23.6753442 4.8 0 12/22/2002 21:44:52 -1 70.6801905 23.6757542 2.5 0 12/22/2002 21:45:04 diff --git a/branches/gpst.gpsman-format/tests/one_ele.dos.gpsml b/branches/gpst.gpsman-format/tests/one_ele.dos.gpsml deleted file mode 100644 index 5f69d87..0000000 --- a/branches/gpst.gpsman-format/tests/one_ele.dos.gpsml +++ /dev/null @@ -1,12 +0,0 @@ - - - -Only one point has elevation - 60.425494 5.299534 - 60.425464 5.29961 - 60.425314 5.299694 27.975 - 60.425384 5.299741 - 60.425339 5.299958 - 60.425238 5.29964 - - diff --git a/branches/gpst.gpsman-format/tests/pause.gpx b/branches/gpst.gpsman-format/tests/pause.gpx deleted file mode 100644 index ab163ea..0000000 --- a/branches/gpst.gpsman-format/tests/pause.gpx +++ /dev/null @@ -1,44 +0,0 @@ - - - - ACTIVE LOG164705 - - - 25.260 - - - - 24.931 - - - - 27.975 - - - - 31.017 - - - - 30.980 - - - - 30.538 - - - - 30.515 - - - - 31.936 - - - - 31.794 - - - - - diff --git a/branches/gpst.gpsman-format/tests/run-tests.pl b/branches/gpst.gpsman-format/tests/run-tests.pl deleted file mode 100755 index 3c9edcf..0000000 --- a/branches/gpst.gpsman-format/tests/run-tests.pl +++ /dev/null @@ -1,2186 +0,0 @@ -#!/usr/bin/perl -w - -#======================================================================= -# $Id$ -# Test suite for gpst. -# -# Character set: UTF-8 -# ©opyleft 2006– Øyvind A. Holm -# License: GNU General Public License version 2 or later, see end of -# file for legal stuff. -#======================================================================= - -BEGIN { - push(@INC, "$ENV{'HOME'}/bin/src/gpstools"); - our @version_array; -} - -use strict; -use Getopt::Long; -use Test::More qw{no_plan}; - -use GPST; -use GPSTdate; -use GPSTdebug; -use GPSTgeo; -use GPSTxml; - -$| = 1; - -our $Debug = 0; - -our %Opt = ( - 'all' => 0, - 'debug' => 0, - 'help' => 0, - 'todo' => 0, - 'verbose' => 0, - 'version' => 0, -); - -our $progname = $0; -$progname =~ s/^.*\/(.*?)$/$1/; - -my $rcs_id = '$Id$'; -my $id_date = $rcs_id; -$id_date =~ s/^.*?\d+ (\d\d\d\d-.*?\d\d:\d\d:\d\d\S+).*/$1/; - -push(@main::version_array, $rcs_id); - -Getopt::Long::Configure("bundling"); -GetOptions( - "all|a" => \$Opt{'all'}, - "debug" => \$Opt{'debug'}, - "help|h" => \$Opt{'help'}, - "todo|t" => \$Opt{'todo'}, - "verbose|v+" => \$Opt{'verbose'}, - "version" => \$Opt{'version'}, -) || die("$progname: Option error. Use -h for help.\n"); - -our %Cmd = ( - 'gpsbabel' => '/usr/local/bin/gpsbabel', -); - -$Opt{'debug'} && ($Debug = 1); -$Opt{'help'} && usage(0); -$Opt{'version'} && print_version(); - -chomp(my $gpx_header = < - -END -my $stripped_gpx_header = $gpx_header; -$stripped_gpx_header =~ s/^\s*(.*)$/$1/mg; - -if ($Opt{'todo'} && !$Opt{'all'}) { - goto todo_section; -} - -diag("Testing conversion routines..."); - -# txt_to_xml() and xml_to_txt() {{{ - -is(txt_to_xml("abc"), - "abc", - "txt_to_xml(\"abc\")"); -is(txt_to_xml("<&>"), - "<&>", - "txt_to_xml(\"<&>\")"); -is(txt_to_xml("first line\nsecond <\rthird\r\n<&>"), - "first line\nsecond <\rthird\r\n<&>", - "txt_to_xml() with multiline string"); - -is(xml_to_txt("abc"), - "abc", - "xml_to_txt(\"abc\")"); -is(xml_to_txt("<&>"), - "<&>", - "xml_to_txt(\"<&>\")"); -is(xml_to_txt("first line\nsecond <\rthird\r\n<&>"), - "first line\nsecond <\rthird\r\n<&>", - "xml_to_txt() with multiline string"); - -# txt_to_xml() and xml_to_txt() }}} -# postgresql_copy_safe() {{{ - -is(postgresql_copy_safe(""), - "", - "postgresql_copy_safe() with empty string"); - -is(postgresql_copy_safe("abcæøåÆØÅ"), - "abcæøåÆØÅ", - "postgresql_copy_safe(\"abcæøåÆØÅ\")"); - -is(postgresql_copy_safe("abc\t'\r\n"), - "abc\\t'\\r\\n", - "postgresql_copy_safe(\"abc\\t'\\r\\n\")"); - -is(postgresql_copy_safe("¤%/&gurgle\t325\\wer\ndfv'\r!\"#\n%\twe\r\x00sdf\xFFsadc\n\t\x00sdc\n"), - "¤%/&gurgle\\t325\\\\wer\\ndfv'\\r!\"#\\n%\\twe\\r\x00sdf\xFFsadc\\n\\t\x00sdc\\n", - "postgresql_copy_safe() with multiline, nulls and stuff"); - -# postgresql_copy_safe() }}} - -diag("Testing date routines..."); - -# sec_to_string() {{{ - -is(sec_to_string(1148220825), - "2006-05-21 14:13:45", - "sec_to_string() without separator"); -is(sec_to_string(1148220825, "T"), - "2006-05-21T14:13:45", - "sec_to_string() with separator"); -is(sec_to_string(-5000), - undef, - "sec_to_string(-5000) — negative numbers unsupported atm"); -is(sec_to_string(""), - undef, - "sec_to_string(\"\")"); -is(sec_to_string("pH()rtY tW0"), - undef, - "sec_to_string() with invalid string"); -is(sec_to_string("00000000000000000000001148220825"), - "2006-05-21 14:13:45", - "sec_to_string() with a bunch of leading zeros"); -is(sec_to_string("1148220825.93"), - "2006-05-21 14:13:45.93", - "sec_to_string() with decimals"); -is(sec_to_string("000000000000000000000000000001148220825.7312"), - "2006-05-21 14:13:45.7312", - "sec_to_string() with decimals and prefixing zeros"); -is(sec_to_string("1148220825.93000"), - "2006-05-21 14:13:45.93", - "sec_to_string() with decimals and extra trailing zeros"); -is(sec_to_string(".863"), - "1970-01-01 00:00:00.863", - "sec_to_string() with missing zero before decimal point"); - -# sec_to_string() }}} -# sec_to_readable() {{{ - -is(sec_to_readable(0), - "0:00:00:00", - "sec_to_readable(0)"); -is(sec_to_readable("pH()rtY tW0"), - undef, - "sec_to_readable() with invalid string"); -is(sec_to_readable(86400), - "1:00:00:00", - "sec_to_readable(86400)"); -is(sec_to_readable(86400*1000), - "1000:00:00:00", - "sec_to_readable(86400*1000)"); -is(sec_to_readable(86400+7200+180+4), - "1:02:03:04", - "sec_to_readable(86400+7200+180+4)"); -is(sec_to_readable("3.14"), - "0:00:00:03.14", - "sec_to_readable(\"3.14\")"); -is(sec_to_readable("-124"), - undef, - "sec_to_readable() rejects negative numbers"); -is(sec_to_readable("-2.34"), - undef, - "sec_to_readable() rejects negative decimal"); -is(sec_to_readable(".87"), - "0:00:00:00.87", - "sec_to_readable(), missing zero before decimal point"); -is(sec_to_readable(""), - "0:00:00:00", - "sec_to_readable() with empty string"); - -# sec_to_readable() }}} - -diag("Testing geo routines..."); - -# ddd_to_dms() {{{ - -is(ddd_to_dms("12.34567"), - "12\xB020'44.4\"", - "ddd_to_dms(\"12.34567\")"); - -is(ddd_to_dms("0"), - "0\xB000'00.0\"", - "ddd_to_dms(\"0\")"); - -is(ddd_to_dms("0.00001"), - "0\xB000'00.0\"", - "ddd_to_dms(\"0.00001\") — Precision of DDD with five decimals"); - -is(ddd_to_dms(""), - "0\xB000'00.0\"", - "ddd_to_dms(\"\")"); - -is(ddd_to_dms("pH()rtY tW0"), - undef, - "ddd_to_dms(\"pH()rtY tW0\")"); - -is(ddd_to_dms("-12.34567"), - "-12\xB020'44.4\"", - "ddd_to_dms(\"-12.34567\")"); - -is(ddd_to_dms("0.34567"), - "0\xB020'44.4\"", - "ddd_to_dms(\"0.34567\")"); - -is(ddd_to_dms(".34567"), - "0\xB020'44.4\"", - "ddd_to_dms(\".34567\")"); - -is(ddd_to_dms("-.34567"), - "-0\xB020'44.4\"", - "ddd_to_dms(\"-.34567\")"); - -is(ddd_to_dms("-0.34567"), - "-0\xB020'44.4\"", - "ddd_to_dms(\"-0.34567\")"); - -is(ddd_to_dms("180"), - "180\xB000'00.0\"", - "ddd_to_dms(\"180\")"); - -is(ddd_to_dms("-180"), - "-180\xB000'00.0\"", - "ddd_to_dms(\"-180\")"); - -is(ddd_to_dms("-1"), - "-1\xB000'00.0\"", - "ddd_to_dms(\"-1\")"); - -is(ddd_to_dms("2-3"), - undef, - "ddd_to_dms(\"2-3\")"); - -# ddd_to_dms() }}} -# dms_to_ddd() {{{ -is(dms_to_ddd(), - 0, - "dms_to_ddd() with no parameters"); -is(dms_to_ddd(0, 0, 0), - 0, - "dms_to_ddd(0, 0, 0)"); -is(dms_to_ddd(12, 30, 45), - 12.5125, - "dms_to_ddd(12, 30, 45)"); -is(dms_to_ddd("asd", 0, 0), - undef, - "dms_to_ddd() with invalid degrees"); -is(dms_to_ddd(0, "asd", 0), - undef, - "dms_to_ddd() with invalid minutes"); -is(dms_to_ddd(0, 0, "asd"), - undef, - "dms_to_ddd() with invalid seconds"); -is(dms_to_ddd("", 0, 0), - 0, - "dms_to_ddd() with empty degree string"); -is(dms_to_ddd(0, 0, ""), - 0, - "dms_to_ddd() with empty second string"); -is(dms_to_ddd(-12, 30, 45), - undef, - "dms_to_ddd() doesn’t accept negative degrees atm"); -is(dms_to_ddd(12, -30, 45), - undef, - "dms_to_ddd() doesn’t accept negative minutes atm"); -is(dms_to_ddd(12, 30, -45), - undef, - "dms_to_ddd() doesn’t accept negative seconds atm"); -# Weird behaviour, this scientific notation thing. -is(num_expand(sprintf("%.08f", dms_to_ddd(0, 0, 0.1))), - "0.00002778", - "dms_to_ddd(0, 0, 0.1) — Precision of DMS with one decimal"); -is(dms_to_ddd(2, 30), - 2.5, - "dms_to_ddd(2, 30)"); -is(dms_to_ddd(4), - 4, - "dms_to_ddd(4)"); -is(dms_to_ddd(4.3), - 4.3, - "dms_to_ddd(4.3)"); -is(dms_to_ddd(120.5, 0.3), - 120.505, - "dms_to_ddd(120.5, 0.3)"); - -# dms_to_ddd() }}} - -diag("Testing trackpoint()..."); # {{{ - -my %Dat = (); - -is(trackpoint(%Dat), - undef, - "trackpoint() receives empty hash"); - -my %Bck = ( - # {{{ - 'format' => 'gpsml', - 'year' => '2003', - 'month' => '06', - 'day' => '13', - 'hour' => '14', - 'min' => '36', - 'sec' => '10', - 'lat' => '59.5214', - 'lon' => '7.392133', - 'ele' => '762', - 'error' => "", - 'type' => 'tp', - # }}} -); - -# trackpoint() (gpsml) {{{ -%Dat = %Bck; -is( - trackpoint(%Dat), - " 59.5214 7.392133 762 \n", - "trackpoint() (gpsml)" -); - -# trackpoint() (gpsml) }}} -# trackpoint() (gpx) {{{ -%Dat = %Bck; -$Dat{'format'} = "gpx"; -is( - trackpoint(%Dat), - qq{ 762 \n}, - "trackpoint() (gpx)" -); - -# trackpoint() (gpx) }}} - -# trackpoint(): Various loop tests {{{ - -for my $Elem (qw{format lat lon type}) { - my %Dat = %Bck; - - $Dat{"$Elem"} = '2d'; - is(trackpoint(%Dat), - undef, - "trackpoint(): {'$Elem'} with invalid value (\"$Dat{$Elem}\") returns undef" - ); - -} - -for my $Elem (qw{year month day hour min sec}) { - # Date tests {{{ - my %Dat; - - %Dat = %Bck; - $Dat{"$Elem"} = ''; - is(trackpoint(%Dat), - " 59.5214 7.392133 762 \n", - "trackpoint(): {'$Elem'} with empty value skips time" - ); - - %Dat = %Bck; - $Dat{"$Elem"} = '2d'; - is(trackpoint(%Dat), - " 59.5214 7.392133 762 \n", - "trackpoint(): {'$Elem'} with invalid value (\"$Dat{$Elem}\") skips time" - ); - - %Dat = %Bck; - $Dat{$Elem} = "00000$Dat{$Elem}"; - is(trackpoint(%Dat), - " 59.5214 7.392133 762 \n", - "trackpoint(): Strip prefixing zeros from {'$Elem'}" - ); - - %Dat = %Bck; - $Dat{"$Elem"} = 0-$Dat{$Elem}; - is(trackpoint(%Dat), - " 59.5214 7.392133 762 \n", - "trackpoint(): {'$Elem'} is negative, skip time" - ); - - if ($Elem ne "sec") { - %Dat = %Bck; - $Dat{"$Elem"} = "$Dat{$Elem}.00"; - is(trackpoint(%Dat), - " 59.5214 7.392133 762 \n", - "trackpoint(): Decimals in {'$Elem'}, skip time" - ); - } - - # Date tests }}} -} - -%Dat = %Bck; -$Dat{'sec'} = "$Dat{'sec'}.00"; -is(trackpoint(%Dat), - " 59.5214 7.392133 762 \n", - "trackpoint(): Remove trailing zeros in {'sec'} decimals" -); - -for my $Elem (qw{format type error}) { - my %Dat = %Bck; - $Dat{$Elem} = undef; - is(trackpoint(%Dat), - undef, - "trackpoint(): Missing {'$Elem'}, return undef" - ); -} - -# Various loop tests }}} - -# trackpoint() }}} - -diag("Testing output from ../gpst"); - -diag("Read empty input (/dev/null)..."); # {{{ -testcmd("../gpst - - - - -END - "", - "Read from /dev/null", -); - -# }}} -testcmd("../gpst -o gpx - - - - -END - "", - "Output gpx from /dev/null", -); - -# }}} -# empty input }}} -diag("Read empty files..."); # {{{ -testcmd("echo ' ' | ../gpst", # {{{ - < - - - - -END - "", - "Don’t print empty trackpoints", -); - -# }}} -# Read empty files }}} -diag("Testing --chronology option..."); # {{{ -testcmd("../gpst --chronology chronology-error.gpsml", # {{{ - < - - -Chronology errors - 60.45369 5.31559 95 - 60.45353 5.31548 94 - 60.45353 5.31561 94 - - 60.45369 5.31597 Out of chronology - -0:00:37:54 - 60.45418 5.31517 92 - 60.45407 5.31542 91 - 60.45401 5.31543 98 - 60.45401 5.31543 98 - 60.45395 5.31544 103 - 60.45391 5.31545 107 - - -END - "gpst: chronology-error.gpsml: \"2006-05-02T09:46:46Z\": Next date is 0:00:06:39 in the past (2006-05-02T09:40:07Z)\n" . - "gpst: chronology-error.gpsml: \"2006-05-02T10:18:09Z\": Duplicated time\n", - "Check for chronology errors and duplicated times", -); - -# }}} -# --chronology option }}} -diag("Testing --skip-dups option..."); # {{{ -testcmd("../gpst -d no_signal.mayko", # {{{ - < - - - 70.6800486 23.6746151 - 70.6799322 23.6740038 - 70.6796266 23.6723991 - 70.6796266 23.6723991 - 70.6796266 23.6723991 - 70.6796266 23.6723991 - 70.6800774 23.6757566 - 70.6801502 23.6753442 - 70.6801905 23.6757542 - - -END - "", - "Remove duplicated positions from gpsml", -); - -# }}} -testcmd("../gpst -d -o csv no_signal.mayko", # {{{ - < - - -ACTIVE LOG164705 - 60.425494 5.299534 25.26 - 60.425464 5.29961 24.931 - 60.425314 5.299694 27.975 - 60.425384 5.299741 31.017 - 60.425339 5.299958 30.98 - 60.425238 5.29964 30.538 - 60.425246 5.299686 30.515 - 60.425345 5.299773 31.936 - 60.425457 5.299419 31.794 - - -END - "", - "--epoch is ignored in gpsml output", -); - -# }}} -testcmd("../gpst -e -o gpx pause.gpx", # {{{ - < - - 25.260 - 24.931 - 27.975 - 31.017 - 30.980 - 30.538 - 30.515 - 31.936 - 31.794 - - - -END - "", - "--epoch is ignored in gpx output", -); - -# }}} -# --epoch option }}} -diag("Testing --fix option..."); # {{{ -testcmd("../gpst --fix --chronology chronology-error.gpsml", # {{{ - < - - -Chronology errors - 60.45369 5.31559 95 - 60.45353 5.31548 94 - 60.45353 5.31561 94 - - 60.45369 5.31597 Out of chronology - -0:00:37:54 - 60.45418 5.31517 92 - 60.45407 5.31542 91 - 60.45401 5.31543 98 - 60.45401 5.31543 98 - 60.45395 5.31544 103 - 60.45391 5.31545 107 - - -END - "gpst: chronology-error.gpsml: \"2006-05-02T09:46:46Z\": Next date is 0:00:06:39 in the past (2006-05-02T09:40:07Z)\n" . - "gpst: chronology-error.gpsml: \"2006-05-02T10:18:09Z\": Duplicated time\n", - "Remove bad timestamps", -); - -# }}} -# --fix option }}} -diag("Testing --from-date option..."); # {{{ -# --from-date option }}} -diag("Testing --help option..."); # {{{ -like(`../gpst -h`, # {{{ - '/Converts between various GPS formats\./', - "Check -h (--help) option" -); -# }}} -# --help option }}} -diag("Testing --inside option..."); # {{{ -testcmd("../gpst --pos1 2.11,2.12 --pos2 3.31,3.32 --inside multitrack-pause.gpx", # {{{ - < - - -track1 - -track2 - 2.11 2.12 - 2.21 2.22 - 2.31 2.32 - 2.41 2.42 - - 2.451 2.452 - -track3 - 3.11 3.12 - 3.21 3.22 - 3.31 3.32 - - -END - "", - "Check --inside option (gpx to gpst)", -); -# }}} - -# --inside option }}} -diag("Testing --undefined option..."); # {{{ -# --undefined option }}} -diag("Testing --near option..."); # {{{ -# --near option }}} -diag("Testing --output option..."); # {{{ -# gpsml (Default) -testcmd("../gpst log.mcsv", # {{{ - < - - - -ACTIVE LOG 125 - 54.96883 -1.62439 77 - 54.96878 -1.62413 77 - 54.96913 -1.62616 77 - 54.96934 -1.62624 77.5 - 54.96934 -1.62596 78 - 54.96931 -1.62645 78 - 54.96918 -1.62603 79 - 54.96901 -1.62364 76.1 - 54.96922 -1.6254 76.1 - 54.96914 -1.62526 75.1 - 54.96911 -1.62494 75.1 - 54.9693 -1.62489 75.1 - 54.96901 -1.62496 75.1 - 54.96871 -1.62466 74.6 - 54.96908 -1.62488 72.7 - -ACTIVE LOG 126 - 54.96904 -1.62482 72.7 - 54.96913 -1.62499 71.3 - 54.96904 -1.62497 70.8 - 54.96913 -1.62496 71.8 - 54.96924 -1.62501 72.2 - 54.9694 -1.62521 71.8 - 54.96916 -1.62515 71.3 - 54.96921 -1.625 71.3 - 54.96801 -1.62417 71.8 - -ACTIVE LOG 127 - 54.96887 -1.62504 70.8 - 54.96898 -1.62476 69.8 - 54.9691 -1.62475 69.4 - 54.96918 -1.62468 70.3 - 54.9692 -1.62465 69.4 - 54.96924 -1.62462 71.8 - 54.96928 -1.62463 71.8 - 54.96945 -1.62466 69.4 - - -END - "", - "Read Mapsource TAB-separated format", -); - -# }}} -testcmd("../gpst two-digit_year.mcsv", # {{{ - < - - - -ACTIVE LOG 032 - 60.41324 5.33352 14 - 60.38802 5.33845 18 - 60.38709 5.3379 19 - 60.38641 5.33732 18 - 60.38581 5.33647 18 - 60.38516 5.33528 15 - 60.38495 5.3349 13 - - -END - "", - "Read Mapsource TAB-separated format with two-digit year", -); - -# }}} -testcmd("../gpst log.gpstxt", # {{{ - < - - - 59.521517 7.391867 762 - 59.5214 7.392133 762 - 59.5213 7.392417 761 - 59.521183 7.3927 761 - - 59.52085 7.393517 760 - 59.520733 7.393783 760 - 59.52065 7.39405 760 - 59.520583 7.394333 760 - 59.520533 7.394633 759 - 59.520483 7.394917 759 - 59.520433 7.395233 759 - - 59.520283 7.396233 758 - 59.520233 7.39655 758 - 59.520183 7.396883 757 - 59.520133 7.397217 757 - 59.5201 7.397567 757 - - -END - "", - "Read Garmin serial text format", -); - -# }}} -testcmd("../gpst log.dos.mayko", # {{{ - < - - - 58.1818158 8.1225077 - 58.1818712 8.12532 - 58.1816347 8.1266031 - 58.1812099 8.1284612 - 58.1810315 8.129395 - 58.1809621 8.13074 - - -END - "", - "Read DOS-formatted Mayko format", -); - -# }}} -testcmd("../gpst log.dos.gpstxt", # {{{ - < - - - 66.908167 15.022983 11472 - 66.90625 15.020667 11472 - 66.904317 15.01835 11472 - 66.9024 15.016017 11473 - 66.900483 15.0137 11474 - 66.898567 15.011383 11474 - 66.896633 15.009067 11475 - 66.894717 15.006733 11475 - 66.8928 15.004417 11475 - 66.890867 15.0021 11475 - 66.88895 14.999783 11475 - - -END - "", - "Read DOS-formatted Garmin serial text format", -); - -# }}} -testcmd("../gpst log.unix.mcsv", # {{{ - < - - - -ACTIVE LOG 058 - 60.36662 5.24885 31.9 - 60.37057 5.22956 35.2 - 60.37019 5.22817 39.6 - 60.37012 5.2279 41 - 60.37009 5.22682 47.2 - 60.37011 5.22641 49.2 - 60.37011 5.22607 50.1 - 60.37002 5.22568 51.1 - 60.3701 5.22548 52.5 - - -END - "", - "Read UNIX-formatted Garmin Mapsource TAB-separated format", -); - -# }}} -testcmd("../gpst multitrack.gpx", # {{{ - < - - -Track 1 - 51.4968266 -0.1448824 - 51.4968227 -0.1449938 - 51.496904 -0.1453202 - -Track 2 - 51.4969214 -0.1453398 - 51.4969816 -0.1455514 - 51.4970224 -0.1457489 1000 - 51.4970452 -0.1457804 - -Track 3 - 51.497068 -0.1458608 - 51.4971658 -0.1460047 - 51.4972469 -0.1461614 - -Track 4 - 51.4972731 -0.1462394 - 51.4973437 -0.1463232 - 51.4973337 -0.1462949 - 51.4973218 -0.1462825 - 51.4973145 -0.1462732 - - -END - "", - "Read GPX file with multiple tracks", -); - -# }}} -testcmd("../gpst compact.gpx", # {{{ - < - - -All whitespace stripped - 70.660932 23.7028354 - 70.6609392 23.7028468 - 70.6609429 23.7028499 - 70.6609381 23.702862 - 70.6609368 23.7028648 - 70.6609344 23.7028652 - 70.6609349 23.7028707 - 70.6609348 23.7028654 - 70.6609347 23.7028599 - 70.6609348 23.7028609 - 70.6609388 23.7028653 - 70.6609426 23.7028732 - - -END - "", - "Read GPX one-liner", -); - -# }}} -testcmd("../gpst missing.gpsml", # {{{ - < - - -Missing various elements - - - 60.42353 5.34185 - 483 - 485 - 60.42347 5.34212 486 - 484 - 486 - Missing everything - 490 - 60.42338 5.34269 487 - - -END - "", - "Read gpsml with various data missing", -); - -# }}} -testcmd("../gpst different_dateformats.gpsml", # {{{ - < - - -Date format variations - 1 1 - 2 2 - 3 3 - 4 4 - - -END - "", - "Read different date formats from gpsml file", -); - -# }}} -testcmd("../gpst multitrack-pause.gpx", # {{{ - file_data("multitrack-pause.gpsml"), - "", - "Should be equal to multitrack-pause.gpsml", -); - -# }}} -# gpx -testcmd("../gpst -o gpx no_signal.mayko", # {{{ - < - - - - - - - - - - - - - -END - "", - "Output GPX from Mayko file with duplicates", -); - -# }}} -testcmd("../gpst -o gpx comments.mayko", # {{{ - < - - - - - - - - - - - - - - - -END - "", - "Output GPX from Mayko file with commented-out lines", -); - -# }}} -testcmd("../gpst -o gpx missing.gpsml", # {{{ - < - - - 483 - 485 - 486 - 484 - 486 - 490 - 487 - - - -END - "", - "Output GPX from gpsml with missing data", -); - -# }}} -# xgraph -testcmd("../gpst -o xgraph multitrack.gpx", # {{{ - <. ☺\t2469.012939\tmountain\t2006-05-08T18:27:59Z\tHer er det &, < og >. ☺\tSchwæra greie\thttp://www.example.org/\tWaypoint -(60.397460000,5.350610000)\tHalfdan Griegs vei\t\\N\t\\N\t\\N\t04-AUG-02 19:42\t04-AUG-02 19:42\t\\N\t\\N -(51.510130000,-0.130410000)\tLeicester Square\t\\N\t\\N\t\\N\t11-FEB-03 18:00\t11-FEB-03 18:00\t\\N\t\\N -(60.968540000,9.285350000)\tLeira camping\t\\N\t\\N\t\\N\t03-OKT-02 21:58\t03-OKT-02 21:58\t\\N\t\\N -END - "", - "Test pgwtab format", -); - -# }}} -# pgwupd -testcmd("../gpst -o pgwupd multitrack.gpx", # {{{ - < coor) < 0.05; - UPDATE logg SET dist = cldist(coor) WHERE (point(51.477880000,-0.001470000) <-> coor) < 0.05; -COMMIT; -BEGIN; - UPDATE logg SET sted = clname(coor) WHERE (point(51.532030,-0.177330) <-> coor) < 0.05; - UPDATE logg SET dist = cldist(coor) WHERE (point(51.532030,-0.177330) <-> coor) < 0.05; -COMMIT; -BEGIN; - UPDATE logg SET sted = clname(coor) WHERE (point(61.636684,8.312254) <-> coor) < 0.05; - UPDATE logg SET dist = cldist(coor) WHERE (point(61.636684,8.312254) <-> coor) < 0.05; -COMMIT; -BEGIN; - UPDATE logg SET sted = clname(coor) WHERE (point(60.397460000,5.350610000) <-> coor) < 0.05; - UPDATE logg SET dist = cldist(coor) WHERE (point(60.397460000,5.350610000) <-> coor) < 0.05; -COMMIT; -BEGIN; - UPDATE logg SET sted = clname(coor) WHERE (point(51.510130000,-0.130410000) <-> coor) < 0.05; - UPDATE logg SET dist = cldist(coor) WHERE (point(51.510130000,-0.130410000) <-> coor) < 0.05; -COMMIT; -BEGIN; - UPDATE logg SET sted = clname(coor) WHERE (point(60.968540000,9.285350000) <-> coor) < 0.05; - UPDATE logg SET dist = cldist(coor) WHERE (point(60.968540000,9.285350000) <-> coor) < 0.05; -COMMIT; -END - "", - "Test pgwupd format", -); - -# }}} -# clean -testcmd("../gpst -t -o clean pause.gpx", # {{{ - < - - -track1 - 1.11 1.12 - 1.21 1.22 - 1.31 1.32 - -track2 - -track3 - - 3.41 3.42 - 3.51 3.52 - 3.61 3.62 - 3.71 3.72 - 3.81 3.82 - - -END - "", - "Check --outside option (gpx to gpst)", -); - -# }}} -# --outside option }}} -diag("Testing --pos1 and --pos2 options..."); # {{{ -# --pos1 and --pos2 options }}} -diag("Testing --require option..."); # {{{ -testcmd("../gpst -re multitrack.gpx", # {{{ - < - - -Track 1 - -Track 2 - 51.4970224 -0.1457489 1000 - -Track 3 - -Track 4 - - -END - "", - "Require elevation from GPX data", -); -# }}} -testcmd("../gpst tracks.gpsman", # {{{ - < - - -ACTIVE LOG - 60.2891111111111 5.22761111111111 54.4517822266 - 60.2885833333333 5.22616666666667 54.4517822266 - - 52.1221666666667 14.0295277777778 1494.98730469 - - 52.0858888888889 14.0401388888889 1494.98730469 - 52.0842777777778 14.0406666666667 1494.02612305 - - 50.0858333333333 14.4290833333333 183.268432617 - 50.0859722222222 14.4291111111111 184.710571289 - - 50.092 14.43625 180.384521484 - 50.092 14.43625 181.345825195 - 50.092 14.4362222222222 182.307128906 - - -END - "", - "Output gpsml format from gpsman", -); - -# }}} -testcmd("../gpst -o gpx -R lat=7,lon=7,ele=2 tracks.gpsman", # {{{ - < - - - ACTIVE LOG - - 54.45 - 54.45 - - - 1494.99 - - - 1494.99 - 1494.03 - - - 183.27 - 184.71 - - - 180.38 - 181.35 - 182.31 - - - -END - "", - "Output GPX format from gpsman", -); -# }}} -testcmd("../gpst -re one_ele.dos.gpsml", # {{{ - < - - -Only one point has elevation - 60.425314 5.299694 27.975 - - -END - "", - "Require elevation from gpsml", -); - -# }}} - -TODO: { - local $TODO = "Shall lat/lon be cleared if one is missing?"; - testcmd("../gpst -re missing.gpsml", # {{{ - < - - -Missing various elements - 483 - 485 - 60.42347 5.34212 486 - 484 - 486 - 490 - 60.42338 5.34269 487 - - -END - "", - "Require elevation", - ); - - # }}} - testcmd("../gpst -rt missing.gpsml", # {{{ - < - - -Missing various elements - - - 60.42353 5.34185 - 483 - 485 - 490 - 60.42338 5.34269 487 - - -END - "", - "Require time", - ); - - # }}} - testcmd("../gpst -rp missing.gpsml", # {{{ - < - - -Missing various elements - 60.42353 5.34185 - 60.42347 5.34212 486 - 60.42338 5.34269 487 - - -END - "", - "Require position", - ); - - # }}} - testcmd("../gpst -ret missing.gpsml", # {{{ - < - - -Missing various elements - 483 - 485 - 490 - 60.42338 5.34269 487 - - -END - "", - "Require elevation and time", - ); - - # }}} - testcmd("../gpst -retp missing.gpsml", # {{{ - < - - -Missing various elements - 60.42338 5.34269 487 - - -END - "", - "Require elevation, time and position", - ); - - # }}} - testcmd("../gpst -rep missing.gpsml", # {{{ - < - - -Missing various elements - 60.42347 5.34212 486 - 60.42338 5.34269 487 - - -END - "", - "Require elevation and position", - ); - - # }}} -} -# --require option }}} -diag("Testing --round option..."); # {{{ -testcmd("../gpst -R lat=4,lon=5,ele=1 pause.gpx", # {{{ - < - - -ACTIVE LOG164705 - 60.4255 5.29953 25.3 - 60.4255 5.29961 24.9 - 60.4253 5.29969 28 - 60.4254 5.29974 31 - 60.4253 5.29996 31 - 60.4252 5.29964 30.5 - 60.4252 5.29969 30.5 - 60.4253 5.29977 31.9 - 60.4255 5.29942 31.8 - - -END - "", - "--round works with lat, lon, ele from gpx", -); - -# }}} -# --round option }}} -diag("Testing --short-date option..."); # {{{ -# --short-date option }}} -diag("Testing --save-to-file option..."); # {{{ -# --save-to-file option }}} -diag("Testing --create-breaks option..."); # {{{ -testcmd("../gpst -t pause.gpx", # {{{ - < - - -ACTIVE LOG164705 - 60.425494 5.299534 25.26 - 60.425464 5.29961 24.931 -0:00:02:18 - 60.425314 5.299694 27.975 -0:00:04:32 - 60.425384 5.299741 31.017 - 60.425339 5.299958 30.98 - 60.425238 5.29964 30.538 - 60.425246 5.299686 30.515 -0:00:02:05 - 60.425345 5.299773 31.936 - 60.425457 5.299419 31.794 - - -END - "", - "Output gpsml with elements from GPX files", -); - -# }}} -testcmd("../gpst -t multitrack-pause.gpx", # {{{ - < - - -track1 - 1.11 1.12 - 1.21 1.22 - 1.31 1.32 - -track2 -0:23:59:58 - 2.11 2.12 - 2.21 2.22 - 2.31 2.32 -0:01:00:00 - 2.41 2.42 - - 2.451 2.452 - -track3 -1:01:00:03 - 3.11 3.12 - 3.21 3.22 - 3.31 3.32 - - 3.41 3.42 - 3.51 3.52 - 3.61 3.62 - 3.71 3.72 - 3.81 3.82 - - -END - "", - "Insert between gpx tracks", -); - -# }}} -testcmd("../gpst -t multitrack-pause.gpsml", # {{{ - < - - -track1 - 1.11 1.12 - 1.21 1.22 - 1.31 1.32 - -track2 -0:23:59:58 - 2.11 2.12 - 2.21 2.22 - 2.31 2.32 -0:01:00:00 - 2.41 2.42 - - 2.451 2.452 - -track3 -1:01:00:03 - 3.11 3.12 - 3.21 3.22 - 3.31 3.32 - - 3.41 3.42 - 3.51 3.52 - 3.61 3.62 - 3.71 3.72 - 3.81 3.82 - - -END - "", - "Insert between gpsml titles", -); - -# }}} -# --create-breaks option }}} -diag("Testing --comment-out-dups option..."); # {{{ -testcmd("../gpst -u no_signal.mayko >nosignal.tmp", # {{{ - "", - "", - "Redirect stdout", -); - -# }}} -testcmd("../gpst nosignal.tmp", # {{{ - < - - - 70.6800486 23.6746151 - 70.6799322 23.6740038 - 70.6796266 23.6723991 -20021222T214351-20021222T214354: CO: No signal \x7B\x7B\x7B - 70.6796266 23.6723991 - 70.6796266 23.6723991 - 70.6796266 23.6723991 -20021222T214351-20021222T214354: CO: No signal \x7D\x7D\x7D - - 70.6800774 23.6757566 - 70.6801502 23.6753442 - 70.6801905 23.6757542 - - -END - "", - "Read output from 'gpst -u *.mayko'", -); - -# }}} -unlink("nosignal.tmp") || warn("nosignal.tmp: Cannot delete file: $!\n"); -testcmd("../gpst -u no_signal.mayko", # {{{ - < - -25.260 -24.931 -27.975 -31.017 -30.980 -30.538 -30.515 -31.936 -31.794 - - - -END - "", - "Strip whitespace from GPX output", -); - - # }}} -testcmd("../gpst -o gpx -w comments.mayko", # {{{ - < - - - - - - - - - - - - - - - -END - "", - "Output whitespace-stripped GPX from Mayko file with commented-out lines", -); - -# }}} -# --strip-whitespace option }}} -diag("Testing --double-y-scale option..."); # {{{ -testcmd("../gpst -y -o clean pause.gpx", # {{{ - < - - - 60.4280897 5.5794667 - 60.4281867 5.5802255 - 103.4034054 129.7271053 - 60.428332 5.5813636 - 60.4283806 5.581743 - - -END - "", - "Strip error from mayko format in gpsml output", -); - -# }}} -testcmd("../gpst -o gpx date_error.mayko", # {{{ - < - - - - - - - - - - - -END - "", - "Strip error from mayko format in gpx output", -); - -# }}} -testcmd("../gpst -o gpstrans date_error.mayko", # {{{ - < - - - 70.6800486 23.6746151 - 70.6799322 23.6740038 - 70.6796266 23.6723991 -20021222T214351-20021222T214354: CO: No signal \x7B\x7B\x7B - 70.6796266 23.6723991 - 70.6796266 23.6723991 - 70.6796266 23.6723991 -20021222T214351-20021222T214354: CO: No signal \x7D\x7D\x7D - - 70.6800774 23.6757566 - 70.6801502 23.6753442 - 70.6801905 23.6757542 - - -END - "", - "Output gpsml from the -u option", - ); - # }}} - $TODO = "Tweak output"; - testcmd("../gpst -o gpx multitrack-pause.gpsml", # {{{ - file_data("multitrack-pause.gpx"), - "", - "Should be equal to multitrack-pause.gpx", - ); - - # }}} - $TODO = 'Fix it.'; - # list_nearest_waypoints() {{{ - - like(list_nearest_waypoints(60.42541, 5.29959, 3), - qr/^\(.*,.*,.*\)$/, - "list_nearest_waypoints()" - ); - - # }}} - } - # TODO tests }}} -} - -diag("Testing finished."); - -sub testcmd { - # {{{ - my ($Cmd, $Exp_stdout, $Exp_stderr, $Desc) = @_; - my $stderr_cmd = ""; - my $deb_str = $Opt{'debug'} ? " --debug" : ""; - my $Txt = join("", - "\"$Cmd\"", - defined($Desc) - ? " - $Desc" - : "" - ); - my $TMP_STDERR = "gpst-stderr.tmp"; - - if (defined($Exp_stderr) && !length($deb_str)) { - $stderr_cmd = " 2>$TMP_STDERR"; - } - is(`$Cmd$deb_str$stderr_cmd`, $Exp_stdout, $Txt); - if (defined($Exp_stderr)) { - if (!length($deb_str)) { - is(file_data($TMP_STDERR), $Exp_stderr, "$Txt (stderr)"); - unlink($TMP_STDERR); - } - } else { - diag("Warning: stderr not defined for '$Txt'"); - } - # }}} -} - -sub file_data { - # Return file content as a string {{{ - my $File = shift; - my $Txt; - if (open(FP, "<", $File)) { - $Txt = join("", ); - close(FP); - return($Txt); - } else { - return undef; - } - # }}} -} - -sub print_version { - # Print program version {{{ - for (@main::version_array) { - print("$_\n"); - } - exit(0); - # }}} -} # print_version() - -sub usage { - # Send the help message to stdout {{{ - my $Retval = shift; - - print(<= $verbose_level) { - print(STDERR "$progname: $Txt\n"); - } - # }}} -} # msg() - -__END__ - -# Plain Old Documentation (POD) {{{ - -=pod - -=head1 NAME - -run-tests.pl - -=head1 REVISION - -$Id$ - -=head1 SYNOPSIS - -run-tests.pl [options] [file [files [...]]] - -=head1 DESCRIPTION - -Contains tests for the gpst(1) program. - -=head1 OPTIONS - -=over 4 - -=item B<-a>, B<--all> - -Run all tests, also TODOs. - -=item B<-h>, B<--help> - -Print a brief help summary. - -=item B<-t>, B<--todo> - -Run only the TODO tests. - -=item B<-v>, B<--verbose> - -Increase level of verbosity. Can be repeated. - -=item B<--version> - -Print version information. - -=item B<--debug> - -Print debugging messages. - -=back - -=head1 AUTHOR - -Made by Øyvind A. Holm Ssunny@sunbase.orgE>. - -=head1 COPYRIGHT - -Copyleft © Øyvind A. Holm Esunny@sunbase.orgE -This is free software; see the file F for legalese stuff. - -=head1 LICENCE - -This program is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2 of the License, or (at your -option) any later version. - -This program is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along -with this program; if not, write to the Free Software Foundation, Inc., -59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -=head1 SEE ALSO - -gpst(1) - -=cut - -# }}} - -# vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w : -# End of file $Id$ diff --git a/branches/gpst.gpsman-format/tests/testcmd b/branches/gpst.gpsman-format/tests/testcmd deleted file mode 100644 index f091c3e..0000000 --- a/branches/gpst.gpsman-format/tests/testcmd +++ /dev/null @@ -1,9 +0,0 @@ -testcmd("../gpst command", # {{{ - <) { - s/^((not )?ok)( \d+ )- /$1 - /; - print; -} -- 2.11.4.GIT