<html>
 <body>
  <div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
   <table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 solid;">
    <tr>
     <td>
      This is an automatically generated e-mail. To reply, visit:
      <a href="http://git.reviewboard.kde.org/r/102538/">http://git.reviewboard.kde.org/r/102538/</a>
     </td>
    </tr>
   </table>
   <br />



 <p>Ship it!</p>



 <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Looks good!
Do you have a kde account, or should we commit for you?</pre>
 <br />







<p>- Thibaut</p>


<br />
<p>On September 6th, 2011, 12:59 p.m., Javier Becerra Elcinto wrote:</p>






<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" style="background-image: url('http://git.reviewboard.kde.org/media/rb/images/review_request_box_top_bg.png'); background-position: left top; background-repeat: repeat-x; border: 1px black solid;">
 <tr>
  <td>

<div>Review request for Marble.</div>
<div>By Javier Becerra Elcinto.</div>


<p style="color: grey;"><i>Updated Sept. 6, 2011, 12:59 p.m.</i></p>




<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
 <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">According to KML 2.2 specification all features (which includes Documents and Folders) can have ExtendedData, but KmlDocumentTagWriter.cpp and KmlFolderTagWriter.cpp did not handle it. 
The patch adds support for writing the ExtendedData of Documents and Folders to kml files using a GeoWriter object.</pre>
  </td>
 </tr>
</table>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
 <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Checked generation of kml file (mydocument.kml) with ExtendedData in <Document> and <Folder>. File "main.cpp" and generated "mydocument.kml" attached below.

/////////
Main.cpp
/////////

//Marble
#include "GeoDataDocument.h"
#include "GeoDataFolder.h"
#include "GeoDataPlacemark.h"
#include "GeoDataExtendedData.h"
#include "GeoDataData.h"
#include "GeoWriter.h"
#include "GeoDataStyle.h"
#include "GeoDataPoint.h"

//Qt
#include <QtGui/QApplication>
#include <QDebug>
#include <QTextCodec>
#include <QFile>
#include <QDir>



void writeKML(Marble::GeoDataDocument *doc)
{
    Marble::GeoWriter writer;
    writer.setDocumentType("http://earth.google.com/kml/2.2" );

    QFile file( doc->fileName());
    if ( !file.open( QIODevice::WriteOnly | QIODevice::Truncate ) )
    {
        qDebug() << "Can not open file" << file.fileName();

    }
    else
    {
        if ( !writer.write( &file, doc ) ) {
            qDebug() << "Can not write to " << file.fileName();
        }
        qDebug()<<QString("File %1 written OK").arg(file.fileName());
        file.close();
    }
}


int main(int argc, char** argv)
{
    QApplication app(argc,argv);


    QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
    QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));

    //Creating a GeoDataDocument from scratch:

    Marble::GeoDataDocument *mydoc=new Marble::GeoDataDocument();
    mydoc->setFileName("mydocument.kml"); //Will identify the document internally, must be unique
    mydoc->setName("My_GeoDataDocument"); //Name for visualisation in MarbleWidget

    //Extended data for the document
    Marble::GeoDataExtendedData *ed_d=new Marble::GeoDataExtendedData;
    Marble::GeoDataData *dd_d=new Marble::GeoDataData;
    QString v_d("Value (GeoDataDocument)");
    dd_d->setDisplayName("Display name (GeoDataDocument)");
    dd_d->setName("Name (GeoDataDocument)");
    dd_d->setValue(v_d);

    ed_d->addValue(*dd_d);
    mydoc->setExtendedData(*ed_d);

    Marble::GeoDataFolder *myfolder=new Marble::GeoDataFolder;
    myfolder->setName("My first folder"); //(setName from base class GeoDataFeature, inherited from GeoDataContainer)

    Marble::GeoDataPlacemark *myplacemark=new Marble::GeoDataPlacemark;
    myplacemark->setName("A placemark in a folder");
    myplacemark->setCoordinate( -2.45, 42.465278,0,Marble::GeoDataPoint::Degree);


    //We create three GeoDataExtendedData, one attached to the Placemark, one to the Folder and
    //one to the document

    Marble::GeoDataExtendedData *ed_p=new Marble::GeoDataExtendedData;
    Marble::GeoDataData *dd_p=new Marble::GeoDataData;
    QString v_p("Value (GeoDataPlacemark)");
    dd_p->setDisplayName("Display name (GeoDataPlacemark)");
    dd_p->setName("Name (GeoDataPlacemark)");
    dd_p->setValue(v_p);
    ed_p->addValue(*dd_p);
    myplacemark->setExtendedData(*ed_p);

    myfolder->append(myplacemark);

    Marble::GeoDataExtendedData *ed_f=new Marble::GeoDataExtendedData;
    Marble::GeoDataData *dd_f=new Marble::GeoDataData;
    QString v_f("Value (GeoDataFolder)");
    dd_f->setDisplayName("Display name (GeoDataFolder)");
    dd_f->setName("Name (GeoDataFolder)");
    dd_f->setValue(v_f);
    ed_f->addValue(*dd_f);
    myfolder->setExtendedData(*ed_f);

    mydoc->append(myfolder);

    //Check that the GeoData* structures contain the extendeddata elements:
    qDebug()<<"ExtendedData in GeoDataDocument:"<<mydoc->extendedData().size();
    qDebug()<<"ExtendedData in GeoDataFolder:"<<myfolder->extendedData().size();
    qDebug()<<"ExtendedData in GeoDataPlacemark:"<<myplacemark->extendedData().size();

    ///Write the file to disk
    writeKML(mydoc);

    while(app.hasPendingEvents())
        app.processEvents();

    return 0;
}


/////////
Generated file mydocument.kml
/////////
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.2">
    <Document>
        <name>My_GeoDataDocument</name>
        <Folder>
            <name>My first folder</name>
            <ExtendedData>
                <Data name="Name (GeoDataFolder)" displayName="Display name (GeoDataFolder)">
                    <value>Value (GeoDataFolder)</value>
                </Data>
            </ExtendedData>
            <Placemark>
                <name>A placemark in a folder</name>
                <ExtendedData>
                    <Data name="Name (GeoDataPlacemark)" displayName="Display name (GeoDataPlacemark)">
                        <value>Value (GeoDataPlacemark)</value>
                    </Data>
                </ExtendedData>
                <Point>
                    <coordinates>-2.4500000000,42.4652780000</coordinates>
                </Point>
            </Placemark>
        </Folder>
        <ExtendedData>
            <Data name="Name (GeoDataDocument)" displayName="Display name (GeoDataDocument)">
                <value>Value (GeoDataDocument)</value>
            </Data>
        </ExtendedData>
    </Document>
</kml></pre>
  </td>
 </tr>
</table>




<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">

 <li>src/lib/geodata/writers/kml/KmlDocumentTagWriter.cpp <span style="color: grey">(aab4c3e)</span></li>

 <li>src/lib/geodata/writers/kml/KmlFolderTagWriter.cpp <span style="color: grey">(561a294)</span></li>

</ul>

<p><a href="http://git.reviewboard.kde.org/r/102538/diff/" style="margin-left: 3em;">View Diff</a></p>




  </td>
 </tr>
</table>








  </div>
 </body>
</html>