QGIS API Documentation 3.38.0-Grenoble (exported)
Loading...
Searching...
No Matches
qgsbabelformat.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsbabelformat.cpp - import/export formats for GPSBabel
3 -------------------
4 begin : Oct 20, 2004
5 copyright : (C) 2004 by Lars Luthman
7
8***************************************************************************/
9
10/***************************************************************************
11 * *
12 * This program is free software; you can redistribute it and/or modify *
13 * it under the terms of the GNU General Public License as published by *
14 * the Free Software Foundation; either version 2 of the License, or *
15 * (at your option) any later version. *
16 * *
17 ***************************************************************************/
18
19#include "qgsbabelformat.h"
20#include <QString>
21
23 : mName( name )
24{
25}
26
28{
29 switch ( type )
30 {
32 return QStringLiteral( "-w" );
34 return QStringLiteral( "-r" );
36 return QStringLiteral( "-t" );
37 }
38 return QString();
39}
40
42{
43 return mName;
44}
45
46QStringList QgsAbstractBabelFormat::importCommand( const QString &, Qgis::GpsFeatureType, const QString &, const QString &, Qgis::BabelCommandFlags ) const
47{
48 return QStringList();
49}
50
51QStringList QgsAbstractBabelFormat::exportCommand( const QString &, Qgis::GpsFeatureType, const QString &, const QString &, Qgis::BabelCommandFlags ) const
52{
53 return QStringList();
54}
55
60
61
62//
63// QgsSimpleBabelFormat
64//
65
66QgsBabelSimpleImportFormat::QgsBabelSimpleImportFormat( const QString &format, const QString &description,
67 Qgis::BabelFormatCapabilities capabilities, const QStringList extensions )
68 : QgsAbstractBabelFormat( format )
69 , mDescription( description )
70 , mExtensions( extensions )
71{
74 mCapabilities &= ~( static_cast< int >( Qgis::BabelFormatCapability::Export ) );
75}
76
77QStringList QgsBabelSimpleImportFormat::importCommand( const QString &babel,
78 Qgis::GpsFeatureType featureType,
79 const QString &input,
80 const QString &output,
81 Qgis::BabelCommandFlags flags ) const
82{
83 return { ( flags & Qgis::BabelCommandFlag::QuoteFilePaths ) ? QStringLiteral( "\"%1\"" ).arg( babel ) : babel,
84 featureTypeToArgument( featureType ),
85 QStringLiteral( "-i" ),
86 name(),
87 QStringLiteral( "-o" ),
88 QStringLiteral( "gpx" ),
89 ( flags & Qgis::BabelCommandFlag::QuoteFilePaths ) ? QStringLiteral( "\"%1\"" ).arg( input ) : input,
90 ( flags & Qgis::BabelCommandFlag::QuoteFilePaths ) ? QStringLiteral( "\"%1\"" ).arg( output ) : output
91 };
92}
QFlags< BabelCommandFlag > BabelCommandFlags
Babel command flags.
Definition qgis.h:1684
QFlags< BabelFormatCapability > BabelFormatCapabilities
Babel GPS format capabilities.
Definition qgis.h:1669
@ QuoteFilePaths
File paths should be enclosed in quotations and escaped.
GpsFeatureType
GPS feature types.
Definition qgis.h:1694
@ Export
Format supports exporting.
@ Import
Format supports importing.
Abstract base class for babel GPS formats.
QString mName
Name of format.
QString name() const
Returns the format's name.
virtual QStringList exportCommand(const QString &babel, Qgis::GpsFeatureType featureType, const QString &input, const QString &output, Qgis::BabelCommandFlags flags=Qgis::BabelCommandFlags()) const
Generates a command for exporting GPS data into a different format using babel.
virtual QStringList importCommand(const QString &babel, Qgis::GpsFeatureType featureType, const QString &input, const QString &output, Qgis::BabelCommandFlags flags=Qgis::BabelCommandFlags()) const
Generates a command for importing data into a GPS format using babel.
Qgis::BabelFormatCapabilities mCapabilities
QgsAbstractBabelFormat(const QString &name=QString())
Constructor for QgsAbstractBabelFormat, with the specified name.
Qgis::BabelFormatCapabilities capabilities() const
Returns the format's capabilities.
static QString featureTypeToArgument(Qgis::GpsFeatureType type)
Converts a GPS feature type to the equivalent babel argument.
QgsBabelSimpleImportFormat(const QString &format, const QString &description, Qgis::BabelFormatCapabilities capabilities, const QStringList extensions=QStringList())
Constructor for QgsBabelSimpleImportFormat.
QStringList importCommand(const QString &babel, Qgis::GpsFeatureType featureType, const QString &input, const QString &output, Qgis::BabelCommandFlags flags=Qgis::BabelCommandFlags()) const override
Generates a command for importing data into a GPS format using babel.