19#if QT_CONFIG( process ) 
   35QString QgsConvertGpxFeatureTypeAlgorithm::name()
 const 
   37  return QStringLiteral( 
"convertgpxfeaturetype" );
 
   40QString QgsConvertGpxFeatureTypeAlgorithm::displayName()
 const 
   42  return QObject::tr( 
"Convert GPX feature type" );
 
   45QStringList QgsConvertGpxFeatureTypeAlgorithm::tags()
 const 
   47  return QObject::tr( 
"gps,tools,babel,tracks,waypoints,routes" ).split( 
',' );
 
   50QString QgsConvertGpxFeatureTypeAlgorithm::group()
 const 
   52  return QObject::tr( 
"GPS" );
 
   55QString QgsConvertGpxFeatureTypeAlgorithm::groupId()
 const 
   57  return QStringLiteral( 
"gps" );
 
   60void QgsConvertGpxFeatureTypeAlgorithm::initAlgorithm( 
const QVariantMap & )
 
   64  addParameter( 
new QgsProcessingParameterEnum( QStringLiteral( 
"CONVERSION" ), QObject::tr( 
"Conversion" ), { QObject::tr( 
"Waypoints from a Route" ), QObject::tr( 
"Waypoints from a Track" ), QObject::tr( 
"Route from Waypoints" ), QObject::tr( 
"Track from Waypoints" ) }, 
false, 0 ) );
 
   71QIcon QgsConvertGpxFeatureTypeAlgorithm::icon()
 const 
   76QString QgsConvertGpxFeatureTypeAlgorithm::svgIconPath()
 const 
   81QString QgsConvertGpxFeatureTypeAlgorithm::shortHelpString()
 const 
   83  return QObject::tr( 
"This algorithm uses the GPSBabel tool to convert GPX features from one type to another (e.g. converting all waypoint features to a route feature)." );
 
   86QString QgsConvertGpxFeatureTypeAlgorithm::shortDescription()
 const 
   88  return QObject::tr( 
"Converts GPX features from one type to another." );
 
   91QgsConvertGpxFeatureTypeAlgorithm *QgsConvertGpxFeatureTypeAlgorithm::createInstance()
 const 
   93  return new QgsConvertGpxFeatureTypeAlgorithm();
 
   99  const QString inputPath = parameterAsString( parameters, QStringLiteral( 
"INPUT" ), context );
 
  100  const QString outputPath = parameterAsString( parameters, QStringLiteral( 
"OUTPUT" ), context );
 
  102  const ConversionType convertType = 
static_cast<ConversionType
>( parameterAsEnum( parameters, QStringLiteral( 
"CONVERSION" ), context ) );
 
  105  if ( babelPath.isEmpty() )
 
  106    babelPath = QStringLiteral( 
"gpsbabel" );
 
  108  QStringList processArgs;
 
  110  createArgumentLists( inputPath, outputPath, convertType, processArgs, logArgs );
 
  111  feedback->
