File: Geo-Coordinates-Transform.t

package info (click to toggle)
libgeo-coordinates-transform-perl 0.10-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 92 kB
  • sloc: perl: 127; makefile: 2
file content (74 lines) | stat: -rw-r--r-- 1,696 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/perl

# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl Geo-Coordinates-Transform.t'

#########################

#use lib '../lib';

# change 'tests => 1' to 'tests => last_test_to_print';

use Test::More tests => 1 + 16;
BEGIN { use_ok('Geo::Coordinates::Transform') };

#########################

# Insert your test code below, the Test::More module is use()ed here so read
# its man page ( perldoc Test::More ) for help writing this test script.

use Geo::Coordinates::Transform;
use Data::Dumper; 

my @lst = ( 47.9805, -116.5586, '47 58.8300', '-116 33.5160', '47 58 49', '-116 33 30', '47 58 49.5', '-116 33 30.5'); 
my $N=1;
 
my $cnv = new Geo::Coordinates::Transform();

my $test_ref = $cnv->cnv_to_dd(\@lst); 

my $out_ref; 
$out_ref = $cnv->cnv_to_ddm(\@lst); 
$out_ref = $cnv->cnv_to_dd($out_ref); 

test_compare($out_ref,$test_ref);

$out_ref = $cnv->cnv_to_dms(\@lst); 
$out_ref = $cnv->cnv_to_dd($out_ref); 

test_compare($test_ref,$out_ref);

sub test_compare
{
 $ref1 = shift @_;
 $ref2 = shift @_;

 for (my $i=0; $i<scalar @{$ref1}; $i++)
 {
   is($ref1->[$i],$ref2->[$i], "Transform of $lst[$i]\n"); 
   $N++; 
 }
}


__DATA__

# Change output format
# dd_fmt = Decimal-Degrees format
# dm_fmt = Decimal-Minutes format
# ds_fmt = Decimal-Second format
$cnv = new Geo::Coordinates::Transform( {dd_fmt=>'%3.2f', dm_fmt=>'%3.1f', ds_fmt=>'%d'} );

$out_ref = $cnv->cnv_to_ddm(\@lst); 
print "ddm\n"; 
print Dumper $out_ref; 

$out_ref = $cnv->cnv_to_dms(\@lst); 
print "\ndms\n"; 
print Dumper $out_ref; 

$out_ref = $cnv->cnv_to_dd(\@lst); 
print "\ndd\n"; 
print Dumper $out_ref;