File Coverage

blib/lib/Eve/Geometry/Polygon.pm
Criterion Covered Total %
statement 21 21 100.0
branch n/a
condition n/a
subroutine 6 6 100.0
pod 3 3 100.0
total 30 30 100.0


line stmt bran cond sub pod time code
1             package Eve::Geometry::Polygon;
2              
3 3     3   4842 use parent qw(Eve::Geometry);
  3         6  
  3         21  
4              
5 3     3   147 use strict;
  3         4  
  3         101  
6 3     3   14 use warnings;
  3         6  
  3         683  
7              
8             =head1 NAME
9              
10             B - a polygon geometry class for map
11             projection purposes.
12              
13             =head1 SYNOPSIS
14              
15             use Eve::Geometry::Polygon;
16              
17             my $geo = Eve::Geometry->new(data => [[$lat, $lng], [$lat, $lng], ...]);
18              
19             =head1 DESCRIPTION
20              
21             The class is a polygon geometry object.
22              
23             =head1 METHODS
24              
25             =head2 B
26              
27             =cut
28              
29             sub init {
30 7     7 1 22 my ($self, %arg_hash) = @_;
31 7         28 Eve::Support::arguments(\%arg_hash, my ($data));
32              
33 7         69 $self->{'length'} = scalar @{$data};
  7         32  
34 7         22 $self->{'data'} = $data;
35             }
36              
37             =head2 B
38              
39             Returns an array reference with the representation of the geometry object.
40              
41             =head3 Returns
42              
43             C.
44              
45             =cut
46              
47             sub export {
48 3     3 1 160 my ($self) = @_;
49              
50 3         36 return $self->data;
51             }
52              
53             =head2 B
54              
55             Returns a string representation of the geometry object.
56              
57             =head3 Returns
58              
59             C.
60              
61             =cut
62              
63             sub serialize {
64 1     1 1 147 my ($self) = @_;
65              
66             return (
67 2         35 'POLYGON(('
68             . join(
69             ',',
70 1         4 map { join(' ', reverse(@{$_})) } @{$self->export()})
  2         10  
  1         4  
71             . '))');
72             }
73              
74             =head1 SEE ALSO
75              
76             =over 4
77              
78             =item C
79              
80             =back
81              
82             =head1 LICENSE AND COPYRIGHT
83              
84             Copyright 2012 Igor Zinovyev.
85              
86             This program is free software; you can redistribute it and/or modify it
87             under the terms of either: the GNU General Public License as published
88             by the Free Software Foundation; or the Artistic License.
89              
90             See http://dev.perl.org/licenses/ for more information.
91              
92              
93             =head1 AUTHOR
94              
95             =over 4
96              
97             =item L
98              
99             =back
100              
101             =cut
102              
103             1;