Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
d3e961e
Geoid separation support for external providers (#4176)
tomasMizera Nov 19, 2025
4436062
Recalculate ellipsoid elevation to orthometric (#4210)
Withalion Nov 19, 2025
9ab6816
Refactor code to use existing QgsCoordinateTransformContext (#4228)
Withalion Nov 20, 2025
2d801ea
Geoid separation support for internal providers (#4216)
Withalion Nov 21, 2025
b09dc43
Squashed commit of the following:
Withalion Nov 24, 2025
6be4dfe
Change default value for elevation_diff
Withalion Dec 1, 2025
7f41eb1
Merge branch 'master' into dev/geoid-support
Withalion Dec 1, 2025
d02bfd3
Custom geoid support (#4238)
Withalion Dec 2, 2025
23bb99b
Fixed plural translation forms (#4183)
kaustuvpokharel Dec 3, 2025
e8d7e46
Fixed android build to sync projects (#4243)
gabriel-bolbotina Dec 3, 2025
daa06be
Refactor support for orthometric heights on iOS
Withalion Dec 4, 2025
7428d5c
Subtract antenna height from altitude
Withalion Dec 4, 2025
a7e1f63
Fix formatting & vcpkg bug
Withalion Dec 4, 2025
c9c6d14
Fix ios patch
Withalion Dec 4, 2025
d95d6ed
Fix ios patch v2
Withalion Dec 4, 2025
d1c7a7f
Fix iOS error & constness
Withalion Dec 5, 2025
c10f6bd
Fix iOS error v3
Withalion Dec 5, 2025
1957130
Add ellipsoidal elevation expr variable
Withalion Dec 5, 2025
37cf85d
Change elevation calculation
Withalion Dec 8, 2025
d3db441
Increase click area for elevation info button
Withalion Dec 8, 2025
59c5557
Merge branch 'master' into dev/geoid-support
Withalion Dec 31, 2025
cd8f19c
Use default transform for internal providers
Withalion Jan 5, 2026
b0ef9a8
Use default geoid model for android fused provider
Withalion Jan 5, 2026
29cd087
Add vertical CRS transform pass through for mock providers
Withalion Jan 6, 2026
fe08648
Add vertical CRS transfrom pass through for bluetooth provider
Withalion Jan 6, 2026
e042e32
Change android fused provider to default on android
Withalion Jan 6, 2026
41f63be
Fix GPS panel geoid model name info
Withalion Jan 6, 2026
48c1ab9
Change behaviour for internal provider on desktops
Withalion Jan 7, 2026
b186942
Use EGM96 geoid model for simulated provider
Withalion Jan 7, 2026
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
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,9 @@ file(
PATTERN "*.cmake" EXCLUDE
PATTERN "vcpkg*" EXCLUDE
)
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/app/assets/us_nga_egm96_15.tif
DESTINATION ${ASSETS_DIR_PATH}/app/android/assets/qgis-data/proj
)

message(STATUS "QGIS_QUICK_DATA_PATH set to ${QGIS_QUICK_DATA_PATH}")
# ########################################################################################
Expand Down
Binary file added app/assets/us_nga_egm96_15.tif
Binary file not shown.
59 changes: 46 additions & 13 deletions app/inpututils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ QString InputUtils::geometryLengthAsString( const QgsGeometry &geometry )
{
QgsDistanceArea distanceArea;
distanceArea.setEllipsoid( QStringLiteral( "WGS84" ) );
distanceArea.setSourceCrs( QgsCoordinateReferenceSystem::fromEpsgId( 4326 ), QgsCoordinateTransformContext() );
distanceArea.setSourceCrs( PositionKit::positionCrs2D(), QgsProject::instance()->transformContext() );

qreal length = distanceArea.measureLength( geometry );

Expand Down Expand Up @@ -880,32 +880,66 @@ QgsPoint InputUtils::transformPoint( const QgsCoordinateReferenceSystem &srcCrs,
// QGIS would convert them to a valid (0, 0) points
if ( srcPoint.isEmpty() )
{
return QgsPoint();
return {};
}

try
{
QgsCoordinateTransform ct( srcCrs, destCrs, context );
const QgsCoordinateTransform ct( srcCrs, destCrs, context );
if ( ct.isValid() )
{
if ( !ct.isShortCircuited() )
{
const QgsPointXY transformed = ct.transform( srcPoint.x(), srcPoint.y() );
const QgsPoint pt( transformed.x(), transformed.y(), srcPoint.z(), srcPoint.m() );
const QgsVector3D transformed = ct.transform( QgsVector3D( srcPoint.x(), srcPoint.y(), srcPoint.z() ) );
const QgsPoint pt( transformed.x(), transformed.y(), transformed.z(), srcPoint.m() );
return pt;
}
else

return srcPoint;
}
}
catch ( QgsCsException &cse )
{
Q_UNUSED( cse )
}

return {};
}

QgsPoint InputUtils::transformPoint( const QgsCoordinateReferenceSystem &srcCrs,
const QgsCoordinateReferenceSystem &destCrs,
const QgsCoordinateTransformContext &context,
const QgsPoint &srcPoint, bool &fallbackOperationOccurred )
{
// we do not want to transform empty points,
// QGIS would convert them to a valid (0, 0) points
if ( srcPoint.isEmpty() )
{
return {};
}

try
{
const QgsCoordinateTransform ct( srcCrs, destCrs, context );
if ( ct.isValid() )
{
if ( !ct.isShortCircuited() )
{
return srcPoint;
const QgsVector3D transformed = ct.transform( QgsVector3D( srcPoint.x(), srcPoint.y(), srcPoint.z() ) );
fallbackOperationOccurred = ct.fallbackOperationOccurred();
const QgsPoint pt( transformed.x(), transformed.y(), transformed.z(), srcPoint.m() );
return pt;
}

return srcPoint;
}
}
catch ( QgsCsException &cse )
{
Q_UNUSED( cse )
}

return QgsPoint();
return {};
}

QPointF InputUtils::transformPointToScreenCoordinates( const QgsCoordinateReferenceSystem &srcCrs, InputMapSettings *mapSettings, const QgsPoint &srcPoint )
Expand Down Expand Up @@ -954,12 +988,11 @@ QgsPoint InputUtils::mapPointToGps( QPointF mapPosition, InputMapSettings *mapSe
return QgsPoint();

QgsPoint positionMapCrs = mapSettings->screenToCoordinate( mapPosition );
QgsCoordinateReferenceSystem crsGPS = coordinateReferenceSystemFromEpsgId( 4326 );

const QgsPointXY transformedXY = transformPoint(
mapSettings->destinationCrs(),
crsGPS,
QgsCoordinateTransformContext(),
PositionKit::positionCrs2D(),
mapSettings->transformContext(),
positionMapCrs
);

Expand Down Expand Up @@ -1716,7 +1749,7 @@ qreal InputUtils::distanceBetweenGpsAndFeature( QgsPoint gpsPosition, const Feat

// Transform gps position to map CRS
QgsPointXY transformedPosition = transformPoint(
coordinateReferenceSystemFromEpsgId( 4326 ),
PositionKit::positionCrs3D(),
mapSettings->destinationCrs(),
mapSettings->transformContext(),
gpsPosition
Expand Down Expand Up @@ -1764,7 +1797,7 @@ qreal InputUtils::angleBetweenGpsAndFeature( QgsPoint gpsPoint, const FeatureLay

// Transform gps position to map CRS
QgsPointXY transformedPosition = transformPoint(
coordinateReferenceSystemFromEpsgId( 4326 ),
PositionKit::positionCrs3D(),
mapSettings->destinationCrs(),
mapSettings->transformContext(),
gpsPoint
Expand Down
8 changes: 8 additions & 0 deletions app/inpututils.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,14 @@ class InputUtils: public QObject
const QgsCoordinateTransformContext &context,
const QgsPoint &srcPoint );

/**
* Overload of transformPoint function, which also notifies the caller if PROJ fallback operation occurred
*/
static QgsPoint transformPoint( const QgsCoordinateReferenceSystem &srcCrs,
const QgsCoordinateReferenceSystem &destCrs,
const QgsCoordinateTransformContext &context,
const QgsPoint &srcPoint, bool &fallbackOperationOccurred );

/**
* Transforms point between CRS and screen pixels
* Return empty QgsPoint if the transformation could not be applied or srcPoint is empty
Expand Down
13 changes: 6 additions & 7 deletions app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -544,13 +544,13 @@ int main( int argc, char *argv[] )
LayerDetailLegendImageProvider *layerDetailLegendImageProvider( new LayerDetailLegendImageProvider );

// build position kit, save active provider to QSettings and load previously active provider
PositionKit pk;
QObject::connect( &pk, &PositionKit::positionProviderChanged, as, [as]( AbstractPositionProvider * provider )
PositionKit *pk = engine.singletonInstance<PositionKit *>( "MMInput", "PositionKit" );
QObject::connect( pk, &PositionKit::positionProviderChanged, as, [as]( AbstractPositionProvider * provider )
{
as->setActivePositionProviderId( provider ? provider->id() : QLatin1String() );
} );
pk.setPositionProvider( pk.constructActiveProvider( as ) );
pk.setAppSettings( as );
pk->setPositionProvider( PositionKit::constructActiveProvider( as ) );
pk->setAppSettings( as );

// Lambda context object can be used in all lambda functions defined here,
// it secures lambdas, so that they are destroyed when this object is destroyed to avoid crashes.
Expand Down Expand Up @@ -658,7 +658,7 @@ int main( int argc, char *argv[] )
notificationModel.addError( message );
} );
// Direct connections
QObject::connect( &app, &QGuiApplication::applicationStateChanged, &pk, &PositionKit::appStateChanged );
QObject::connect( &app, &QGuiApplication::applicationStateChanged, pk, &PositionKit::appStateChanged );
QObject::connect( &app, &QGuiApplication::applicationStateChanged, &activeProject, &ActiveProject::appStateChanged );
QObject::connect( &pw, &ProjectWizard::projectCreated, &localProjectsManager, &LocalProjectsManager::addLocalProject );
QObject::connect( &activeProject, &ActiveProject::projectReloaded, vm.get(), &VariablesManager::merginProjectChanged );
Expand Down Expand Up @@ -690,7 +690,7 @@ int main( int argc, char *argv[] )
if ( tests.testingRequested() )
{
tests.initTestDeclarative();
tests.init( ma.get(), &iu, vm.get(), &pk, as );
tests.init( ma.get(), &iu, vm.get(), pk, as );
return tests.runTest();
}
#endif
Expand Down Expand Up @@ -733,7 +733,6 @@ int main( int argc, char *argv[] )
engine.rootContext()->setContextProperty( "__projectWizard", &pw );
engine.rootContext()->setContextProperty( "__localProjectsManager", &localProjectsManager );
engine.rootContext()->setContextProperty( "__variablesManager", vm.get() );
engine.rootContext()->setContextProperty( "__positionKit", &pk );

// add image provider to pass QIcons/QImages from C++ to QML
engine.rootContext()->setContextProperty( "__layerTreeModelPixmapProvider", layerTreeModelPixmapProvider );
Expand Down
4 changes: 3 additions & 1 deletion app/map/inputcoordinatetransformer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@
*/

#include "inputcoordinatetransformer.h"

#include "positionkit.h"
#include "qgslogger.h"

InputCoordinateTransformer::InputCoordinateTransformer( QObject *parent )
: QObject( parent )
{
mCoordinateTransform.setSourceCrs( QgsCoordinateReferenceSystem::fromEpsgId( 4326 ) );
mCoordinateTransform.setSourceCrs( PositionKit::positionCrs3D() );
}

QgsPoint InputCoordinateTransformer::projectedPosition() const
Expand Down
4 changes: 2 additions & 2 deletions app/maptools/recordingmaptool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void RecordingMapTool::addPoint( const QgsPoint &point )
pointToAdd = mPositionKit->positionCoordinate();

QgsPoint transformed = InputUtils::transformPoint(
PositionKit::positionCRS(),
PositionKit::positionCrs3D(),
mActiveLayer->crs(),
mActiveLayer->transformContext(),
pointToAdd
Expand Down Expand Up @@ -594,7 +594,7 @@ void RecordingMapTool::onPositionChanged()
QgsPoint position = mPositionKit->positionCoordinate();

QgsPointXY transformed = InputUtils::transformPoint(
PositionKit::positionCRS(),
PositionKit::positionCrs3D(),
mActiveLayer->sourceCrs(),
mActiveLayer->transformContext(),
position
Expand Down
7 changes: 6 additions & 1 deletion app/position/geoposition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ GeoPosition::GeoPosition() : QgsGpsInformation()
latitude = std::numeric_limits<double>::quiet_NaN();
longitude = std::numeric_limits<double>::quiet_NaN();
elevation = std::numeric_limits<double>::quiet_NaN();
elevation_diff = std::numeric_limits<double>::quiet_NaN();
direction = -1;
speed = -1;
pdop = -1;
Expand Down Expand Up @@ -48,6 +49,11 @@ GeoPosition GeoPosition::fromQgsGpsInformation( const QgsGpsInformation &other )
out.elevation = other.elevation;
}

if ( !qgsDoubleNear( other.elevation_diff, 0 ) )
{
out.elevation_diff = other.elevation_diff;
}

if ( !std::isnan( other.direction ) )
{
out.direction = other.direction;
Expand Down Expand Up @@ -88,7 +94,6 @@ GeoPosition GeoPosition::fromQgsGpsInformation( const QgsGpsInformation &other )
out.vdop = other.vdop;
}

out.elevation_diff = other.elevation_diff;
out.satellitesVisible = other.satellitesInView.count();
out.satellitesInView = other.satellitesInView;
out.satellitesUsed = other.satellitesUsed;
Expand Down
2 changes: 2 additions & 0 deletions app/position/geoposition.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ class GeoPosition : public QgsGpsInformation

QString fixStatusString;

bool isMock = false;

// copies all data from QgsGpsInformation other and updates satellitesVisible
static GeoPosition fromQgsGpsInformation( const QgsGpsInformation &other );

Expand Down
2 changes: 1 addition & 1 deletion app/position/mapposition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ void MapPosition::recalculateMapPosition()
{
QgsPointXY srcPoint = QgsPointXY( geoposition.x(), geoposition.y() );
QgsPointXY mapPositionXY = InputUtils::transformPointXY(
mPositionKit->positionCRS(),
mPositionKit->positionCrs3D(),
mMapSettings->destinationCrs(),
mMapSettings->transformContext(),
srcPoint
Expand Down
68 changes: 65 additions & 3 deletions app/position/positionkit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,57 @@ PositionKit::PositionKit( QObject *parent )
{
}

QgsCoordinateReferenceSystem PositionKit::positionCRS()
QgsCoordinateReferenceSystem PositionKit::positionCrs3D( const bool forceDefault )
{
if ( !forceDefault )
{
bool crsExists = false;
const QString crsWktDef = QgsProject::instance()->readEntry( QStringLiteral( "Mergin" ), QStringLiteral( "TargetVerticalCRS" ), QString(), &crsExists );
if ( crsExists )
{
const QgsCoordinateReferenceSystem verticalCrs = QgsCoordinateReferenceSystem::fromWkt( crsWktDef );
QString compoundCrsError{};
const QgsCoordinateReferenceSystem compoundCrs = QgsCoordinateReferenceSystem::createCompoundCrs( positionCrs2D(), verticalCrs, compoundCrsError );
if ( compoundCrs.isValid() && compoundCrsError.isEmpty() )
{
return compoundCrs;
}
CoreUtils::log( QStringLiteral( "PositionKit" ), QStringLiteral( "Failed to create custom compound crs: %1" ).arg( compoundCrsError ) );
}
}

return QgsCoordinateReferenceSystem::fromEpsgId( 9707 );
}

QString PositionKit::positionCrs3DGeoidModelName() const
{
if ( !mPosition.isMock )
{
const QgsCoordinateReferenceSystem crs = positionCrs3D( true ).verticalCrs();
return crs.description();
}

bool valueRead = false;
const bool isVerticalCRSPassedThrough = QVariant( QgsProject::instance()->readEntry( QStringLiteral( "Mergin" ), QStringLiteral( "VerticalCRSPassThrough" ), QVariant( true ).toString(), &valueRead ) ).toBool();
if ( valueRead && !isVerticalCRSPassedThrough )
{
const QgsCoordinateReferenceSystem crs = positionCrs3D().verticalCrs();
return crs.description();
}

return {};
}

QgsCoordinateReferenceSystem PositionKit::positionCrs2D()
{
return QgsCoordinateReferenceSystem::fromEpsgId( 4326 );
}

QgsCoordinateReferenceSystem PositionKit::positionCrs3DEllipsoidHeight()
{
return QgsCoordinateReferenceSystem::fromEpsgId( 4979 );
}

void PositionKit::startUpdates()
{
if ( mPositionProvider )
Expand Down Expand Up @@ -148,7 +194,11 @@ AbstractPositionProvider *PositionKit::constructActiveProvider( AppSettings *app
{
if ( InputUtils::isMobilePlatform() )
{
#ifdef ANDROID
return constructProvider( QStringLiteral( "internal" ), QStringLiteral( "android_fused" ) );
#else
return constructProvider( QStringLiteral( "internal" ), QStringLiteral( "devicegps" ) );
#endif
}
else // desktop
{
Expand Down Expand Up @@ -205,9 +255,9 @@ void PositionKit::parsePositionUpdate( const GeoPosition &newPosition )
hasAnythingChanged = true;
}

if ( !qgsDoubleNear( newPosition.elevation, mPosition.elevation ) )
if ( !qgsDoubleNear( newPosition.elevation - antennaHeight(), mPosition.elevation ) )
{
mPosition.elevation = newPosition.elevation;
mPosition.elevation = newPosition.elevation - antennaHeight();
emit altitudeChanged( mPosition.elevation );
hasAnythingChanged = true;
}
Expand Down Expand Up @@ -323,6 +373,13 @@ void PositionKit::parsePositionUpdate( const GeoPosition &newPosition )
hasAnythingChanged = true;
}

if ( newPosition.isMock != mPosition.isMock )
{
mPosition.isMock = newPosition.isMock;
emit isMockPositionChanged( mPosition.isMock );
hasAnythingChanged = true;
}

if ( hasAnythingChanged )
{
emit positionChanged( mPosition );
Expand Down Expand Up @@ -449,6 +506,11 @@ const GeoPosition &PositionKit::position() const
return mPosition;
}

bool PositionKit::isMockPosition() const
{
return mPosition.isMock;
}

AppSettings *PositionKit::appSettings() const
{
return mAppSettings;
Expand Down
Loading
Loading