12 if (!$geometry instanceof
Point)
17 if (!isset($this->components[0]))
23 $outerRing = $this->components[0];
24 if (!$this->isPointInsideClosedRing($outerRing, $geometry))
29 $innerRings = array_slice($this->components, 1);
30 foreach ($innerRings as $innerRing)
32 if ($this->isPointInsideClosedRing($innerRing, $geometry))
48 private function isPointInsideClosedRing(
LineString $lineString,
Point $point):
bool
50 $polygonContainsPoint =
false;
59 foreach ($lineStringPoints as $lineStringPoint)
61 $lineStringLats[] = $lineStringPoint->getLat();
62 $lineStringLngs[] = $lineStringPoint->getLng();
65 for ($node = 0, $altNode = $componentsCount - 1; $node < $componentsCount; $altNode = $node++)
67 $condition = ($lineStringLngs[$node] > $point->
getLng()) !== ($lineStringLngs[$altNode] > $point->
getLng())
68 && ($point->
getLat() < ($lineStringLats[$altNode] - $lineStringLats[$node])
69 * ($point->
getLng() - $lineStringLngs[$node])
70 / ($lineStringLngs[$altNode] - $lineStringLngs[$node]) + $lineStringLats[$node]);
74 $polygonContainsPoint = !$polygonContainsPoint;
78 return $polygonContainsPoint;