line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Encoding and name #_{ |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=encoding utf8 |
4
|
|
|
|
|
|
|
=head1 NAME |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
Geo::OSM::Primitive::Way - Abstract base class for the Open Street Map data primitive I. |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=cut |
9
|
|
|
|
|
|
|
package Geo::OSM::Primitive::Way; |
10
|
|
|
|
|
|
|
our @ISA = qw(Geo::OSM::Primitive); |
11
|
|
|
|
|
|
|
#_} |
12
|
|
|
|
|
|
|
#_{ use … |
13
|
1
|
|
|
1
|
|
441
|
use warnings; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
42
|
|
14
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
29
|
|
15
|
|
|
|
|
|
|
|
16
|
1
|
|
|
1
|
|
6
|
use utf8; |
|
1
|
|
|
|
|
14
|
|
|
1
|
|
|
|
|
7
|
|
17
|
1
|
|
|
1
|
|
34
|
use Carp; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
95
|
|
18
|
1
|
|
|
1
|
|
9
|
use Geo::OSM::Primitive; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
382
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
#_} |
21
|
|
|
|
|
|
|
our $VERSION = 0.01; |
22
|
|
|
|
|
|
|
#_{ Synopsis |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 SYNOPSIS |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
… |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=cut |
29
|
|
|
|
|
|
|
#_} |
30
|
|
|
|
|
|
|
#_{ Overview |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 OVERVIEW |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
The idea is to encapsulte methods that use OpenStreetMap data (that is possibly stored in L. |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=cut |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
#_} |
39
|
|
|
|
|
|
|
#_{ Methods |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 METHODS |
42
|
|
|
|
|
|
|
=cut |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub new { #_{ |
45
|
|
|
|
|
|
|
#_{ POD |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head2 new |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
my $way = Geo::OSM::Primitive::Way->new($osm_way_id); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=cut |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
#_} |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
56
|
0
|
|
|
|
|
|
my $id = shift; |
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
my $self = $class->SUPER::new($id, 'way'); |
59
|
0
|
0
|
|
|
|
|
croak "Wrong class $class" unless $self->isa('Geo::OSM::Primitive::Way'); |
60
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
$self->{nodes} = []; |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
return $self; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
} #_} |
66
|
|
|
|
|
|
|
sub nodes { #_{ |
67
|
|
|
|
|
|
|
#_{ POD |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head2 nodes |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
my @nodes = $way -> nodes(); |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Returns the nodes, stored in the cache via L, that the way conisist of. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=cut |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
#_} |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
return @{$self->{cache}->{nodes}}; |
|
0
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
} #_} |
84
|
|
|
|
|
|
|
sub start_end_coordinates { #_{ |
85
|
|
|
|
|
|
|
#_{ POD |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head2 start_end_coordinates |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
my ($lat_start, $lon_start, $lat_end, $lon_end) = $way -> start_end_coordinates(); |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Returns the way's start and end coordinates. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=cut |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
#_} |
96
|
|
|
|
|
|
|
|
97
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
98
|
0
|
|
|
|
|
|
my @nodes = $self->nodes; |
99
|
|
|
|
|
|
|
|
100
|
0
|
|
|
|
|
|
return ($nodes[0]->lat, $nodes[0]->lon, $nodes[-1]->lat, $nodes[-1]->lon); |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
} #_} |
103
|
|
|
|
|
|
|
sub _set_cache_nodes { #_{ |
104
|
|
|
|
|
|
|
#_{ POD |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head2 _set_cache_nodes |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
$way->_set_cache_nodes($node_1, $node_2, $node_3, … $node_n); |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=cut |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
#_} |
113
|
|
|
|
|
|
|
|
114
|
0
|
|
|
0
|
|
|
my $self = shift; |
115
|
0
|
|
|
|
|
|
$self->{cache}->{nodes} = \@_; |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
} #_} |
118
|
|
|
|
|
|
|
# sub add_node { #_{ |
119
|
|
|
|
|
|
|
# #_{ POD |
120
|
|
|
|
|
|
|
# |
121
|
|
|
|
|
|
|
# =head2 add_node |
122
|
|
|
|
|
|
|
# |
123
|
|
|
|
|
|
|
# my $node = Geo::OSM::Primitive::Node->new($osm_node_id …); |
124
|
|
|
|
|
|
|
# my $way = Geo::OSM::Primitive::Way ->new($osm_way_id …); |
125
|
|
|
|
|
|
|
# |
126
|
|
|
|
|
|
|
# $way->add_node($node); |
127
|
|
|
|
|
|
|
# |
128
|
|
|
|
|
|
|
# =cut |
129
|
|
|
|
|
|
|
# |
130
|
|
|
|
|
|
|
# #_} |
131
|
|
|
|
|
|
|
# |
132
|
|
|
|
|
|
|
# my $self = shift; |
133
|
|
|
|
|
|
|
# my $node = shift; |
134
|
|
|
|
|
|
|
# |
135
|
|
|
|
|
|
|
# croak "$node is not a Geo::OSM::Primitive::Node" unless $node->isa($node); |
136
|
|
|
|
|
|
|
# push @{$self->{nodes}}, $node; |
137
|
|
|
|
|
|
|
# |
138
|
|
|
|
|
|
|
# } #_} |
139
|
|
|
|
|
|
|
# sub cnt_nodes { #_{ |
140
|
|
|
|
|
|
|
# #_{ POD |
141
|
|
|
|
|
|
|
# |
142
|
|
|
|
|
|
|
# =head2 cnt_nodes |
143
|
|
|
|
|
|
|
# |
144
|
|
|
|
|
|
|
# my $cnt_nodes_in_way = $way->cnt_nodes(); |
145
|
|
|
|
|
|
|
# |
146
|
|
|
|
|
|
|
# =cut |
147
|
|
|
|
|
|
|
# |
148
|
|
|
|
|
|
|
# #_} |
149
|
|
|
|
|
|
|
# |
150
|
|
|
|
|
|
|
# my $self = shift; |
151
|
|
|
|
|
|
|
# |
152
|
|
|
|
|
|
|
# return scalar @{$self->{nodes}} |
153
|
|
|
|
|
|
|
# |
154
|
|
|
|
|
|
|
# } #_} |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
#_} |
157
|
|
|
|
|
|
|
#_{ POD: Copyright |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head1 Copyright |
160
|
|
|
|
|
|
|
Copyright © 2017 René Nyffenegger, Switzerland. All rights reserved. |
161
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
162
|
|
|
|
|
|
|
under the terms of the the Artistic License (2.0). You may obtain a |
163
|
|
|
|
|
|
|
copy of the full license at: L |
164
|
|
|
|
|
|
|
=cut |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
#_} |
167
|
|
|
|
|
|
|
#_{ POD: Source Code |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head1 Source Code |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
The source code is on L<< github|https://github.com/ReneNyffenegger/perl-Geo-OSM-Primitive >>. Meaningful pull requests are welcome. |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=cut |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
#_} |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
'tq84'; |