Skip to content

Instantly share code, notes, and snippets.

@RoyCabrera
RoyCabrera / point_in_polygon.php
Created October 23, 2019 15:15 — forked from Fil/point_in_polygon.php
point in polygon
<?php
/* is (lon, lat) inside the polygon $p?
* use ray casting algorithm (http://en.wikipedia.org/wiki/Point_in_polygon)
* ie. project a horizontal line from our point to each segment
* code adapted from http://stackoverflow.com/questions/14149099/raycasting-algorithm-with-gps-coordinates
*/
function inside_polygon($test_point, $points) {