toGeoJSON(); } /** * @return string a geoJSON string representation of the object. */ public function toGeoJSON () { $numberOfGeometries = count($this->geometryArray); if ($numberOfGeometries > 0) { $str = ""; for ($i=0; $i < $numberOfGeometries; $i++) { if ($i > 0) { $str .= ","; } $str .= $this->geometryArray[$i]->toGeoJSON(); } return "{\"type\": \"GeometryCollection\", \"geometries\": [" . $str . "]}"; } $e = new mb_exception("KMLMultiGeometry: toGeoJSON: this geometryArray is empty."); return ""; } /** * Appends a new geometry to this multi geometry. * * @param object $aGeometry should be of type {@link KMLLine}, {@link KMLPoint}, * {@link KMLPolygon} or {@link KMLMultiGeometry}. * @return bool true, if appending the geometry succeeded; else false. */ public function append ($aGeometry) { if (KMLGeometry::isGeometry($aGeometry)) { array_push($this->geometryArray, $aGeometry); return true; } return false; } private $geometryArray = array(); } ?>