Fix build

This commit is contained in:
Nyall Dawson 2022-11-11 11:52:50 +10:00
parent bbd0a239b8
commit 09b0d0c2ed
8 changed files with 66 additions and 50 deletions

View File

@ -136,6 +136,20 @@ the GPS position is changed.
void updateGpsSettings();
%Docstring
Should be called whenever the QGIS GPS settings are changed.
%End
double totalTrackLength() const;
%Docstring
Returns the total length of the current digitized track (in meters).
The returned length is calculated using ellipsoidal calculations.
%End
double trackDistanceFromStart() const;
%Docstring
Returns the direct length from the first vertex in the track to the last (in meters).
The returned length is calculated using ellipsoidal calculations.
%End
signals:
@ -160,6 +174,11 @@ The ``vertex`` point will be in WGS84 coordinate reference system.
void stateChanged( const QgsGpsInformation &info );
%Docstring
Emitted whenever the associated GPS device state is changed.
%End
void distanceAreaChanged();
%Docstring
Emitted whenever the distance area used to calculate track distances is changed.
%End
protected:

View File

@ -96,21 +96,6 @@ QgsAppGpsDigitizing::~QgsAppGpsDigitizing()
mRubberBand = nullptr;
}
double QgsAppGpsDigitizing::totalTrackLength() const
{
QVector<QgsPointXY> points;
QgsGeometry::convertPointList( mCaptureListWgs84, points );
return mDa.measureLine( points );
}
double QgsAppGpsDigitizing::trackDistanceFromStart() const
{
if ( mCaptureListWgs84.empty() )
return 0;
return mDa.measureLine( { QgsPointXY( mCaptureListWgs84.constFirst() ), QgsPointXY( mCaptureListWgs84.constLast() )} );
}
const QgsDistanceArea &QgsAppGpsDigitizing::distanceArea() const
{
return mDa;

View File

@ -47,20 +47,6 @@ class APP_EXPORT QgsAppGpsDigitizing: public QgsGpsLogger
QgsAppGpsDigitizing( QgsAppGpsConnection *connection, QgsMapCanvas *canvas, QObject *parent = nullptr );
~QgsAppGpsDigitizing() override;
/**
* Returns the total length of the current digitized track (in meters).
*
* The returned length is calculated using ellipsoidal calculations.
*/
double totalTrackLength() const;
/**
* Returns the direct length from the first vertex in the track to the last (in meters).
*
* The returned length is calculated using ellipsoidal calculations.
*/
double trackDistanceFromStart() const;
/**
* Returns the distance area calculator used to calculate track lengths.
*/
@ -73,16 +59,6 @@ class APP_EXPORT QgsAppGpsDigitizing: public QgsGpsLogger
void createVertexAtCurrentLocation();
/**
* Emitted whenever the recorded track is changed.
*/
void trackChanged();
/**
* Emitted whenever the distance area used to calculate track distances is changed.
*/
void distanceAreaChanged();
private slots:
void addVertex( const QgsPoint &wgs84Point );
void onTrackReset();
@ -97,8 +73,6 @@ class APP_EXPORT QgsAppGpsDigitizing: public QgsGpsLogger
void startLogging();
void stopLogging();
void updateDistanceArea();
private:
void createRubberBand();
QVariant timestamp( QgsVectorLayer *vlayer, int idx );

View File

@ -208,7 +208,8 @@ QgsGpsInformationWidget::QgsGpsInformationWidget( QgsAppGpsConnection *connectio
}
} );
connect( mDigitizing, &QgsAppGpsDigitizing::trackChanged, this, &QgsGpsInformationWidget::updateTrackInformation );
connect( mDigitizing, &QgsAppGpsDigitizing::trackVertexAdded, this, &QgsGpsInformationWidget::updateTrackInformation );
connect( mDigitizing, &QgsAppGpsDigitizing::trackReset, this, &QgsGpsInformationWidget::updateTrackInformation );
connect( mDigitizing, &QgsAppGpsDigitizing::distanceAreaChanged, this, &QgsGpsInformationWidget::updateTrackInformation );
}

View File

@ -196,7 +196,8 @@ void QgsGpsToolBar::setGpsDigitizing( QgsAppGpsDigitizing *digitizing )
{
mDigitizing = digitizing;
connect( mDigitizing, &QgsAppGpsDigitizing::distanceAreaChanged, this, &QgsGpsToolBar::updateLocationLabel );
connect( mDigitizing, &QgsAppGpsDigitizing::trackChanged, this, &QgsGpsToolBar::updateLocationLabel );
connect( mDigitizing, &QgsAppGpsDigitizing::trackVertexAdded, this, &QgsGpsToolBar::updateLocationLabel );
connect( mDigitizing, &QgsAppGpsDigitizing::trackReset, this, &QgsGpsToolBar::updateLocationLabel );
}
void QgsGpsToolBar::setAddVertexButtonEnabled( bool enabled )

