| 1 | package Eve::Geometry::Polygon; | ||
| 2 | |||
| 3 | 4 | ▶ | use parent qw(Eve::Geometry); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | |||
| 5 | 4 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 4 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | |||
| 8 | =head1 NAME | ||
| 9 | |||
| 10 | B<Eve::Geometry::Polygon> - 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<init()> | ||
| 26 | |||
| 27 | =cut | ||
| 28 | |||
| 29 | 7 | ▶ | sub init { |
|
Subroutine
init: called CC=1 SCAR=0.0
Pod
documented
| |||
| 30 | 7 | my ($self, %arg_hash) = @_; | |
| 31 | 7 | Eve::Support::arguments(\%arg_hash, my ($data)); | |
| 32 | |||
| 33 | 7 | $self->{'length'} = scalar @{$data}; | |
| 34 | 7 | $self->{'data'} = $data; | |
| 35 | } | ||
| 36 | |||
| 37 | =head2 B<export()> | ||
| 38 | |||
| 39 | Returns an array reference with the representation of the geometry object. | ||
| 40 | |||
| 41 | =head3 Returns | ||
| 42 | |||
| 43 | C<ARRAY>. | ||
| 44 | |||
| 45 | =cut | ||
| 46 | |||
| 47 | 3 | ▶ | sub export { |
|
Subroutine
export: called CC=1 SCAR=0.0
Pod
documented
| |||
| 48 | 3 | my ($self) = @_; | |
| 49 | |||
| 50 | 3 | return $self->data; | |
| 51 | } | ||
| 52 | |||
| 53 | =head2 B<serialize()> | ||
| 54 | |||
| 55 | Returns a string representation of the geometry object. | ||
| 56 | |||
| 57 | =head3 Returns | ||
| 58 | |||
| 59 | C<ARRAY>. | ||
| 60 | |||
| 61 | =cut | ||
| 62 | |||
| 63 | 1 | ▶ | sub serialize { |
|
Subroutine
serialize: called CC=1 SCAR=0.0
Pod
documented
| |||
| 64 | 1 | my ($self) = @_; | |
| 65 | |||
| 66 | return ( | ||
| 67 | 'POLYGON((' | ||
| 68 | . join( | ||
| 69 | ',', | ||
| 70 | 1 | map { join(' ', reverse(@{$_})) } @{$self->export()}) | |
| 71 | . '))'); | ||
| 72 | } | ||
| 73 | |||
| 74 | =head1 SEE ALSO | ||
| 75 | |||
| 76 | =over 4 | ||
| 77 | |||
| 78 | =item C<Eve::Class> | ||
| 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<Igor Zinovyev|mailto:zinigor@gmail.com> | ||
| 98 | |||
| 99 | =back | ||
| 100 | |||
| 101 | =cut | ||
| 102 | |||
| 103 | 4 | 1; | |