Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Tomcat42
perl-GIS-Distance
gps_diff.pl
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File gps_diff.pl of Package perl-GIS-Distance
#! /usr/bin/perl -w # # gps_diff.pl -- calculate distance of two GPS waypioints. use Getopt::Long qw(:config no_ignore_case); use Pod::Usage; use GIS::Distance; use Data::Dumper; my $version = '0.1'; my $write = 0; my $read = 0; my $help = 0; my $polar = 0; my $verbose = 1; my $fname = "$ENV{HOME}/.gpsdiff_last"; GetOptions( "help|?" => \$help, "filename|f=s" => \$fname, "write|w" => \$write, "polar|P" => \$polar, "acquire|a" => \$acquire, "verbose|v+" => \$verbose, "version|V" => sub { print "$version\n"; exit }, "quiet" => sub { $verbose = 0; }, ) or $help++; my @p1; my @p2; if ((scalar @ARGV) == 0) { @p1 = slurpfile(); @p2 = acquire() if $acquire; } if ((scalar @ARGV) == 2) { if ($acquire) { @p1 = (shift,shift); @p2 = acquire(); } else { @p1 = slurpfile(); @p2 = (shift,shift); } } elsif ((scalar @ARGV) == 4) { @p1 = (shift,shift); @p2 = (shift,shift); } else { $help++; } # print Dumper [@p1], [@p2]; $help++ unless $write or @p1; pod2usage(-verbose => 1, -msg => qq{ gpsdiff V$version Usage: $0 [options] start_lat start_lon end_lat end_lon or using a saved position: $0 [options] -w last_lat last_lon $0 [options] next_lat next_lon Valid options are: -v Be more verbose. Default: $verbose. -q Be quiet, not verbose. -f --filename last_lat_lon.sav Default: $fname -P Use polar formula. Default: Haversine. -w save the endpoint to file. To be used with two params form in subsequent calls. Default: need 4 params. -h --help -? Print this online help. }) if $help; if ($write) { open O, ">", $fname or die "cannot write $fname: $!"; print O "$p2[0] $p2[1]\n"; close O or die "could not write $fname: $!"; exit unless @p1; } my $gis = GIS::Distance->new(); $gis->formula( 'Polar' ) if $polar; # Optional, default is Haversine. my $distance = $gis->distance( @p1 => @p2 ); print "distance (@p1) -> (@p2): " if $verbose; printf "%.2f m\n", $distance->meters(); # die Dumper $distance; exit 0; ########################################## sub slurpfile { open IN, "<", $fname or return (); my $line = <IN>; close IN; chomp $line; return ($1,$2) if $line =~ m{([\d\.]+)\s+([\d\.]+)}; return (); } sub acquire { die "acquire from gpsd not impl."; }
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor