Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Measurement Tool #3574

Merged
merged 62 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from 54 commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
cd7dc4c
styling new tool
VitorVieiraZ Aug 13, 2024
f77fc89
starting new crosshair
VitorVieiraZ Aug 13, 2024
427948d
crosshair development
VitorVieiraZ Aug 14, 2024
e20055f
adding label support to MMCrosshair
VitorVieiraZ Aug 15, 2024
6b879bc
removing unused datacrosshair
VitorVieiraZ Aug 15, 2024
6561eac
top left button support for mmdrawer
VitorVieiraZ Aug 15, 2024
04dca5d
close shape icon, new buttons for measure drawer, new connections
VitorVieiraZ Aug 15, 2024
c1317ed
measure crosshair added
VitorVieiraZ Aug 16, 2024
d4a21fc
cpp files for measurement tool + moving MMMeasureDrawer to MMMeasurem…
VitorVieiraZ Aug 16, 2024
947347e
finish measure dialog moved and connected to measurement tools
VitorVieiraZ Aug 16, 2024
b91b67c
fixing measurement tools drawer onClosed
VitorVieiraZ Aug 16, 2024
b591199
first working version
VitorVieiraZ Aug 20, 2024
ce1a6d3
close shape procedures first part
VitorVieiraZ Aug 20, 2024
91376bd
new enhancements and tool development steps
VitorVieiraZ Aug 22, 2024
012dbd6
fixing perimeter and area
VitorVieiraZ Aug 23, 2024
15b6e86
new properties
VitorVieiraZ Aug 23, 2024
af44ea9
fixing crs and ellipsoid
VitorVieiraZ Aug 23, 2024
8a963fc
converting area to project area units
VitorVieiraZ Aug 23, 2024
03d3a98
on development
VitorVieiraZ Aug 26, 2024
8c54e59
temp crs handling
VitorVieiraZ Aug 27, 2024
467f904
in progress
VitorVieiraZ Aug 27, 2024
01d647b
binding values to cpp measurement tool
VitorVieiraZ Aug 28, 2024
ba2eaae
binding values to cpp class
VitorVieiraZ Aug 28, 2024
86ce8c9
binding properties to cpp class
VitorVieiraZ Aug 28, 2024
46ba896
code organizing and new custom crosshair for measurement tool, highli…
VitorVieiraZ Aug 30, 2024
cc053f9
code cleanup plus enhancements
VitorVieiraZ Sep 4, 2024
977d7be
format cpp code
VitorVieiraZ Sep 4, 2024
497ef13
last adjustments
VitorVieiraZ Sep 4, 2024
f844efb
refinements in code
VitorVieiraZ Sep 4, 2024
f0820cf
fix linux build
VitorVieiraZ Sep 5, 2024
f68ed79
showInfoTextMessage supports more than 1 line
VitorVieiraZ Sep 6, 2024
669e434
fixing qml warnings
VitorVieiraZ Sep 10, 2024
82a75c4
post review adjustments
VitorVieiraZ Sep 11, 2024
83a3683
adding small button to gallery and testFormatAreaInProjectUnit
VitorVieiraZ Sep 23, 2024
976464e
post review measurement tool
VitorVieiraZ Sep 24, 2024
3964f64
last adjustment
VitorVieiraZ Sep 24, 2024
0183d0b
small adjustment
VitorVieiraZ Sep 24, 2024
2efa1cb
ongoing post review changes
VitorVieiraZ Sep 27, 2024
985d7a1
mapSettings handling, MMDrawerHeader text eliding, activeProject para…
VitorVieiraZ Sep 30, 2024
9c5856f
fixing tests
VitorVieiraZ Oct 1, 2024
0ca29c7
handling done button functionality
VitorVieiraZ Oct 1, 2024
32aeb20
fixing ci
VitorVieiraZ Oct 2, 2024
15c4bb4
updating finalizeMeasurement header description
VitorVieiraZ Oct 2, 2024
9e196f7
adding measurement tool tests
VitorVieiraZ Oct 3, 2024
ff5c5c7
adjust ci to produce aab
VitorVieiraZ Oct 4, 2024
00db84e
fixing aab producing ci
VitorVieiraZ Oct 4, 2024
146e13f
smaller version of drawer title
VitorVieiraZ Oct 4, 2024
6f14f69
post review changes
VitorVieiraZ Oct 7, 2024
3428de2
small renaming
VitorVieiraZ Oct 7, 2024
16ba557
binding done button to isValidGeometry property
VitorVieiraZ Oct 7, 2024
951a63f
in progress - final review changes
VitorVieiraZ Oct 11, 2024
8a6e67b
final adjustments for review
VitorVieiraZ Oct 11, 2024
cf05463
Merge branch 'master' into enhancement/measurementTool
VitorVieiraZ Oct 14, 2024
65bbbc6
Merge branch 'master' into enhancement/measurementTool
VitorVieiraZ Oct 14, 2024
b86b10b
length if done button was clicked, perimeter if close shape was clicked
VitorVieiraZ Oct 17, 2024
dd3c896
small fix
VitorVieiraZ Oct 17, 2024
4f1e62d
technical changes application
VitorVieiraZ Oct 18, 2024
7a7deb4
using locale to return units
VitorVieiraZ Oct 18, 2024
7afd49f
small fix in formatUnits
VitorVieiraZ Oct 18, 2024
1f39fc6
fixing tests
VitorVieiraZ Oct 21, 2024
8e9a40e
checking if points are equal before adding and enabling map label mou…
VitorVieiraZ Oct 21, 2024
d14f7f4
revert android CI debug changes
tomasMizera Oct 22, 2024
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: 0 additions & 3 deletions .github/workflows/android.yml
VitorVieiraZ marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,6 @@ jobs:
name: Mergin Maps ${{ env.INPUT_VERSION_CODE }} APK [v7 + v8a]

