Revert "Merge branch 'use-trunc-rounding' into rounding-fixes"
[gpstools.git] / latlon
blobd563bf02cd2db042eac03c4b853716cd92a40048
1 #!/usr/bin/perl -w
3 #=======================================================================
4 # latlon
5 # File ID: 42441484-6158-11df-b790-90e6ba3022ac
6 # Setter lat og lon på veipunkter i «riktig» rekkefølge.
8 # Character set: UTF-8
9 # ©opyleft 2010– Øyvind A. Holm <sunny@sunbase.org>
10 # License: GNU General Public License version 3 or later, see end of
11 # file for legal stuff.
12 #=======================================================================
14 use strict;
15 use Getopt::Long;
17 $| = 1;
19 our $Debug = 0;
21 our %Opt = (
23 'debug' => 0,
24 'help' => 0,
25 'verbose' => 0,
26 'version' => 0,
30 our $progname = $0;
31 $progname =~ s/^.*\/(.*?)$/$1/;
32 our $VERSION = "0.00";
34 Getopt::Long::Configure("bundling");
35 GetOptions(
37 "debug" => \$Opt{'debug'},
38 "help|h" => \$Opt{'help'},
39 "verbose|v+" => \$Opt{'verbose'},
40 "version" => \$Opt{'version'},
42 ) || die("$progname: Option error. Use -h for help.\n");
44 $Opt{'debug'} && ($Debug = 1);
45 $Opt{'help'} && usage(0);
46 if ($Opt{'version'}) {
47 print_version();
48 exit(0);
51 while (<>) {
52 if (/^(.*?\s+)(lon="\S+")(\s+)(lat="\S+?")(>.*)/) {
53 print("$1$4$3$2$5\n");
54 } else {
55 print;
59 sub print_version {
60 # Print program version {{{
61 print("$progname v$VERSION\n");
62 # }}}
63 } # print_version()
65 sub usage {
66 # Send the help message to stdout {{{
67 my $Retval = shift;
69 if ($Opt{'verbose'}) {
70 print("\n");
71 print_version();
73 print(<<END);
75 Usage: $progname [options] [file [files [...]]]
77 Options:
79 -h, --help
80 Show this help.
81 -v, --verbose
82 Increase level of verbosity. Can be repeated.
83 --version
84 Print version information.
85 --debug
86 Print debugging messages.
88 END
89 exit($Retval);
90 # }}}
91 } # usage()
93 sub msg {
94 # Print a status message to stderr based on verbosity level {{{
95 my ($verbose_level, $Txt) = @_;
97 if ($Opt{'verbose'} >= $verbose_level) {
98 print(STDERR "$progname: $Txt\n");
100 # }}}
101 } # msg()
103 sub D {
104 # Print a debugging message {{{
105 $Debug || return;
106 my @call_info = caller;
107 chomp(my $Txt = shift);
108 my $File = $call_info[1];
109 $File =~ s#\\#/#g;
110 $File =~ s#^.*/(.*?)$#$1#;
111 print(STDERR "$File:$call_info[2] $$ $Txt\n");
112 return("");
113 # }}}
114 } # D()
116 __END__
118 # Plain Old Documentation (POD) {{{
120 =pod
122 =head1 NAME
126 =head1 SYNOPSIS
128 [options] [file [files [...]]]
130 =head1 DESCRIPTION
134 =head1 OPTIONS
136 =over 4
138 =item B<-h>, B<--help>
140 Print a brief help summary.
142 =item B<-v>, B<--verbose>
144 Increase level of verbosity. Can be repeated.
146 =item B<--version>
148 Print version information.
150 =item B<--debug>
152 Print debugging messages.
154 =back
156 =head1 BUGS
160 =head1 AUTHOR
162 Made by Øyvind A. Holm S<E<lt>sunny@sunbase.orgE<gt>>.
164 =head1 COPYRIGHT
166 Copyleft © Øyvind A. Holm E<lt>sunny@sunbase.orgE<gt>
167 This is free software; see the file F<COPYING> for legalese stuff.
169 =head1 LICENCE
171 This program is free software: you can redistribute it and/or modify it
172 under the terms of the GNU General Public License as published by the
173 Free Software Foundation, either version 3 of the License, or (at your
174 option) any later version.
176 This program is distributed in the hope that it will be useful, but
177 WITHOUT ANY WARRANTY; without even the implied warranty of
178 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
179 See the GNU General Public License for more details.
181 You should have received a copy of the GNU General Public License along
182 with this program.
183 If not, see L<http://www.gnu.org/licenses/>.
185 =head1 SEE ALSO
187 =cut
189 # }}}
191 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :