You are here

public function GPX::write in geoPHP 7

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

Serialize geometries into a GPX string.

Parameters

Geometry $geometry:

Return value

string The GPX string representation of the input geometries

Overrides GeoAdapter::write

File

geoPHP/lib/adapters/GPX.class.php, line 36

Class

GPX
PHP Geometry/GPX encoder/decoder

Code

public function write(Geometry $geometry, $namespace = FALSE) {
  if ($geometry
    ->isEmpty()) {
    return NULL;
  }
  if ($namespace) {
    $this->namespace = $namespace;
    $this->nss = $namespace . ':';
  }
  return '<' . $this->nss . 'gpx creator="geoPHP" version="1.0">' . $this
    ->geometryToGPX($geometry) . '</' . $this->nss . 'gpx>';
}