PHP code example of spinen / laravel-geometry

1. Go to this page and download the library: Download spinen/laravel-geometry 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/ */

    

spinen / laravel-geometry example snippets


// Area of Polygon
$points = [[1,1], [2,2], [3,2], [3,4]];

$geoJson = '{"type":"Polygon", "coordinates":[' . json_encode($points) . ']}';

$geo = new geoPHP();
$mapper = new Spinen\Geometry\Support\TypeMapper();
$geometry = new Spinen\Geometry\Geometry($geo, $mapper);

$collection = $geometry->parseGeoJson($geoJson); // see above for more parse options

$squareMeters = $collection->getSquareMeters();
$acres = $collection->getAcres();