| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# Encoding and name #_{ |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=encoding utf8 |
|
4
|
|
|
|
|
|
|
=head1 NAME |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
Geo::OSM::Render::Renderer - Render OpenStreetMap data encaspulated via L, possibly stored in a L database. |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=cut |
|
9
|
|
|
|
|
|
|
package Geo::OSM::Render::Renderer; |
|
10
|
|
|
|
|
|
|
#_} |
|
11
|
|
|
|
|
|
|
#_{ use … |
|
12
|
4
|
|
|
4
|
|
56392
|
use warnings; |
|
|
4
|
|
|
|
|
14
|
|
|
|
4
|
|
|
|
|
215
|
|
|
13
|
4
|
|
|
4
|
|
36
|
use strict; |
|
|
4
|
|
|
|
|
13
|
|
|
|
4
|
|
|
|
|
140
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
4
|
|
|
4
|
|
598
|
use utf8; |
|
|
4
|
|
|
|
|
33
|
|
|
|
4
|
|
|
|
|
37
|
|
|
16
|
4
|
|
|
4
|
|
157
|
use Carp; |
|
|
4
|
|
|
|
|
12
|
|
|
|
4
|
|
|
|
|
2285
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
#_} |
|
19
|
|
|
|
|
|
|
our $VERSION = 0.01; |
|
20
|
|
|
|
|
|
|
#_{ Synopsis |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=cut |
|
26
|
|
|
|
|
|
|
#_} |
|
27
|
|
|
|
|
|
|
#_{ Overview |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 OVERVIEW |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
… |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=cut |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
#_} |
|
36
|
|
|
|
|
|
|
#_{ Methods |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 METHODS |
|
39
|
|
|
|
|
|
|
=cut |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub new { #_{ |
|
42
|
|
|
|
|
|
|
#_{ POD |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head2 new |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
my $proj = Geo::OSM::Render::Projection->new(); # Use derived class! |
|
47
|
|
|
|
|
|
|
my $vp = Geo::OSM::Render::Viewport ->new(); # Use derived class! |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
my $osm_renderer = Geo::OSM::Render::Renderer->new( |
|
50
|
|
|
|
|
|
|
$proj, |
|
51
|
|
|
|
|
|
|
$vp |
|
52
|
|
|
|
|
|
|
); |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=cut |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
#_} |
|
58
|
|
|
|
|
|
|
|
|
59
|
2
|
|
|
2
|
1
|
18
|
my $class = shift; |
|
60
|
|
|
|
|
|
|
|
|
61
|
2
|
|
|
|
|
6
|
my $self = {}; |
|
62
|
2
|
|
|
|
|
6
|
bless $self, $class; |
|
63
|
|
|
|
|
|
|
|
|
64
|
2
|
50
|
|
|
|
23
|
croak "Wrong class $class" unless $self->isa('Geo::OSM::Render::Renderer'); |
|
65
|
|
|
|
|
|
|
|
|
66
|
2
|
|
|
|
|
11
|
while (@_) { |
|
67
|
4
|
100
|
|
|
|
36
|
if ($_[0] -> isa('Geo::OSM::Render::Viewport')) { |
|
68
|
2
|
|
|
|
|
8
|
$self->{viewport} = shift; |
|
69
|
2
|
|
|
|
|
7
|
next; |
|
70
|
|
|
|
|
|
|
} |
|
71
|
2
|
50
|
|
|
|
13
|
if ($_[0] -> isa('Geo::OSM::Render::Projection')) { |
|
72
|
2
|
|
|
|
|
26
|
$self->{projection} = shift; |
|
73
|
2
|
|
|
|
|
14
|
next; |
|
74
|
|
|
|
|
|
|
} |
|
75
|
0
|
|
|
|
|
0
|
last; |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
2
|
|
|
|
|
9
|
return $self; |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
} #_} |
|
81
|
|
|
|
|
|
|
sub render_node { #_{ |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
#_{ POD |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head2 render_node |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
$osm_svg_renderer->render_node($node); |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Renders C<< $node>> which must be a L (or derived from it)i. |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=cut |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
#_} |
|
94
|
|
|
|
|
|
|
|
|
95
|
2
|
|
|
2
|
1
|
3
|
my $self = shift; |
|
96
|
2
|
|
|
|
|
4
|
my $node = shift; |
|
97
|
|
|
|
|
|
|
|
|
98
|
2
|
50
|
|
|
|
8
|
croak "$node is not a Node" unless $node->isa('Geo::OSM::Primitive::Node'); |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
} #_} |
|
101
|
|
|
|
|
|
|
sub render_way { #_{ |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
#_{ POD |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head2 render_way |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
$osm_svg_renderer->render_way($way); |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Renders C<< $way>> which must be a L (or derived from it)i. |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=cut |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
#_} |
|
114
|
|
|
|
|
|
|
|
|
115
|
1
|
|
|
1
|
1
|
2
|
my $self = shift; |
|
116
|
1
|
|
|
|
|
3
|
my $way = shift; |
|
117
|
|
|
|
|
|
|
|
|
118
|
1
|
50
|
|
|
|
11
|
croak "$way is not a Way" unless $way->isa('Geo::OSM::Primitive::Way'); |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
} #_} |
|
121
|
|
|
|
|
|
|
sub lat_lon_to_map_coordinates { #_{ |
|
122
|
|
|
|
|
|
|
#_{ POD |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head2 lat_lon_to_map_coordinates |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
my ($map_x, $map_y) = $osm_svg_renderer->lat_lon_to_map_coordinates($lat, $lon); |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Convert the lattitude/longitude pair C<<$lat>> and C<<$lon>> to map coordinates and return them. |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=cut |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
#_} |
|
133
|
|
|
|
|
|
|
|
|
134
|
9
|
|
|
9
|
1
|
72
|
my $self = shift; |
|
135
|
|
|
|
|
|
|
# my $node = shift; |
|
136
|
9
|
|
|
|
|
12
|
my $lat = shift; |
|
137
|
9
|
|
|
|
|
11
|
my $lon = shift; |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
# croak "$node is not a node" unless $node->isa('Geo::OSM::Primitive::Node'); |
|
140
|
|
|
|
|
|
|
|
|
141
|
9
|
|
|
|
|
27
|
my ($x , $y ) = $self->{projection}->lat_lon_to_x_y($lat , $lon ); |
|
142
|
|
|
|
|
|
|
# my ($x , $y ) = $self->{projection}->lat_lon_to_x_y($node->{lat}, $node->{lon}); |
|
143
|
9
|
|
|
|
|
33
|
my ($x_map, $y_map) = $self->{viewport }->x_y_to_map_x_y($x, $y); |
|
144
|
|
|
|
|
|
|
|
|
145
|
9
|
|
|
|
|
22
|
return ($x_map, $y_map); |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
} #_} |
|
148
|
|
|
|
|
|
|
sub node_to_map_coordinates { #_{ |
|
149
|
|
|
|
|
|
|
#_{ POD |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head2 node_to_map_coordinates |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
my ($map_x, $map_y) = $osm_svg_renderer->node_to_map_coordinates($node); |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=cut |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
#_} |
|
158
|
|
|
|
|
|
|
|
|
159
|
7
|
|
|
7
|
1
|
100
|
my $self = shift; |
|
160
|
7
|
|
|
|
|
10
|
my $node = shift; |
|
161
|
|
|
|
|
|
|
|
|
162
|
7
|
50
|
|
|
|
20
|
croak "$node is not a node" unless $node->isa('Geo::OSM::Primitive::Node'); |
|
163
|
|
|
|
|
|
|
|
|
164
|
7
|
|
|
|
|
21
|
return $self->lat_lon_to_map_coordinates($node->lat, $node->lon); |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
# my ($x , $y ) = $self->{projection}->lat_lon_to_x_y($node->{lat}, $node->{lon}); |
|
167
|
|
|
|
|
|
|
# my ($x_map, $y_map) = $self->{viewport }->x_y_to_map_x_y($x, $y); |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
# return ($x_map, $y_map); |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
} #_} |
|
172
|
|
|
|
|
|
|
#_} |
|
173
|
|
|
|
|
|
|
#_{ POD: Author |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=head1 AUTHOR |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
René Nyffenegger |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=cut |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
#_} |
|
182
|
|
|
|
|
|
|
#_{ POD: Copyright and License |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
Copyright © 2017 René Nyffenegger, Switzerland. All rights reserved. |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
189
|
|
|
|
|
|
|
under the terms of the the Artistic License (2.0). You may obtain a |
|
190
|
|
|
|
|
|
|
copy of the full license at: L |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=cut |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
#_} |
|
195
|
|
|
|
|
|
|
#_{ POD: Source Code |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=head1 Source Code |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
The source code is on L<< github|https://github.com/ReneNyffenegger/perl-Geo-OSM-Render >>. Meaningful pull requests are welcome. |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=cut |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
#_} |
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
'tq84'; |