| 1 | package XML::Loy::GeoRSS; | ||||||||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||
| 5 | 1 | use XML::Loy with => ( | |||||||||||||||||||||||||||||||||
| 6 | prefix => 'georss', | ||||||||||||||||||||||||||||||||||
| 7 | namespace => 'http://www.georss.org/georss' | ||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | ); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Carp qw/carp/; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use Scalar::Util qw/looks_like_number/; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||
| 13 | # No constructor | ||||||||||||||||||||||||||||||||||
| 14 | sub new { | ||||||||||||||||||||||||||||||||||
| 15 | 0 | ▶ | carp 'Only use ' . __PACKAGE__ . ' as an extension'; | ||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 16 | 0 | return; | |||||||||||||||||||||||||||||||||
| 17 | }; | ||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||
| 20 | # Add 'point' element | ||||||||||||||||||||||||||||||||||
| 21 | sub geo_point { | ||||||||||||||||||||||||||||||||||
| 22 | 4 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
geo_point: called CC=9 SCAR=23.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||
| 24 | # Get | ||||||||||||||||||||||||||||||||||
| 25 | 4 | ▶ | if (@_ <= 1) { | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||
| 26 | # Get point object | ||||||||||||||||||||||||||||||||||
| 27 | 2 | ▶ | my $point = $self->find('point') or return; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 28 | 2 | ▶ | $point = $point->[ shift // 0 ] or return; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
shift() // 0
MC/DC0%0/1
shift() // 0
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||
| 30 | # Wrong namespace | ||||||||||||||||||||||||||||||||||
| 31 | 2 | ▶ | return if $point->namespace ne __PACKAGE__->_namespace; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||
| 33 | # Return point | ||||||||||||||||||||||||||||||||||
| 34 | 2 | return [ split /\s+/, $point->text ]; | |||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||
| 37 | # Set | ||||||||||||||||||||||||||||||||||
| 38 | ▶ | elsif (@_ == 2 && looks_like_number($_[0]) && looks_like_number($_[1])) { | |||||||||||||||||||||||||||||||||
|
Condition66%4/6
@_ == 2 and &looks_like_number($_[0]) and &looks_like_number($_[1])
@_ == 2 and &looks_like_number($_[0])
MC/DC33%1/3
@_ == 2 and &looks_like_number($_[0]) and &looks_like_number($_[1])
@_ == 2
&looks_like_number($_[0])
&looks_like_number($_[1])
Truth table50%2/4
A and B and C
A= @_ == 2B= &looks_like_number($_[0])C= &looks_like_number($_[1])
| |||||||||||||||||||||||||||||||||||
| 39 | 1 | return $self->add(point => $_[0] . ' ' . $_[1]); | |||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||
| 42 | # Parameterlist has wrong length | ||||||||||||||||||||||||||||||||||
| 43 | 1 | return; | |||||||||||||||||||||||||||||||||
| 44 | }; | ||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||
| 47 | # Add 'line' element | ||||||||||||||||||||||||||||||||||
| 48 | sub geo_line { | ||||||||||||||||||||||||||||||||||
| 49 | 14 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
geo_line: called CC=10 SCAR=23.3
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||
| 51 | # Get | ||||||||||||||||||||||||||||||||||
| 52 | 14 | ▶ | if (@_ <= 1) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 53 | 10 | ▶ | my $line = $self->find('line') or return; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 54 | 10 | ▶ | $line = $line->[ shift // 0 ] or return; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
shift() // 0
MC/DC100%1/1
shift() // 0
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||
| 56 | # Wrong namespace | ||||||||||||||||||||||||||||||||||
| 57 | 10 | ▶ | return if $line->namespace ne __PACKAGE__->_namespace; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||
| 59 | # Return line | ||||||||||||||||||||||||||||||||||
| 60 | 10 | my @points; | |||||||||||||||||||||||||||||||||
| 61 | 10 | my @v = split /\s+/, $line->text; | |||||||||||||||||||||||||||||||||
| 62 | 10 | ▶ | push @points, [ shift(@v), shift(@v) // 0 ] while @v; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
shift @v // 0
MC/DC0%0/1
shift @v // 0
shift @v
Truth table50%1/2
A
A= shift @v
| |||||||||||||||||||||||||||||||||||
| 63 | 10 | return \@points; | |||||||||||||||||||||||||||||||||
| 64 | }; | ||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||
| 66 | # Parameterlist not even or too small | ||||||||||||||||||||||||||||||||||
| 67 | 4 | ▶ | return if @_ % 2 || @_ < 4; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@_ % 2 or @_ < 4
MC/DC100%2/2
@_ % 2 or @_ < 4
@_ % 2
@_ < 4
Truth table100%3/3
A or B
A= @_ % 2B= @_ < 4
| |||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||
| 69 | # Set | ||||||||||||||||||||||||||||||||||
| 70 | 2 | return $self->add(line => join(' ',@_) ); | |||||||||||||||||||||||||||||||||
| 71 | }; | ||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||
| 74 | # Add 'polygon' element | ||||||||||||||||||||||||||||||||||
| 75 | sub geo_polygon { | ||||||||||||||||||||||||||||||||||
| 76 | 13 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
geo_polygon: called CC=12 SCAR=25.3
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||
| 78 | # Get | ||||||||||||||||||||||||||||||||||
| 79 | 13 | ▶ | if (@_ <= 1) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 80 | 8 | ▶ | my $poly = $self->find('polygon') or return; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 81 | 8 | ▶ | $poly = $poly->[ shift // 0 ] or return; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
shift() // 0
MC/DC0%0/1
shift() // 0
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||
| 83 | # Wrong namespace | ||||||||||||||||||||||||||||||||||
| 84 | 8 | ▶ | return if $poly->namespace ne __PACKAGE__->_namespace; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||
| 86 | # Return polygon | ||||||||||||||||||||||||||||||||||
| 87 | 8 | my @points; | |||||||||||||||||||||||||||||||||
| 88 | 8 | my @v = split /\s+/, $poly->text; | |||||||||||||||||||||||||||||||||
| 89 | 8 | ▶ | push @points, [ shift(@v), shift(@v) // 0 ] while @v; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
shift @v // 0
MC/DC0%0/1
shift @v // 0
shift @v
Truth table50%1/2
A
A= shift @v
| |||||||||||||||||||||||||||||||||||
| 90 | 8 | return \@points; | |||||||||||||||||||||||||||||||||
| 91 | }; | ||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||
| 93 | # Parameterlist not even or too small | ||||||||||||||||||||||||||||||||||
| 94 | 5 | ▶ | return if @_ % 2 || @_ < 6; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@_ % 2 or @_ < 6
MC/DC100%2/2
@_ % 2 or @_ < 6
@_ % 2
@_ < 6
Truth table100%3/3
A or B
A= @_ % 2B= @_ < 6
| |||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||
| 96 | # Last pair is not identical to first pair | ||||||||||||||||||||||||||||||||||
| 97 | 2 | ▶ | if ($_[0] != $_[$#_ - 1] && $_[1] != $_[$#_]) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$_[0] != $_[$#_ - 1] and $_[1] != $_[$#_]
MC/DC50%1/2
$_[0] != $_[$#_ - 1] and $_[1] != $_[$#_]
$_[0] != $_[$#_ - 1]
$_[1] != $_[$#_]
Truth table66%2/3
A and B
A= $_[0] != $_[$#_ - 1]B= $_[1] != $_[$#_]
| |||||||||||||||||||||||||||||||||||
| 98 | 1 | push(@_, @_[0..1]); | |||||||||||||||||||||||||||||||||
| 99 | }; | ||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||
| 101 | # Add polygon | ||||||||||||||||||||||||||||||||||
| 102 | 2 | return $self->add(polygon => join(' ', @_)); | |||||||||||||||||||||||||||||||||
| 103 | }; | ||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||
| 106 | # Add properties | ||||||||||||||||||||||||||||||||||
| 107 | sub geo_property { | ||||||||||||||||||||||||||||||||||
| 108 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
geo_property: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||
| 110 | 1 | my %properties = @_; | |||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||
| 112 | # Add all available properties | ||||||||||||||||||||||||||||||||||
| 113 | 1 | foreach my $tag (grep(/^(?:(?:relationship|featuretype)tag|featurename)$/i, | |||||||||||||||||||||||||||||||||
| 114 | keys %properties)) { | ||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||
| 116 | 3 | my $val = $properties{$tag}; | |||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||
| 118 | # Add as an array, if it is one | ||||||||||||||||||||||||||||||||||
| 119 | 3 | ▶ | foreach (ref $val ? @$val : ($val)) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 120 | 5 | $self->add( lc($tag) => $_ ); | |||||||||||||||||||||||||||||||||
| 121 | }; | ||||||||||||||||||||||||||||||||||
| 122 | }; | ||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||
| 124 | 1 | return $self; | |||||||||||||||||||||||||||||||||
| 125 | }; | ||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||
| 128 | # Add 'floor' element | ||||||||||||||||||||||||||||||||||
| 129 | sub geo_floor { | ||||||||||||||||||||||||||||||||||
| 130 | 1 | ▶ | shift->add(floor => shift); | ||||||||||||||||||||||||||||||||
|
Subroutine
geo_floor: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 131 | }; | ||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||
| 134 | # Add 'elev' element | ||||||||||||||||||||||||||||||||||
| 135 | sub geo_elev { | ||||||||||||||||||||||||||||||||||
| 136 | 1 | ▶ | shift->add(elev => shift); | ||||||||||||||||||||||||||||||||
|
Subroutine
geo_elev: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 137 | }; | ||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||
| 140 | # Add 'radius' element | ||||||||||||||||||||||||||||||||||
| 141 | sub geo_radius { | ||||||||||||||||||||||||||||||||||
| 142 | 1 | ▶ | shift->add(radius => shift); | ||||||||||||||||||||||||||||||||
|
Subroutine
geo_radius: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 143 | }; | ||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||
| 146 | # Add 'where' element | ||||||||||||||||||||||||||||||||||
| 147 | sub geo_where { | ||||||||||||||||||||||||||||||||||
| 148 | 1 | ▶ | shift->add('where'); | ||||||||||||||||||||||||||||||||
|
Subroutine
geo_where: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 149 | }; | ||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||
| 152 | # Add 'box' element | ||||||||||||||||||||||||||||||||||
| 153 | sub geo_box { | ||||||||||||||||||||||||||||||||||
| 154 | 8 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
geo_box: called CC=7 SCAR=19.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||
| 156 | 8 | ▶ | if (@_ <= 1) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 157 | 4 | ▶ | my $box = $self->find('box') or return; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 158 | 4 | ▶ | $box = $box->[ shift // 0 ] or return; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
shift() // 0
MC/DC0%0/1
shift() // 0
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||
| 160 | # Wrong namespace | ||||||||||||||||||||||||||||||||||
| 161 | 4 | ▶ | return if $box->namespace ne __PACKAGE__->_namespace; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||
| 163 | # Return box | ||||||||||||||||||||||||||||||||||
| 164 | 4 | my @points; | |||||||||||||||||||||||||||||||||
| 165 | 4 | my @v = split /\s+/, $box->text; | |||||||||||||||||||||||||||||||||
| 166 | return [ | ||||||||||||||||||||||||||||||||||
| 167 | 4 | [$v[0], $v[1]], | |||||||||||||||||||||||||||||||||
| 168 | [$v[2], $v[3]] | ||||||||||||||||||||||||||||||||||
| 169 | ]; | ||||||||||||||||||||||||||||||||||
| 170 | }; | ||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||
| 172 | # Parameterlist has wrong length | ||||||||||||||||||||||||||||||||||
| 173 | 4 | ▶ | return unless @_ == 4; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||
| 175 | 1 | return $self->add(box => join(' ',@_)); | |||||||||||||||||||||||||||||||||
| 176 | }; | ||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||
| 179 | # Add 'circle' element | ||||||||||||||||||||||||||||||||||
| 180 | sub geo_circle { | ||||||||||||||||||||||||||||||||||
| 181 | 6 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
geo_circle: called CC=7 SCAR=19.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||
| 183 | 6 | ▶ | if (@_ <= 1) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 184 | 3 | ▶ | my $circle = $self->find('circle') or return; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 185 | 3 | ▶ | $circle = $circle->[ shift // 0 ] or return; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
shift() // 0
MC/DC0%0/1
shift() // 0
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||
| 187 | # Wrong namespace | ||||||||||||||||||||||||||||||||||
| 188 | 3 | ▶ | return if $circle->namespace ne __PACKAGE__->_namespace; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||
| 190 | # Return point | ||||||||||||||||||||||||||||||||||
| 191 | 3 | my @v = split /\s+/, $circle->text; | |||||||||||||||||||||||||||||||||
| 192 | 3 | return [ [ $v[0], $v[1] ], $v[2] ]; | |||||||||||||||||||||||||||||||||
| 193 | }; | ||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||
| 195 | # Parameterlist has wrong length | ||||||||||||||||||||||||||||||||||
| 196 | 3 | ▶ | return unless @_ == 3; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||
| 198 | 1 | return $self->add(circle => join(' ',@_)); | |||||||||||||||||||||||||||||||||
| 199 | }; | ||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||
| 202 | 1 | 1; | |||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||
| 205 | __END__ | ||||||||||||||||||||||||||||||||||