PHP code example of lyhty / geometry

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

    

lyhty / geometry example snippets


$p1 = new Point(0, 4);
$p2 = new Point(1, 5);
$p3 = new Point(2, 6);
$p4 = new Point(3, 7);

$ls1 = new LineString([$p1, $p2]);
$ls2 = new LineString([$p3, $p4]);
$mp = new MultiPoint([$p1, $p2, $p3, $p4]);

$g = new Polygon([$ls1, $ls2]);
$c = new GeometryCollection([$p1, $ls1, $mp, $p1]);

class Example extends Model
{
    use HasGeometryAttributes;

    protected array $geometryAttributes = [
        'home_yard_boundary'
    ];
}