QGpCoreTools/GoogleEarthKML.h
Go to the documentation of this file.
00001 /***************************************************************************
00002 **
00003 **  This file is part of QGpCoreTools.
00004 **
00005 **  This library is free software; you can redistribute it and/or
00006 **  modify it under the terms of the GNU Lesser General Public
00007 **  License as published by the Free Software Foundation; either
00008 **  version 2.1 of the License, or (at your option) any later version.
00009 **
00010 **  This file is distributed in the hope that it will be useful, but WITHOUT
00011 **  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 **  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
00013 **  License for more details.
00014 **
00015 **  You should have received a copy of the GNU Lesser General Public
00016 **  License along with this library; if not, write to the Free Software
00017 **  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00018 **
00019 **  See http://www.geopsy.org for more information.
00020 **
00021 **  Created: 2011-03-02
00022 **  Authors:
00023 **    Marc Wathelet (ISTerre, Grenoble, France)
00024 **
00025 ***************************************************************************/
00026 
00027 #ifndef GOOGLEEARTHKML_H
00028 #define GOOGLEEARTHKML_H
00029 
00030 #include "TreeContainer.h"
00031 #include "NamedPoint.h"
00032 #include "QGpCoreToolsDLLExport.h"
00033 
00034 namespace QGpCoreTools {
00035 
00036   class QGPCORETOOLS_EXPORT GoogleEarthKML : public XMLClass
00037   {
00038   public:
00039     class QGPCORETOOLS_EXPORT Point: public XMLClass
00040     {
00041     public:
00042       Point();
00043 
00044       virtual const QString& xml_tagName() const {return xmlPointTag;}
00045       static const QString xmlPointTag;
00046 
00047       const ::QGpCoreTools::Point& coordinates() const {return _coordinates;}
00048       void setCoodinates(const ::QGpCoreTools::Point& p) {_coordinates=p;}
00049     protected:
00050       virtual void xml_writeProperties(XML_WRITEPROPERTIES_ARGS) const;
00051       virtual XMLMember xml_member(XML_MEMBER_ARGS);
00052       virtual bool xml_setProperty(XML_SETPROPERTY_ARGS);
00053     private:
00054       ::QGpCoreTools::Point _coordinates;
00055     };
00056 
00057     class QGPCORETOOLS_EXPORT Placemark: public XMLClass
00058     {
00059     public:
00060       Placemark();
00061 
00062       virtual const QString& xml_tagName() const {return xmlPlacemarkTag;}
00063       static const QString xmlPlacemarkTag;
00064 
00065       void setName(const QString& n) {_name=n;}
00066       const QString& name() const {return _name;}
00067 
00068       const ::QGpCoreTools::Point& coordinates() const {return _point.coordinates();}
00069       void setCoordinates(const ::QGpCoreTools::Point& p) {_point.setCoodinates(p);}
00070     protected:
00071       virtual void xml_writeProperties(XML_WRITEPROPERTIES_ARGS) const;
00072       virtual void xml_writeChildren(XML_WRITECHILDREN_ARGS) const;
00073       virtual XMLMember xml_member(XML_MEMBER_ARGS);
00074       virtual bool xml_setProperty(XML_SETPROPERTY_ARGS);
00075     private:
00076       QString _name;
00077       Point _point;
00078     };
00079 
00080     class QGPCORETOOLS_EXPORT Folder: public TreeContainer
00081     {
00082     public:
00083       Folder(Folder * parent=0): TreeContainer(parent) {}
00084       ~Folder();
00085 
00086       virtual const QString& xml_tagName() const {return xmlFolderTag;}
00087       static const QString xmlFolderTag;
00088 
00089       void setName(const QString& n) {_name=n;}
00090       const QString& name() const {return _name;}
00091 
00092       void addPlacemark(Placemark * p) {_placemarks.append(p);}
00093       void clearPlacemarks();
00094 
00095       void collectPoints(QList<NamedPoint>& list) const;
00096     protected:
00097       virtual void xml_writeProperties(XML_WRITEPROPERTIES_ARGS) const;
00098       virtual void xml_writeChildren(XML_WRITECHILDREN_ARGS) const;
00099       virtual XMLMember xml_member(XML_MEMBER_ARGS);
00100       virtual bool xml_setProperty(XML_SETPROPERTY_ARGS);
00101     private:
00102       QString _name;
00103       QList<Placemark *> _placemarks;
00104     };
00105 
00106     class QGPCORETOOLS_EXPORT Document: public XMLClass
00107     {
00108     public:
00109       Document();
00110 
00111       virtual const QString& xml_tagName() const {return xmlDocumentTag;}
00112       static const QString xmlDocumentTag;
00113 
00114       void setName(const QString& n) {_name=n;}
00115       const QString& name() const {return _name;}
00116 
00117       QList<NamedPoint> points() const;
00118 
00119       const Folder * mainFolder() const {return &_root;}
00120       Folder * mainFolder() {return &_root;}
00121     protected:
00122       virtual void xml_writeProperties(XML_WRITEPROPERTIES_ARGS) const;
00123       virtual void xml_writeChildren(XML_WRITECHILDREN_ARGS) const;
00124       virtual XMLMember xml_member(XML_MEMBER_ARGS);
00125       virtual bool xml_setProperty(XML_SETPROPERTY_ARGS);
00126     private:
00127       QString _name;
00128       Folder _root;
00129     };
00130 
00131   public:
00132     GoogleEarthKML();
00133 
00134     virtual const QString& xml_tagName() const {return xmlGoogleEarthKMLTag;}
00135     static const QString xmlGoogleEarthKMLTag;
00136 
00137     bool save(const QString& fileName);
00138 
00139     Document& document() {return _document;}
00140     const Document& document() const {return _document;}
00141 
00142     virtual void xml_attributes(XML_ATTRIBUTES_ARGS) const;
00143   protected:
00144     virtual void xml_writeChildren(XML_WRITECHILDREN_ARGS) const;
00145     virtual XMLMember xml_member(XML_MEMBER_ARGS);
00146   private:
00147     Document _document;
00148   };
00149 
00150 } // namespace QGpCoreTools
00151 
00152 #endif // GOOGLEEARTHKML_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines