Skip to content

Commit

Permalink
new properties
Browse files Browse the repository at this point in the history
  • Loading branch information
VitorVieiraZ committed Aug 23, 2024
1 parent fd43f6c commit df49a6e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
15 changes: 10 additions & 5 deletions app/maptools/measurementmaptool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,11 @@ double MeasurementMapTool::updateDistance( const QgsPoint &crosshairPoint )

QgsPoint lastPoint = mPoints.last();

double distance = QgsDistanceArea().measureLine( crosshairPoint, lastPoint );
QgsDistanceArea mDistanceArea;
mDistanceArea.setEllipsoid( QStringLiteral( "WGS84" ) );
mDistanceArea.setSourceCrs( mapSettings()->destinationCrs(), mapSettings()->transformContext() );

return distance;
return mDistanceArea.measureLine( crosshairPoint, lastPoint );
}

void MeasurementMapTool::closeShape()
Expand All @@ -106,9 +108,12 @@ void MeasurementMapTool::closeShape()

setRecordedGeometry( polygonGeometry );

QgsDistanceArea distanceArea;
double area = distanceArea.measureArea( polygonGeometry );
double perimeter = distanceArea.measurePerimeter( polygonGeometry );
QgsDistanceArea mDistanceArea;
mDistanceArea.setEllipsoid( QStringLiteral( "WGS84" ) );
mDistanceArea.setSourceCrs( mapSettings()->destinationCrs(), mapSettings()->transformContext() );

double area = mDistanceArea.measureArea( polygonGeometry );
double perimeter = mDistanceArea.measurePerimeter( polygonGeometry );

emit shapeAreaAndPerimeter( area , perimeter );
emit canCloseShape( false );
Expand Down
3 changes: 3 additions & 0 deletions app/maptools/measurementmaptool.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ class MeasurementMapTool : public AbstractMapTool
const QgsGeometry &recordedGeometry() const;
void setRecordedGeometry( const QgsGeometry &newRecordedGeometry );

QgsVectorLayer *activeLayer() const;
void setActiveLayer( QgsVectorLayer *newActiveLayer );

signals:
void recordedGeometryChanged( const QgsGeometry &recordedGeometry );

Expand Down
20 changes: 7 additions & 13 deletions app/qml/map/MMMeasurementTools.qml
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,18 @@ Item {

signal finishMeasurement()

Component.onCompleted: map.mapSettings.extentChanged.connect( onScreenPositionChanged )
Component.onDestruction: map.mapSettings.extentChanged.disconnect( onScreenPositionChanged )

MM.MeasurementMapTool {
id: mapTool
mapSettings: root.map.mapSettings

onCanCloseShape: function( canClose ) {
measurePanel.canCloseShape = canClose;
}

onCanCloseShape: function( canClose ) { measurePanel.canCloseShape = canClose; }
onCanUndo: function( canUndo ) { measurePanel.canUndo = canUndo; }
onShapeAreaAndPerimeter: function( area, perimeter) {
measurePanel.area = area.toFixed( 1 ) + "";;
measurePanel.perimeter = perimeter.toFixed( 1 ) + " m";;
}

onCanUndo: function( canUndo ) {
measurePanel.canUndo = canUndo;
measurePanel.area = area.toFixed( 1 ) + "";
measurePanel.perimeter = perimeter.toFixed( 1 ) + " m";
}
}

Expand Down Expand Up @@ -147,7 +144,4 @@ Item {
measurePanel.canCloseShape = false
mapTool.repeat()
}


Component.onCompleted: map.mapSettings.extentChanged.connect( onScreenPositionChanged )
}

0 comments on commit df49a6e

Please sign in to comment.