| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Geo::GoogleEarth::Pluggable::Plugin::CircleByCenterPoint; |
|
2
|
1
|
|
|
1
|
|
29747
|
use Geo::Forward; |
|
|
1
|
|
|
|
|
9114
|
|
|
|
1
|
|
|
|
|
27
|
|
|
3
|
1
|
|
|
1
|
|
8
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
25
|
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
|
1
|
|
|
|
|
6
|
|
|
|
1
|
|
|
|
|
622
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION='0.03'; |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Geo::GoogleEarth::Pluggable::Plugin::CircleByCenterPoint - CircleByCenterPoint plugin for Geo::GoogleEarth::Pluggable |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
use Geo::GoogleEarth::Pluggable; |
|
15
|
|
|
|
|
|
|
my $document=Geo::GoogleEarth::Pluggable->new; |
|
16
|
|
|
|
|
|
|
my $circle=$document->CircleByCenterPoint(%data); |
|
17
|
|
|
|
|
|
|
my $arc=$document->ArcByCenterPoint(%data); |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 USAGE |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 METHODS |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head2 CircleByCenterPoint |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my $polygon=$document->CircleByCenterPoint( |
|
28
|
|
|
|
|
|
|
name => "My CircleByCenterPoint", |
|
29
|
|
|
|
|
|
|
radius => 1000, #meters |
|
30
|
|
|
|
|
|
|
lat => 38.896079, #WGS-84 degrees |
|
31
|
|
|
|
|
|
|
lon => -77.036554, #WGS-84 degrees |
|
32
|
|
|
|
|
|
|
alt => 0, #reference see LookAt |
|
33
|
|
|
|
|
|
|
deltaAngle => 7.2, #default |
|
34
|
|
|
|
|
|
|
); |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=cut |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub CircleByCenterPoint { |
|
39
|
0
|
|
|
0
|
1
|
|
my $self=shift; #$self isa Geo::GoogleEarth::Pluggable::Folder object |
|
40
|
0
|
|
|
|
|
|
my %data=@_; |
|
41
|
0
|
|
0
|
|
|
|
$data{"startAngle"} ||= 0; |
|
42
|
0
|
|
|
|
|
|
$data{"endAngle"} = $data{"startAngle"} + 360; |
|
43
|
0
|
|
|
|
|
|
return $self->ArcByCenterPoint(%data); |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head2 ArcByCenterPoint |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
my $polygon=$document->ArcByCenterPoint( |
|
49
|
|
|
|
|
|
|
name => "My ArcByCenterPoint", |
|
50
|
|
|
|
|
|
|
radius => 500, #meters |
|
51
|
|
|
|
|
|
|
startAngle => 33.3, #degrees CW/North |
|
52
|
|
|
|
|
|
|
endAngle => 245.7, #degrees CW/North |
|
53
|
|
|
|
|
|
|
deltaAngle => 7.2, #default |
|
54
|
|
|
|
|
|
|
lat => 38.889, #WGS-84 degrees |
|
55
|
|
|
|
|
|
|
lon =>-77.035, #WGS-84 degrees |
|
56
|
|
|
|
|
|
|
alt => 0, #reference LookAt |
|
57
|
|
|
|
|
|
|
); |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=cut |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub ArcByCenterPoint { |
|
62
|
0
|
|
|
0
|
1
|
|
my $self=shift; #$self isa Geo::GoogleEarth::Pluggable::Folder object |
|
63
|
0
|
|
|
|
|
|
my %data=@_; |
|
64
|
0
|
|
0
|
|
|
|
$data{"startAngle"} ||= 0; |
|
65
|
0
|
|
0
|
|
|
|
$data{"endAngle"} ||= 180; |
|
66
|
0
|
|
0
|
|
|
|
$data{"deltaAngle"} ||= 7.2; |
|
67
|
0
|
0
|
|
|
|
|
$data{"deltaAngle"} = 0.1 if $data{"deltaAngle"} < 0.1; |
|
68
|
0
|
0
|
|
|
|
|
$data{"deltaAngle"} = 90 if $data{"deltaAngle"} > 90; |
|
69
|
0
|
|
|
|
|
|
my $interpolate = int(($data{"endAngle"} - $data{"startAngle"})/$data{"deltaAngle"}); |
|
70
|
0
|
|
|
|
|
|
$data{"deltaAngle"} = ($data{"endAngle"} - $data{"startAngle"})/$interpolate; |
|
71
|
0
|
0
|
|
|
|
|
$data{"radius"} = 1000 unless defined $data{"radius"}; |
|
72
|
0
|
|
0
|
|
|
|
$data{"alt"} ||= 0; |
|
73
|
0
|
|
|
|
|
|
my $coordinates=[]; |
|
74
|
0
|
|
|
|
|
|
my $gf=Geo::Forward->new; |
|
75
|
0
|
|
|
|
|
|
foreach my $index (0 .. $interpolate) { |
|
76
|
0
|
|
|
|
|
|
$data{"angle"}=$data{"startAngle"} + $index * $data{"deltaAngle"}; |
|
77
|
0
|
|
|
|
|
|
my ($lat,$lon,$baz)=$gf->forward(@data{qw{lat lon angle radius}}); |
|
78
|
0
|
|
|
|
|
|
push @$coordinates, {lon=>$lon, lat=>$lat, alt=>$data{"alt"}}; |
|
79
|
|
|
|
|
|
|
} |
|
80
|
0
|
|
|
|
|
|
$data{"coordinates"}=$coordinates; |
|
81
|
0
|
|
|
|
|
|
my $isCircle=abs($data{"endAngle"} - $data{"startAngle"} - 360) <= 0.00001; |
|
82
|
0
|
|
|
|
|
|
delete(@data{qw{lat lon angle radius alt deltaAngle startAngle endAngle}}); |
|
83
|
|
|
|
|
|
|
#use Data::Dumper; |
|
84
|
|
|
|
|
|
|
#print Dumper([\%data]); |
|
85
|
0
|
0
|
|
|
|
|
if ($isCircle) { |
|
86
|
0
|
|
|
|
|
|
return $self->LinearRing(%data); |
|
87
|
|
|
|
|
|
|
} else { |
|
88
|
0
|
|
|
|
|
|
return $self->LineString(%data); |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head2 BoundingBox |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
my $box=$folder->BoundingBox( |
|
95
|
|
|
|
|
|
|
name => "My Box", |
|
96
|
|
|
|
|
|
|
ulat => 39.1, |
|
97
|
|
|
|
|
|
|
ulon => -77.1, |
|
98
|
|
|
|
|
|
|
llat => 38.9, |
|
99
|
|
|
|
|
|
|
llon => -77.3, |
|
100
|
|
|
|
|
|
|
alt => 0 |
|
101
|
|
|
|
|
|
|
); |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=cut |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub BoundingBox { |
|
106
|
0
|
|
|
0
|
1
|
|
my $self=shift; |
|
107
|
0
|
|
|
|
|
|
my %data=@_; |
|
108
|
0
|
|
0
|
|
|
|
$data{"alt"} ||= 0; |
|
109
|
0
|
|
|
|
|
|
$data{"coordinates"}=[ |
|
110
|
|
|
|
|
|
|
{lat=>$data{"ulat"}, lon=>$data{"ulon"}, alt=>$data{"alt"}}, |
|
111
|
|
|
|
|
|
|
{lat=>$data{"llat"}, lon=>$data{"ulon"}, alt=>$data{"alt"}}, |
|
112
|
|
|
|
|
|
|
{lat=>$data{"llat"}, lon=>$data{"llon"}, alt=>$data{"alt"}}, |
|
113
|
|
|
|
|
|
|
{lat=>$data{"ulat"}, lon=>$data{"llon"}, alt=>$data{"alt"}}, |
|
114
|
|
|
|
|
|
|
{lat=>$data{"ulat"}, lon=>$data{"ulon"}, alt=>$data{"alt"}}, |
|
115
|
|
|
|
|
|
|
]; |
|
116
|
0
|
|
|
|
|
|
delete(@data{qw{ulat ulon llat llon}}); |
|
117
|
0
|
|
|
|
|
|
return $self->LinearRing(%data) |
|
118
|
|
|
|
|
|
|
} |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 BUGS |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 SUPPORT |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 AUTHOR |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Michael R. Davis |
|
127
|
|
|
|
|
|
|
CPAN ID: MRDVT |
|
128
|
|
|
|
|
|
|
STOP, LLC |
|
129
|
|
|
|
|
|
|
domain=>michaelrdavis,tld=>com,account=>perl |
|
130
|
|
|
|
|
|
|
http://www.stopllc.com/ |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
This program is free software licensed under the... |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
The BSD License |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
The full text of the license can be found in the |
|
139
|
|
|
|
|
|
|
LICENSE file included with this module. |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
L |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=cut |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
1; |