Skip to content
Permalink
Browse files

QgsArcGisRestUtils::parseCompoundCurve(): fix crash on CircularString…

… / "c"

Spotted by cppcheck

Independently of this fix, it looks like the geometry building when
mixing linestrings and circularstrings would need some more love...
  • Loading branch information
rouault authored and nyalldawson committed May 18, 2020
1 parent 996d812 commit 7762168e7743a25900c128270e187b6e0f811f89
Showing with 12 additions and 1 deletion.
  1. +2 −1 src/providers/arcgisrest/qgsarcgisrestutils.cpp
  2. +10 −0 tests/src/providers/testqgsarcgisrestutils.cpp
@@ -171,12 +171,13 @@ std::unique_ptr< QgsCompoundCurve > QgsArcGisRestUtils::parseCompoundCurve( cons
if ( compoundCurve->curveAt( compoundCurve->nCurves() - 1 )->nCoordinates() < 2 )
compoundCurve->removeCurve( compoundCurve->nCurves() - 1 );

const QgsPoint endPointCircularString = circularString->endPoint();
compoundCurve->addCurve( circularString.release() );

// Prepare a new line string
lineString = new QgsLineString;
compoundCurve->addCurve( lineString );
lineString->addVertex( circularString->endPoint() );
lineString->addVertex( endPointCircularString );
}
}
return compoundCurve;
@@ -54,6 +54,7 @@ class TestQgsArcGisRestUtils : public QObject
void testParseRendererSimple();
void testParseRendererCategorized();
void testParseLabeling();
void testParseCompoundCurve();

private:

@@ -607,5 +608,14 @@ QVariantMap TestQgsArcGisRestUtils::jsonStringToMap( const QString &string ) con
return doc.object().toVariantMap();
}

void TestQgsArcGisRestUtils::testParseCompoundCurve()
{
QVariantMap map = jsonStringToMap( "{\"curvePaths\": [[[6,3],[5,3],{\"c\": [[3,3],[1,4]]}]]}" );
std::unique_ptr< QgsMultiCurve > curve( QgsArcGisRestUtils::parseEsriGeometryPolyline( map, QgsWkbTypes::Point ) );
QVERIFY( curve );
// FIXME: the final linestring with one single point (1 4) is wrong !
QCOMPARE( curve->asWkt(), QStringLiteral( "MultiCurve (CompoundCurve ((6 3, 5 3),CircularString (5 3, 3 3, 1 4),(1 4)))" ) );
}

QGSTEST_MAIN( TestQgsArcGisRestUtils )
#include "testqgsarcgisrestutils.moc"

0 comments on commit 7762168

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