Completed
Push — master ( 0885cd...ef8e35 )
by Antoine
02:22
created

MultiPolygon::pointInPolygon()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 6
cts 6
cp 1
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 5
nc 3
nop 1
crap 3
1
<?php
2
3
namespace League\Geotools\Polygon;
4
5
use League\Geotools\Coordinate\CoordinateInterface;
6
use League\Geotools\GeometryCollection;
7
8
class MultiPolygon extends GeometryCollection implements PolygonInterface
9
{
10
    const TYPE = 'MULTIPOLYGON';
11
12
    /**
13
     * @return string
14
     */
15 1
    public function getGeometryType()
16
    {
17 1
        return self::TYPE;
18
    }
19
20
    /**
21
     * @param  CoordinateInterface $coordinate
22
     * @return boolean
23
     */
24 2
    public function pointInPolygon(CoordinateInterface $coordinate)
25
    {
26
        /** @var PolygonInterface $polygon */
27 2
        foreach ($this->elements as $polygon) {
28 2
            if ($polygon->pointInPolygon($coordinate)) {
29 1
                return true;
30
            }
31 1
        }
32
33 1
        return false;
34
    }
35
36
    /**
37
     * @param  CoordinateInterface $coordinate
38
     * @return boolean
39
     */
40 2
    public function pointOnBoundary(CoordinateInterface $coordinate)
41
    {
42
        /** @var PolygonInterface $polygon */
43 2
        foreach ($this->elements as $polygon) {
44 2
            if ($polygon->pointOnBoundary($coordinate)) {
45 1
                return true;
46
            }
47 1
        }
48
49 1
        return false;
50
    }
51
52
    /**
53
     * @param  CoordinateInterface $coordinate
54
     * @return boolean
55
     */
56 2
    public function pointOnVertex(CoordinateInterface $coordinate)
57
    {
58
        /** @var PolygonInterface $polygon */
59 2
        foreach ($this->elements as $polygon) {
60 2
            if ($polygon->pointOnVertex($coordinate)) {
61 1
                return true;
62
            }
63 1
        }
64
65 1
        return false;
66
    }
67
}
68