Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions app/position/positionkit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,13 @@ void PositionKit::parsePositionUpdate( const GeoPosition &newPosition )
hasAnythingChanged = true;
}

if ( !qgsDoubleNear( newPosition.elevation_diff, mPosition.elevation_diff ) )
{
mPosition.elevation_diff = newPosition.elevation_diff;
emit geoidSeparationChanged( mPosition.elevation_diff );
hasAnythingChanged = true;
}

if ( newPosition.hasValidPosition() != mHasPosition )
{
mHasPosition = newPosition.hasValidPosition();
Expand Down Expand Up @@ -349,6 +356,11 @@ double PositionKit::altitude() const
return mPosition.elevation;
}

double PositionKit::geoidSeparation() const
{
return mPosition.elevation_diff;
}

QgsPoint PositionKit::positionCoordinate() const
{
if ( mPosition.hasValidPosition() )
Expand Down
4 changes: 4 additions & 0 deletions app/position/positionkit.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ class PositionKit : public QObject

Q_PROPERTY( double latitude READ latitude NOTIFY latitudeChanged )
Q_PROPERTY( double longitude READ longitude NOTIFY longitudeChanged )

Q_PROPERTY( double altitude READ altitude NOTIFY altitudeChanged )
Q_PROPERTY( double geoidSeparation READ geoidSeparation NOTIFY geoidSeparationChanged )

// auxiliary property providing QgsPoint for lat/long/alt instead of separate properties
Q_PROPERTY( QgsPoint positionCoordinate READ positionCoordinate NOTIFY positionCoordinateChanged )
Expand Down Expand Up @@ -84,6 +86,7 @@ class PositionKit : public QObject
double latitude() const;
double longitude() const;
double altitude() const;
double geoidSeparation() const;
QgsPoint positionCoordinate() const;
bool hasPosition() const;

Expand Down Expand Up @@ -127,6 +130,7 @@ class PositionKit : public QObject
void latitudeChanged( double );
void longitudeChanged( double );
void altitudeChanged( double );
void geoidSeparationChanged( double );
void positionCoordinateChanged( QgsPoint );
void hasPositionChanged( bool );

Expand Down
15 changes: 15 additions & 0 deletions app/qml/gps/MMGpsDataDrawer.qml
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,21 @@ MMComponents.MMDrawer {

alignmentRight: Positioner.index % 2 === 1
}

MMGpsComponents.MMGpsDataText {
width: parent.width / 2

title: qsTr( "Geoid separation" )
value: {
if ( !__positionKit.hasPosition || Number.isNaN( __positionKit.geoidSeparation ) ) {
return qsTr( "N/A" )
}
__inputUtils.formatNumber( __positionKit.geoidSeparation, 2 ) + " m"
}
visible: __positionKit.positionProvider && __positionKit.positionProvider.type() === "external"

alignmentRight: Positioner.index % 2 === 1
}
}
}

Expand Down
1 change: 1 addition & 0 deletions app/variablesmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ QgsExpressionContextScope *VariablesManager::positionScope()
addPositionVariable( scope, QStringLiteral( "longitude" ), position.longitude );
addPositionVariable( scope, QStringLiteral( "latitude" ), position.latitude );
addPositionVariable( scope, QStringLiteral( "altitude" ), position.elevation );
addPositionVariable( scope, QStringLiteral( "geoid_separation" ), position.elevation_diff );
addPositionVariable( scope, QStringLiteral( "horizontal_accuracy" ), getGeoPositionAttribute( position.hacc ) );
addPositionVariable( scope, QStringLiteral( "vertical_accuracy" ), getGeoPositionAttribute( position.vacc ) );
addPositionVariable( scope, QStringLiteral( "ground_speed" ), getGeoPositionAttribute( position.speed ) );
Expand Down
68 changes: 68 additions & 0 deletions vcpkg/ports/qtpositioning/android15_altitude_fix.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
diff --git a/src/plugins/position/android/jar/src/org/qtproject/qt/android/positioning/QtPositioning.java b/src/plugins/position/android/jar/src/org/qtproject/qt/android/positioning/QtPositioning.java
index e4163b09..afb2889e 100644
--- a/src/plugins/position/android/jar/src/org/qtproject/qt/android/positioning/QtPositioning.java
+++ b/src/plugins/position/android/jar/src/org/qtproject/qt/android/positioning/QtPositioning.java
@@ -112,6 +112,8 @@ class QtPositioning implements LocationListener
static private void addMslAltitude(Location location)
{
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
+ if (location.hasMslAltitude()) // Nothing to be done
+ return;
if (altitudeConverter == null)
altitudeConverter = new AltitudeConverter();
try {
diff --git a/src/plugins/position/android/src/jnipositioning.cpp b/src/plugins/position/android/src/jnipositioning.cpp
index 2b2919fa..0abc2cad 100644
--- a/src/plugins/position/android/src/jnipositioning.cpp
+++ b/src/plugins/position/android/src/jnipositioning.cpp
@@ -220,7 +220,7 @@ namespace AndroidPositioning {
return ret;
}

- QGeoPositionInfo positionInfoFromJavaLocation(const jobject &location)
+ QGeoPositionInfo positionInfoFromJavaLocation(const jobject &location, bool useAltConverter)
{
QGeoPositionInfo info;

@@ -241,8 +241,11 @@ namespace AndroidPositioning {
coordinate.setAltitude(value);
}
// MSL altitude, available in API Level 34+.
- // It will be available only if we requested it when starting updates.
- if (QNativeInterface::QAndroidApplication::sdkVersion() >= 34) {
+ // In API Level 34 it was available only if we manually added it.
+ // In API Level 35 (and potentially later), it's automatically added
+ // to the location object, so we need to use it *only* when the user
+ // set the relevant plugin parameter.
+ if (useAltConverter && QNativeInterface::QAndroidApplication::sdkVersion() >= 34) {
attributeExists = jniObject.callMethod<jboolean>("hasMslAltitude");
if (attributeExists) {
const jdouble value = jniObject.callMethod<jdouble>("getMslAltitudeMeters");
@@ -451,7 +454,7 @@ namespace AndroidPositioning {
if (location == nullptr)
return QGeoPositionInfo();

- const QGeoPositionInfo info = positionInfoFromJavaLocation(location);
+ const QGeoPositionInfo info = positionInfoFromJavaLocation(location, useAltitudeConverter);

return info;
}
@@ -615,7 +618,6 @@ static void positionUpdated(JNIEnv *env, jobject thiz, QtJniTypes::Location loca
{
Q_UNUSED(env);
Q_UNUSED(thiz);
- QGeoPositionInfo info = AndroidPositioning::positionInfoFromJavaLocation(location.object());

QGeoPositionInfoSourceAndroid *source = AndroidPositioning::idToPosSource()->value(androidClassKey);
if (!source) {
@@ -623,6 +625,10 @@ static void positionUpdated(JNIEnv *env, jobject thiz, QtJniTypes::Location loca
return;
}

+ const bool useAltitudeConverter = source->useAltitudeConverter();
+ QGeoPositionInfo info =
+ AndroidPositioning::positionInfoFromJavaLocation(location.object(), useAltitudeConverter);
+
//we need to invoke indirectly as the Looper thread is likely to be not the same thread
if (!isSingleUpdate)
QMetaObject::invokeMethod(source, "processPositionUpdate", Qt::AutoConnection,
3 changes: 2 additions & 1 deletion vcpkg/ports/qtpositioning/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ include("${SCRIPT_PATH}/qt_install_submodule.cmake")

set(${PORT}_PATCHES
devendor-poly2tri.patch
foregroundservice.patch)
foregroundservice.patch
android15_altitude_fix.patch)

vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
Expand Down
Loading