PHP code example of worthwhileindustries / geojson-rewind

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

    

worthwhileindustries / geojson-rewind example snippets




ce = [
    'type' => 'Polygon',
    'coordinates' => [
    [ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ],
    [ [100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2] ]
    ]
];
$enforce_rfc7946=true;
$output = Vicchi\GeoJson\Rewind::rewind($source, $enforce_rfc7946);

// show output for demonstration purposes
var_dump($output);


$> php test.php
array(2) {
  ["type"]=>
  string(7) "Polygon"
  ["coordinates"]=>
  array(2) {
    [0]=>
    array(5) {
      [0]=>
      array(2) {
        [0]=>
        float(100)
        [1]=>
        float(0)
      }
      [1]=>
      array(2) {
        [0]=>
        float(101)
        [1]=>
        float(0)
      }
      [2]=>
      array(2) {
        [0]=>
        float(101)
        [1]=>
        float(1)
      }
      [3]=>
      array(2) {
        [0]=>
        float(100)
        [1]=>
        float(1)
      }
      [4]=>
      array(2) {
        [0]=>
        float(100)
        [1]=>
        float(0)
      }
    }
    [1]=>
    array(5) {
      [0]=>
      array(2) {
        [0]=>
        float(100.2)
        [1]=>
        float(0.2)
      }
      [1]=>
      array(2) {
        [0]=>
        float(100.2)
        [1]=>
        float(0.8)
      }
      [2]=>
      array(2) {
        [0]=>
        float(100.8)
        [1]=>
        float(0.8)
      }
      [3]=>
      array(2) {
        [0]=>
        float(100.8)
        [1]=>
        float(0.2)
      }
      [4]=>
      array(2) {
        [0]=>
        float(100.2)
        [1]=>
        float(0.2)
      }
    }
  }
}