Code Duplication    Length = 83-83 lines in 2 locations

htdocs/lib2/logic/coordinate.class.php 1 location

@@ 291-373 (lines=83) @@
288
     * @param int $lw
289
     * @return array
290
     */
291
    public function wgs2pot($bw, $lw)
292
    {
293
        /* Copyright (c) 2006, HELMUT H. HEIMEIER
294
           Permission is hereby granted, free of charge, to any person obtaining a
295
           copy of this software and associated documentation files (the "Software"),
296
           to deal in the Software without restriction, including without limitation
297
           the rights to use, copy, modify, merge, publish, distribute, sublicense,
298
           and/or sell copies of the Software, and to permit persons to whom the
299
           Software is furnished to do so, subject to the following conditions:
300
           The above copyright notice and this permission notice shall be included
301
           in all copies or substantial portions of the Software.*/
302
303
        /* Die Funktion verschiebt das Kartenbezugssystem (map datum) vom
304
           WGS84 Datum (World Geodetic System 84) zum in Deutschland
305
           gebräuchlichen Potsdam-Datum. Geographische Länge lw und Breite
306
           bw gemessen in grad auf dem WGS84 Ellipsoid müssen
307
           gegeben sein. Ausgegeben werden geographische Länge lp
308
           und Breite bp (in grad) auf dem Bessel-Ellipsoid.
309
           Bei der Transformation werden die Ellipsoidachsen parallel
310
           verschoben um dx = -606 m, dy = -23 m und dz = -413 m.*/
311
312
        // Geographische Länge lw und Breite bw im WGS84 Datum
313
        if ($lw == '' || $bw == '') {
314
            return [
315
                0,
316
                0,
317
            ];
318
        }
319
        $lw = (float) $lw;
320
        $bw = (float) $bw;
321
322
        // Quellsystem WGS 84 Datum
323
        // Große Halbachse a und Abplattung fq
324
        $a = 6378137.000;
325
        $fq = 3.35281066e-3;
326
327
        // Zielsystem Potsdam Datum
328
        // Abplattung f
329
        $f = $fq - 1.003748e-5;
330
331
        // Parameter für datum shift
332
        $dx = - 606;
333
        $dy = - 23;
334
        $dz = - 413;
335
336
        // Quadrat der ersten numerischen Exzentrizität in Quell- und Zielsystem
337
        $e2q = (2 * $fq - $fq * $fq);
338
        $e2 = (2 * $f - $f * $f);
339
340
        // Breite und Länge in Radianten
341
        $b1 = $bw * (pi() / 180);
342
        $l1 = $lw * (pi() / 180);
343
344
        // Querkrümmungshalbmesser nd
345
        $nd = $a / sqrt(1 - $e2q * sin($b1) * sin($b1));
346
347
        // Kartesische Koordinaten des Quellsystems WGS84
348
        $xw = $nd * cos($b1) * cos($l1);
349
        $yw = $nd * cos($b1) * sin($l1);
350
        $zw = (1 - $e2q) * $nd * sin($b1);
351
352
        // Kartesische Koordinaten des Zielsystems (datum shift) Potsdam
353
        $x = $xw + $dx;
354
        $y = $yw + $dy;
355
        $z = $zw + $dz;
356
357
        // Berechnung von Breite und Länge im Zielsystem
358
        $rb = sqrt($x * $x + $y * $y);
359
        $b2 = (180 / pi()) * atan(($z / $rb) / (1 - $e2));
360
361
        if ($x > 0) {
362
            $l2 = (180 / pi()) * atan($y / $x);
363
        } elseif ($x < 0 && $y > 0) {
364
            $l2 = (180 / pi()) * atan($y / $x) + 180;
365
        } else {
366
            $l2 = (180 / pi()) * atan($y / $x) - 180;
367
        }
368
369
        return [
370
            $l2,
371
            $b2,
372
        ];
373
    }
374
375
    public function geo2gk($bp, $lp)