pushCommandInfo( QObject::tr( 
"Conversion command: " ) + babelPath + 
' ' + logArgs.join( 
' ' ) );
 
  113  QgsBlockingProcess babelProcess( babelPath, processArgs );
 
  114  babelProcess.setStdErrHandler( [feedback]( 
const QByteArray &ba ) {
 
  117  babelProcess.setStdOutHandler( [feedback]( 
const QByteArray &ba ) {
 
  121  const int res = babelProcess.run( feedback );
 
  124    feedback->
pushInfo( QObject::tr( 
"Process was canceled and did not complete" ) );
 
  126  else if ( !feedback->
isCanceled() && babelProcess.exitStatus() == QProcess::CrashExit )
 
  132    feedback->
pushInfo( QObject::tr( 
"Process completed successfully" ) );
 
  134  else if ( babelProcess.processError() == QProcess::FailedToStart )
 
  136    throw QgsProcessingException( QObject::tr( 
"Process %1 failed to start. Either %1 is missing, or you may have insufficient permissions to run the program." ).arg( babelPath ) );
 
  143  std::unique_ptr<QgsVectorLayer> layer;
 
  146  switch ( convertType )
 
  148    case QgsConvertGpxFeatureTypeAlgorithm::WaypointsFromRoute:
 
  149    case QgsConvertGpxFeatureTypeAlgorithm::WaypointsFromTrack:
 
  150      layer = std::make_unique<QgsVectorLayer>( outputPath + 
"?type=waypoint", layerName, QStringLiteral( 
"gpx" ) );
 
  152    case QgsConvertGpxFeatureTypeAlgorithm::RouteFromWaypoints:
 
  153      layer = std::make_unique<QgsVectorLayer>( outputPath + 
"?type=route", layerName, QStringLiteral( 
"gpx" ) );
 
  155    case QgsConvertGpxFeatureTypeAlgorithm::TrackFromWaypoints:
 
  156      layer = std::make_unique<QgsVectorLayer>( outputPath + 
"?type=track", layerName, QStringLiteral( 
"gpx" ) );
 
  161  if ( !layer->isValid() )
 
  163    feedback->
reportError( QObject::tr( 
"Resulting file is not a valid GPX layer" ) );
 
  167    const QString layerId = layer->id();
 
  168    outputs.insert( QStringLiteral( 
"OUTPUT_LAYER" ), layerId );
 
  174  outputs.insert( QStringLiteral( 
"OUTPUT" ), outputPath );
 
  178void QgsConvertGpxFeatureTypeAlgorithm::createArgumentLists( 
const QString &inputPath, 
const QString &outputPath, ConversionType conversion, QStringList &processArgs, QStringList &logArgs )
 
  180  logArgs.reserve( 10 );
 
  181  processArgs.reserve( 10 );
 
  182  for ( 
const QString &arg : { QStringLiteral( 
"-i" ), QStringLiteral( 
"gpx" ), QStringLiteral( 
"-f" ) } )
 
  189  logArgs << QStringLiteral( 
"\"%1\"" ).arg( inputPath );
 
  190  processArgs << inputPath;
 
  192  QStringList convertStrings;
 
  193  switch ( conversion )
 
  195    case QgsConvertGpxFeatureTypeAlgorithm::WaypointsFromRoute:
 
  196      convertStrings << QStringLiteral( 
"-x" ) << QStringLiteral( 
"transform,wpt=rte,del" );
 
  198    case QgsConvertGpxFeatureTypeAlgorithm::WaypointsFromTrack:
 
  199      convertStrings << QStringLiteral( 
"-x" ) << QStringLiteral( 
"transform,wpt=trk,del" );
 
  201    case QgsConvertGpxFeatureTypeAlgorithm::RouteFromWaypoints:
 
  202      convertStrings << QStringLiteral( 
"-x" ) << QStringLiteral( 
"transform,rte=wpt,del" );
 
  204    case QgsConvertGpxFeatureTypeAlgorithm::TrackFromWaypoints:
 
  205      convertStrings << QStringLiteral( 
"-x" ) << QStringLiteral( 
"transform,trk=wpt,del" );
 
  208  logArgs << convertStrings;
 
  209  processArgs << convertStrings;
 
  211  for ( 
const QString &arg : { QStringLiteral( 
"-o" ), QStringLiteral( 
"gpx" ), QStringLiteral( 
"-F" ) } )
 
  217  logArgs << QStringLiteral( 
"\"%1\"" ).arg( outputPath );
 
  218  processArgs << outputPath;
 
  226QString QgsConvertGpsDataAlgorithm::name()
 const 
  228  return QStringLiteral( 
"convertgpsdata" );
 
  231QString QgsConvertGpsDataAlgorithm::displayName()
 const 
  233  return QObject::tr( 
"Convert GPS data" );
 
  236QStringList QgsConvertGpsDataAlgorithm::tags()
 const 
  238  return QObject::tr( 
"gps,tools,babel,tracks,waypoints,routes,gpx,import,export" ).split( 
',' );
 
  241QString QgsConvertGpsDataAlgorithm::group()
 const 
  243  return QObject::tr( 
"GPS" );
 
  246QString QgsConvertGpsDataAlgorithm::groupId()
 const 
  248  return QStringLiteral( 
"gps" );
 
  251void QgsConvertGpsDataAlgorithm::initAlgorithm( 
const QVariantMap & )
 
  255  auto formatParam = std::make_unique<QgsProcessingParameterString>( QStringLiteral( 
"FORMAT" ), QObject::tr( 
"Format" ) );
 
  259  for ( 
const QString &format : formatNames )
 
  260    formats << 
QgsApplication::gpsBabelFormatRegistry()->importFormat( format )->description();
 
  262  std::sort( formats.begin(), formats.end(), []( 
const QString &a, 
const QString &b ) {
 
  263    return a.compare( b, Qt::CaseInsensitive ) < 0;
 
  266  formatParam->setMetadata( { { QStringLiteral( 
"widget_wrapper" ), QVariantMap( { { QStringLiteral( 
"value_hints" ), formats } } ) }
 
  268  addParameter( formatParam.release() );
 
  270  addParameter( 
new QgsProcessingParameterEnum( QStringLiteral( 
"FEATURE_TYPE" ), QObject::tr( 
"Feature type" ), { QObject::tr( 
"Waypoints" ), QObject::tr( 
"Routes" ), QObject::tr( 
"Tracks" ) }, 
false, 0 ) );
 
  277QIcon QgsConvertGpsDataAlgorithm::icon()
 const 
  282QString QgsConvertGpsDataAlgorithm::svgIconPath()
 const 
  287QString QgsConvertGpsDataAlgorithm::shortHelpString()
 const 
  289  return QObject::tr( 
"This algorithm uses the GPSBabel tool to convert a GPS data file from a range of formats to the GPX standard format." );
 
  292QString QgsConvertGpsDataAlgorithm::shortDescription()
 const 
  294  return QObject::tr( 
"Converts a GPS data file from a range of formats to the GPX standard format." );
 
  297QgsConvertGpsDataAlgorithm *QgsConvertGpsDataAlgorithm::createInstance()
 const 
  299  return new QgsConvertGpsDataAlgorithm();
 
  304  const QString inputPath = parameterAsString( parameters, QStringLiteral( 
"INPUT" ), context );
 
  305  const QString outputPath = parameterAsString( parameters, QStringLiteral( 
"OUTPUT" ), context );
 
  310  if ( babelPath.isEmpty() )
 
  311    babelPath = QStringLiteral( 
"gpsbabel" );
 
  313  const QString formatName = parameterAsString( parameters, QStringLiteral( 
"FORMAT" ), context );
 
  324  switch ( featureType )
 
  329        throw QgsProcessingException( QObject::tr( 
"The GPSBabel format “%1” does not support converting waypoints." )
 
  330                                        .arg( formatName ) );
 
  337        throw QgsProcessingException( QObject::tr( 
"The GPSBabel format “%1” does not support converting routes." )
 
  338                                        .arg( formatName ) );
 
  345        throw QgsProcessingException( QObject::tr( 
"The GPSBabel format “%1” does not support converting tracks." )
 
  346                                        .arg( formatName ) );
 
  354  const QStringList processCommand = format->
importCommand( babelPath, featureType, inputPath, outputPath );
 
  355  feedback->
pushCommandInfo( QObject::tr( 
"Conversion command: " ) + logCommand.join( 
' ' ) );
 
  357  QgsBlockingProcess babelProcess( processCommand.value( 0 ), processCommand.mid( 1 ) );
 
  358  babelProcess.setStdErrHandler( [feedback]( 
const QByteArray &ba ) {
 
  361  babelProcess.setStdOutHandler( [feedback]( 
const QByteArray &ba ) {
 
  365  const int res = babelProcess.run( feedback );
 
  368    feedback->
pushInfo( QObject::tr( 
"Process was canceled and did not complete" ) );
 
  370  else if ( !feedback->
isCanceled() && babelProcess.exitStatus() == QProcess::CrashExit )
 
  376    feedback->
pushInfo( QObject::tr( 
"Process completed successfully" ) );
 
  378  else if ( babelProcess.processError() == QProcess::FailedToStart )
 
  380    throw QgsProcessingException( QObject::tr( 
"Process %1 failed to start. Either %1 is missing, or you may have insufficient permissions to run the program." ).arg( babelPath ) );
 
  387  std::unique_ptr<QgsVectorLayer> layer;
 
  390  switch ( featureType )
 
  393      layer = std::make_unique<QgsVectorLayer>( outputPath + 
"?type=waypoint", layerName, QStringLiteral( 
"gpx" ) );
 
  396      layer = std::make_unique<QgsVectorLayer>( outputPath + 
"?type=route", layerName, QStringLiteral( 
"gpx" ) );
 
  399      layer = std::make_unique<QgsVectorLayer>( outputPath + 
"?type=track", layerName, QStringLiteral( 
"gpx" ) );
 
  404  if ( !layer->isValid() )
 
  406    feedback->
reportError( QObject::tr( 
"Resulting file is not a valid GPX layer" ) );
 
  410    const QString layerId = layer->id();
 
  411    outputs.insert( QStringLiteral( 
"OUTPUT_LAYER" ), layerId );
 
  417  outputs.insert( QStringLiteral( 
"OUTPUT" ), outputPath );
 
  425QString QgsDownloadGpsDataAlgorithm::name()
 const 
  427  return QStringLiteral( 
"downloadgpsdata" );
 
  430QString QgsDownloadGpsDataAlgorithm::displayName()
 const 
  432  return QObject::tr( 
"Download GPS data from device" );
 
  435QStringList QgsDownloadGpsDataAlgorithm::tags()
 const 
  437  return QObject::tr( 
"gps,tools,babel,tracks,waypoints,routes,gpx,import,export,export,device,serial" ).split( 
',' );
 
  440QString QgsDownloadGpsDataAlgorithm::group()
 const 
  442  return QObject::tr( 
"GPS" );
 
  445QString QgsDownloadGpsDataAlgorithm::groupId()
 const 
  447  return QStringLiteral( 
"gps" );
 
  450void QgsDownloadGpsDataAlgorithm::initAlgorithm( 
const QVariantMap & )
 
  452  auto deviceParam = std::make_unique<QgsProcessingParameterString>( QStringLiteral( 
"DEVICE" ), QObject::tr( 
"Device" ) );
 
  455  std::sort( deviceNames.begin(), deviceNames.end(), []( 
const QString &a, 
const QString &b ) {
 
  456    return a.compare( b, Qt::CaseInsensitive ) < 0;
 
  459  deviceParam->setMetadata( { { QStringLiteral( 
"widget_wrapper" ), QVariantMap( { { QStringLiteral( 
"value_hints" ), deviceNames } } ) }
 
  461  addParameter( deviceParam.release() );
 
  464  const QList<QPair<QString, QString>> devices = 
QgsGpsDetector::availablePorts() << QPair<QString, QString>( QStringLiteral( 
"usb:" ), QStringLiteral( 
"usb:" ) );
 
  465  auto portParam = std::make_unique<QgsProcessingParameterString>( QStringLiteral( 
"PORT" ), QObject::tr( 
"Port" ) );
 
  468  for ( 
auto it = devices.constBegin(); it != devices.constEnd(); ++it )
 
  470  std::sort( ports.begin(), ports.end(), []( 
const QString &a, 
const QString &b ) {
 
  471    return a.compare( b, Qt::CaseInsensitive ) < 0;
 
  474  portParam->setMetadata( { { QStringLiteral( 
"widget_wrapper" ), QVariantMap( { { QStringLiteral( 
"value_hints" ), ports } } ) }
 
  476  addParameter( portParam.release() );
 
  478  addParameter( 
new QgsProcessingParameterEnum( QStringLiteral( 
"FEATURE_TYPE" ), QObject::tr( 
"Feature type" ), { QObject::tr( 
"Waypoints" ), QObject::tr( 
"Routes" ), QObject::tr( 
"Tracks" ) }, 
false, 0 ) );
 
  485QIcon QgsDownloadGpsDataAlgorithm::icon()
 const 
  490QString QgsDownloadGpsDataAlgorithm::svgIconPath()
 const 
  495QString QgsDownloadGpsDataAlgorithm::shortHelpString()
 const 
  497  return QObject::tr( 
"This algorithm uses the GPSBabel tool to download data from a GPS device into the GPX standard format." );
 
  500QString QgsDownloadGpsDataAlgorithm::shortDescription()
 const 
  502  return QObject::tr( 
"Downloads data from a GPS device into the GPX standard format." );
 
  505QgsDownloadGpsDataAlgorithm *QgsDownloadGpsDataAlgorithm::createInstance()
 const 
  507  return new QgsDownloadGpsDataAlgorithm();
 
  512  const QString outputPath = parameterAsString( parameters, QStringLiteral( 
"OUTPUT" ), context );
 
  516  if ( babelPath.isEmpty() )
 
  517    babelPath = QStringLiteral( 
"gpsbabel" );
 
  519  const QString deviceName = parameterAsString( parameters, QStringLiteral( 
"DEVICE" ), context );
 
  527  const QString portName = parameterAsString( parameters, QStringLiteral( 
"PORT" ), context );
 
  529  const QList<QPair<QString, QString>> devices = 
QgsGpsDetector::availablePorts() << QPair<QString, QString>( QStringLiteral( 
"usb:" ), QStringLiteral( 
"usb:" ) );
 
  530  QStringList validPorts;
 
  531  for ( 
auto it = devices.constBegin(); it != devices.constEnd(); ++it )
 
  533    if ( it->first.compare( portName, Qt::CaseInsensitive ) == 0 || it->second.compare( portName, Qt::CaseInsensitive ) == 0 )
 
  535      inputPort = it->first;
 
  537    validPorts << it->first;
 
  539  if ( inputPort.isEmpty() )
 
  542                                    .arg( portName, validPorts.join( QLatin1String( 
", " ) ) ) );
 
  545  switch ( featureType )
 
  550        throw QgsProcessingException( QObject::tr( 
"The GPSBabel format “%1” does not support converting waypoints." )
 
  551                                        .arg( deviceName ) );
 
  558        throw QgsProcessingException( QObject::tr( 
"The GPSBabel format “%1” does not support converting routes." )
 
  559                                        .arg( deviceName ) );
 
  566        throw QgsProcessingException( QObject::tr( 
"The GPSBabel format “%1” does not support converting tracks." )
 
  567                                        .arg( deviceName ) );
 
  575  const QStringList processCommand = format->
importCommand( babelPath, featureType, inputPort, outputPath );
 
  576  feedback->
pushCommandInfo( QObject::tr( 
"Download command: " ) + logCommand.join( 
' ' ) );
 
  578  QgsBlockingProcess babelProcess( processCommand.value( 0 ), processCommand.mid( 1 ) );
 
  579  babelProcess.setStdErrHandler( [feedback]( 
const QByteArray &ba ) {
 
  582  babelProcess.setStdOutHandler( [feedback]( 
const QByteArray &ba ) {
 
  586  const int res = babelProcess.run( feedback );
 
  589    feedback->
pushInfo( QObject::tr( 
"Process was canceled and did not complete" ) );
 
  591  else if ( !feedback->
isCanceled() && babelProcess.exitStatus() == QProcess::CrashExit )
 
  597    feedback->
pushInfo( QObject::tr( 
"Process completed successfully" ) );
 
  599  else if ( babelProcess.processError() == QProcess::FailedToStart )
 
  601    throw QgsProcessingException( QObject::tr( 
"Process %1 failed to start. Either %1 is missing, or you may have insufficient permissions to run the program." ).arg( babelPath ) );
 
  608  std::unique_ptr<QgsVectorLayer> layer;
 
  611  switch ( featureType )
 
  614      layer = std::make_unique<QgsVectorLayer>( outputPath + 
"?type=waypoint", layerName, QStringLiteral( 
"gpx" ) );
 
  617      layer = std::make_unique<QgsVectorLayer>( outputPath + 
"?type=route", layerName, QStringLiteral( 
"gpx" ) );
 
  620      layer = std::make_unique<QgsVectorLayer>( outputPath + 
"?type=track", layerName, QStringLiteral( 
"gpx" ) );
 
  625  if ( !layer->isValid() )
 
  627    feedback->
reportError( QObject::tr( 
"Resulting file is not a valid GPX layer" ) );
 
  631    const QString layerId = layer->id();
 
  632    outputs.insert( QStringLiteral( 
"OUTPUT_LAYER" ), layerId );
 
  638  outputs.insert( QStringLiteral( 
"OUTPUT" ), outputPath );
 
  647QString QgsUploadGpsDataAlgorithm::name()
 const 
  649  return QStringLiteral( 
"uploadgpsdata" );
 
  652QString QgsUploadGpsDataAlgorithm::displayName()
 const 
  654  return QObject::tr( 
"Upload GPS data to device" );
 
  657QStringList QgsUploadGpsDataAlgorithm::tags()
 const 
  659  return QObject::tr( 
"gps,tools,babel,tracks,waypoints,routes,gpx,import,export,export,device,serial" ).split( 
',' );
 
  662QString QgsUploadGpsDataAlgorithm::group()
 const 
  664  return QObject::tr( 
"GPS" );
 
  667QString QgsUploadGpsDataAlgorithm::groupId()
 const 
  669  return QStringLiteral( 
"gps" );
 
  672void QgsUploadGpsDataAlgorithm::initAlgorithm( 
const QVariantMap & )
 
  676  auto deviceParam = std::make_unique<QgsProcessingParameterString>( QStringLiteral( 
"DEVICE" ), QObject::tr( 
"Device" ) );
 
  679  std::sort( deviceNames.begin(), deviceNames.end(), []( 
const QString &a, 
const QString &b ) {
 
  680    return a.compare( b, Qt::CaseInsensitive ) < 0;
 
  683  deviceParam->setMetadata( { { QStringLiteral( 
"widget_wrapper" ), QVariantMap( { { QStringLiteral( 
"value_hints" ), deviceNames } } ) }
 
  685  addParameter( deviceParam.release() );
 
  687  const QList<QPair<QString, QString>> devices = 
QgsGpsDetector::availablePorts() << QPair<QString, QString>( QStringLiteral( 
"usb:" ), QStringLiteral( 
"usb:" ) );
 
  688  auto portParam = std::make_unique<QgsProcessingParameterString>( QStringLiteral( 
"PORT" ), QObject::tr( 
"Port" ) );
 
  691  for ( 
auto it = devices.constBegin(); it != devices.constEnd(); ++it )
 
  693  std::sort( ports.begin(), ports.end(), []( 
const QString &a, 
const QString &b ) {
 
  694    return a.compare( b, Qt::CaseInsensitive ) < 0;
 
  697  portParam->setMetadata( { { QStringLiteral( 
"widget_wrapper" ), QVariantMap( { { QStringLiteral( 
"value_hints" ), ports } } ) }
 
  699  addParameter( portParam.release() );
 
  701  addParameter( 
new QgsProcessingParameterEnum( QStringLiteral( 
"FEATURE_TYPE" ), QObject::tr( 
"Feature type" ), { QObject::tr( 
"Waypoints" ), QObject::tr( 
"Routes" ), QObject::tr( 
"Tracks" ) }, 
false, 0 ) );
 
  704QIcon QgsUploadGpsDataAlgorithm::icon()
 const 
  709QString QgsUploadGpsDataAlgorithm::svgIconPath()
 const 
  714QString QgsUploadGpsDataAlgorithm::shortHelpString()
 const 
  716  return QObject::tr( 
"This algorithm uses the GPSBabel tool to upload data to a GPS device from the GPX standard format." );
 
  719QString QgsUploadGpsDataAlgorithm::shortDescription()
 const 
  721  return QObject::tr( 
"Uploads data to a GPS device from the GPX standard format." );
 
  724QgsUploadGpsDataAlgorithm *QgsUploadGpsDataAlgorithm::createInstance()
 const 
  726  return new QgsUploadGpsDataAlgorithm();
 
  731  const QString inputPath = parameterAsString( parameters, QStringLiteral( 
"INPUT" ), context );
 
  735  if ( babelPath.isEmpty() )
 
  736    babelPath = QStringLiteral( 
"gpsbabel" );
 
  738  const QString deviceName = parameterAsString( parameters, QStringLiteral( 
"DEVICE" ), context );
 
  746  const QString portName = parameterAsString( parameters, QStringLiteral( 
"PORT" ), context );
 
  748  const QList<QPair<QString, QString>> devices = 
QgsGpsDetector::availablePorts() << QPair<QString, QString>( QStringLiteral( 
"usb:" ), QStringLiteral( 
"usb:" ) );
 
  749  QStringList validPorts;
 
  750  for ( 
auto it = devices.constBegin(); it != devices.constEnd(); ++it )
 
  752    if ( it->first.compare( portName, Qt::CaseInsensitive ) == 0 || it->second.compare( portName, Qt::CaseInsensitive ) == 0 )
 
  754      outputPort = it->first;
 
  756    validPorts << it->first;
 
  758  if ( outputPort.isEmpty() )
 
  761                                    .arg( portName, validPorts.join( QLatin1String( 
", " ) ) ) );
 
  765  switch ( featureType )
 
  771                                        .arg( deviceName ) );
 
  779                                        .arg( deviceName ) );
 
  787                                        .arg( deviceName ) );
 
  795  const QStringList processCommand = format->
exportCommand( babelPath, featureType, inputPath, outputPort );
 
  796  feedback->
pushCommandInfo( QObject::tr( 
"Upload command: " ) + logCommand.join( 
' ' ) );
 
  798  QgsBlockingProcess babelProcess( processCommand.value( 0 ), processCommand.mid( 1 ) );
 
  799  babelProcess.setStdErrHandler( [feedback]( 
const QByteArray &ba ) {
 
  802  babelProcess.setStdOutHandler( [feedback]( 
const QByteArray &ba ) {
 
  806  const int res = babelProcess.run( feedback );
 
  809    feedback->
pushInfo( QObject::tr( 
"Process was canceled and did not complete" ) );
 
  811  else if ( !feedback->
isCanceled() && babelProcess.exitStatus() == QProcess::CrashExit )
 
  817    feedback->
pushInfo( QObject::tr( 
"Process completed successfully" ) );
 
  819  else if ( babelProcess.processError() == QProcess::FailedToStart )
 
  821    throw QgsProcessingException( QObject::tr( 
"Process %1 failed to start. Either %1 is missing, or you may have insufficient permissions to run the program." ).arg( babelPath ) );
 
@ File
Parameter is a single file.
 
@ QuoteFilePaths
File paths should be enclosed in quotations and escaped.
 
GpsFeatureType
GPS feature types.
 
@ Tracks
Format supports tracks.
 
@ Waypoints
Format supports waypoints.
 
@ Routes
Format supports routes.
 
Extends QApplication to provide access to QGIS specific resources such as theme paths,...
 
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
 
static QgsBabelFormatRegistry * gpsBabelFormatRegistry()
Returns the application's GPSBabel format registry, used for managing GPSBabel formats.
 
static QString iconPath(const QString &iconFile)
Returns path to the desired icon file.
 
bool isCanceled() const
Tells whether the operation has been canceled already.
 
static QList< QPair< QString, QString > > availablePorts()
 
QgsMapLayer * addMapLayer(QgsMapLayer *layer, bool takeOwnership=true)
Add a layer to the store.
 
Details for layers to load into projects.
 
Contains information about the context in which a processing algorithm is executed.
 
void addLayerToLoadOnCompletion(const QString &layer, const QgsProcessingContext::LayerDetails &details)
Adds a layer to load (by ID or datasource) into the canvas upon completion of the algorithm or model.
 
QgsProject * project() const
Returns the project in which the algorithm is being executed.
 
QgsMapLayerStore * temporaryLayerStore()
Returns a reference to the layer store used for storing temporary layers during algorithm execution.
 
Custom exception class for processing related exceptions.
 
Base class for providing feedback from a processing algorithm.
 
virtual void pushCommandInfo(const QString &info)
Pushes an informational message containing a command from the algorithm.
 
virtual void pushInfo(const QString &info)
Pushes a general informational message from the algorithm.
 
virtual void pushDebugInfo(const QString &info)
Pushes an informational message containing debugging helpers from the algorithm.
 
virtual void reportError(const QString &error, bool fatalError=false)
Reports that the algorithm encountered an error while executing.
 
A vector layer output for processing algorithms.
 
An enum based parameter for processing algorithms, allowing for selection from predefined values.
 
A generic file based destination parameter, for specifying the destination path for a file (non-map l...
 
An input file or folder parameter for processing algorithms.
 
@ Vector
Vector layer type.
 
static QString suggestLayerNameFromFilePath(const QString &path)
Suggests a suitable layer name given only a file path.
 
T value(const QString &dynamicKeyPart=QString()) const
Returns settings value.
 
static const QgsSettingsEntryString * settingsGpsBabelPath
Settings entry path to GPSBabel executable.