PHP code example of hannesvdvreken / pip

1. Go to this page and download the library: Download hannesvdvreken/pip library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

hannesvdvreken / pip example snippets


$coords = [
    [51.046945330263, 3.7388005491447],
    [50.884119340619, 4.7054353759129],
    [51.260385196697, 4.3696193284848],
];

$poly = new \Geometry\Polygon($coords);

$coords = $poly->getOutline();
$poly->setOutline($coords);

$centroid = $poly->centroid();
echo "the centroid of the polygon is ($centroid[0], $centroid[1]).\n";

if ($poly->isValid()) {
    echo "the polygon was succesfully created.\n";
}

if (!$poly->isClockwise()) {
    echo "the points define a counter-clockwise polygon.\n";
}

if ($poly->pip($x, $y)) {
    echo "the polygon