- name: build AAB
if: ${{ github.ref_name == 'master' || github.ref_type == 'tag' }}
env:
ANDROID_NDK_ROOT: ${{ steps.setup-ndk.outputs.ndk-path }}
ANDROID_NDK_HOST: darwin-x86_64
Expand All @@ -286,14 +285,12 @@ jobs:
find . | grep .aab

- name: Rename AAB artefacts
if: ${{ github.ref_name == 'master' || github.ref_type == 'tag' }}
run: |
mv \
${{ github.workspace }}/build-Input/app/android-build/build/outputs/bundle/release/android-build-release.aab \
${{ github.workspace }}/merginmaps-${{ env.INPUT_VERSION_CODE }}.aab

- name: Upload AAB to Artifacts
if: ${{ github.ref_name == 'master' || github.ref_type == 'tag' }}
uses: actions/upload-artifact@v3
with:
path: ${{ github.workspace }}/merginmaps-${{ env.INPUT_VERSION_CODE }}.aab
Expand Down
2 changes: 2 additions & 0 deletions app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ set(MM_SRCS
maptools/abstractmaptool.cpp
maptools/recordingmaptool.cpp
maptools/splittingmaptool.cpp
maptools/measurementmaptool.cpp
ios/iosimagepicker.cpp
ios/iosutils.cpp
position/providers/abstractpositionprovider.cpp
Expand Down Expand Up @@ -109,6 +110,7 @@ set(MM_HDRS
maptools/abstractmaptool.h
maptools/recordingmaptool.h
maptools/splittingmaptool.h
maptools/measurementmaptool.h
ios/iosimagepicker.h
ios/iosutils.h
position/providers/abstractpositionprovider.h
Expand Down
7 changes: 7 additions & 0 deletions app/icons/CloseShape.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions app/icons/Measure.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions app/icons/icons.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,7 @@
<file>ZoomToProject.svg</file>
<file>StakeOut.svg</file>
<file>Student.svg</file>
<file>Measure.svg</file>
<file>CloseShape.svg</file>
</qresource>
</RCC>
23 changes: 23 additions & 0 deletions app/images/NeutralMMSymbol.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/images/images.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<file>ExternalGpsGreen.svg</file>
<file>NegativeMMSymbol.svg</file>
<file>PositiveMMSymbol.svg</file>
<file>NeutralMMSymbol.svg</file>
<file>CloseAccount.svg</file>
<file>Attention.svg</file>
<file>Bubble.svg</file>
Expand Down
48 changes: 38 additions & 10 deletions app/inpututils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,27 +168,50 @@ QString InputUtils::formatNumber( const double number, int precision )
return QString::number( number, 'f', precision );
}

QString InputUtils::formatDistanceInProjectUnit( const double distanceInMeters, int precision, Qgis::DistanceUnit destUnit )
QString InputUtils::formatDistanceInProjectUnit( const double distanceInMeters, int precision, QgsProject *activeProject )
VitorVieiraZ marked this conversation as resolved.
Show resolved Hide resolved
{
Qgis::DistanceUnit distUnit = destUnit;
if ( !activeProject )
return QString();

if ( distUnit == Qgis::DistanceUnit::Unknown )
{
distUnit = QgsProject::instance()->distanceUnits();
}
return InputUtils::formatDistanceHelper( distanceInMeters, precision, activeProject->distanceUnits() );
}

if ( distUnit == Qgis::DistanceUnit::Unknown )
QString InputUtils::formatDistanceHelper( const double distanceInMeters, int precision, Qgis::DistanceUnit destUnit )
{
if ( destUnit == Qgis::DistanceUnit::Unknown )
{
return QString::number( distanceInMeters, 'f', precision );
destUnit = Qgis::DistanceUnit::Meters;
}

double factor = QgsUnitTypes::fromUnitToUnitFactor( Qgis::DistanceUnit::Meters, distUnit );
double factor = QgsUnitTypes::fromUnitToUnitFactor( Qgis::DistanceUnit::Meters, destUnit );
double distance = distanceInMeters * factor;
QString abbreviation = QgsUnitTypes::toAbbreviatedString( distUnit );
QString abbreviation = QgsUnitTypes::toAbbreviatedString( destUnit );
VitorVieiraZ marked this conversation as resolved.
Show resolved Hide resolved

return QString( "%1 %2" ).arg( QString::number( distance, 'f', precision ), abbreviation );
VitorVieiraZ marked this conversation as resolved.
Show resolved Hide resolved
}

QString InputUtils::formatAreaInProjectUnit( const double areaInSquareMeters, int precision, QgsProject *activeProject )
{
if ( !activeProject )
return QString();

return InputUtils::formatAreaHelper( areaInSquareMeters, precision, activeProject->areaUnits() );
}

QString InputUtils::formatAreaHelper( const double areaInSquareMeters, int precision, Qgis::AreaUnit destUnit )
{
if ( destUnit == Qgis::AreaUnit::Unknown )
{
destUnit = Qgis::AreaUnit::SquareMeters;
}

double factor = QgsUnitTypes::fromUnitToUnitFactor( Qgis::AreaUnit::SquareMeters, destUnit );
double area = areaInSquareMeters * factor;
QString abbreviation = QgsUnitTypes::toAbbreviatedString( destUnit );

return QString( "%1 %2" ).arg( QString::number( area, 'f', precision ), abbreviation );
}

QString InputUtils::formatDateTimeDiff( const QDateTime &tMin, const QDateTime &tMax )
{
qint64 daysDiff = tMin.daysTo( tMax );
Expand Down Expand Up @@ -2194,3 +2217,8 @@ bool InputUtils::openLink( const QString &homePath, const QString &link )

return true;
}

double InputUtils::pixelDistanceBetween( const QPointF &p1, const QPointF &p2 )
{
return std::hypot( p1.x() - p2.x(), p1.y() - p2.y() );
}
12 changes: 11 additions & 1 deletion app/inpututils.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,12 @@ class InputUtils: public QObject
Q_INVOKABLE QString getFileName( const QString &filePath );
Q_INVOKABLE QString formatProjectName( const QString &fullProjectName );
Q_INVOKABLE QString formatNumber( const double number, int precision = 1 );
Q_INVOKABLE QString formatDistanceInProjectUnit( const double distanceInMeters, int precision = 1, Qgis::DistanceUnit destUnit = Qgis::DistanceUnit::Unknown );
Q_INVOKABLE QString formatDistanceInProjectUnit( const double distanceInMeters, int precision, QgsProject *activeProject );
Q_INVOKABLE QString formatAreaInProjectUnit( const double areaInSquareMeters, int precision, QgsProject *activeProject );

static QString formatDistanceHelper( const double distanceInMeters, int precision, Qgis::DistanceUnit destUnit );
static QString formatAreaHelper( const double areaInSquareMeters, int precision, Qgis::AreaUnit destUnit );

Q_INVOKABLE void setExtentToFeature( const FeatureLayerPair &pair, InputMapSettings *mapSettings );

/**
Expand Down Expand Up @@ -579,6 +584,11 @@ class InputUtils: public QObject
*/
static QVector<QString> qgisProfilerLog();

/**
* Calculates the Euclidean distance between two pixel points
*/
static double pixelDistanceBetween( const QPointF &p1, const QPointF &p2 );

public slots:
void onQgsLogMessageReceived( const QString &message, const QString &tag, Qgis::MessageLevel level );

Expand Down
2 changes: 2 additions & 0 deletions app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
#include "maptools/abstractmaptool.h"
#include "maptools/recordingmaptool.h"
#include "maptools/splittingmaptool.h"
#include "maptools/measurementmaptool.h"

#include "layer/layertreemodel.h"
#include "layer/layertreemodelpixmapprovider.h"
Expand Down Expand Up @@ -348,6 +349,7 @@ void initDeclarative()
qmlRegisterUncreatableType< AbstractMapTool >( "mm", 1, 0, "AbstractMapTool", "Instantiate one of child map tools instead" );
qmlRegisterType< RecordingMapTool >( "mm", 1, 0, "RecordingMapTool" );
qmlRegisterType< SplittingMapTool >( "mm", 1, 0, "SplittingMapTool" );
qmlRegisterType< MeasurementMapTool >( "mm", 1, 0, "MeasurementMapTool" );
}

void addQmlImportPath( QQmlEngine &engine )
Expand Down
4 changes: 4 additions & 0 deletions app/maptools/abstractmaptool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ void AbstractMapTool::setMapSettings( InputMapSettings *newMapSettings )
{
if ( mMapSettings == newMapSettings )
return;

emit onAboutToChangeMapSettings();

mMapSettings = newMapSettings;

emit mapSettingsChanged( mMapSettings );
}
3 changes: 1 addition & 2 deletions app/maptools/abstractmaptool.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@ class AbstractMapTool : public QObject
void setMapSettings( InputMapSettings *newMapSettings );

signals:

void onAboutToChangeMapSettings();
void mapSettingsChanged( InputMapSettings *mapSettings );

private:

InputMapSettings *mMapSettings = nullptr;
};

Expand Down
Loading
Loading