line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Eve::Geometry; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
6858
|
use parent qw(Eve::Class); |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
20
|
|
4
|
|
|
|
|
|
|
|
5
|
3
|
|
|
3
|
|
129
|
use strict; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
103
|
|
6
|
3
|
|
|
3
|
|
14
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
74
|
|
7
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
|
3154
|
use POSIX qw(strtod); |
|
3
|
|
|
|
|
14213
|
|
|
3
|
|
|
|
|
20
|
|
9
|
|
|
|
|
|
|
|
10
|
3
|
|
|
3
|
|
3973
|
use Eve::Geometry::Point; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
90
|
|
11
|
3
|
|
|
3
|
|
1080
|
use Eve::Geometry::Polygon; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
1425
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
B - an abstract geometry class for map projection purposes. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 SYNOPSIS |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
use Eve::Geometry; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my $geo = Eve::Geometry->from_string( |
22
|
|
|
|
|
|
|
string => 'PostGIS textual geometry representation'); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 DESCRIPTION |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
The class is a base for a generic geometry object that is required in |
27
|
|
|
|
|
|
|
all operations with objects on the map projection. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 METHODS |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head2 B |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
A static method that parses the PostGIS textual representation of a |
34
|
|
|
|
|
|
|
geometry object and returns a corresponding object. |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head3 B |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=over 4 |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=item C |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=back |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head3 B |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=over 4 |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=item C |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
an object that implements the C abstract class. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=back |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=cut |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub from_string { |
57
|
2
|
|
|
2
|
1
|
1923
|
my ($class, %arg_hash) = @_; |
58
|
2
|
|
|
|
|
10
|
Eve::Support::arguments(\%arg_hash, my ($string)); |
59
|
|
|
|
|
|
|
|
60
|
2
|
|
|
|
|
20
|
my $result; |
61
|
2
|
100
|
|
|
|
8
|
if ($string =~ m/^POINT/) { |
62
|
|
|
|
|
|
|
|
63
|
1
|
|
|
|
|
4
|
$string =~ s/^POINT\(//; |
64
|
1
|
|
|
|
|
4
|
$string =~ s/\)$//g; |
65
|
|
|
|
|
|
|
|
66
|
1
|
|
|
|
|
4
|
my ($lng, $lat) = split(' ', $string); |
67
|
|
|
|
|
|
|
|
68
|
1
|
|
|
|
|
30
|
$lat = strtod($lat); |
69
|
1
|
|
|
|
|
4
|
$lng = strtod($lng); |
70
|
|
|
|
|
|
|
|
71
|
1
|
|
|
|
|
16
|
$result = Eve::Geometry::Point->new(data => [$lat, $lng]); |
72
|
|
|
|
|
|
|
} else { |
73
|
1
|
|
|
|
|
4
|
$string =~ s/^POLYGON\(\(//; |
74
|
1
|
|
|
|
|
4
|
$string =~ s/\)\)$//g; |
75
|
|
|
|
|
|
|
|
76
|
1
|
|
|
|
|
3
|
my $data = []; |
77
|
1
|
|
|
|
|
3
|
my @pairs = split(',', $string); |
78
|
|
|
|
|
|
|
|
79
|
3
|
|
|
|
|
6
|
map { |
80
|
1
|
|
|
|
|
3
|
my ($lng, $lat) = split(' ', $_); |
81
|
3
|
|
|
|
|
14
|
$lat = strtod($lat); |
82
|
3
|
|
|
|
|
8
|
$lng = strtod($lng); |
83
|
3
|
|
|
|
|
3
|
push @{$data}, [$lat, $lng]; |
|
3
|
|
|
|
|
8
|
|
84
|
|
|
|
|
|
|
} @pairs; |
85
|
|
|
|
|
|
|
|
86
|
1
|
|
|
|
|
9
|
$result = Eve::Geometry::Polygon->new(data => $data); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 METHODS |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head2 B |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Clones and returns the object. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head3 Returns |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
The object identical to self. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=cut |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub clone { |
104
|
2
|
|
|
2
|
1
|
1677
|
my ($self) = @_; |
105
|
|
|
|
|
|
|
|
106
|
2
|
|
|
|
|
12
|
return $self->new(data => $self->export()); |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head2 B |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Returns an array reference with the representation of the geometry object. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head3 Returns |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
C. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=cut |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub export { |
120
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
121
|
|
|
|
|
|
|
|
122
|
0
|
|
|
|
|
|
return [$self->latitude, $self->longitude]; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head2 B |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
Returns a string representation of the geometry object. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head3 Returns |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
C. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=cut |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
sub serialize { |
136
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
137
|
|
|
|
|
|
|
|
138
|
0
|
|
|
|
|
|
return 'POINT((' . join(' ', @{$self->export()}) . '))'; |
|
0
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head1 SEE ALSO |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=over 4 |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=item C |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=back |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Copyright 2012 Igor Zinovyev. |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
154
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
155
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head1 AUTHOR |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=over 4 |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=item L |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=back |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=cut |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
1; |