File Coverage

lib/Neo4j/Types/Generic/Point.pm
Criterion Covered Total %
statement 31 31 100.0
branch 6 6 100.0
condition n/a
subroutine 14 14 100.0
pod 2 9 100.0
total 53 60 100.0


line stmt bran cond sub pod time code
1 3     3   116298 use v5.10.1;
  3         9  
2 3     3   15 use strict;
  3         4  
  3         63  
3 3     3   11 use warnings;
  3         4  
  3         231  
4              
5             package Neo4j::Types::Generic::Point;
6             # ABSTRACT: Generic representation of a Neo4j spatial point value
7             $Neo4j::Types::Generic::Point::VERSION = '2.00';
8              
9 3     3   15 use parent 'Neo4j::Types::Point';
  3         4  
  3         20  
10              
11 3     3   229 use Carp qw(croak);
  3         13  
  3         1518  
12              
13              
14             my %DIM = ( 4326 => 2, 4979 => 3, 7203 => 2, 9157 => 3 );
15              
16             sub new {
17             # uncoverable pod - see Generic.pod
18 33     33 0 13080 my ($class, $srid, @coordinates) = @_;
19            
20 33 100       179 croak "Points must have SRID" unless defined $srid;
21 29         84 my $dim = $DIM{$srid};
22 29 100       125 croak "Unsupported SRID $srid" unless defined $dim;
23 25 100       152 croak "Points with SRID $srid must have $dim dimensions" if @coordinates < $dim;
24 19         157 return bless [ $srid, @coordinates[0 .. $dim - 1] ], __PACKAGE__;
25             }
26              
27              
28             sub X {
29             # uncoverable pod - see Generic.pod
30 2     2 0 8 return shift->[1];
31             }
32              
33              
34             sub longitude {
35             # uncoverable pod - see Generic.pod
36 2     2 0 8 return shift->[1];
37             }
38              
39              
40             sub Y {
41             # uncoverable pod - see Generic.pod
42 2     2 0 11 return shift->[2];
43             }
44              
45              
46             sub latitude {
47             # uncoverable pod - see Generic.pod
48 2     2 0 7 return shift->[2];
49             }
50              
51              
52             sub Z {
53             # uncoverable pod - see Generic.pod
54 2     2 0 9 return shift->[3];
55             }
56              
57              
58             sub height {
59             # uncoverable pod - see Generic.pod
60 2     2 0 7 return shift->[3];
61             }
62              
63              
64             sub srid {
65 14     14 1 168744 return shift->[0];
66             }
67              
68              
69             sub coordinates {
70 29     29 1 67 my @coordinates = @{$_[0]}[ 1 .. $#{$_[0]} ];
  29         241  
  29         81  
71 29         199 return @coordinates;
72             }
73              
74              
75             1;