mirror of
https://github.com/qgis/QGIS.git
synced 2025-11-22 00:14:55 -05:00
add tests for multi point class
This commit is contained in:
parent
9122cb5564
commit
f62079b3a8
@ -43,6 +43,7 @@ class TestQgsMultiPoint: public QObject
|
||||
void clear();
|
||||
void assignment();
|
||||
void cast();
|
||||
void isValid();
|
||||
void toCurveType();
|
||||
void toFromWKB();
|
||||
void toFromWKBWithZ();
|
||||
@ -59,6 +60,7 @@ class TestQgsMultiPoint: public QObject
|
||||
void closestSegment();
|
||||
void boundingBox();
|
||||
void boundary();
|
||||
void segmentLength();
|
||||
};
|
||||
|
||||
void TestQgsMultiPoint::constructor()
|
||||
@ -353,6 +355,16 @@ void TestQgsMultiPoint::insertGeometry()
|
||||
|
||||
QVERIFY( mp.isEmpty() );
|
||||
QCOMPARE( mp.numGeometries(), 0 );
|
||||
|
||||
mp.insertGeometry( new QgsPoint(), 0 );
|
||||
|
||||
QVERIFY( mp.isEmpty() );
|
||||
QCOMPARE( mp.numGeometries(), 1 );
|
||||
|
||||
mp.insertGeometry( new QgsPoint( 0, 0 ), 0 );
|
||||
|
||||
QVERIFY( !mp.isEmpty() );
|
||||
QCOMPARE( mp.numGeometries(), 2 );
|
||||
}
|
||||
|
||||
void TestQgsMultiPoint::clone()
|
||||
@ -426,6 +438,20 @@ void TestQgsMultiPoint::cast()
|
||||
QVERIFY( QgsMultiPoint().cast( &mp ) );
|
||||
}
|
||||
|
||||
void TestQgsMultiPoint::isValid()
|
||||
{
|
||||
QString error;
|
||||
|
||||
QgsMultiPoint mp;
|
||||
QVERIFY( mp.isValid( error ) );
|
||||
|
||||
mp.addGeometry( new QgsPoint() );
|
||||
QVERIFY( mp.isValid( error ) );
|
||||
|
||||
mp.addGeometry( new QgsPoint( 0, 0 ) );
|
||||
QVERIFY( mp.isValid( error ) );
|
||||
}
|
||||
|
||||
void TestQgsMultiPoint::toCurveType()
|
||||
{
|
||||
QgsMultiPoint mp;
|
||||
@ -607,6 +633,22 @@ void TestQgsMultiPoint::exportImport()
|
||||
QCOMPARE( exportC.asKml(), expectedKml );
|
||||
QString expectedKmlPrec3( QStringLiteral( "<MultiGeometry><Point><coordinates>1.111,11.111</coordinates></Point><Point><coordinates>1.333,0.667</coordinates></Point></MultiGeometry>" ) );
|
||||
QCOMPARE( exportFloat.asKml( 3 ), expectedKmlPrec3 );
|
||||
|
||||
QgsMultiPoint exportZ;
|
||||
exportZ.addGeometry( new QgsPoint( QgsWkbTypes::PointZ, 0, 10, 0 ) );
|
||||
exportZ.addGeometry( new QgsPoint( QgsWkbTypes::PointZ, 10, 0, 1 ) );
|
||||
|
||||
QString expectedJsonZ( "{\"coordinates\":[[0.0,10.0,0.0],[10.0,0.0,1.0]],\"type\":\"MultiPoint\"}" );
|
||||
res = exportZ.asJson();
|
||||
QCOMPARE( res, expectedJsonZ );
|
||||
|
||||
QgsMultiPoint exportM;
|
||||
exportM.addGeometry( new QgsPoint( QgsWkbTypes::PointM, 0, 10, 0 ) );
|
||||
exportM.addGeometry( new QgsPoint( QgsWkbTypes::PointM, 10, 0, 1 ) );
|
||||
|
||||
QString expectedJsonM( "{\"coordinates\":[[0.0,10.0],[10.0,0.0]],\"type\":\"MultiPoint\"}" );
|
||||
res = exportM.asJson();
|
||||
QCOMPARE( res, expectedJsonM );
|
||||
}
|
||||
|
||||
void TestQgsMultiPoint::vertexNumberFromVertexId()
|
||||
@ -754,5 +796,16 @@ void TestQgsMultiPoint::boundary()
|
||||
QVERIFY( !mp.boundary() );
|
||||
}
|
||||
|
||||
void TestQgsMultiPoint::segmentLength()
|
||||
{
|
||||
QgsMultiPoint mp;
|
||||
QCOMPARE( mp.segmentLength( QgsVertexId( 0, 0, 0 ) ), 0.0 );
|
||||
|
||||
mp.addGeometry( new QgsPoint( 0, 0 ) );
|
||||
mp.addGeometry( new QgsPoint( 1, 1 ) );
|
||||
|
||||
QCOMPARE( mp.segmentLength( QgsVertexId( 1, 0, 0 ) ), 0.0 );
|
||||
}
|
||||
|
||||
QGSTEST_MAIN( TestQgsMultiPoint )
|
||||
#include "testqgsmultipoint.moc"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user