Passed
Pull Request — main (#6)
by Frank
09:17
created

AbstractCylindricalEqualAreaProjection   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 5
eloc 6
c 1
b 0
f 1
dl 0
loc 29
ccs 0
cts 10
cp 0
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getMaxLatitude() 0 3 1
A getMaxY() 0 3 1
A getMaxX() 0 3 1
A getY() 0 3 1
A getX() 0 3 1
1
<?php
2
declare(strict_types=1);
3
4
namespace PrinsFrank\PhpGeoSVG\Projection;
5
6
use PrinsFrank\PhpGeoSVG\Geometry\Position\Position;
7
8
abstract class AbstractCylindricalEqualAreaProjection implements Projection
9
{
10
    abstract public function getStandardParallelDegree(): float;
11
12
    abstract public function getWidthToHeightAspectRatio(): float;
13
14
    public function getX(Position $position): float
15
    {
16
        return (deg2rad($position->longitude) - 0) * cos(deg2rad($this->getStandardParallelDegree()));
17
    }
18
19
    public function getY(Position $position): float
20
    {
21
        return sin($position->latitude) / cos($this->getStandardParallelDegree());
22
    }
23
24
    public function getMaxX(): float
25
    {
26
        return 360;
27
    }
28
29
    public function getMaxY(): float
30
    {
31
        return 700;
32
    }
33
34
    public function getMaxLatitude(): float
35
    {
36
        return 90;
37
    }
38
}
39