protected function handleStartElement($name, $attribs) { switch ($name) { case 'DOCUMENT': $this->elementStack[] = new KMLDocument($name, $attribs); break; case 'FOLDER': $parent = end($this->elementStack); $folder = new KMLFolder($name, $attribs); $this->elementStack[] = $folder; // we need to do this before the element is completed // since this info needs to be available for nested children if ($parent instanceof KMLFolder) { $parentCategory = $parent->getId(); $newFolderIndex = count($parent->getChildCategories()); } else { $parentCategory = $this->dataController->getCategoryId(); $newFolderIndex = count($this->items); } $folder->setId(substr(md5($parentCategory . $newFolderIndex), 0, strlen($parentCategory) - 1)); // something unique break; case 'STYLE': $this->elementStack[] = new KMLStyle($name, $attribs); break; case 'STYLEMAP': $style = new KMLStyle($name, $attribs); $style->setStyleContainer($this); $this->elementStack[] = $style; break; case 'PLACEMARK': $placemark = new KMLPlacemark($name, $attribs); $parent = end($this->elementStack); $placemark->addCategoryId($this->dataController->getCategoryId()); if ($parent instanceof KMLFolder) { $placemark->addCategoryId($parent->getId()); } $this->elementStack[] = $placemark; break; case 'POINT': $this->elementStack[] = new KMLPoint($name, $attribs); break; case 'LINESTRING': $this->elementStack[] = new KMLLineString($name, $attribs); break; case 'LINEARRING': $this->elementStack[] = new KMLLinearRing($name, $attribs); break; case 'POLYGON': $this->elementStack[] = new KMLPolygon($name, $attribs); break; } }
protected function handleStartElement($name, $attribs) { switch ($name) { case 'DOCUMENT': $this->elementStack[] = new KMLDocument($name, $attribs); break; case 'FOLDER': $parent = end($this->elementStack); $folder = new KMLFolder($name, $attribs); $this->elementStack[] = $folder; if ($parent instanceof KMLFolder) { $parentCategory = $parent->getId(); $newFolderIndex = count($parent->categories()); $parent->addItem($folder); } else { $parentCategory = $this->getId(); $newFolderIndex = count($this->folders); //$newFolderIndex = $this->itemCount; $this->addFolder($folder); } $folder->setId(substr(md5($parentCategory . $newFolderIndex), 0, strlen($parentCategory) - 1)); // something unique break; case 'STYLE': $this->elementStack[] = new KMLStyle($name, $attribs); break; case 'STYLEMAP': $style = new KMLStyle($name, $attribs); $style->setStyleContainer($this); $this->elementStack[] = $style; break; case 'PLACEMARK': $placemark = new KMLPlacemark($name, $attribs); $parent = end($this->elementStack); $this->elementStack[] = $placemark; if ($parent instanceof KMLFolder) { $parent->addItem($placemark); } else { $this->addPlacemark($placemark); } break; case 'POINT': $this->elementStack[] = new KMLPoint($name, $attribs); break; case 'LINESTRING': $this->elementStack[] = new KMLLineString($name, $attribs); break; case 'LINEARRING': $this->elementStack[] = new KMLLinearRing($name, $attribs); break; case 'POLYGON': $this->elementStack[] = new KMLPolygon($name, $attribs); break; } }
protected function handleStartElement($name, $attribs) { switch ($name) { case 'DOCUMENT': $this->elementStack[] = new KMLDocument($name, $attribs); break; case 'FOLDER': $folder = new KMLFolder($name, $attribs); $parent = end($this->elementStack); // we need to do this before the element is completed // since this info needs to be available for nested children if ($parent instanceof KMLFolder) { $newFolderIndex = count($parent->getListItems()); $categoryPath = $parent->getCategory(); } elseif ($parent instanceof KMLDocument) { // child of root element $newFolderIndex = count($this->items); $categoryPath = $this->category; } $categoryPath[] = $newFolderIndex; $folder->setIndex($newFolderIndex); $folder->setCategory($categoryPath); $this->elementStack[] = $folder; break; case 'STYLE': $this->elementStack[] = new KMLStyle($name, $attribs); break; case 'STYLEMAP': $style = new KMLStyle($name, $attribs); $style->setStyleContainer($this); $this->elementStack[] = $style; break; case 'PLACEMARK': $placemark = new KMLPlacemark($name, $attribs); $parent = end($this->elementStack); if (!($parent instanceof KMLFolder)) { // child of root element $placemark->setCategory($this->category); } $this->elementStack[] = $placemark; break; case 'POINT': $this->elementStack[] = new KMLPoint($name, $attribs); break; case 'LINESTRING': $this->elementStack[] = new KMLLineString($name, $attribs); break; case 'LINEARRING': $this->elementStack[] = new KMLLinearRing($name, $attribs); break; case 'POLYGON': $this->elementStack[] = new KMLPolygon($name, $attribs); break; } }
protected function handleStartElement($name, $attribs) { switch ($name) { case 'DOCUMENT': $this->elementStack[] = new KMLDocument($name, $attribs); break; case 'FOLDER': $this->elementStack[] = new KMLFolder($name, $attribs); break; case 'STYLE': $this->elementStack[] = new KMLStyle($name, $attribs); break; case 'STYLEMAP': $style = new KMLStyle($name, $attribs); $style->setStyleContainer($this); $this->elementStack[] = $style; break; case 'PLACEMARK': $this->elementStack[] = new KMLPlacemark($name, $attribs); break; case 'POINT': $this->elementStack[] = new KMLPoint($name, $attribs); break; case 'LINESTRING': $this->elementStack[] = new KMLLineString($name, $attribs); break; case 'LINEARRING': $this->elementStack[] = new KMLLinearRing($name, $attribs); break; case 'POLYGON': $this->elementStack[] = new KMLPolygon($name, $attribs); break; //case 'ICONSTYLE': // $this->elementStack[] = new KMLIconStyle($name, $attribs); // break; } }