QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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 }
qgsbabelformat.h
Qgis::GpsFeatureType::Waypoint
@ Waypoint
Waypoint.
QgsAbstractBabelFormat::capabilities
Qgis::BabelFormatCapabilities capabilities() const
Returns the format's capabilities.
Definition: qgsbabelformat.cpp:56
QgsAbstractBabelFormat::QgsAbstractBabelFormat
QgsAbstractBabelFormat(const QString &name=QString())
Constructor for QgsAbstractBabelFormat, with the specified name.
Definition: qgsbabelformat.cpp:22
QgsBabelSimpleImportFormat::importCommand
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.
Definition: qgsbabelformat.cpp:77
Qgis::BabelCommandFlag::QuoteFilePaths
@ QuoteFilePaths
File paths should be enclosed in quotations and escaped.
QgsAbstractBabelFormat::mCapabilities
Qgis::BabelFormatCapabilities mCapabilities
Definition: qgsbabelformat.h:98
Qgis::BabelFormatCapability::Export
@ Export
Format supports exporting.
QgsAbstractBabelFormat::mName
QString mName
Name of format.
Definition: qgsbabelformat.h:96
QgsAbstractBabelFormat::exportCommand
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.
Definition: qgsbabelformat.cpp:51
QgsAbstractBabelFormat::importCommand
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.
Definition: qgsbabelformat.cpp:46
Qgis::GpsFeatureType::Route
@ Route
Route.
Qgis::GpsFeatureType
GpsFeatureType
Babel command flags.
Definition: qgis.h:886
Qgis::BabelFormatCapability::Import
@ Import
Format supports importing.
QgsAbstractBabelFormat
Abstract base class for babel GPS formats.
Definition: qgsbabelformat.h:33
QgsAbstractBabelFormat::name
QString name() const
Returns the format's name.
Definition: qgsbabelformat.cpp:41
QgsBabelSimpleImportFormat::QgsBabelSimpleImportFormat
QgsBabelSimpleImportFormat(const QString &format, const QString &description, Qgis::BabelFormatCapabilities capabilities, const QStringList extensions=QStringList())
Constructor for QgsBabelSimpleImportFormat.
Definition: qgsbabelformat.cpp:66
Qgis::GpsFeatureType::Track
@ Track
Track.
QgsAbstractBabelFormat::featureTypeToArgument
static QString featureTypeToArgument(Qgis::GpsFeatureType type)
Converts a GPS feature type to the equivalent babel argument.
Definition: qgsbabelformat.cpp:27