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