mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
Remove GPX feature type conversion from GPS tools plugin
This functionality is now exposed by the processing algorithm instead
This commit is contained in:
parent
d187a14847
commit
8eff5e7620
@ -130,8 +130,6 @@ void QgsGpsPlugin::run()
|
||||
this, &QgsGpsPlugin::loadGPXFile );
|
||||
connect( myPluginGui, &QgsGpsPluginGui::importGPSFile,
|
||||
this, &QgsGpsPlugin::importGPSFile );
|
||||
connect( myPluginGui, &QgsGpsPluginGui::convertGPSFile,
|
||||
this, &QgsGpsPlugin::convertGPSFile );
|
||||
connect( myPluginGui, &QgsGpsPluginGui::downloadFromGPS,
|
||||
this, &QgsGpsPlugin::downloadFromGPS );
|
||||
connect( myPluginGui, &QgsGpsPluginGui::uploadToGPS,
|
||||
@ -253,93 +251,6 @@ void QgsGpsPlugin::importGPSFile( const QString &inputFileName, QgsBabelFormat *
|
||||
emit closeGui();
|
||||
}
|
||||
|
||||
void QgsGpsPlugin::convertGPSFile( const QString &inputFileName,
|
||||
int convertType,
|
||||
const QString &outputFileName,
|
||||
const QString &layerName )
|
||||
{
|
||||
// what features does the user want to import?
|
||||
QStringList convertStrings;
|
||||
|
||||
switch ( convertType )
|
||||
{
|
||||
case 0:
|
||||
convertStrings << QStringLiteral( "-x" ) << QStringLiteral( "transform,wpt=rte,del" );
|
||||
break;
|
||||
case 1:
|
||||
convertStrings << QStringLiteral( "-x" ) << QStringLiteral( "transform,rte=wpt,del" );
|
||||
break;
|
||||
case 2:
|
||||
convertStrings << QStringLiteral( "-x" ) << QStringLiteral( "transform,trk=wpt,del" );
|
||||
break;
|
||||
case 3:
|
||||
convertStrings << QStringLiteral( "-x" ) << QStringLiteral( "transform,wpt=trk,del" );
|
||||
break;
|
||||
default:
|
||||
QgsDebugMsg( QStringLiteral( "Illegal conversion index!" ) );
|
||||
return;
|
||||
}
|
||||
|
||||
// try to start the gpsbabel process
|
||||
QStringList babelArgs;
|
||||
babelArgs << mBabelPath << QStringLiteral( "-i" ) << QStringLiteral( "gpx" ) << QStringLiteral( "-f" ) << QStringLiteral( "\"%1\"" ).arg( inputFileName )
|
||||
<< convertStrings << QStringLiteral( "-o" ) << QStringLiteral( "gpx" ) << QStringLiteral( "-F" ) << QStringLiteral( "\"%1\"" ).arg( outputFileName );
|
||||
QgsDebugMsg( QStringLiteral( "Conversion command: " ) + babelArgs.join( "|" ) );
|
||||
|
||||
QProcess babelProcess;
|
||||
babelProcess.start( babelArgs.value( 0 ), babelArgs.mid( 1 ) );
|
||||
if ( !babelProcess.waitForStarted() )
|
||||
{
|
||||
QMessageBox::warning( nullptr, tr( "Convert GPS File" ),
|
||||
tr( "Could not start GPSBabel!" ) );
|
||||
return;
|
||||
}
|
||||
|
||||
// wait for gpsbabel to finish (or the user to cancel)
|
||||
QProgressDialog progressDialog( tr( "Importing data…" ), tr( "Cancel" ), 0, 0 );
|
||||
progressDialog.setWindowModality( Qt::WindowModal );
|
||||
for ( int i = 0; babelProcess.state() == QProcess::Running; ++i )
|
||||
{
|
||||
progressDialog.setValue( i / 64 );
|
||||
if ( progressDialog.wasCanceled() )
|
||||
return;
|
||||
}
|
||||
|
||||
// did we get any data?
|
||||
if ( babelProcess.exitStatus() != 0 )
|
||||
{
|
||||
QString babelError( babelProcess.readAllStandardError() );
|
||||
QString errorMsg( tr( "Could not convert data from %1!\n\n" )
|
||||
.arg( inputFileName ) );
|
||||
errorMsg += babelError;
|
||||
QMessageBox::warning( nullptr, tr( "Convert GPS File" ), errorMsg );
|
||||
return;
|
||||
}
|
||||
|
||||
// add the layer
|
||||
switch ( convertType )
|
||||
{
|
||||
case 0:
|
||||
case 3:
|
||||
drawVectorLayer( outputFileName + "?type=waypoint",
|
||||
layerName, QStringLiteral( "gpx" ) );
|
||||
break;
|
||||
case 1:
|
||||
drawVectorLayer( outputFileName + "?type=route",
|
||||
layerName, QStringLiteral( "gpx" ) );
|
||||
break;
|
||||
case 2:
|
||||
drawVectorLayer( outputFileName + "?type=track",
|
||||
layerName, QStringLiteral( "gpx" ) );
|
||||
break;
|
||||
default:
|
||||
QgsDebugMsg( QStringLiteral( "Illegal conversion index!" ) );
|
||||
return;
|
||||
}
|
||||
|
||||
emit closeGui();
|
||||
}
|
||||
|
||||
void QgsGpsPlugin::downloadFromGPS( const QString &device, const QString &port,
|
||||
bool downloadWaypoints, bool downloadRoutes,
|
||||
bool downloadTracks, const QString &outputFileName,
|
||||
|
@ -67,10 +67,6 @@ class QgsGpsPlugin: public QObject, public QgisPlugin
|
||||
bool importWaypoints, bool importRoutes,
|
||||
bool importTracks, const QString &outputFileName,
|
||||
const QString &layerName );
|
||||
void convertGPSFile( const QString &inputFileName,
|
||||
int convertType,
|
||||
const QString &outputFileName,
|
||||
const QString &layerName );
|
||||
void downloadFromGPS( const QString &device, const QString &port,
|
||||
bool downloadWaypoints, bool downloadRoutes,
|
||||
bool downloadTracks, const QString &outputFileName,
|
||||
|
@ -39,8 +39,6 @@ QgsGpsPluginGui::QgsGpsPluginGui( const BabelMap &importers,
|
||||
QgsGui::instance()->enableAutoGeometryRestore( this );
|
||||
connect( pbnIMPInput, &QPushButton::clicked, this, &QgsGpsPluginGui::pbnIMPInput_clicked );
|
||||
connect( pbnIMPOutput, &QPushButton::clicked, this, &QgsGpsPluginGui::pbnIMPOutput_clicked );
|
||||
connect( pbnCONVInput, &QPushButton::clicked, this, &QgsGpsPluginGui::pbnCONVInput_clicked );
|
||||
connect( pbnCONVOutput, &QPushButton::clicked, this, &QgsGpsPluginGui::pbnCONVOutput_clicked );
|
||||
connect( pbnDLOutput, &QPushButton::clicked, this, &QgsGpsPluginGui::pbnDLOutput_clicked );
|
||||
connect( pbnRefresh, &QPushButton::clicked, this, &QgsGpsPluginGui::pbnRefresh_clicked );
|
||||
connect( buttonBox, &QDialogButtonBox::accepted, this, &QgsGpsPluginGui::buttonBox_accepted );
|
||||
@ -53,7 +51,6 @@ QgsGpsPluginGui::QgsGpsPluginGui( const BabelMap &importers,
|
||||
populatePortComboBoxes();
|
||||
populateULLayerComboBox();
|
||||
populateIMPBabelFormats();
|
||||
populateCONVDialog();
|
||||
|
||||
connect( pbULEditDevices, &QAbstractButton::clicked, this, &QgsGpsPluginGui::openDeviceEditor );
|
||||
connect( pbDLEditDevices, &QAbstractButton::clicked, this, &QgsGpsPluginGui::openDeviceEditor );
|
||||
@ -70,12 +67,6 @@ QgsGpsPluginGui::QgsGpsPluginGui( const BabelMap &importers,
|
||||
this, &QgsGpsPluginGui::enableRelevantControls );
|
||||
connect( leIMPLayer, &QLineEdit::textChanged,
|
||||
this, &QgsGpsPluginGui::enableRelevantControls );
|
||||
connect( leCONVInput, &QLineEdit::textChanged,
|
||||
this, &QgsGpsPluginGui::enableRelevantControls );
|
||||
connect( leCONVOutput, &QLineEdit::textChanged,
|
||||
this, &QgsGpsPluginGui::enableRelevantControls );
|
||||
connect( leCONVLayer, &QLineEdit::textChanged,
|
||||
this, &QgsGpsPluginGui::enableRelevantControls );
|
||||
connect( leDLOutput, &QLineEdit::textChanged,
|
||||
this, &QgsGpsPluginGui::enableRelevantControls );
|
||||
connect( leDLBasename, &QLineEdit::textChanged,
|
||||
@ -146,18 +137,6 @@ void QgsGpsPluginGui::buttonBox_accepted()
|
||||
cmbULPort->currentData().toString() );
|
||||
break;
|
||||
}
|
||||
|
||||
case 4:
|
||||
{
|
||||
// or convert between waypoints/tracks=
|
||||
int convertType = cmbCONVType->currentData().toInt();
|
||||
|
||||
emit convertGPSFile( leCONVInput->text(),
|
||||
convertType,
|
||||
leCONVOutput->text(),
|
||||
leCONVLayer->text() );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// The slots that are called above will emit closeGui() when successful.
|
||||
@ -228,16 +207,6 @@ void QgsGpsPluginGui::enableRelevantControls()
|
||||
else
|
||||
pbnOK->setEnabled( true );
|
||||
}
|
||||
|
||||
// convert between waypoint/routes
|
||||
else if ( tabWidget->currentIndex() == 4 )
|
||||
{
|
||||
if ( ( leCONVInput->text().isEmpty() ) || ( leCONVOutput->text().isEmpty() ) ||
|
||||
( leCONVLayer->text().isEmpty() ) )
|
||||
pbnOK->setEnabled( false );
|
||||
else
|
||||
pbnOK->setEnabled( true );
|
||||
}
|
||||
}
|
||||
|
||||
void QgsGpsPluginGui::buttonBox_rejected()
|
||||
@ -351,14 +320,6 @@ void QgsGpsPluginGui::populatePortComboBoxes()
|
||||
cmbULPort->setCurrentIndex( idx < 0 ? 0 : idx );
|
||||
}
|
||||
|
||||
void QgsGpsPluginGui::populateCONVDialog()
|
||||
{
|
||||
cmbCONVType->addItem( tr( "Waypoints from a Route" ), QVariant( int( 0 ) ) );
|
||||
cmbCONVType->addItem( tr( "Waypoints from a Track" ), QVariant( int( 3 ) ) );
|
||||
cmbCONVType->addItem( tr( "Route from Waypoints" ), QVariant( int( 1 ) ) );
|
||||
cmbCONVType->addItem( tr( "Track from Waypoints" ), QVariant( int( 2 ) ) );
|
||||
}
|
||||
|
||||
void QgsGpsPluginGui::populateULLayerComboBox()
|
||||
{
|
||||
for ( std::vector<QgsVectorLayer *>::size_type i = 0; i < mGPXLayers.size(); ++i )
|
||||
@ -394,41 +355,6 @@ void QgsGpsPluginGui::populateIMPBabelFormats()
|
||||
cmbDLDevice->setCurrentIndex( d );
|
||||
}
|
||||
|
||||
void QgsGpsPluginGui::pbnCONVInput_clicked()
|
||||
{
|
||||
QgsSettings settings;
|
||||
QString dir = settings.value( QStringLiteral( "Plugin-GPS/gpxdirectory" ), QDir::homePath() ).toString();
|
||||
QString myFileNameQString = QFileDialog::getOpenFileName(
|
||||
this,
|
||||
tr( "Select GPX file" ),
|
||||
dir,
|
||||
tr( "GPS eXchange format (*.gpx)" ) );
|
||||
if ( !myFileNameQString.isEmpty() )
|
||||
{
|
||||
leCONVInput->setText( myFileNameQString );
|
||||
settings.setValue( QStringLiteral( "Plugin-GPS/gpxdirectory" ), QFileInfo( myFileNameQString ).absolutePath() );
|
||||
}
|
||||
}
|
||||
|
||||
void QgsGpsPluginGui::pbnCONVOutput_clicked()
|
||||
{
|
||||
QgsSettings settings;
|
||||
QString dir = settings.value( QStringLiteral( "Plugin-GPS/gpxdirectory" ), QDir::homePath() ).toString();
|
||||
QString myFileNameQString =
|
||||
QFileDialog::getSaveFileName( this,
|
||||
tr( "Choose a file name to save under" ),
|
||||
dir,
|
||||
tr( "GPS eXchange format" ) + " (*.gpx)" );
|
||||
if ( !myFileNameQString.isEmpty() )
|
||||
{
|
||||
if ( !myFileNameQString.endsWith( QLatin1String( ".gpx" ), Qt::CaseInsensitive ) )
|
||||
{
|
||||
myFileNameQString += QLatin1String( ".gpx" );
|
||||
}
|
||||
leCONVOutput->setText( myFileNameQString );
|
||||
settings.setValue( QStringLiteral( "Plugin-GPS/gpxdirectory" ), QFileInfo( myFileNameQString ).absolutePath() );
|
||||
}
|
||||
}
|
||||
|
||||
void QgsGpsPluginGui::openDeviceEditor()
|
||||
{
|
||||
@ -445,7 +371,7 @@ void QgsGpsPluginGui::devicesUpdated()
|
||||
void QgsGpsPluginGui::restoreState()
|
||||
{
|
||||
QgsSettings settings;
|
||||
tabWidget->setCurrentIndex( settings.value( QStringLiteral( "Plugin-GPS/lastTab" ), 4 ).toInt() );
|
||||
tabWidget->setCurrentIndex( settings.value( QStringLiteral( "Plugin-GPS/lastTab" ), 0 ).toInt() );
|
||||
}
|
||||
|
||||
void QgsGpsPluginGui::showHelp()
|
||||
|
@ -53,9 +53,6 @@ class QgsGpsPluginGui : public QDialog, private Ui::QgsGpsPluginGuiBase
|
||||
void pbnIMPInput_clicked();
|
||||
void pbnIMPOutput_clicked();
|
||||
|
||||
void pbnCONVInput_clicked();
|
||||
void pbnCONVOutput_clicked();
|
||||
|
||||
void pbnDLOutput_clicked();
|
||||
|
||||
private:
|
||||
@ -63,7 +60,6 @@ class QgsGpsPluginGui : public QDialog, private Ui::QgsGpsPluginGuiBase
|
||||
void populateULLayerComboBox();
|
||||
void populateIMPBabelFormats();
|
||||
void populatePortComboBoxes();
|
||||
void populateCONVDialog();
|
||||
|
||||
void saveState();
|
||||
void restoreState();
|
||||
@ -91,10 +87,6 @@ class QgsGpsPluginGui : public QDialog, private Ui::QgsGpsPluginGuiBase
|
||||
bool importWaypoints, bool importRoutes,
|
||||
bool importTracks, const QString &outputFileName,
|
||||
const QString &layerName );
|
||||
void convertGPSFile( const QString &inputFileName,
|
||||
int convertType,
|
||||
const QString &outputFileName,
|
||||
const QString &layerName );
|
||||
void downloadFromGPS( const QString &device, const QString &port, bool downloadWaypoints,
|
||||
bool downloadRoutes, bool downloadTracks,
|
||||
const QString &outputFileName, const QString &layerName );
|
||||
|
@ -21,7 +21,7 @@
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>3</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab1">
|
||||
<attribute name="title">
|
||||
@ -517,116 +517,6 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab5">
|
||||
<attribute name="title">
|
||||
<string>GPX Conversions</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_6">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="textLabel5_4">
|
||||
<property name="text">
|
||||
<string>GPX input file</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>pbnCONVInput</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="leCONVInput">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="pbnCONVInput">
|
||||
<property name="text">
|
||||
<string>Browse…</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="textLabel5_3">
|
||||
<property name="text">
|
||||
<string>Conversion</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>cmbCONVType</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="cmbCONVType">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>10</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="textLabel5_2">
|
||||
<property name="text">
|
||||
<string>GPX output file</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>leCONVOutput</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="leCONVOutput"/>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="textLabel5_1">
|
||||
<property name="text">
|
||||
<string>Layer name</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>leCONVLayer</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="leCONVLayer"/>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<spacer name="verticalSpacer_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QPushButton" name="pbnCONVOutput">
|
||||
<property name="text">
|
||||
<string>Save As…</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
@ -673,12 +563,6 @@
|
||||
<tabstop>cmbULDevice</tabstop>
|
||||
<tabstop>pbULEditDevices</tabstop>
|
||||
<tabstop>cmbULPort</tabstop>
|
||||
<tabstop>leCONVInput</tabstop>
|
||||
<tabstop>pbnCONVInput</tabstop>
|
||||
<tabstop>cmbCONVType</tabstop>
|
||||
<tabstop>leCONVOutput</tabstop>
|
||||
<tabstop>pbnCONVOutput</tabstop>
|
||||
<tabstop>leCONVLayer</tabstop>
|
||||
<tabstop>buttonBox</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user