public function TimezonePolygon::isInside in Geo Time Zone 8.2
Same name and namespace in other branches
- 8.3 src/TimezonePolygon.php \Drupal\geotimezone\TimezonePolygon::isInside()
- 8 src/TimezonePolygon.php \Drupal\geotimezone\TimezonePolygon::isInside()
- 6.2 src/TimezonePolygon.php \Drupal\geotimezone\TimezonePolygon::isInside()
- 6 src/TimezonePolygon.php \Drupal\geotimezone\TimezonePolygon::isInside()
- 7.2 src/TimezonePolygon.php \Drupal\geotimezone\TimezonePolygon::isInside()
- 7 src/TimezonePolygon.php \Drupal\geotimezone\TimezonePolygon::isInside()
Determine if points are inside the polygon.
Parameters
float $y:
float $x:
Return value
bool
File
- src/
TimezonePolygon.php, line 36 - Contains \Drupal\geotimezone\TimezonePolygon.
Class
- TimezonePolygon
- Computes if given coordinates are inside the time zone polygon.
Namespace
Drupal\geotimezoneCode
public function isInside($y, $x) {
$numPoints = count($this->points);
$jY = $this->points[$numPoints - 2];
$jX = $this->points[$numPoints - 1];
$inside = FALSE;
for ($i = 0; $i < $numPoints;) {
$iY = $this->points[$i++];
$iX = $this->points[$i++];
if ($iY > $y != $jY > $y && $x < ($jX - $iX) * ($y - $iY) / ($jY - $iY) + $iX - 0.0001) {
$inside = !$inside;
}
$jX = $iX;
$jY = $iY;
}
return $inside;
}