Line data Source code
1 : /****************************************************************************** 2 : * $Id$ 3 : * 4 : * Project: KML Driver 5 : * Purpose: Class for building up the node structure of the kml file. 6 : * Author: Jens Oberender, j.obi@troja.net 7 : * 8 : ****************************************************************************** 9 : * Copyright (c) 2007, Jens Oberender 10 : * Copyright (c) 2009-2012, Even Rouault <even dot rouault at spatialys.com> 11 : * 12 : * Permission is hereby granted, free of charge, to any person obtaining a 13 : * copy of this software and associated documentation files (the "Software"), 14 : * to deal in the Software without restriction, including without limitation 15 : * the rights to use, copy, modify, merge, publish, distribute, sublicense, 16 : * and/or sell copies of the Software, and to permit persons to whom the 17 : * Software is furnished to do so, subject to the following conditions: 18 : * 19 : * The above copyright notice and this permission notice shall be included 20 : * in all copies or substantial portions of the Software. 21 : * 22 : * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 23 : * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 : * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 25 : * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 : * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 27 : * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 28 : * DEALINGS IN THE SOFTWARE. 29 : ****************************************************************************/ 30 : #ifndef OGR_KMLNODE_H_INCLUDED 31 : #define OGR_KMLNODE_H_INCLUDED 32 : 33 : #ifdef HAVE_EXPAT 34 : 35 : #include "kml.h" 36 : #include "kmlutility.h" 37 : // std 38 : #include <iostream> 39 : #include <string> 40 : #include <vector> 41 : 42 : std::string Nodetype2String(Nodetype const &type); 43 : 44 : class KMLNode 45 : { 46 : CPL_DISALLOW_COPY_ASSIGN(KMLNode) 47 : public: 48 : KMLNode(); 49 : ~KMLNode(); 50 : 51 : void print(unsigned int what = 3); 52 : int classify(KML *poKML, int nRecLevel = 0); 53 : void eliminateEmpty(KML *poKML); 54 : bool hasOnlyEmpty() const; 55 : 56 : void setType(Nodetype type); 57 : Nodetype getType() const; 58 : 59 : void setName(std::string const &name); 60 : const std::string &getName() const; 61 : 62 : void setLevel(std::size_t level); 63 : std::size_t getLevel() const; 64 : 65 : void addAttribute(Attribute *poAttr); 66 : 67 : void setParent(KMLNode *poNode); 68 : KMLNode *getParent() const; 69 : 70 : void addChildren(KMLNode *poNode); 71 : std::size_t countChildren() const; 72 : 73 : KMLNode *getChild(std::size_t index) const; 74 : 75 : void addContent(std::string const &text); 76 : void appendContent(std::string const &text); 77 : std::string getContent(std::size_t index) const; 78 : void deleteContent(std::size_t index); 79 : std::size_t numContent() const; 80 : 81 : void setLayerNumber(int nNum); 82 : int getLayerNumber() const; 83 : 84 : std::string getNameElement() const; 85 : std::string getDescriptionElement() const; 86 : 87 : std::size_t getNumFeatures(); 88 : Feature *getFeature(std::size_t nNum, int &nLastAsked, int &nLastCount); 89 : 90 : OGRGeometry *getGeometry(Nodetype eType = Unknown); 91 : 92 74 : bool is25D() const 93 : { 94 74 : return b25D_; 95 : } 96 : 97 : private: 98 : typedef std::vector<KMLNode *> kml_nodes_t; 99 : kml_nodes_t *pvpoChildren_; 100 : 101 : typedef std::vector<std::string> kml_content_t; 102 : kml_content_t *pvsContent_; 103 : 104 : typedef std::vector<Attribute *> kml_attributes_t; 105 : kml_attributes_t *pvoAttributes_; 106 : 107 : KMLNode *poParent_; 108 : std::size_t nLevel_; 109 : std::string sName_; 110 : 111 : Nodetype eType_; 112 : bool b25D_; 113 : 114 : int nLayerNumber_; 115 : int nNumFeatures_; 116 : 117 : void unregisterLayerIfMatchingThisNode(KML *poKML); 118 : }; 119 : 120 : #endif // HAVE_EXPAT 121 : 122 : #endif /* KMLNODE_H_INCLUDED */