Skip to content
This repository was archived by the owner on Oct 1, 2024. It is now read-only.

Commit b29f5e2

Browse files
authored
Merge pull request #108 from njbarrett/bugfix/multipoint-one-point
🐛 fix issue with multipoints only containing one point
2 parents 0a10f6d + 2f74c7b commit b29f5e2

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/Geometries/MultiPoint.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,23 @@
22

33
class MultiPoint extends PointCollection implements GeometryInterface, \JsonSerializable
44
{
5+
/**
6+
* @param Point[] $points
7+
*/
8+
public function __construct(array $points)
9+
{
10+
if (count($points) < 1) {
11+
throw new InvalidArgumentException('$points must contain at least one entry');
12+
}
13+
$validated = array_filter($points, function ($value) {
14+
return $value instanceof Point;
15+
});
16+
if (count($points) !== count($validated)) {
17+
throw new InvalidArgumentException('$points must be an array of Points');
18+
}
19+
$this->points = $points;
20+
}
21+
522
public function is3d()
623
{
724
if(count($this->points) === 0) return false;

0 commit comments

Comments
 (0)