QGIS API Documentation  3.24.2-Tisler (13c1a02865)
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
6  email : [email protected]
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 
46 QStringList QgsAbstractBabelFormat::importCommand( const QString &, Qgis::GpsFeatureType, const QString &, const QString &, Qgis::BabelCommandFlags ) const
47 {
48  return QStringList();
49 }
50 
51 QStringList QgsAbstractBabelFormat::exportCommand( const QString &, Qgis::GpsFeatureType, const QString &, const QString &, Qgis::BabelCommandFlags ) const
52 {
53  return QStringList();
54 }
55 
56 Qgis::BabelFormatCapabilities QgsAbstractBabelFormat::capabilities() const
57 {
58  return mCapabilities;
59 }
60 
61 
62 //
63 // QgsSimpleBabelFormat
64 //
65 
66 QgsBabelSimpleImportFormat::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 
77 QStringList 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 }
@ QuoteFilePaths
File paths should be enclosed in quotations and escaped.
GpsFeatureType
Babel command flags.
Definition: qgis.h:666
@ 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.