| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Geo::JSON::Simple; |
|
2
|
|
|
|
|
|
|
BEGIN { |
|
3
|
2
|
|
|
2
|
|
192722
|
$Geo::JSON::Simple::AUTHORITY = 'cpan:GETTY'; |
|
4
|
|
|
|
|
|
|
} |
|
5
|
|
|
|
|
|
|
{ |
|
6
|
|
|
|
|
|
|
$Geo::JSON::Simple::VERSION = '0.001'; |
|
7
|
|
|
|
|
|
|
} |
|
8
|
|
|
|
|
|
|
# ABSTRACT: Simplified functions for generating Geo::JSON objects |
|
9
|
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
23
|
use strict; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
76
|
|
|
11
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
191
|
|
|
12
|
2
|
|
|
2
|
|
18
|
use Exporter 'import'; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
76
|
|
|
13
|
2
|
|
|
2
|
|
16
|
use Carp 'croak'; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
182
|
|
|
14
|
2
|
|
|
|
|
217
|
use List::MoreUtils qw( |
|
15
|
|
|
|
|
|
|
natatime |
|
16
|
2
|
|
|
2
|
|
1117
|
); |
|
|
2
|
|
|
|
|
1679
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
2
|
|
|
2
|
|
2367
|
use Geo::JSON; |
|
|
2
|
|
|
|
|
66323
|
|
|
|
2
|
|
|
|
|
142
|
|
|
19
|
2
|
|
|
2
|
|
2445
|
use Geo::JSON::Point; |
|
|
2
|
|
|
|
|
879626
|
|
|
|
2
|
|
|
|
|
69
|
|
|
20
|
2
|
|
|
2
|
|
2320
|
use Geo::JSON::MultiPoint; |
|
|
2
|
|
|
|
|
9881
|
|
|
|
2
|
|
|
|
|
91
|
|
|
21
|
2
|
|
|
2
|
|
2417
|
use Geo::JSON::LineString; |
|
|
2
|
|
|
|
|
8821
|
|
|
|
2
|
|
|
|
|
170
|
|
|
22
|
2
|
|
|
2
|
|
2712
|
use Geo::JSON::MultiLineString; |
|
|
2
|
|
|
|
|
8765
|
|
|
|
2
|
|
|
|
|
99
|
|
|
23
|
2
|
|
|
2
|
|
2475
|
use Geo::JSON::Polygon; |
|
|
2
|
|
|
|
|
8160
|
|
|
|
2
|
|
|
|
|
76
|
|
|
24
|
2
|
|
|
2
|
|
2038
|
use Geo::JSON::MultiPolygon; |
|
|
2
|
|
|
|
|
8162
|
|
|
|
2
|
|
|
|
|
80
|
|
|
25
|
2
|
|
|
2
|
|
2329
|
use Geo::JSON::Feature; |
|
|
2
|
|
|
|
|
15133
|
|
|
|
2
|
|
|
|
|
104
|
|
|
26
|
2
|
|
|
2
|
|
2317
|
use Geo::JSON::FeatureCollection; |
|
|
2
|
|
|
|
|
9878
|
|
|
|
2
|
|
|
|
|
83
|
|
|
27
|
2
|
|
|
2
|
|
5007
|
use Geo::JSON::GeometryCollection; |
|
|
2
|
|
|
|
|
29767
|
|
|
|
2
|
|
|
|
|
1680
|
|
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
our @EXPORT = qw( |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
point |
|
32
|
|
|
|
|
|
|
multipoint |
|
33
|
|
|
|
|
|
|
linestring |
|
34
|
|
|
|
|
|
|
multilinestring |
|
35
|
|
|
|
|
|
|
polygon |
|
36
|
|
|
|
|
|
|
multipolygon |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
feature |
|
39
|
|
|
|
|
|
|
featurecollection |
|
40
|
|
|
|
|
|
|
geometrycollection |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
from_geo_json |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
); |
|
45
|
|
|
|
|
|
|
|
|
46
|
6
|
|
|
6
|
1
|
31097
|
sub point { Geo::JSON::Point->new({ coordinates => [ $_[0], $_[1] ] }) } |
|
47
|
1
|
|
|
1
|
1
|
7654
|
sub multipoint { Geo::JSON::MultiPoint->new({ coordinates => [ _make_positions(@_) ] }) } |
|
48
|
|
|
|
|
|
|
|
|
49
|
1
|
|
|
1
|
1
|
6136
|
sub linestring { Geo::JSON::LineString->new({ coordinates => [ _make_positions(@_) ] }) } |
|
50
|
2
|
|
|
|
|
7
|
sub multilinestring { Geo::JSON::MultiLineString->new({ coordinates => [ map { |
|
51
|
1
|
|
|
1
|
1
|
7056
|
[_make_positions(@{$_})] |
|
|
2
|
|
|
|
|
26
|
|
|
52
|
|
|
|
|
|
|
} @_ ] }) } |
|
53
|
|
|
|
|
|
|
|
|
54
|
1
|
|
|
1
|
1
|
6180
|
sub polygon { Geo::JSON::Polygon->new({ coordinates => [ _make_linear_ring(@_) ] }) } |
|
55
|
0
|
|
|
|
|
0
|
sub multipolygon { Geo::JSON::MultiPolygon->new({ coordinates => [ map { |
|
56
|
0
|
|
|
0
|
1
|
0
|
[_make_linear_ring(@{$_})] |
|
|
0
|
|
|
|
|
0
|
|
|
57
|
|
|
|
|
|
|
} @_ ] }) } |
|
58
|
|
|
|
|
|
|
|
|
59
|
2
|
|
|
|
|
5
|
sub _make_linear_ring { map { |
|
60
|
1
|
|
|
1
|
|
3
|
my @coordlist = _make_positions(@{$_}); [@coordlist,$coordlist[0]] |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
16
|
|
|
61
|
|
|
|
|
|
|
} @_ } |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub _make_positions { |
|
64
|
6
|
|
|
6
|
|
67
|
my $it = natatime 2, @_; |
|
65
|
6
|
|
|
|
|
8
|
my @coords; |
|
66
|
6
|
|
|
|
|
53
|
while (my @pair = $it->()) { |
|
67
|
22
|
|
|
|
|
109
|
push @coords, [@pair]; |
|
68
|
|
|
|
|
|
|
} |
|
69
|
6
|
|
|
|
|
68
|
return @coords; |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub feature { |
|
73
|
3
|
|
|
3
|
1
|
190
|
my ( $object, %properties ) = @_; |
|
74
|
3
|
|
|
|
|
70
|
Geo::JSON::Feature->new({ |
|
75
|
|
|
|
|
|
|
geometry => $object, |
|
76
|
|
|
|
|
|
|
properties => \%properties |
|
77
|
|
|
|
|
|
|
}); |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub featurecollection { |
|
81
|
1
|
|
|
1
|
1
|
141
|
my @features; |
|
82
|
|
|
|
|
|
|
my $current_geometry; |
|
83
|
0
|
|
|
|
|
0
|
my @args; |
|
84
|
1
|
|
|
|
|
3
|
for (@_) { |
|
85
|
10
|
100
|
|
|
|
27
|
if (ref $_) { |
|
|
|
50
|
|
|
|
|
|
|
86
|
2
|
100
|
|
|
|
7
|
if ($current_geometry) { |
|
87
|
1
|
|
|
|
|
5
|
push @features, feature($current_geometry, @args); |
|
88
|
1
|
|
|
|
|
249
|
@args = (); |
|
89
|
1
|
|
|
|
|
3
|
$current_geometry = $_; |
|
90
|
|
|
|
|
|
|
} else { |
|
91
|
1
|
|
|
|
|
3
|
$current_geometry = $_; |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
} elsif (!$current_geometry) { |
|
94
|
0
|
|
|
|
|
0
|
croak "featurecollection needs to start with a geometry"; |
|
95
|
|
|
|
|
|
|
} else { |
|
96
|
8
|
|
|
|
|
12
|
push @args, $_; |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
} |
|
99
|
1
|
50
|
|
|
|
5
|
if ($current_geometry) { |
|
100
|
1
|
|
|
|
|
3
|
push @features, feature($current_geometry, @args); |
|
101
|
|
|
|
|
|
|
} |
|
102
|
|
|
|
|
|
|
Geo::JSON::FeatureCollection->new({ |
|
103
|
1
|
|
|
|
|
254
|
features => \@features |
|
104
|
|
|
|
|
|
|
}); |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub geometrycollection { |
|
108
|
1
|
|
|
1
|
1
|
139
|
Geo::JSON::GeometryCollection->new({ |
|
109
|
|
|
|
|
|
|
geometries => \@_ |
|
110
|
|
|
|
|
|
|
}); |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
|
|
113
|
0
|
|
|
0
|
1
|
|
sub from_geo_json { Geo::JSON->from_json(@_) } |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
1; |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
__END__ |