Skip to content

Commit

Permalink
Add getSouthWest() and getNorthEast() methods to Bounds class to retu…
Browse files Browse the repository at this point in the history
…rn corresponding coordinates.

Signed-off-by: Sam Poyigi <6567634+sampoyigi@users.noreply.github.com>
  • Loading branch information
sampoyigi committed Feb 5, 2024
1 parent 2698e39 commit 097b354
Showing 1 changed file with 28 additions and 9 deletions.
37 changes: 28 additions & 9 deletions src/Geolite/Model/Bounds.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static function fromPolygon(Contracts\PolygonInterface $polygon)
}

/**
* @param float $north
* @param float $north
* @return $this
*/
public function setNorth($north)
Expand All @@ -71,7 +71,7 @@ public function setNorth($north)
}

/**
* @param float $east
* @param float $east
* @return $this
*/
public function setEast($east)
Expand All @@ -82,7 +82,7 @@ public function setEast($east)
}

/**
* @param float $south
* @param float $south
* @return $this
*/
public function setSouth($south)
Expand All @@ -93,7 +93,7 @@ public function setSouth($south)
}

/**
* @param float $west
* @param float $west
* @return $this
*/
public function setWest($west)
Expand Down Expand Up @@ -143,6 +143,26 @@ public function getEast(): float
return $this->east;
}

/**
* Returns the south west coordinates.
*
* @return Coordinates
*/
public function getSouthWest(): Coordinates
{
return new Coordinates($this->south, $this->west);
}

/**
* Returns the north east coordinates.
*
* @return Coordinates
*/
public function getNorthEast(): Coordinates
{
return new Coordinates($this->north, $this->east);
}

/**
* @return int
*/
Expand All @@ -152,7 +172,7 @@ public function getPrecision()
}

/**
* @param int $precision
* @param int $precision
* @return $this
*/
public function setPrecision($precision)
Expand All @@ -163,7 +183,7 @@ public function setPrecision($precision)
}

/**
* @param Contracts\CoordinatesInterface $coordinate
* @param Contracts\CoordinatesInterface $coordinate
* @return bool
*/
public function pointInBounds(Contracts\CoordinatesInterface $coordinate)
Expand Down Expand Up @@ -200,7 +220,7 @@ public function setPolygon(Contracts\PolygonInterface $polygon)
}

/**
* @param Contracts\BoundsInterface $bounds
* @param Contracts\BoundsInterface $bounds
* @return Contracts\BoundsInterface
*/
public function merge(Contracts\BoundsInterface $bounds)
Expand Down Expand Up @@ -243,8 +263,7 @@ protected function addCoordinate(Contracts\CoordinatesInterface $coordinate)
$this->setSouth($latitude);
$this->setEast($longitude);
$this->setWest($longitude);
}
else {
} else {
if (bccomp($latitude, $this->getSouth(), $this->getPrecision()) === -1)
$this->setSouth($latitude);

Expand Down

0 comments on commit 097b354

Please sign in to comment.