Add support for Google Earth (KML)

This patch adds an 'Export to KML' option to the ride
menu. It will create a .kml file including power, hr,
torque etc. These can be viewed alongside the map view
in Google Earth 5.2.

Please note this requires libkml. The features of libkml
that are required were introduced in revision 852 which
means that as of Aug 2010 you will need to checkout from
the SVN source repo and build;

svn checkout http://libkml.googlecode.com/svn/trunk/ libkml-read-only

and the ./configure mantra that worked successfully for
me on Mac OS X was;

./configure CC="gcc -arch i386" CXX="g++ -arch i386" --disable-swig

Building on WIN32 is currently fraught with issues, unless
you build via MSVC 2010. Linux is straight forward but you will
need to install / apt-get libcurl.

Fixes #133.
This commit is contained in:
Mark Liversedge
2010-08-26 10:47:49 +01:00
parent 48a25081ed
commit f6eb97ec0f
6 changed files with 391 additions and 0 deletions

View File

@@ -29,6 +29,9 @@
#include "ConfigDialog.h"
#include "CriticalPowerWindow.h"
#include "GcRideFile.h"
#ifdef GC_HAVE_KML
#include "KmlRideFile.h"
#endif
#include "PwxRideFile.h"
#include "LTMWindow.h"
#include "PfPvWindow.h"
@@ -374,6 +377,10 @@ MainWindow::MainWindow(const QDir &home) :
SLOT(exportCSV()), tr("Ctrl+E"));
rideMenu->addAction(tr("Export to GC..."), this,
SLOT(exportGC()));
#ifdef GC_HAVE_KML
rideMenu->addAction(tr("&Export to KML..."), this,
SLOT(exportKML()));
#endif
rideMenu->addAction(tr("Export to PWX..."), this,
SLOT(exportPWX()));
rideMenu->addSeparator ();
@@ -713,6 +720,28 @@ MainWindow::exportGC()
reader.writeRideFile(currentRide(), file);
}
#ifdef GC_HAVE_KML
void
MainWindow::exportKML()
{
if ((treeWidget->selectedItems().size() != 1)
|| (treeWidget->selectedItems().first()->type() != RIDE_TYPE)) {
QMessageBox::critical(this, tr("Select Ride"), tr("No ride selected!"));
return;
}
QString fileName = QFileDialog::getSaveFileName(
this, tr("Export KML"), QDir::homePath(), tr("Google Earth KML (*.kml)"));
if (fileName.length() == 0)
return;
QString err;
QFile file(fileName);
KmlFileReader reader;
reader.writeRideFile(currentRide(), file);
}
#endif
void
MainWindow::exportCSV()
{