| @@ 375-475 (lines=101) @@ | ||
| 372 | ]; |
|
| 373 | } |
|
| 374 | ||
| 375 | public function geo2gk($bp, $lp) |
|
| 376 | { |
|
| 377 | /* Copyright (c) 2006, HELMUT H. HEIMEIER |
|
| 378 | Permission is hereby granted, free of charge, to any person obtaining a |
|
| 379 | copy of this software and associated documentation files (the "Software"), |
|
| 380 | to deal in the Software without restriction, including without limitation |
|
| 381 | the rights to use, copy, modify, merge, publish, distribute, sublicense, |
|
| 382 | and/or sell copies of the Software, and to permit persons to whom the |
|
| 383 | Software is furnished to do so, subject to the following conditions: |
|
| 384 | The above copyright notice and this permission notice shall be included |
|
| 385 | in all copies or substantial portions of the Software.*/ |
|
| 386 | ||
| 387 | /* Die Funktion wandelt geographische Koordinaten in GK Koordinaten |
|
| 388 | um. Geographische Länge lp und Breite bp müssen im Potsdam Datum |
|
| 389 | gegeben sein. Berechnet werden Rechtswert rw und Hochwert hw.*/ |
|
| 390 | ||
| 391 | //Geographische Länge lp und Breite bp im Potsdam Datum |
|
| 392 | if ($lp == '' || $bp == '') { |
|
| 393 | return [ |
|
| 394 | 0, |
|
| 395 | 0, |
|
| 396 | ]; |
|
| 397 | } |
|
| 398 | $lp = (float) $lp; |
|
| 399 | $bp = (float) $bp; |
|
| 400 | ||
| 401 | // Potsdam Datum |
|
| 402 | // Große Halbachse a und Abplattung f |
|
| 403 | $a = 6377397.155; // + $falseeasting; |
|
| 404 | $f = 3.34277321e-3; |
|
| 405 | ||
| 406 | // Polkrümmungshalbmesser c |
|
| 407 | $c = $a / (1 - $f); |
|
| 408 | ||
| 409 | // Quadrat der zweiten numerischen Exzentrizität |
|
| 410 | $ex2 = (2 * $f - $f * $f) / ((1 - $f) * (1 - $f)); |
|
| 411 | $ex4 = $ex2 * $ex2; |
|
| 412 | $ex6 = $ex4 * $ex2; |
|
| 413 | $ex8 = $ex4 * $ex4; |
|
| 414 | ||
| 415 | // Koeffizienten zur Berechnung der Meridianbogenlänge |
|
| 416 | $e0 = $c * (pi() / 180) * (1 - 3 * $ex2 / 4 + 45 * $ex4 / 64 - 175 * $ex6 / 256 + 11025 * $ex8 / 16384); |
|
| 417 | $e2 = $c * (-3 * $ex2 / 8 + 15 * $ex4 / 32 - 525 * $ex6 / 1024 + 2205 * $ex8 / 4096); |
|
| 418 | $e4 = $c * (15 * $ex4 / 256 - 105 * $ex6 / 1024 + 2205 * $ex8 / 16384); |
|
| 419 | $e6 = $c * (-35 * $ex6 / 3072 + 315 * $ex8 / 12288); |
|
| 420 | ||
| 421 | // Breite in Radianten |
|
| 422 | $br = $bp * pi() / 180; |
|
| 423 | ||
| 424 | $tan1 = tan($br); |
|
| 425 | $tan2 = $tan1 * $tan1; |
|
| 426 | $tan4 = $tan2 * $tan2; |
|
| 427 | ||
| 428 | $cos1 = cos($br); |
|
| 429 | $cos2 = $cos1 * $cos1; |
|
| 430 | $cos4 = $cos2 * $cos2; |
|
| 431 | $cos3 = $cos2 * $cos1; |
|
| 432 | $cos5 = $cos4 * $cos1; |
|
| 433 | ||
| 434 | $etasq = $ex2 * $cos2; |
|
| 435 | ||
| 436 | // Querkrümmungshalbmesser nd |
|
| 437 | $nd = $c / sqrt(1 + $etasq); |
|
| 438 | ||
| 439 | // Meridianbogenlänge g aus gegebener geographischer Breite bp |
|
| 440 | $g = $e0 * $bp + $e2 * sin(2 * $br) + $e4 * sin(4 * $br) + $e6 * sin(6 * $br); |
|
| 441 | ||
| 442 | // Längendifferenz dl zum Bezugsmeridian lh |
|
| 443 | $kz = round($lp / 3); |
|
| 444 | $lh = $kz * 3; |
|
| 445 | $dl = ($lp - $lh) * pi() / 180; |
|
| 446 | $dl2 = $dl * $dl; |
|
| 447 | $dl4 = $dl2 * $dl2; |
|
| 448 | $dl3 = $dl2 * $dl; |
|
| 449 | $dl5 = $dl4 * $dl; |
|
| 450 | ||
| 451 | // Hochwert hw und Rechtswert rw als Funktion von geographischer Breite und Länge |
|
| 452 | $hw = ($g + $nd * $cos2 * $tan1 * $dl2 / 2 + $nd * $cos4 * $tan1 * (5 - $tan2 + 9 * $etasq) |
|
| 453 | * $dl4 / 24); |
|
| 454 | $rw = ($nd * $cos1 * $dl + $nd * $cos3 * (1 - $tan2 + $etasq) * $dl3 / 6 + |
|
| 455 | $nd * $cos5 * (5 - 18 * $tan2 + $tan4) * $dl5 / 120 + $kz * 1e6 + 500000); |
|
| 456 | ||
| 457 | $nk = $hw - (int) $hw; |
|
| 458 | if ($nk < 0.5) { |
|
| 459 | $hw = (int) $hw; |
|
| 460 | } else { |
|
| 461 | $hw = ((int) $hw) + 1; |
|
| 462 | } |
|
| 463 | ||
| 464 | $nk = $rw - (int) $rw; |
|
| 465 | if ($nk < 0.5) { |
|
| 466 | $rw = (int) $rw; |
|
| 467 | } else { |
|
| 468 | $rw = (int) ($rw + 1); |
|
| 469 | } |
|
| 470 | ||
| 471 | return [ |
|
| 472 | $rw, |
|
| 473 | $hw, |
|
| 474 | ]; |
|
| 475 | } |
|
| 476 | ||
| 477 | // return string |
|
| 478 | public function getRD() |
|
| @@ 441-541 (lines=101) @@ | ||
| 438 | * |
|
| 439 | * @return int[] |
|
| 440 | */ |
|
| 441 | public function geo2gk($bp, $lp) |
|
| 442 | { |
|
| 443 | /* Copyright (c) 2006, HELMUT H. HEIMEIER |
|
| 444 | Permission is hereby granted, free of charge, to any person obtaining a |
|
| 445 | copy of this software and associated documentation files (the "Software"), |
|
| 446 | to deal in the Software without restriction, including without limitation |
|
| 447 | the rights to use, copy, modify, merge, publish, distribute, sublicense, |
|
| 448 | and/or sell copies of the Software, and to permit persons to whom the |
|
| 449 | Software is furnished to do so, subject to the following conditions: |
|
| 450 | The above copyright notice and this permission notice shall be included |
|
| 451 | in all copies or substantial portions of the Software.*/ |
|
| 452 | ||
| 453 | /* Die Funktion wandelt geographische Koordinaten in GK Koordinaten |
|
| 454 | um. Geographische Länge lp und Breite bp müssen im Potsdam Datum |
|
| 455 | gegeben sein. Berechnet werden Rechtswert rw und Hochwert hw.*/ |
|
| 456 | ||
| 457 | //Geographische Länge lp und Breite bp im Potsdam Datum |
|
| 458 | if ($lp == '' || $bp == '') { |
|
| 459 | return [ |
|
| 460 | 0, |
|
| 461 | 0, |
|
| 462 | ]; |
|
| 463 | } |
|
| 464 | $lp = (float) $lp; |
|
| 465 | $bp = (float) $bp; |
|
| 466 | ||
| 467 | // Potsdam Datum |
|
| 468 | // Große Halbachse a und Abplattung f |
|
| 469 | $a = 6377397.155; // + $falseeasting; |
|
| 470 | $f = 3.34277321e-3; |
|
| 471 | ||
| 472 | // Polkrümmungshalbmesser c |
|
| 473 | $c = $a / (1 - $f); |
|
| 474 | ||
| 475 | // Quadrat der zweiten numerischen Exzentrizität |
|
| 476 | $ex2 = (2 * $f - $f * $f) / ((1 - $f) * (1 - $f)); |
|
| 477 | $ex4 = $ex2 * $ex2; |
|
| 478 | $ex6 = $ex4 * $ex2; |
|
| 479 | $ex8 = $ex4 * $ex4; |
|
| 480 | ||
| 481 | // Koeffizienten zur Berechnung der Meridianbogenlänge |
|
| 482 | $e0 = $c * (pi() / 180) * (1 - 3 * $ex2 / 4 + 45 * $ex4 / 64 - 175 * $ex6 / 256 + 11025 * $ex8 / 16384); |
|
| 483 | $e2 = $c * (- 3 * $ex2 / 8 + 15 * $ex4 / 32 - 525 * $ex6 / 1024 + 2205 * $ex8 / 4096); |
|
| 484 | $e4 = $c * (15 * $ex4 / 256 - 105 * $ex6 / 1024 + 2205 * $ex8 / 16384); |
|
| 485 | $e6 = $c * (- 35 * $ex6 / 3072 + 315 * $ex8 / 12288); |
|
| 486 | ||
| 487 | // Breite in Radianten |
|
| 488 | $br = $bp * pi() / 180; |
|
| 489 | ||
| 490 | $tan1 = tan($br); |
|
| 491 | $tan2 = $tan1 * $tan1; |
|
| 492 | $tan4 = $tan2 * $tan2; |
|
| 493 | ||
| 494 | $cos1 = cos($br); |
|
| 495 | $cos2 = $cos1 * $cos1; |
|
| 496 | $cos4 = $cos2 * $cos2; |
|
| 497 | $cos3 = $cos2 * $cos1; |
|
| 498 | $cos5 = $cos4 * $cos1; |
|
| 499 | ||
| 500 | $etasq = $ex2 * $cos2; |
|
| 501 | ||
| 502 | // Querkrümmungshalbmesser nd |
|
| 503 | $nd = $c / sqrt(1 + $etasq); |
|
| 504 | ||
| 505 | // Meridianbogenlänge g aus gegebener geographischer Breite bp |
|
| 506 | $g = $e0 * $bp + $e2 * sin(2 * $br) + $e4 * sin(4 * $br) + $e6 * sin(6 * $br); |
|
| 507 | ||
| 508 | // Längendifferenz dl zum Bezugsmeridian lh |
|
| 509 | $kz = round($lp / 3); |
|
| 510 | $lh = $kz * 3; |
|
| 511 | $dl = ($lp - $lh) * pi() / 180; |
|
| 512 | $dl2 = $dl * $dl; |
|
| 513 | $dl4 = $dl2 * $dl2; |
|
| 514 | $dl3 = $dl2 * $dl; |
|
| 515 | $dl5 = $dl4 * $dl; |
|
| 516 | ||
| 517 | // Hochwert hw und Rechtswert rw als Funktion von geographischer Breite und Länge |
|
| 518 | $hw = ($g + $nd * $cos2 * $tan1 * $dl2 / 2 + $nd * $cos4 * $tan1 * (5 - $tan2 + 9 * $etasq) |
|
| 519 | * $dl4 / 24); |
|
| 520 | $rw = ($nd * $cos1 * $dl + $nd * $cos3 * (1 - $tan2 + $etasq) * $dl3 / 6 + |
|
| 521 | $nd * $cos5 * (5 - 18 * $tan2 + $tan4) * $dl5 / 120 + $kz * 1e6 + 500000); |
|
| 522 | ||
| 523 | $nk = $hw - (int) $hw; |
|
| 524 | if ($nk < 0.5) { |
|
| 525 | $hw = (int) $hw; |
|
| 526 | } else { |
|
| 527 | $hw = ((int) $hw) + 1; |
|
| 528 | } |
|
| 529 | ||
| 530 | $nk = $rw - (int) $rw; |
|
| 531 | if ($nk < 0.5) { |
|
| 532 | $rw = (int) $rw; |
|
| 533 | } else { |
|
| 534 | $rw = (int) ($rw + 1); |
|
| 535 | } |
|
| 536 | ||
| 537 | return [ |
|
| 538 | $rw, |
|
| 539 | $hw, |
|
| 540 | ]; |
|
| 541 | } |
|
| 542 | ||
| 543 | /** |
|
| 544 | * RD Dutch Grid |
|