You are here

public function GeoJSON::write in geoPHP 8

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

Serializes an object into a geojson string

Parameters

Geometry $obj The object to serialize:

Return value

string The GeoJSON string

Overrides GeoAdapter::write

File

geoPHP/lib/adapters/GeoJSON.class.php, line 120

Class

GeoJSON
GeoJSON class : a geojson reader/writer.

Code

public function write(Geometry $geometry, $return_array = FALSE) {
  if ($return_array) {
    return $this
      ->getArray($geometry);
  }
  else {
    return json_encode($this
      ->getArray($geometry));
  }
}