| 1 | package Geo::JapanMesh; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 4 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 4 | ▶ | use version; our $VERSION = qv('0.0.2'); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 4 | ▶ | use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 4 | ▶ | use Exporter; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 4 | @ISA = qw(Exporter); | |||||||||||||||||||||||||||||||||||||||||
| 11 | 4 | @EXPORT = qw(latlng2japanmesh japanmesh2latlng japanmesh2rect); | |||||||||||||||||||||||||||||||||||||||||
| 12 | 4 | @EXPORT_OK = qw( | |||||||||||||||||||||||||||||||||||||||||
| 13 | latlng2iareamesh iareamesh2latlng iareamesh2rect | ||||||||||||||||||||||||||||||||||||||||||
| 14 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 15 | 4 | %EXPORT_TAGS = ( | |||||||||||||||||||||||||||||||||||||||||
| 16 | iareamesh => [qw(latlng2iareamesh iareamesh2latlng iareamesh2rect)], | ||||||||||||||||||||||||||||||||||||||||||
| 17 | japanmesh => [qw(latlng2japanmesh japanmesh2latlng japanmesh2rect)], | ||||||||||||||||||||||||||||||||||||||||||
| 18 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | # Export function for JapanMesh | ||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | 15 | ▶ | sub latlng2japanmesh { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
latlng2japanmesh: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 15 | my $lat = shift; | |||||||||||||||||||||||||||||||||||||||||
| 24 | 15 | my $lng = shift; | |||||||||||||||||||||||||||||||||||||||||
| 25 | 15 | ▶ | my $num = shift || 1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() || 1
MC/DC0%0/1
shift() || 1
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | 15 | ▶ | croak("Level number must be between 1 and 3") if ( $num !~ /^[1-3]$/ ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | 15 | my ( $slat, $slng ) = _latlng2msec( $lat, $lng ); | |||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | 15 | return _latlng2japanmesh( $slat, $slng, $num ); | |||||||||||||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | sub japanmesh2latlng{ | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
japanmesh2latlng: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | my @rect = japanmesh2rect(@_); | |||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | return @rect[4..6]; | |||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | 3 | ▶ | sub japanmesh2rect { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
japanmesh2rect: called CC=4 SCAR=15.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | 3 | my $jmesh = shift; | |||||||||||||||||||||||||||||||||||||||||
| 41 | 3 | my @res = grep { defined($_) } ( $jmesh =~ /(\d{2})(\d{2})\-?(?:(\d)(\d)\-?(?:(\d)(\d))?)?/ ); | |||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | 3 | ▶ | croak("Maybe format is wrong: $jmesh") if ( @res < 2 || @res > 6 || @res % 2 != 0 ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
@res < 2 or @res > 6 or @res % 2 != 0
@res < 2 or @res > 6
MC/DC0%0/3
@res < 2 or @res > 6 or @res % 2 != 0
@res < 2
@res > 6
@res % 2 != 0
Truth table25%1/4
A or B or C
A= @res < 2B= @res > 6C= @res % 2 != 0
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | 3 | my ( $mny, $mnx, $mxy, $mxx, $lvl ) = _japanmesh2rect( @res ); | |||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | 3 | ( $mny, $mnx, $mxy, $mxx ) = _msec2latlng( $mny, $mnx, $mxy, $mxx ); | |||||||||||||||||||||||||||||||||||||||||
| 48 | 3 | my ( $cy, $cx ) = ( ( $mny + $mxy ) / 2, ( $mnx + $mxx ) / 2 ); | |||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | 3 | return ( $mny, $mnx, $mxy, $mxx, $cy, $cx, $lvl ); | |||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | # Export function for iAreaMesh | ||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | 15 | ▶ | sub latlng2iareamesh { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
latlng2iareamesh: called CC=4 SCAR=14.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | 15 | my $lat = shift; | |||||||||||||||||||||||||||||||||||||||||
| 57 | 15 | my $lng = shift; | |||||||||||||||||||||||||||||||||||||||||
| 58 | 15 | ▶ | my $num = shift || 1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() || 1
MC/DC0%0/1
shift() || 1
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | 15 | ▶ | croak("Level number must be between 1 and 8") if ( $num !~ /^[1-8]$/ ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | 15 | my ( $slat, $slng ) = _latlng2msec( $lat, $lng ); | |||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | 15 | ▶ | return _latlng2japanmesh( $slat, $slng, $num ) if ( $num < 3 ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | 15 | my ( $ret, $a, $b ) = _latlng2japanmesh( $slat, $slng, -2 ); | |||||||||||||||||||||||||||||||||||||||||
| 67 | 15 | $ret =~ s/\-//g; | |||||||||||||||||||||||||||||||||||||||||
| 68 | 15 | return _latlng2iareamesh( $ret, $a, $b, $num - 2, 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | sub iareamesh2latlng{ | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
iareamesh2latlng: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | my @rect = iareamesh2rect(@_); | |||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | return @rect[4..6]; | |||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | 341 | ▶ | sub iareamesh2rect { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
iareamesh2rect: called CC=4 SCAR=14.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | 341 | my $imesh = shift; | |||||||||||||||||||||||||||||||||||||||||
| 78 | 341 | my @res = grep { defined($_) } ( $imesh =~ /(\d{2})(\d{2})(?:(\d)(\d)(?:(\d{1,6}))?)?/ ); | |||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | 341 | ▶ | croak("Maybe format is wrong: $imesh") if ( @res < 2 || @res > 5 ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@res < 2 or @res > 5
MC/DC0%0/2
@res < 2 or @res > 5
@res < 2
@res > 5
Truth table33%1/3
A or B
A= @res < 2B= @res > 5
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | 341 | my ( $mny, $mnx, $mxy, $mxx, $lvl ) = _japanmesh2rect( splice( @res, 0, 4 ) ); | |||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | 341 | ▶ | if ( @res ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 85 | 340 | ( $mny, $mnx, $mxy, $mxx, $lvl ) = _iareamesh2rect( $res[0], $mny, $mnx, 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||
| 88 | 341 | ( $mny, $mnx, $mxy, $mxx ) = _msec2latlng( $mny, $mnx, $mxy, $mxx ); | |||||||||||||||||||||||||||||||||||||||||
| 89 | 341 | my ( $cy, $cx ) = ( ( $mny + $mxy ) / 2, ( $mnx + $mxx ) / 2 ); | |||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | 341 | return ( $mny, $mnx, $mxy, $mxx, $cy, $cx, $lvl ); | |||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | # Internal function for Common Use | ||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||
| 96 | 30 | ▶ | sub _latlng2msec { map { $_ * 3600000 } @_; } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_latlng2msec: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | 344 | ▶ | sub _msec2latlng { map { $_ / 3600000 } @_; } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_msec2latlng: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | # Internal function for JapanMesh | ||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | 30 | ▶ | sub _latlng2japanmesh { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_latlng2japanmesh: called CC=6 SCAR=18.3
| |||||||||||||||||||||||||||||||||||||||||||
| 103 | 30 | my $lat = shift; | |||||||||||||||||||||||||||||||||||||||||
| 104 | 30 | my $lng = shift; | |||||||||||||||||||||||||||||||||||||||||
| 105 | 30 | my $num = shift; | |||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | 30 | my $p = int( $lat / 2400000 ); | |||||||||||||||||||||||||||||||||||||||||
| 108 | 30 | my $a = $lat - $p * 2400000; | |||||||||||||||||||||||||||||||||||||||||
| 109 | 30 | my $s = int( $lng / 3600000 ) - 100; | |||||||||||||||||||||||||||||||||||||||||
| 110 | 30 | my $c = $lng - ( $s + 100 ) * 3600000; | |||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | 30 | my $ret = $p.$s; | |||||||||||||||||||||||||||||||||||||||||
| 113 | 30 | ▶ | return $ret if ( $num == 1 ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | 25 | my $q = int( $a / 300000 ); | |||||||||||||||||||||||||||||||||||||||||
| 116 | 25 | my $t = int( $c / 450000 ); | |||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||
| 118 | 25 | $ret .= "-$q$t"; | |||||||||||||||||||||||||||||||||||||||||
| 119 | 25 | ▶ | return $ret if ( $num == 2 ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | 20 | my $b = $a - $q * 300000; | |||||||||||||||||||||||||||||||||||||||||
| 122 | 20 | my $d = $c - $t * 450000; | |||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||
| 124 | 20 | ▶ | return ($ret, $b, $d) if ( $num == -2 ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||
| 126 | 5 | my $r = int( $b / 30000 ); | |||||||||||||||||||||||||||||||||||||||||
| 127 | 5 | my $u = int( $d / 45000 ); | |||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||
| 129 | 5 | $ret .= "-$r$u"; | |||||||||||||||||||||||||||||||||||||||||
| 130 | 5 | ▶ | return $ret if ( $num == 3 ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | my $e = $b - $r * 30000; | |||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | my $f = $d - $u * 45000; | |||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | return ($ret, $e, $f) if ( $num == -3 ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | 344 | ▶ | sub _japanmesh2rect { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_japanmesh2rect: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 139 | 344 | my @codes = @_; | |||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | 344 | my ( $mny, $mnx ) = ( 0.0, 100.0 * 3600000 ); | |||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||
| 143 | 344 | my ( $cy1, $cx1 ) = splice( @codes, 0, 2 ); | |||||||||||||||||||||||||||||||||||||||||
| 144 | 344 | ( $mny, $mnx ) = ( $mny + $cy1 * 2400000, $mnx + $cx1 * 3600000 ); | |||||||||||||||||||||||||||||||||||||||||
| 145 | 344 | my ( $mxy, $mxx ) = ( $mny + 2400000, $mnx + 3600000 ); | |||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||
| 147 | 344 | ▶ | return ( $mny, $mnx, $mxy, $mxx, 1 ) unless ( @codes ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||
| 149 | 343 | my ( $cy2, $cx2 ) = splice( @codes, 0, 2 ); | |||||||||||||||||||||||||||||||||||||||||
| 150 | 343 | ( $mny, $mnx ) = ( $mny + $cy2 * 300000, $mnx + $cx2 * 450000 ); | |||||||||||||||||||||||||||||||||||||||||
| 151 | 343 | ( $mxy, $mxx ) = ( $mny + 300000, $mnx + 450000 ); | |||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||
| 153 | 343 | ▶ | return ( $mny, $mnx, $mxy, $mxx, 2 ) unless ( @codes ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||
| 155 | 1 | my ( $cy3, $cx3 ) = @codes; | |||||||||||||||||||||||||||||||||||||||||
| 156 | 1 | ( $mny, $mnx ) = ( $mny + $cy3 * 30000, $mnx + $cx3 * 45000 ); | |||||||||||||||||||||||||||||||||||||||||
| 157 | 1 | ( $mxy, $mxx ) = ( $mny + 30000, $mnx + 45000 ); | |||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||
| 159 | 1 | return ( $mny, $mnx, $mxy, $mxx, 3 ); | |||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||
| 162 | # Internal function for iAreaMesh | ||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||
| 164 | 75 | ▶ | sub _latlng2iareamesh { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_latlng2iareamesh: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 165 | 75 | my $ret = shift; | |||||||||||||||||||||||||||||||||||||||||
| 166 | 75 | my $y = shift; | |||||||||||||||||||||||||||||||||||||||||
| 167 | 75 | my $x = shift; | |||||||||||||||||||||||||||||||||||||||||
| 168 | 75 | my $num = shift; | |||||||||||||||||||||||||||||||||||||||||
| 169 | 75 | my $depth = shift; | |||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||
| 171 | 75 | my $divy = 300000 / 2 ** $depth; | |||||||||||||||||||||||||||||||||||||||||
| 172 | 75 | my $divx = 450000 / 2 ** $depth; | |||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||
| 174 | 75 | my $rety = int( $y / $divy ); | |||||||||||||||||||||||||||||||||||||||||
| 175 | 75 | my $nxty = $y - $rety * $divy; | |||||||||||||||||||||||||||||||||||||||||
| 176 | 75 | my $retx = int( $x / $divx ); | |||||||||||||||||||||||||||||||||||||||||
| 177 | 75 | my $nxtx = $x - $retx * $divx; | |||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||
| 179 | 75 | $ret .= $retx + $rety * 2; | |||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||
| 181 | 75 | ▶ | return $depth >= $num ? $ret | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 182 | : _latlng2iareamesh( $ret, $nxty, $nxtx, $num, $depth + 1 ); | ||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||
| 186 | 1252 | ▶ | sub _iareamesh2rect { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_iareamesh2rect: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 187 | 1252 | my ( $code, $mny, $mnx, $depth ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||
| 189 | 1252 | my $divy = 300000 / 2 ** $depth; | |||||||||||||||||||||||||||||||||||||||||
| 190 | 1252 | my $divx = 450000 / 2 ** $depth; | |||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||
| 192 | 1252 | my ( $this, $rest ) = $code =~ /^([0-3])(?:([0-3]+))?$/; | |||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||
| 194 | 1252 | ▶ | croak("Maybe format is wrong") unless ( defined( $this ) ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||
| 196 | 1252 | my $dy = int( $this / 2 ); | |||||||||||||||||||||||||||||||||||||||||
| 197 | 1252 | my $dx = $this % 2; | |||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||
| 199 | 1252 | ( $mny, $mnx ) = ( $mny + $dy * $divy, $mnx + $dx * $divx ); | |||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||
| 201 | 1252 | ▶ | return _iareamesh2rect( $rest, $mny, $mnx, $depth + 1 ) if ( defined( $rest ) ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||
| 203 | 340 | my ( $mxy, $mxx ) = ( $mny + $divy, $mnx + $divx ); | |||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||
| 205 | 340 | return ( $mny, $mnx, $mxy, $mxx, $depth + 2 ); | |||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||
| 208 | 4 | 1; # Magic true value required at end of module | |||||||||||||||||||||||||||||||||||||||||
| 209 | __END__ | ||||||||||||||||||||||||||||||||||||||||||