Skip to content
Permalink
Browse files

[FEATURE][tracing curves] Trace tools generates curved geometries

  • Loading branch information
olivierdalang committed Apr 20, 2020
1 parent ab423ca commit 350a49597ba34e49b0388cc1f0358c54c7cfe473
Showing with 33 additions and 1 deletion.
  1. +33 −1 src/gui/qgsmaptoolcapture.cpp
@@ -13,8 +13,10 @@
* *
***************************************************************************/

#include "qgsmaptoolcapture.h"
#include <ogr_api.h>
#include <ogr_geometry.h>

#include "qgsmaptoolcapture.h"
#include "qgsexception.h"
#include "qgsfeatureiterator.h"
#include "qgsgeometryvalidator.h"
@@ -289,10 +291,40 @@ bool QgsMapToolCapture::tracingAddVertex( const QgsPointXY &point )
mSnappingMatches.append( QgsPointLocator::Match() );
}

// If the layer supports curves, we de-approximate curves
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( mCanvas->currentLayer() );
if ( vlayer->dataProvider()->capabilities().testFlag( QgsVectorDataProvider::Capability::CircularGeometries ) )
{
// We convert the capture curve to OGR geometry
OGRGeometry *ogrCaptureCurve;
OGRGeometryFactory::createFromWkt( mCaptureCurve.asWkt().toLocal8Bit().data(), nullptr, &ogrCaptureCurve );

// We de-approximate the curves using OGR (the geometry must be forced to linear first, as a mCaptureCurve is a CompoundCurve)
OGRGeometry *ogrLinestring = ogrCaptureCurve->getLinearGeometry(); // it must be forced to linear, as captuecurve is a compound curve
OGRGeometry *ogrRecurved = ogrLinestring->getCurveGeometry();

// We save back to mCaptureCurve
mCaptureCurve.clear();
mCaptureCurve.fromWkt( QString::fromStdString( ogrRecurved->exportToWkt() ) );
}

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

// Required to avoid this (took values from https://github.com/OSGeo/gdal/blob/master/gdal/ogr/ogrgeometry.cpp):
// qgsmaptoolcapture.cpp.obj : error LNK2019: unresolved external symbol "private: static int __cdecl OGRWktOptions::getDefaultPrecision(void)" (?getDefaultPrecision@OGRWktOptions@@CAHXZ) referenced in function "public: __cdecl OGRWktOptions::OGRWktOptions(void)" (??0OGRWktOptions@@QEAA@XZ)
// qgsmaptoolcapture.cpp.obj : error LNK2019: unresolved external symbol "private: static bool __cdecl OGRWktOptions::getDefaultRound(void)" (?getDefaultRound@OGRWktOptions@@CA_NXZ) referenced in function "public: __cdecl OGRWktOptions::OGRWktOptions(void)" (??0OGRWktOptions@@QEAA@XZ)
// output\bin\qgis_gui.dll : fatal error LNK1120: 2 unresolved externals
int OGRWktOptions::getDefaultPrecision( void )
{
return 15;
}
bool OGRWktOptions::getDefaultRound( void )
{
return true;
}

QgsRubberBand *QgsMapToolCapture::takeRubberBand()
{
return mRubberBand.release();

0 comments on commit 350a495

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