mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-27 00:33:48 -05:00
fixes #18497 : Correct line size method when snapping multipolygon
This commit is contained in:
parent
394e5d8d76
commit
abda6c42ff
@ -23,6 +23,7 @@
|
||||
#include "qgsgeometryutils.h"
|
||||
#include "qgsmapsettings.h"
|
||||
#include "qgssurface.h"
|
||||
#include "qgsmultisurface.h"
|
||||
#include "qgscurve.h"
|
||||
|
||||
///@cond PRIVATE
|
||||
@ -718,7 +719,7 @@ int QgsGeometrySnapper::polyLineSize( const QgsAbstractGeometry *geom, int iPart
|
||||
{
|
||||
int nVerts = geom->vertexCount( iPart, iRing );
|
||||
|
||||
if ( qgsgeometry_cast< const QgsSurface * >( geom ) )
|
||||
if ( qgsgeometry_cast< const QgsSurface * >( geom ) || qgsgeometry_cast< const QgsMultiSurface * >( geom ) )
|
||||
{
|
||||
QgsPoint front = geom->vertexAt( QgsVertexId( iPart, iRing, 0 ) );
|
||||
QgsPoint back = geom->vertexAt( QgsVertexId( iPart, iRing, nVerts - 1 ) );
|
||||
|
@ -50,6 +50,7 @@ class TestQgsGeometrySnapper : public QObject
|
||||
void internalSnapper();
|
||||
void insertExtra();
|
||||
void duplicateNodes();
|
||||
void snapMultiPolygonToPolygon();
|
||||
};
|
||||
|
||||
void TestQgsGeometrySnapper::initTestCase()
|
||||
@ -612,6 +613,24 @@ void TestQgsGeometrySnapper::duplicateNodes()
|
||||
|
||||
}
|
||||
|
||||
void TestQgsGeometrySnapper::snapMultiPolygonToPolygon()
|
||||
{
|
||||
QgsVectorLayer *rl = new QgsVectorLayer( QStringLiteral( "Polygon" ), QStringLiteral( "x" ), QStringLiteral( "memory" ) );
|
||||
QgsFeature ff( 0 );
|
||||
QgsGeometry refGeom = QgsGeometry::fromWkt( QStringLiteral( "Polygon((0 0, 10 0, 10 10, 0 10, 0 0))" ) );
|
||||
ff.setGeometry( refGeom );
|
||||
QgsFeatureList flist;
|
||||
flist << ff;
|
||||
rl->dataProvider()->addFeatures( flist );
|
||||
|
||||
// test MultiPolygon that could be removed in the process https://issues.qgis.org/issues/18497
|
||||
QgsGeometry polygonGeom = QgsGeometry::fromWkt( QStringLiteral( "MultiPolygon(((0.1 -0.1, 5 0.1, 9.9 0.1, 0.1 -0.1)))" ) );
|
||||
QgsGeometrySnapper snapper( rl );
|
||||
QgsGeometry result = snapper.snapGeometry( polygonGeom, 1 );
|
||||
QCOMPARE( result.asWkt(), QStringLiteral( "MultiPolygon (((0 0, 5 0, 10 0, 0 0)))" ) );
|
||||
|
||||
}
|
||||
|
||||
|
||||
QGSTEST_MAIN( TestQgsGeometrySnapper )
|
||||
#include "testqgsgeometrysnapper.moc"
|
||||
|
Loading…
x
Reference in New Issue
Block a user