| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# ABSTRACT: Convenient representation of company from Yandex Maps |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Yandex::Geo::Company; |
|
4
|
|
|
|
|
|
|
$Yandex::Geo::Company::VERSION = '0.02'; |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
58911
|
use Object::Tiny qw{ name phones links url vk address postalCode }; |
|
|
1
|
|
|
|
|
232
|
|
|
|
1
|
|
|
|
|
4
|
|
|
8
|
1
|
|
|
1
|
|
711
|
use JSON::XS; |
|
|
1
|
|
|
|
|
5073
|
|
|
|
1
|
|
|
|
|
311
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub from_geo_json { |
|
12
|
0
|
|
|
0
|
1
|
|
my $feature_collection = shift; |
|
13
|
|
|
|
|
|
|
|
|
14
|
0
|
|
|
|
|
|
my @res; |
|
15
|
|
|
|
|
|
|
|
|
16
|
0
|
|
|
|
|
|
for my $f ( @{ $feature_collection->features } ) { |
|
|
0
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
0
|
|
|
|
|
|
my $company_meta = $f->properties->{CompanyMetaData}; |
|
19
|
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
|
my $h = {}; |
|
21
|
|
|
|
|
|
|
|
|
22
|
0
|
|
|
|
|
|
for (qw/id name shortName url address postalCode/) { |
|
23
|
0
|
|
|
|
|
|
$h->{$_} = $company_meta->{$_}; |
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
push @{ $h->{phones} }, $_->{formatted} |
|
27
|
0
|
|
|
|
|
|
for ( @{ $company_meta->{Phones} } ); |
|
|
0
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
push @{ $h->{links} }, $_->{href} for ( @{ $company_meta->{Links} } ); |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
my $vk_link = |
|
30
|
0
|
|
|
|
|
|
( grep { $_->{aref} eq '#vkontakte' } @{ $company_meta->{Links} } ) |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
[0]; |
|
32
|
0
|
0
|
|
|
|
|
$h->{vk} = $vk_link->{href} if defined $vk_link; |
|
33
|
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
my $company_obj = __PACKAGE__->new(%$h); |
|
35
|
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
push @result, $company_obj; |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
return \@result; |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub from_json { |
|
46
|
0
|
|
|
0
|
1
|
|
my $json_str = shift; |
|
47
|
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
my $res = decode_json $json_str; |
|
49
|
0
|
|
|
|
|
|
my $features = @{ $res->{features} }; |
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
my @result; |
|
52
|
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
for my $f (@$features) { |
|
54
|
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
my $company_meta = $f->{properties}{CompanyMetaData}; |
|
56
|
0
|
|
|
|
|
|
my $h = {}; |
|
57
|
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
for (qw/id name shortName url address postalCode/) { |
|
59
|
0
|
|
|
|
|
|
$h->{$_} = $company_meta->{$_}; |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
push @{ $h->{phones} }, $_->{formatted} |
|
63
|
0
|
|
|
|
|
|
for ( @{ $company_meta->{Phones} } ); |
|
|
0
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
push @{ $h->{links} }, $_->{href} for ( @{ $company_meta->{Links} } ); |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
my $vk_link = |
|
66
|
0
|
|
|
|
|
|
( grep { $_->{aref} eq '#vkontakte' } @{ $company_meta->{Links} } ) |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
[0]; |
|
68
|
0
|
0
|
|
|
|
|
$h->{vk} = $vk_link->{href} if defined $vk_link; |
|
69
|
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
my $company_obj = __PACKAGE__->new(%$h); |
|
71
|
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
push @result, $company_obj; |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
return \@result; |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1; |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
__END__ |