function test_Format_KML_write() { // make sure id, name, and description are preserved $kmlExpected = self::test_content; $options = array("folderName" => "OpenLayers export", "foldersDesc" => "Vector geometries from OpenLayers"); $format = new KML($options); $features = $format->read($kmlExpected); $kmlOut = $format->write($features); $kmlOut = preg_replace("/<\\?[^>]*\\?>/", '', $kmlOut); // Remove XML Prolog $this->assertTrue($kmlExpected == trim($kmlOut)); $this->assertEqual($kmlExpected, trim($kmlOut)); }
public function collectionToKML($geom) { $components = $geom->getComponents(); $str = '<' . $this->nss . 'MultiGeometry>'; foreach ($geom->getComponents() as $comp) { $sub_adapter = new KML(); $str .= $sub_adapter->write($comp); } return $str . '</' . $this->nss . 'MultiGeometry>'; }
<?php require_once 'lib/Format/KML.class.php'; $options = array("extractStyles" => true); $test = new KML($options); /** read **/ $test->read("KML_Samples.kml"); //Util::dump($test->features, "features"); /** write **/ $kml = $test->write($test->features); Util::dump($kml, "kml !");