View File

@ -16,6 +16,7 @@
#include "qgsgpslogger.h"
#include "qgsgpsconnection.h"
#include "gmath.h"
#include "qgsgeometry.h"
#include <QTimer>
#include <QTimeZone>
@ -66,12 +67,14 @@ void QgsGpsLogger::setConnection( QgsGpsConnection *connection )
void QgsGpsLogger::setEllipsoid( const QString &ellipsoid )
{
mDistanceCalculator.setEllipsoid( ellipsoid );
emit distanceAreaChanged();
}
void QgsGpsLogger::setTransformContext( const QgsCoordinateTransformContext &context )
{
mTransformContext = context;
mDistanceCalculator.setSourceCrs( mWgs84CRS, mTransformContext );
emit distanceAreaChanged();
}
QgsCoordinateTransformContext QgsGpsLogger::transformContext() const
@ -162,6 +165,21 @@ void QgsGpsLogger::updateGpsSettings()
switchAcquisition();
}
double QgsGpsLogger::totalTrackLength() const
{
QVector<QgsPointXY> points;
QgsGeometry::convertPointList( mCaptureListWgs84, points );
return mDistanceCalculator.measureLine( points );
}
double QgsGpsLogger::trackDistanceFromStart() const
{
if ( mCaptureListWgs84.empty() )
return 0;
return mDistanceCalculator.measureLine( { QgsPointXY( mCaptureListWgs84.constFirst() ), QgsPointXY( mCaptureListWgs84.constLast() )} );
}
void QgsGpsLogger::switchAcquisition()
{
if ( mAcquisitionInterval > 0 )

View File

@ -160,6 +160,20 @@ class CORE_EXPORT QgsGpsLogger : public QObject
*/
void updateGpsSettings();
/**
* Returns the total length of the current digitized track (in meters).
*
* The returned length is calculated using ellipsoidal calculations.
*/
double totalTrackLength() const;
/**
* Returns the direct length from the first vertex in the track to the last (in meters).
*
* The returned length is calculated using ellipsoidal calculations.
*/
double trackDistanceFromStart() const;
signals:
/**
@ -184,6 +198,11 @@ class CORE_EXPORT QgsGpsLogger : public QObject
*/
void stateChanged( const QgsGpsInformation &info );
/**
* Emitted whenever the distance area used to calculate track distances is changed.
*/
void distanceAreaChanged();
protected:
//! WGS84 coordinate reference system

View File

@ -27,8 +27,6 @@
#include "options/qgsgpsoptions.h"
#include "qgsprojectgpssettings.h"
#include "qgsgpsconnection.h"
#include "nmeatime.h"
#include <QSignalSpy>
/**
@ -451,14 +449,14 @@ void TestQgsGpsIntegration::testTrackDistance()
QCOMPARE( QgsProject::instance()->gpsSettings()->destinationLayer(), lineString );
lineString->startEditing();
QSignalSpy spy( &gpsDigitizing, &QgsAppGpsDigitizing::trackChanged );
QSignalSpy spy( &gpsDigitizing, &QgsAppGpsDigitizing::trackVertexAdded );
QgsGpsInformation info;
info.latitude = 45;
info.longitude = 100;
gpsDigitizing.gpsStateChanged( info );
gpsDigitizing.addVertex();
gpsDigitizing.createVertexAtCurrentLocation();
QCOMPARE( spy.count(), 1 );
QCOMPARE( gpsDigitizing.totalTrackLength(), 0 );
@ -468,7 +466,7 @@ void TestQgsGpsIntegration::testTrackDistance()
info.longitude = 100;
gpsDigitizing.gpsStateChanged( info );
gpsDigitizing.addVertex();
gpsDigitizing.createVertexAtCurrentLocation();
QCOMPARE( spy.count(), 2 );
QgsProject::instance()->setCrs( QgsCoordinateReferenceSystem( "EPSG:3857" ) );
@ -484,13 +482,14 @@ void TestQgsGpsIntegration::testTrackDistance()
info.longitude = 101;
gpsDigitizing.gpsStateChanged( info );
gpsDigitizing.addVertex();
gpsDigitizing.createVertexAtCurrentLocation();
QCOMPARE( spy.count(), 3 );
QGSCOMPARENEAR( gpsDigitizing.totalTrackLength(), 188604.338, 1 );
QGSCOMPARENEAR( gpsDigitizing.trackDistanceFromStart(), 135869.0912, 1 );
QSignalSpy spyReset( &gpsDigitizing, &QgsGpsLogger::trackReset );
gpsDigitizing.resetTrack();
QCOMPARE( spy.count(), 4 );
QCOMPARE( spyReset.count(), 1 );
}