line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Encoding and name #_{ |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=encoding utf8 |
4
|
|
|
|
|
|
|
=head1 NAME |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
Geo::OSM::DBI::Primitive::Relation - Derivation of L<< Geo::OSM::Primitive::Relation >> and L<>, to be used with L<< Geo::OSM::DBI >>. |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=cut |
9
|
|
|
|
|
|
|
package Geo::OSM::DBI::Primitive::Relation; |
10
|
|
|
|
|
|
|
#_} |
11
|
|
|
|
|
|
|
#_{ use … |
12
|
6
|
|
|
6
|
|
50
|
use warnings; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
298
|
|
13
|
6
|
|
|
6
|
|
44
|
use strict; |
|
6
|
|
|
|
|
16
|
|
|
6
|
|
|
|
|
162
|
|
14
|
|
|
|
|
|
|
|
15
|
6
|
|
|
6
|
|
35
|
use utf8; |
|
6
|
|
|
|
|
16
|
|
|
6
|
|
|
|
|
81
|
|
16
|
6
|
|
|
6
|
|
164
|
use Carp; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
389
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# use Geo::OSM::Primitive; |
19
|
6
|
|
|
6
|
|
4574
|
use Geo::OSM::Primitive::Relation; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
use Geo::OSM::DBI::Primitive; |
21
|
|
|
|
|
|
|
use Geo::OSM::DBI::Primitive::Node; |
22
|
|
|
|
|
|
|
use Geo::OSM::DBI::Primitive::Way; |
23
|
|
|
|
|
|
|
our @ISA=qw(Geo::OSM::Primitive::Relation Geo::OSM::DBI::Primitive); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
#_} |
26
|
|
|
|
|
|
|
our $VERSION = 0.01; |
27
|
|
|
|
|
|
|
#_{ Synopsis |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 SYNOPSIS |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
… |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=cut |
34
|
|
|
|
|
|
|
#_} |
35
|
|
|
|
|
|
|
#_{ Overview |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 OVERVIEW |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
… |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=cut |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
#_} |
44
|
|
|
|
|
|
|
#_{ Methods |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 METHODS |
47
|
|
|
|
|
|
|
=cut |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub new { #_{ |
50
|
|
|
|
|
|
|
#_{ POD |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head2 new |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
my $osm_dbi = Geo::OSM::DBI->new(…); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
new($osm_relation_id, $osm_dbi); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=cut |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
#_} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
my $class = shift; |
63
|
|
|
|
|
|
|
my $id = shift; |
64
|
|
|
|
|
|
|
my $osm_dbi = shift; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
my $self = $class->SUPER::new($id); |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
croak "not a Geo::OSM::DBI::Primitive::Relation" unless $self -> isa('Geo::OSM::DBI::Primitive::Relation'); |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
$self->_init_geo_osm_dbi_primitive($osm_dbi); |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
return $self; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
} #_} |
75
|
|
|
|
|
|
|
sub members { #_{ |
76
|
|
|
|
|
|
|
#_{ POD |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head2 members |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
my @members = $rel->members(); |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Returns the members of the relation. The returned elements are hashes with |
83
|
|
|
|
|
|
|
the keys C (role of the member) and C (the member itself, |
84
|
|
|
|
|
|
|
a L, L or |
85
|
|
|
|
|
|
|
a L. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
my $elem = shift @members; |
88
|
|
|
|
|
|
|
my $primitive = $elem->{mem}; |
89
|
|
|
|
|
|
|
my $role = $elem->{rol}; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=cut |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
#_} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
my $self = shift; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
my $sth = $self->{osm_dbi}->{dbh}->prepare( #_{ |
98
|
|
|
|
|
|
|
" select |
99
|
|
|
|
|
|
|
rm.nod_id, |
100
|
|
|
|
|
|
|
rm.way_id, |
101
|
|
|
|
|
|
|
rm.rel_id, |
102
|
|
|
|
|
|
|
rm.rol |
103
|
|
|
|
|
|
|
from |
104
|
|
|
|
|
|
|
rel_mem rm |
105
|
|
|
|
|
|
|
where |
106
|
|
|
|
|
|
|
rm.rel_of = ? |
107
|
|
|
|
|
|
|
order by |
108
|
|
|
|
|
|
|
order_ |
109
|
|
|
|
|
|
|
") or croak; #_} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
$sth->execute($self->{id}); |
112
|
|
|
|
|
|
|
my @ret; |
113
|
|
|
|
|
|
|
while (my $r = $sth->fetchrow_hashref) { #_{ |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
my $elem; |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
if (defined $r->{nod_id}) { $elem = Geo::OSM::DBI::Primitive::Node ->new($r->{nod_id}, $self->{osm_dbi}) } |
118
|
|
|
|
|
|
|
elsif (defined $r->{way_id}) { $elem = Geo::OSM::DBI::Primitive::Way ->new($r->{way_id}, $self->{osm_dbi}) } |
119
|
|
|
|
|
|
|
elsif (defined $r->{rel_id}) { $elem = Geo::OSM::DBI::Primitive::Relation->new($r->{rel_id}, $self->{osm_dbi}) } |
120
|
|
|
|
|
|
|
else {die "Neither nod_id, nor way_id, nor rel_id defined"}; |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
$elem->_set_cache_role($self, $r->{rol}); |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
push @ret, $elem; |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
} #_} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
return @ret; |
129
|
|
|
|
|
|
|
} #_} |
130
|
|
|
|
|
|
|
#_} |
131
|
|
|
|
|
|
|
#_{ POD: Copyright and license |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head1 COPYRIGHT and LICENSE |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
Copyright © 2017 René Nyffenegger, Switzerland. All rights reserved. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
138
|
|
|
|
|
|
|
under the terms of the the Artistic License (2.0). You may obtain a |
139
|
|
|
|
|
|
|
copy of the full license at: L |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=cut |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
#_} |
144
|
|
|
|
|
|
|
#_{ POD: Source Code |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head1 SOURCE CODE |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
The source code is on L<< github|https://github.com/ReneNyffenegger/perl-Geo-OSM-DBI >>. Meaningful pull requests are welcome. |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=cut |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
#_} |