mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-26 00:02:08 -05:00
167 lines
4.4 KiB
C++
167 lines
4.4 KiB
C++
|
/***************************************************************************
|
||
|
qgsbabelformat.cpp - import/export formats for GPSBabel
|
||
|
Functions:
|
||
|
|
||
|
-------------------
|
||
|
begin : Oct 20, 2004
|
||
|
copyright : (C) 2004 by Lars Luthman
|
||
|
email : larsl@users.sourceforge.net
|
||
|
|
||
|
***************************************************************************/
|
||
|
|
||
|
/***************************************************************************
|
||
|
* *
|
||
|
* This program is free software; you can redistribute it and/or modify *
|
||
|
* it under the terms of the GNU General Public License as published by *
|
||
|
* the Free Software Foundation; either version 2 of the License, or *
|
||
|
* (at your option) any later version. *
|
||
|
* *
|
||
|
***************************************************************************/
|
||
|
/* $Id$ */
|
||
|
|
||
|
#include "qgsbabelformat.h"
|
||
|
|
||
|
#include <qregexp.h>
|
||
|
#include <qstring.h>
|
||
|
|
||
|
|
||
|
QgsBabelFormat::QgsBabelFormat()
|
||
|
: mSupportsImport(false), mSupportsExport(false), mSupportsWaypoints(false),
|
||
|
mSupportsRoutes(false), mSupportsTracks(false) {
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
const QString& QgsBabelFormat::getName() const {
|
||
|
static QString name = "";
|
||
|
return name;
|
||
|
}
|
||
|
|
||
|
|
||
|
QStringList QgsBabelFormat::getImportCommand(const QString& babel,
|
||
|
const QString& featuretype,
|
||
|
const QString& input,
|
||
|
const QString& output) const {
|
||
|
QStringList empty;
|
||
|
return empty;
|
||
|
}
|
||
|
|
||
|
|
||
|
QStringList QgsBabelFormat::getExportCommand(const QString& babel,
|
||
|
const QString& featuretype,
|
||
|
const QString& input,
|
||
|
const QString& output) const {
|
||
|
QStringList empty;
|
||
|
return empty;
|
||
|
}
|
||
|
|
||
|
|
||
|
bool QgsBabelFormat::supportsImport() const {
|
||
|
return mSupportsImport;
|
||
|
}
|
||
|
|
||
|
|
||
|
bool QgsBabelFormat::supportsExport() const {
|
||
|
return mSupportsExport;
|
||
|
}
|
||
|
|
||
|
|
||
|
bool QgsBabelFormat::supportsWaypoints() const {
|
||
|
return mSupportsWaypoints;
|
||
|
}
|
||
|
|
||
|
|
||
|
bool QgsBabelFormat::supportsRoutes() const {
|
||
|
return mSupportsRoutes;
|
||
|
}
|
||
|
|
||
|
|
||
|
bool QgsBabelFormat::supportsTracks() const {
|
||
|
return mSupportsTracks;
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
QgsSimpleBabelFormat::QgsSimpleBabelFormat(const QString& format,
|
||
|
bool hasWaypoints, bool hasRoutes,
|
||
|
bool hasTracks) : mFormat(format) {
|
||
|
mSupportsWaypoints = hasWaypoints;
|
||
|
mSupportsRoutes = hasRoutes;
|
||
|
mSupportsTracks = hasTracks;
|
||
|
mSupportsImport = true;
|
||
|
mSupportsExport = false;
|
||
|
}
|
||
|
|
||
|
|
||
|
QStringList QgsSimpleBabelFormat::getImportCommand(const QString& babel,
|
||
|
const QString& featuretype,
|
||
|
const QString& input,
|
||
|
const QString& output)const{
|
||
|
QStringList args;
|
||
|
args<<babel<<featuretype<<"-i"<<mFormat<<"-o"<<"gpx"<<input<<output;
|
||
|
return args;
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
QgsBabelCommand::QgsBabelCommand(const QString& importCmd,
|
||
|
const QString& exportCmd) {
|
||
|
mSupportsWaypoints = true;
|
||
|
mSupportsRoutes = true;
|
||
|
mSupportsTracks = true;
|
||
|
mSupportsImport = false;
|
||
|
mSupportsExport = false;
|
||
|
if (!importCmd.isEmpty()) {
|
||
|
mImportCmd = QStringList::split(QRegExp("\\s"), importCmd);
|
||
|
mSupportsImport = true;
|
||
|
}
|
||
|
if (!exportCmd.isEmpty()) {
|
||
|
mExportCmd = QStringList::split(QRegExp("\\s"), exportCmd);
|
||
|
mSupportsExport = true;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
QStringList QgsBabelCommand::getImportCommand(const QString& babel,
|
||
|
const QString& featuretype,
|
||
|
const QString& input,
|
||
|
const QString& output) const {
|
||
|
QStringList copy;
|
||
|
QStringList::const_iterator iter;
|
||
|
for (iter = mImportCmd.begin(); iter != mImportCmd.end(); ++iter) {
|
||
|
if (*iter == "%babel")
|
||
|
copy.append(babel);
|
||
|
else if (*iter == "%type")
|
||
|
copy.append(featuretype);
|
||
|
else if (*iter == "%in")
|
||
|
copy.append(input);
|
||
|
else if (*iter == "%out")
|
||
|
copy.append(output);
|
||
|
else
|
||
|
copy.append(*iter);
|
||
|
}
|
||
|
return copy;
|
||
|
}
|
||
|
|
||
|
|
||
|
QStringList QgsBabelCommand::getExportCommand(const QString& babel,
|
||
|
const QString& featuretype,
|
||
|
const QString& input,
|
||
|
const QString& output) const {
|
||
|
QStringList copy;
|
||
|
QStringList::const_iterator iter;
|
||
|
for (iter = mExportCmd.begin(); iter != mExportCmd.end(); ++iter) {
|
||
|
if (*iter == "%babel")
|
||
|
copy.append(babel);
|
||
|
else if (*iter == "%type")
|
||
|
copy.append(featuretype);
|
||
|
else if (*iter == "%in")
|
||
|
copy.append(input);
|
||
|
else if (*iter == "%out")
|
||
|
copy.append(output);
|
||
|
else
|
||
|
copy.append(*iter);
|
||
|
}
|
||
|
return copy;
|
||
|
}
|