Esempio n. 1
0
 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;
     }
 }