Skip to content

Commit

Permalink
Fix #38493 Circle Shape tool when layer crs != map crs
Browse files Browse the repository at this point in the history
  • Loading branch information
YoannQDQ authored and nyalldawson committed Apr 2, 2023
1 parent 66e038e commit 5f732bd
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/app/maptools/qgsmaptoolshapecircleabstract.cpp
Expand Up @@ -15,6 +15,9 @@

#include "qgsmaptoolshapecircleabstract.h"
#include "qgsmaptoolcapture.h"
#include "qgsmapcanvas.h"
#include "qgssettingsentryimpl.h"
#include "qgssettingsregistrycore.h"

void QgsMapToolShapeCircleAbstract::clean()
{
Expand All @@ -29,7 +32,19 @@ void QgsMapToolShapeCircleAbstract::addCircleToParentTool()

mParentTool->clearCurve();

std::unique_ptr<QgsCircularString> lineString( mCircle.toCircularString() );

mParentTool->addCurve( lineString.release() );
// Check whether to draw the circle as a polygon or a circular string
auto layerCrs = mParentTool->layer()->crs();
auto mapCrs = mParentTool->canvas()->mapSettings().destinationCrs();
bool drawAsPolygon = layerCrs != mapCrs;
if ( drawAsPolygon )
{
int segments = QgsSettingsRegistryCore::settingsDigitizingOffsetQuadSeg->value() * 12;
std::unique_ptr<QgsLineString> ls( mCircle.toLineString( segments ) );
mParentTool->addCurve( ls.release() );
}
else
{
std::unique_ptr<QgsCircularString> ls( mCircle.toCircularString() );
mParentTool->addCurve( ls.release() );
}
}

0 comments on commit 5f732bd

Please sign in to comment.