Passed
Push — 4.x ( c37faa...bd875a )
by Doug
12:53
created

VerticalPoint::getHeight()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 * PHPCoord.
4
 *
5
 * @author Doug Wright
6
 */
7
declare(strict_types=1);
8
9
namespace PHPCoord;
10
11
use PHPCoord\CoordinateReferenceSystem\CoordinateReferenceSystem;
12
use PHPCoord\CoordinateReferenceSystem\Vertical;
13
use PHPCoord\UnitOfMeasure\Length\Length;
14
use PHPCoord\UnitOfMeasure\UnitOfMeasureFactory;
15
16
/**
17
 * Coordinate representing a vertical dimension.
18
 * @author Doug Wright
19
 */
20
class VerticalPoint extends Point
21
{
22
    /**
23
     * Height.
24
     * @var Length
25
     */
26
    protected $height;
27
28
    /**
29
     * Coordinate reference system.
30
     * @var CoordinateReferenceSystem
31
     */
32
    protected $crs;
33
34
    /**
35
     * Constructor.
36
     * @param Length $height refer to CRS for preferred unit of measure, but any length unit accepted
37
     */
38
    public function __construct(Length $height, Vertical $crs)
39
    {
40
        $this->height = UnitOfMeasureFactory::convertLength($height, $crs->getCoordinateSystem()->getAxes()[1]->getUnitOfMeasureId());
41
        $this->crs = $crs;
42
    }
43
44
    public function getHeight(): Length
45
    {
46
        return $this->height;
47
    }
48
49
    public function getCRS(): CoordinateReferenceSystem
50
    {
51
        return $this->crs;
52
    }
53
54
    public function __toString(): string
55
    {
56
        return "({$this->height})";
57
    }
58
}
59