File Coverage

blib/lib/Geo/Leaflet/Circle.pm
Criterion Covered Total %
statement 25 25 100.0
branch 6 12 50.0
condition n/a
subroutine 8 8 100.0
pod 4 4 100.0
total 43 49 87.7


line stmt bran cond sub pod time code
1             package Geo::Leaflet::Circle;
2 2     2   13 use strict;
  2         4  
  2         74  
3 2     2   7 use warnings;
  2         2  
  2         123  
4 2     2   11 use base qw{Geo::Leaflet::Objects};
  2         3  
  2         648  
5              
6             our $VERSION = '0.04';
7             our $PACKAGE = __PACKAGE__;
8              
9             =head1 NAME
10              
11             Geo::Leaflet::Circle - Leaflet circle object
12              
13             =head1 SYNOPSIS
14              
15             use Geo::Leaflet;
16             my $map = Geo::Leaflet->new;
17             my $circle = $map->circle(
18             lat => $lat,
19             lon => $lon,
20             radius => $radius,
21             options => {},
22             );
23              
24             =head1 DESCRIPTION
25              
26             This package constructs a Leaflet circle object for use on a L map.
27              
28             =head1 PROPERTIES
29              
30             =head2 lat
31              
32             =cut
33              
34             sub lat {
35 1     1 1 1 my $self = shift;
36 1 50       2 $self->{'lat'} = shift if @_;
37 1 50       2 die("Error: lat required") unless defined $self->{'lat'};
38 1         3 return $self->{'lat'};
39             }
40              
41             =head2 lon
42              
43             =cut
44              
45             sub lon {
46 1     1 1 2 my $self = shift;
47 1 50       2 $self->{'lon'} = shift if @_;
48 1 50       27 die("Error: lon required") unless defined $self->{'lon'};
49 1         7 return $self->{'lon'};
50             }
51              
52             =head2 radius
53              
54             =cut
55              
56             sub radius {
57 2     2 1 2 my $self = shift;
58 2 50       3 $self->{'radius'} = shift if @_;
59 2         5 return $self->{'radius'};
60             }
61              
62             =head2 options
63              
64             =head1 METHODS
65              
66             =head2 stringify
67              
68             =cut
69              
70 1     1   2 sub _method_name {'circle'};
71              
72             sub stringify {
73 1     1 1 1 my $self = shift;
74 1         5 my $options = $self->options;
75 1 50       3 $options->{'radius'} = $self->radius if defined $self->radius; #radius is set in options
76 1         3 return $self->stringify_base([$self->lat, $self->lon]);
77             }
78              
79             =head1 SEE ALSO
80              
81             =head1 AUTHOR
82              
83             Michael R. Davis
84              
85             =head1 COPYRIGHT AND LICENSE
86              
87             Copyright (C) 2024 by Michael R. Davis
88              
89             MIT LICENSE
90              
91             =cut
92              
93             1;