| Conditions | 2 |
| Paths | 1 |
| Total Lines | 80 |
| Code Lines | 73 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 1 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 180 | public function convertToLatitudeLongitude($N, $E, $N0, $E0, $phi0, $lambda0) |
||
| 181 | { |
||
| 182 | |||
| 183 | $phi0 = deg2rad($phi0); |
||
| 184 | $lambda0 = deg2rad($lambda0); |
||
| 185 | |||
| 186 | $refEll = $this->getReferenceEllipsoid(); |
||
| 187 | $F0 = $this->getScaleFactor(); |
||
| 188 | |||
| 189 | $a = $refEll->getMaj(); |
||
| 190 | $b = $refEll->getMin(); |
||
| 191 | $eSquared = $refEll->getEcc(); |
||
| 192 | $n = ($a - $b) / ($a + $b); |
||
| 193 | $phiPrime = (($N - $N0) / ($a * $F0)) + $phi0; |
||
| 194 | |||
| 195 | do { |
||
| 196 | $M = |
||
| 197 | ($b * $F0) |
||
| 198 | * (((1 + $n + ((5 / 4) * $n * $n) + ((5 / 4) * $n * $n * $n)) |
||
| 199 | * ($phiPrime - $phi0)) |
||
| 200 | - (((3 * $n) + (3 * $n * $n) + ((21 / 8) * $n * $n * $n)) |
||
| 201 | * sin($phiPrime - $phi0) |
||
| 202 | * cos($phiPrime + $phi0)) |
||
| 203 | + ((((15 / 8) * $n * $n) + ((15 / 8) * $n * $n * $n)) |
||
| 204 | * sin(2 * ($phiPrime - $phi0)) |
||
| 205 | * cos(2 * ($phiPrime + $phi0))) |
||
| 206 | - (((35 / 24) * $n * $n * $n) |
||
| 207 | * sin(3 * ($phiPrime - $phi0)) |
||
| 208 | * cos(3 * ($phiPrime + $phi0)))); |
||
| 209 | $phiPrime += ($N - $N0 - $M) / ($a * $F0); |
||
| 210 | } while (($N - $N0 - $M) >= 0.001); |
||
| 211 | $v = $a * $F0 * pow(1 - $eSquared * pow(sin($phiPrime), 2), -0.5); |
||
| 212 | $rho = |
||
| 213 | $a |
||
| 214 | * $F0 |
||
| 215 | * (1 - $eSquared) |
||
| 216 | * pow(1 - $eSquared * pow(sin($phiPrime), 2), -1.5); |
||
| 217 | $etaSquared = ($v / $rho) - 1; |
||
| 218 | $VII = tan($phiPrime) / (2 * $rho * $v); |
||
| 219 | $VIII = |
||
| 220 | (tan($phiPrime) / (24 * $rho * pow($v, 3))) |
||
| 221 | * (5 |
||
| 222 | + (3 * pow(tan($phiPrime), 2)) |
||
| 223 | + $etaSquared |
||
| 224 | - (9 * pow(tan($phiPrime), 2) * $etaSquared)); |
||
| 225 | $IX = |
||
| 226 | (tan($phiPrime) / (720 * $rho * pow($v, 5))) |
||
| 227 | * (61 |
||
| 228 | + (90 * pow(tan($phiPrime), 2)) |
||
| 229 | + (45 * pow(tan($phiPrime), 2) * pow(tan($phiPrime), 2))); |
||
| 230 | $X = (1 / cos($phiPrime)) / $v; |
||
| 231 | $XI = |
||
| 232 | ((1 / cos($phiPrime)) / (6 * $v * $v * $v)) |
||
| 233 | * (($v / $rho) + (2 * pow(tan($phiPrime), 2))); |
||
| 234 | $XII = |
||
| 235 | ((1 / cos($phiPrime)) / (120 * pow($v, 5))) |
||
| 236 | * (5 |
||
| 237 | + (28 * pow(tan($phiPrime), 2)) |
||
| 238 | + (24 * pow(tan($phiPrime), 4))); |
||
| 239 | $XIIA = |
||
| 240 | ((1 / cos($phiPrime)) / (5040 * pow($v, 7))) |
||
| 241 | * (61 |
||
| 242 | + (662 * pow(tan($phiPrime), 2)) |
||
| 243 | + (1320 * pow(tan($phiPrime), 4)) |
||
| 244 | + (720 |
||
| 245 | * pow(tan($phiPrime), 6))); |
||
| 246 | $phi = |
||
| 247 | $phiPrime |
||
| 248 | - ($VII * pow($E - $E0, 2)) |
||
| 249 | + ($VIII * pow($E - $E0, 4)) |
||
| 250 | - ($IX * pow($E - $E0, 6)); |
||
| 251 | $lambda = |
||
| 252 | $lambda0 |
||
| 253 | + ($X * ($E - $E0)) |
||
| 254 | - ($XI * pow($E - $E0, 3)) |
||
| 255 | + ($XII * pow($E - $E0, 5)) |
||
| 256 | - ($XIIA * pow($E - $E0, 7)); |
||
| 257 | |||
| 258 | return new LatLng(rad2deg($phi), rad2deg($lambda), 0, $refEll); |
||
| 259 | } |
||
| 260 | } |
||
| 261 |