-
-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathMultiPolygon.php
80 lines (71 loc) · 2.29 KB
/
MultiPolygon.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
declare(strict_types=1);
namespace Brick\Geo;
use Brick\Geo\Attribute\NoProxy;
use Brick\Geo\Projector\Projector;
use Override;
/**
* A MultiPolygon is a MultiSurface whose elements are Polygons.
*
* The assertions for MultiPolygons are as follows:
*
* a) The interiors of 2 Polygons that are elements of a MultiPolygon may not intersect;
* b) The boundaries of any 2 Polygons that are elements of a MultiPolygon may not "cross" and may touch at only
* a finite number of Points;
* c) A MultiPolygon is defined as topologically closed;
* d) A MultiPolygon may not have cut lines, spikes or punctures, a MultiPolygon is a regular closed Point set;
* e) The interior of a MultiPolygon with more than 1 Polygon is not connected; the number of connected
* components of the interior of a MultiPolygon is equal to the number of Polygons in the MultiPolygon.
*
* The boundary of a MultiPolygon is a set of closed Curves (LineStrings) corresponding to the boundaries of its
* element Polygons. Each Curve in the boundary of the MultiPolygon is in the boundary of exactly 1 element
* Polygon, and every Curve in the boundary of an element Polygon is in the boundary of the MultiPolygon.
*
* @extends MultiSurface<Polygon>
* @final
*/
class MultiPolygon extends MultiSurface
{
/**
* @return list<list<list<list<float>>>>
*/
#[Override]
public function toArray() : array
{
return array_map(
fn(Polygon $polygon) => $polygon->toArray(),
$this->geometries,
);
}
#[NoProxy, Override]
public function geometryType() : string
{
return 'MultiPolygon';
}
#[NoProxy, Override]
public function geometryTypeBinary() : int
{
return Geometry::MULTIPOLYGON;
}
#[Override]
public function dimension() : int
{
return 2;
}
#[Override]
protected function containedGeometryType() : string
{
return Polygon::class;
}
#[Override]
public function project(Projector $projector): MultiPolygon
{
return new MultiPolygon(
$projector->getTargetCoordinateSystem($this->coordinateSystem),
...array_map(
fn (Polygon $polygon) => $polygon->project($projector),
$this->geometries,
),
);
}
}