Line data Source code
1 : /****************************************************************************** 2 : * 3 : * Project: KML Driver 4 : * Purpose: Class for building up the node structure of the kml file. 5 : * Author: Jens Oberender, j.obi@troja.net 6 : * 7 : ****************************************************************************** 8 : * Copyright (c) 2007, Jens Oberender 9 : * Copyright (c) 2009-2012, Even Rouault <even dot rouault at spatialys.com> 10 : * 11 : * SPDX-License-Identifier: MIT 12 : ****************************************************************************/ 13 : #ifndef OGR_KMLNODE_H_INCLUDED 14 : #define OGR_KMLNODE_H_INCLUDED 15 : 16 : #ifdef HAVE_EXPAT 17 : 18 : #include "kml.h" 19 : #include "kmlutility.h" 20 : // std 21 : #include <iostream> 22 : #include <limits> 23 : #include <string> 24 : #include <vector> 25 : 26 : std::string Nodetype2String(Nodetype const &type); 27 : 28 : class KMLNode 29 : { 30 : CPL_DISALLOW_COPY_ASSIGN(KMLNode) 31 : public: 32 : KMLNode(); 33 : ~KMLNode(); 34 : 35 : void print(unsigned int what = 3); 36 : int classify(KML *poKML, int nRecLevel = 0); 37 : void eliminateEmpty(KML *poKML); 38 : bool hasOnlyEmpty() const; 39 : 40 : void setType(Nodetype type); 41 : Nodetype getType() const; 42 : 43 : void setName(std::string const &name); 44 : const std::string &getName() const; 45 : 46 : void setLevel(std::size_t level); 47 : std::size_t getLevel() const; 48 : 49 : void addAttribute(Attribute *poAttr); 50 : 51 : void setParent(KMLNode *poNode); 52 : KMLNode *getParent() const; 53 : 54 : void addChildren(KMLNode *poNode); 55 : std::size_t countChildren() const; 56 : 57 : KMLNode *getChild(std::size_t index) const; 58 : 59 : void addContent(std::string const &text); 60 : void appendContent(std::string const &text); 61 : std::string getContent(std::size_t index) const; 62 : void deleteContent(std::size_t index); 63 : std::size_t numContent() const; 64 : 65 : void setLayerNumber(int nNum); 66 : int getLayerNumber() const; 67 : 68 : std::string getNameElement() const; 69 : std::string getDescriptionElement() const; 70 : 71 : std::size_t getNumFeatures(); 72 : Feature *getFeature(std::size_t nNum, int &nLastAsked, int &nLastCount); 73 : 74 : OGRGeometry *getGeometry(Nodetype eType = Unknown); 75 : 76 74 : bool is25D() const 77 : { 78 74 : return b25D_; 79 : } 80 : 81 : private: 82 : typedef std::vector<KMLNode *> kml_nodes_t; 83 : kml_nodes_t *pvpoChildren_ = nullptr; 84 : 85 : typedef std::vector<std::string> kml_content_t; 86 : kml_content_t *pvsContent_ = nullptr; 87 : 88 : typedef std::vector<Attribute *> kml_attributes_t; 89 : kml_attributes_t *pvoAttributes_ = nullptr; 90 : 91 : KMLNode *poParent_ = nullptr; 92 : std::size_t nLevel_ = 0; 93 : std::string sName_{}; 94 : 95 : Nodetype eType_ = Unknown; 96 : bool b25D_ = false; 97 : 98 : int nLayerNumber_ = -1; 99 : size_t nNumFeatures_ = std::numeric_limits<size_t>::max(); 100 : 101 : void unregisterLayerIfMatchingThisNode(KML *poKML); 102 : }; 103 : 104 : #endif // HAVE_EXPAT 105 : 106 : #endif /* KMLNODE_H_INCLUDED */