|
@@ -19,6 +19,8 @@ |
|
|
#include "qgsapplication.h" |
|
|
#include "qgscoordinatereferencesystem.h" |
|
|
#include "qgsrectangle.h" |
|
|
#include "qgsgcpgeometrytransformer.h" |
|
|
#include "qgsgeometry.h" |
|
|
|
|
|
#include <QDir> |
|
|
|
|
@@ -1524,6 +1526,40 @@ class TestQgsGcpTransformer : public QObject |
|
|
QGSCOMPARENEAR( y, 186514, 1 ); |
|
|
} |
|
|
|
|
|
|
|
|
// geometry transformer |
|
|
void testGeometryTransfomer() |
|
|
{ |
|
|
QgsGcpGeometryTransformer transformer( QgsGcpTransformerInterface::TransformMethod::Projective, |
|
|
QVector< QgsPointXY >() << QgsPointXY( 288, 1126 ) |
|
|
<< QgsPointXY( 2352, 716 ) |
|
|
<< QgsPointXY( 2067, 2398 ) |
|
|
<< QgsPointXY( 1102, 2209 ), |
|
|
QVector< QgsPointXY >() << QgsPointXY( 321210, 130280 ) |
|
|
<< QgsPointXY( 322698, 129979 ) |
|
|
<< QgsPointXY( 322501, 192061 ) |
|
|
<< QgsPointXY( 321803, 192198 ) ); |
|
|
|
|
|
QgsGeometry geom = QgsGeometry::fromWkt( QStringLiteral( "LineString(288 1000, 2352 1150, 2067 2500, 1102 2300)" ) ); |
|
|
bool ok = false; |
|
|
QCOMPARE( transformer.transform( geom, ok ).asWkt( 0 ), QStringLiteral( "LineString (321256 123764, 322688 142909, 322495 197069, 321782 198051)" ) ); |
|
|
QVERIFY( ok ); |
|
|
|
|
|
// invalid parameters -- not enough GCPs |
|
|
QgsGcpGeometryTransformer transformer2( QgsGcpTransformerInterface::TransformMethod::PolynomialOrder2, |
|
|
QVector< QgsPointXY >() << QgsPointXY( 288, 1126 ) |
|
|
<< QgsPointXY( 2352, 716 ) |
|
|
<< QgsPointXY( 2067, 2398 ) |
|
|
<< QgsPointXY( 1102, 2209 ), |
|
|
QVector< QgsPointXY >() << QgsPointXY( 321210, 130280 ) |
|
|
<< QgsPointXY( 322698, 129979 ) |
|
|
<< QgsPointXY( 322501, 192061 ) |
|
|
<< QgsPointXY( 321803, 192198 ) ); |
|
|
QCOMPARE( transformer2.transform( geom, ok ).asWkt( 0 ), QStringLiteral( "LineString (288 1000, 2352 1150, 2067 2500, 1102 2300)" ) ); |
|
|
QVERIFY( !ok ); |
|
|
} |
|
|
|
|
|
|
|
|
}; |
|
|
|
|
|
QGSTEST_MAIN( TestQgsGcpTransformer ) |
|
|