1. Go to this page and download the library: Download willvincent/polyclip 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/ */
willvincent / polyclip example snippets
use Polyclip\Clipper;
use GeoJson\Geometry\Polygon;
$polygon1 = new Polygon([[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]]]);
$polygon2 = new Polygon([[[1, 1], [3, 1], [3, 3], [1, 3], [1, 1]]]);
$result = Clipper::union($polygon1, $polygon2);
echo json_encode($result); // Outputs the resulting GeoJSON Feature
use GeoJson\Feature\FeatureCollection;
use GeoJson\Feature\Feature;
$collection = new FeatureCollection([
new Feature($polygon1),
new Feature($polygon2),
]);
$result = Clipper::union($collection);