376
    {

htdocs_symfony/src/Repository/CoordinatesRepository.php 1 location

@@ 351-433 (lines=83) @@
348
     *
349
     * @return float[]|int[]
350
     */
351
    public function wgs2pot($bw, $lw)
352
    : array {
353
        /* Copyright (c) 2006, HELMUT H. HEIMEIER
354
           Permission is hereby granted, free of charge, to any person obtaining a
355
           copy of this software and associated documentation files (the "Software"),
356
           to deal in the Software without restriction, including without limitation
357
           the rights to use, copy, modify, merge, publish, distribute, sublicense,
358
           and/or sell copies of the Software, and to permit persons to whom the
359
           Software is furnished to do so, subject to the following conditions:
360
           The above copyright notice and this permission notice shall be included
361
           in all copies or substantial portions of the Software.*/
362
363
        /* Die Funktion verschiebt das Kartenbezugssystem (map datum) vom
364
           WGS84 Datum (World Geodetic System 84) zum in Deutschland
365
           gebräuchlichen Potsdam-Datum. Geographische Länge lw und Breite
366
           bw gemessen in grad auf dem WGS84 Ellipsoid müssen
367
           gegeben sein. Ausgegeben werden geographische Länge lp
368
           und Breite bp (in grad) auf dem Bessel-Ellipsoid.
369
           Bei der Transformation werden die Ellipsoidachsen parallel
370
           verschoben um dx = -606 m, dy = -23 m und dz = -413 m.*/
371
372
        // Geographische Länge lw und Breite bw im WGS84 Datum
373
        if ($lw == '' || $bw == '') {
374
            return [
375
                0,
376
                0,
377
            ];
378
        }
379
        $lw = (float) $lw;
380
        $bw = (float) $bw;
381
382
        // Quellsystem WGS 84 Datum
383
        // Große Halbachse a und Abplattung fq
384
        $a = 6378137.000;
385
        $fq = 3.35281066e-3;
386
387
        // Zielsystem Potsdam Datum
388
        // Abplattung f
389
        $f = $fq - 1.003748e-5;
390
391
        // Parameter für datum shift
392
        $dx = - 606;
393
        $dy = - 23;
394
        $dz = - 413;
395
396
        // Quadrat der ersten numerischen Exzentrizität in Quell- und Zielsystem
397
        $e2q = (2 * $fq - $fq * $fq);
398
        $e2 = (2 * $f - $f * $f);
399
400
        // Breite und Länge in Radianten
401
        $b1 = $bw * (pi() / 180);
402
        $l1 = $lw * (pi() / 180);
403
404
        // Querkrümmungshalbmesser nd
405
        $nd = $a / sqrt(1 - $e2q * sin($b1) * sin($b1));
406
407
        // Kartesische Koordinaten des Quellsystems WGS84
408
        $xw = $nd * cos($b1) * cos($l1);
409
        $yw = $nd * cos($b1) * sin($l1);
410
        $zw = (1 - $e2q) * $nd * sin($b1);
411
412
        // Kartesische Koordinaten des Zielsystems (datum shift) Potsdam
413
        $x = $xw + $dx;
414
        $y = $yw + $dy;
415
        $z = $zw + $dz;
416
417
        // Berechnung von Breite und Länge im Zielsystem
418
        $rb = sqrt($x * $x + $y * $y);
419
        $b2 = (180 / pi()) * atan(($z / $rb) / (1 - $e2));
420
421
        if ($x > 0) {
422
            $l2 = (180 / pi()) * atan($y / $x);
423
        } elseif ($x < 0 && $y > 0) {
424
            $l2 = (180 / pi()) * atan($y / $x) + 180;
425
        } else {
426
            $l2 = (180 / pi()) * atan($y / $x) - 180;
427
        }
428
429
        return [
430
            $l2,
431
            $b2,
432
        ];
433
    }
434
435
    /**
436
     * @param float $bp