vendor/geo-io/geometry/src/Point.php line 8

Open in your IDE?
  1. <?php
  2. namespace GeoIO\Geometry;
  3. use GeoIO\Dimension;
  4. use GeoIO\Geometry\Exception\MissingCoordinateException;
  5. class Point extends BaseGeometry
  6. {
  7.     private $coordinates;
  8.     public function __construct($dimensionCoordinates $coordinates null$srid null)
  9.     {
  10.         $this->dimension $dimension;
  11.         $this->srid $srid;
  12.         $this->coordinates $coordinates;
  13.         $this->assert();
  14.     }
  15.     public function isEmpty()
  16.     {
  17.         return null === $this->coordinates;
  18.     }
  19.     public function getX()
  20.     {
  21.         if (null === $this->coordinates) {
  22.             return null;
  23.         }
  24.         return $this->coordinates->getX();
  25.     }
  26.     public function getY()
  27.     {
  28.         if (null === $this->coordinates) {
  29.             return null;
  30.         }
  31.         return $this->coordinates->getY();
  32.     }
  33.     public function getZ()
  34.     {
  35.         if (null === $this->coordinates) {
  36.             return null;
  37.         }
  38.         return $this->coordinates->getZ();
  39.     }
  40.     public function getM()
  41.     {
  42.         if (null === $this->coordinates) {
  43.             return null;
  44.         }
  45.         return $this->coordinates->getM();
  46.     }
  47.     private function assert()
  48.     {
  49.         $dimension $this->getDimension();
  50.         $this->assertDimension($dimension);
  51.         if (null === $this->getZ() &&
  52.             (Dimension::DIMENSION_4D === $dimension ||
  53.              Dimension::DIMENSION_3DZ === $dimension)) {
  54.             throw MissingCoordinateException::create('Z'$dimension);
  55.         }
  56.         if (null === $this->getM() &&
  57.             (Dimension::DIMENSION_4D === $dimension ||
  58.              Dimension::DIMENSION_3DM === $dimension)) {
  59.             throw MissingCoordinateException::create('M'$dimension);
  60.         }
  61.     }
  62. }