PHP code example of prezent / phpwktadapter

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

    

prezent / phpwktadapter example snippets


 

andesmedt\PHPWKTAdapter\WKTAdapter;

$adapter = new WKTAdapter();
$res = $adapter->read('SRID=31370;POINT(30 10)');
var_dump($res); 

 

andesmedt\PHPWKTAdapter\WKTAdapter;

$adapter = new WKTAdapter();

try {
    $res = $adapter->read('SRID=31370;POINT(bad format)');
} catch (UnexpectedValueException $e) {
    var_dump($e->getMessage());
}

array(
    // the geometry object type
    "type"      =>  string,
    // integer or float values for POINT - nested array (integer or float) for other geometry types
    "value"     =>  array,
    // integer representing the EWKT SRID, null when not present 
    "srid"      =>  integer | null,
    // string (Z, M or ZM) representing the dimension, null when not present 
    "dimension" =>  string | null
)