File: 005_value.t

package info (click to toggle)
libgps-point-perl 0.20-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 124 kB
  • sloc: perl: 310; makefile: 2
file content (106 lines) | stat: -rwxr-xr-x 3,046 bytes parent folder | download | duplicates (4)
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# -*- perl -*-

use strict;
use warnings;
use Test::More tests => 36;
use Test::Number::Delta;

BEGIN { use_ok( 'GPS::Point' ); }

my $pt1 = GPS::Point->new(lat=>39,
                          lon=>-77,
                          mode=>2);
isa_ok ($pt1, 'GPS::Point');

is($pt1->lat,  39, "lat");
is($pt1->lon, -77, "lon");
is($pt1->mode, 2, "lon");

is($pt1->fix, "1", "fix method");
$pt1->mode(undef);
is($pt1->fix, "0", "fix method");
$pt1->mode(3);
is($pt1->fix, "1", "fix method");

is(scalar($pt1->latlon), "39 -77", "latlon method scalar context");

my @latlon=$pt1->latlon;
is($latlon[0],  39, "latlon method array context");
is($latlon[1], -77, "latlon method array context");

SKIP: {
  eval { require Geo::ECEF };
  skip "Geo::ECEF not installed", 5 if $@;

  ok(1, "We have Geo::ECEF but is it geo::ecef on Win32?");

  my $sub=Geo::ECEF->can("new");
  skip "We have geo::ecef but need Geo::ECEF on Win32", 4 unless $sub;

  ok(1, "Running tests that require Geo::ECEF");

  my @xyz=$pt1->ecef;
  delta_ok($xyz[0], 3857229.79658403, "ecef method x" );
  delta_ok($xyz[1], 3123523.10163777, "ecef method y" );
  delta_ok($xyz[2], 3992317.02275173, "ecef method z" );
}

SKIP: {
  eval { require Geo::Point };
  skip "Geo::Point not installed", 5 if $@;

  ok(1, "Running tests that require Geo::Point");

  my $pt=$pt1->GeoPoint;
  is( ref($pt),   "Geo::Point", "Geo::Point");
  is( $pt->lat,   "39",         "GeoPoint->lat");
  is( $pt->long,  "-77",        "GeoPoint->long");
  is( $pt->proj,  "wgs84",      "GeoPoint->proj");
}

SKIP: {
  eval { require Geo::Inverse };
  skip "Geo::Inverse not installed", 5 if $@;

  ok(1, "Running tests that require Geo::Inverse");

  my $pt1=GPS::Point->new(lat=>39,   lon=>-77);
  my $pt2=GPS::Point->new(lat=>39.1, lon=>-77.1);
  my @dist=$pt1->distance($pt2);
  delta_ok($dist[2], 14077.7169524386, "distance method array context");
  delta_ok($dist[0], 322.08605713267, "distance faz");
  delta_ok($dist[1], 142.02305726502, "distance baz");

  my $dist=$pt1->distance($pt2);
  delta_ok( $dist, "14077.7169524386", "distance method scalar context");
}

SKIP: {
  eval { require Geo::Forward };
  skip "Geo::Forward not installed", 5 if $@;

  ok(1, "Running tests that require Geo::Forward");

  my $pt1=GPS::Point->new(lat=>39, lon=>-77, heading=>322.08605713267, speed=>100);
  my $pt2=$pt1->forward(14077.7169524386);
  delta_ok($pt2->lat, 39.1, 'forward->lat');
  delta_ok($pt2->lon, -77.1, 'forward->lon');

  my $pt3=$pt1->track(140.777169524386);
  delta_ok($pt3->lat, 39.1, 'track->lat');
  delta_ok($pt3->lon, -77.1, 'track->lon');
}

my $pt4=GPS::Point->new(time=>"1260855713");
is($pt4->time, "1260855713", "time method" );

SKIP: {
  eval { require DateTime };
  skip "DateTime not installed", 4 if $@;

  ok(1, "Running tests that require DateTime");

  isa_ok($pt4->datetime,       "DateTime",            "datetime method" );
  is($pt4->datetime->datetime, "2009-12-15T05:41:53", "datetime method" );
  is($pt4->datetime->epoch,    "1260855713",          "datetime method" );
}