You are here

public function EWKT::write in geoPHP 8

Same name and namespace in other branches
  1. 7 geoPHP/lib/adapters/EWKT.class.php \EWKT::write()

Serialize geometries into an EWKT string.

Parameters

Geometry $geometry:

Return value

string The Extended-WKT string representation of the input geometries

Overrides WKT::write

File

geoPHP/lib/adapters/EWKT.class.php, line 15

Class

EWKT
EWKT (Extended Well Known Text) Adapter

Code

public function write(Geometry $geometry) {
  $srid = $geometry
    ->SRID();
  $wkt = '';
  if ($srid) {
    $wkt = 'SRID=' . $srid . ';';
    $wkt .= $geometry
      ->out('wkt');
    return $wkt;
  }
  else {
    return $geometry
      ->out('wkt');
  }
}