File: distance.t

package info (click to toggle)
libgeo-libproj-ffi-perl 1.01-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 304 kB
  • sloc: perl: 1,339; makefile: 11
file content (57 lines) | stat: -rw-r--r-- 1,153 bytes parent folder | download
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
#!perl
use strict;
use warnings;
use lib 'lib';

use Test::More;
use Test::Exception;
my $no_warnings;
use if $no_warnings = $ENV{AUTHOR_TESTING} ? 1 : 0, 'Test::Warnings';

# Distances
# https://proj.org/development/reference/functions.html#distances

plan tests => 4 + 7 + 2 + $no_warnings;

use Geo::LibProj::FFI qw( :all );


my ($c, $p, $a, $b, $d);

lives_and { ok $c = proj_context_create() } 'context_create';
lives_and { ok $p = proj_create($c, "EPSG:4979") } 'create';
lives_and { ok $a = proj_coord(  .21, 1.3, 0, 0 ) } 'coord a';
lives_and { ok $b = proj_coord( -1.3, .68, 5, 0 ) } 'coord b';


# proj_lp_dist

lives_ok { proj_lp_dist($p, $a, $b) } 'lp_dist';


# proj_lpz_dist

lives_ok { proj_lpz_dist($p, $a, $b) } 'lpz_dist';


# proj_xy_dist

lives_ok { $d = -1; $d = proj_xy_dist($a, $b) } 'xy_dist';
like $d, qr/^1\.6/, 'xy_dist ballpark';


# proj_xyz_dist

lives_ok { $d = -1; $d = proj_xyz_dist($a, $b) } 'xyz_dist';
like $d, qr/^5\.2/, 'xyz_dist ballpark';


# proj_geod

lives_ok { proj_geod($p, $a, $b) } 'geod';


lives_ok { proj_destroy($p) } 'destroy';
lives_ok { proj_context_destroy($c) } 'context_destroy';

done_testing;