for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* PHPCoord.
*
* @author Doug Wright
*/
declare(strict_types=1);
namespace PHPCoord;
use PHPCoord\CoordinateReferenceSystem\CoordinateReferenceSystem;
use PHPCoord\CoordinateReferenceSystem\Vertical;
use PHPCoord\UnitOfMeasure\Length\Length;
use PHPCoord\UnitOfMeasure\Length\Metre;
use PHPCoord\UnitOfMeasure\UnitOfMeasureFactory;
* Coordinate representing a vertical dimension.
class VerticalPoint extends Point
{
* Height.
* @var Length
protected $height;
* Coordinate reference system.
* @var CoordinateReferenceSystem
protected $crs;
* Constructor.
* @param Length $height refer to CRS for preferred unit of measure, but any length unit accepted
public function __construct(Length $height, Vertical $crs)
$this->height = UnitOfMeasureFactory::convertLength($height, $crs->getCoordinateSystem()->getAxes()[1]->getUnitOfMeasureId());
$this->crs = $crs;
}
public function getHeight(): Length
return $this->height;
public function getCRS(): CoordinateReferenceSystem
return $this->crs;
public function calculateDistance(Point $to): Length
/* @var self $to */
return new Metre(abs($this->height->asMetres()->getValue() - $to->height->asMetres()->getValue()));
public function __toString(): string
return "({$this->height})";