PHP code example of geo-io / wkb-generator

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

    

geo-io / wkb-generator example snippets


class MyExtractor implements GeoIO\Extractor
{
    public function extractType($geometry)
    {
        if ($geometry instanceof MyPoint) {
            return self::TYPE_POINT;
        }

        // ...
    }

    public function extractCoordinatesFromPoint($point)
    {
        return array(
            'x' => $point->getX(),
            'y' => $point->getY(),
            'z' => null,
            'm' => null,
        );
    }

    // ...
}

$extractor = MyExtractor();
$generator = new GeoIO\WKB\Generator\Generator($extractor, array(
    'hex' => true
));

echo $generator->generate(new MyPoint(1, 2));
// Outputs:
// 0101000000000000000000f03f0000000000000040