Skip to content
Permalink
Browse files

[tracing curves] use new line to curves api instead of OGR's

  • Loading branch information
olivierdalang committed May 11, 2020
1 parent 65ab51e commit 2ba0702752adb66d9985cdb3e8c5e18becb90c66
Showing with 3 additions and 13 deletions.
  1. +3 −13 src/gui/qgsmaptoolcapture.cpp
@@ -13,8 +13,6 @@
* *
***************************************************************************/

#include "ogr_srs_api.h"

#include "qgsmaptoolcapture.h"
#include "qgsexception.h"
#include "qgsfeatureiterator.h"
@@ -295,17 +293,9 @@ bool QgsMapToolCapture::tracingAddVertex( const QgsPointXY &point )
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( mCanvas->currentLayer() );
if ( vlayer->dataProvider()->capabilities().testFlag( QgsVectorDataProvider::Capability::CircularGeometries ) )
{
// We convert the capture curve to OGR geometry
QByteArray wkb = mCaptureCurve.asWkb();
OGRGeometryH ogrCaptureCurve;
OGR_G_CreateFromWkb( ( unsigned char *) wkb.constData(), nullptr, &ogrCaptureCurve, wkb.size() );

// We de-approximate the curves using OGR (the geometry must be forced to linear first, as a mCaptureCurve is a CompoundCurve)
OGRGeometryH ogrLinestring = OGR_G_GetLinearGeometry( ogrCaptureCurve, 0, nullptr );
OGRGeometryH ogrRecurved = OGR_G_GetCurveGeometry( ogrLinestring, nullptr );

// We save back to mCaptureCurve
mCaptureCurve = *qgsgeometry_cast<QgsCompoundCurve *>( QgsOgrUtils::ogrGeometryToQgsGeometry( ogrRecurved ).constGet() );
QgsGeometry linear = QgsGeometry( mCaptureCurve.segmentize() );
QgsGeometry curved = linear.convertToCurves();
mCaptureCurve = *qgsgeometry_cast<QgsCompoundCurve *>( curved.constGet() );
}

tracer->reportError( QgsTracer::ErrNone, true ); // clear messagebar if there was any error

0 comments on commit 2ba0702

Please sign in to comment.
You can’t perform that action at this time.