Skip to content

Commit

Permalink
Merge pull request #108 from njbarrett/bugfix/multipoint-one-point
Browse files Browse the repository at this point in the history
🐛 fix issue with multipoints only containing one point
  • Loading branch information
njbarrett committed Mar 21, 2019
2 parents 0a10f6d + 2f74c7b commit b29f5e2
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/Geometries/MultiPoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,23 @@

class MultiPoint extends PointCollection implements GeometryInterface, \JsonSerializable
{
/**
* @param Point[] $points
*/
public function __construct(array $points)
{
if (count($points) < 1) {
throw new InvalidArgumentException('$points must contain at least one entry');
}
$validated = array_filter($points, function ($value) {
return $value instanceof Point;
});
if (count($points) !== count($validated)) {
throw new InvalidArgumentException('$points must be an array of Points');
}
$this->points = $points;
}

public function is3d()
{
if(count($this->points) === 0) return false;
Expand Down

0 comments on commit b29f5e2

Please sign in to comment.