You are here

public function GeoJSON::write in geoPHP 7

Same name and namespace in other branches
  1. 8 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 125

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));
  }
}