"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tests/src/core/testqgscoordinatereferencesystem.cpp" between
QGIS-final-3_10_11.tar.gz and QGIS-final-3_10_12.tar.gz

About: QGIS (Quantum GIS) is a Geographic Information System that supports vector, raster, and database formats. Long-term release (3.10.x series).

testqgscoordinatereferencesystem.cpp  (QGIS-final-3_10_11):testqgscoordinatereferencesystem.cpp  (QGIS-final-3_10_12)
skipping to change at line 329 skipping to change at line 329
QCOMPARE( myCrs.ellipsoidAcronym(), QStringLiteral( "WGS84" ) ); QCOMPARE( myCrs.ellipsoidAcronym(), QStringLiteral( "WGS84" ) );
#endif #endif
myCrs = QgsCoordinateReferenceSystem::fromOgcWmsCrs( QStringLiteral( "not a cr s" ) ); myCrs = QgsCoordinateReferenceSystem::fromOgcWmsCrs( QStringLiteral( "not a cr s" ) );
QVERIFY( !myCrs.isValid() ); QVERIFY( !myCrs.isValid() );
} }
void TestQgsCoordinateReferenceSystem::ogcWmsCrsCache() void TestQgsCoordinateReferenceSystem::ogcWmsCrsCache()
{ {
// test that crs can be retrieved correctly from cache // test that crs can be retrieved correctly from cache
QgsCoordinateReferenceSystem crs = QgsCoordinateReferenceSystem::fromOgcWmsCrs QgsCoordinateReferenceSystem crs;
( QStringLiteral( "EPSG:4326" ) ); QVERIFY( crs.createFromOgcWmsCrs( QStringLiteral( "EPSG:4326" ) ) );
QVERIFY( crs.isValid() ); QVERIFY( crs.isValid() );
QCOMPARE( crs.authid(), QStringLiteral( "EPSG:4326" ) ); QCOMPARE( crs.authid(), QStringLiteral( "EPSG:4326" ) );
QVERIFY( QgsCoordinateReferenceSystem::sOgcCache.contains( QStringLiteral( "EP SG:4326" ) ) ); QVERIFY( QgsCoordinateReferenceSystem::sOgcCache.contains( QStringLiteral( "EP SG:4326" ) ) );
// a second time, so crs is fetched from cache // a second time, so crs is fetched from cache
QgsCoordinateReferenceSystem crs2 = QgsCoordinateReferenceSystem::fromOgcWmsCr QgsCoordinateReferenceSystem crs2;
s( QStringLiteral( "EPSG:4326" ) ); QVERIFY( crs2.createFromOgcWmsCrs( QStringLiteral( "EPSG:4326" ) ) );
QVERIFY( crs2.isValid() ); QVERIFY( crs2.isValid() );
QCOMPARE( crs2.authid(), QStringLiteral( "EPSG:4326" ) ); QCOMPARE( crs2.authid(), QStringLiteral( "EPSG:4326" ) );
// invalid // invalid
QgsCoordinateReferenceSystem crs3 = QgsCoordinateReferenceSystem::fromOgcWmsCr QgsCoordinateReferenceSystem crs3;
s( QStringLiteral( "not a CRS" ) ); QVERIFY( !crs3.createFromOgcWmsCrs( QStringLiteral( "not a CRS" ) ) );
QVERIFY( !crs3.isValid() ); QVERIFY( !crs3.isValid() );
QVERIFY( QgsCoordinateReferenceSystem::sOgcCache.contains( QStringLiteral( "no t a CRS" ) ) ); QVERIFY( QgsCoordinateReferenceSystem::sOgcCache.contains( QStringLiteral( "no t a CRS" ) ) );
// a second time, so invalid crs is fetched from cache // a second time, so invalid crs is fetched from cache
QgsCoordinateReferenceSystem crs4 = QgsCoordinateReferenceSystem::fromOgcWmsCr QgsCoordinateReferenceSystem crs4;
s( QStringLiteral( "not a CRS" ) ); QVERIFY( !crs4.createFromOgcWmsCrs( QStringLiteral( "not a CRS" ) ) );
QVERIFY( !crs4.isValid() ); QVERIFY( !crs4.isValid() );
QgsCoordinateReferenceSystem::invalidateCache(); QgsCoordinateReferenceSystem::invalidateCache();
QVERIFY( !QgsCoordinateReferenceSystem::sOgcCache.contains( QStringLiteral( "E PSG:4326" ) ) ); QVERIFY( !QgsCoordinateReferenceSystem::sOgcCache.contains( QStringLiteral( "E PSG:4326" ) ) );
} }
void TestQgsCoordinateReferenceSystem::createFromSrid() void TestQgsCoordinateReferenceSystem::createFromSrid()
{ {
QgsCoordinateReferenceSystem myCrs; QgsCoordinateReferenceSystem myCrs;
myCrs.createFromPostgisSrid( GEOSRID ); myCrs.createFromPostgisSrid( GEOSRID );
skipping to change at line 381 skipping to change at line 385
QCOMPARE( crs.authid(), QStringLiteral( "EPSG:3112" ) ); QCOMPARE( crs.authid(), QStringLiteral( "EPSG:3112" ) );
QVERIFY( QgsCoordinateReferenceSystem::sSrIdCache.contains( 3112 ) ); QVERIFY( QgsCoordinateReferenceSystem::sSrIdCache.contains( 3112 ) );
// a second time, so crs is fetched from cache // a second time, so crs is fetched from cache
QgsCoordinateReferenceSystem crs2; QgsCoordinateReferenceSystem crs2;
crs2.createFromPostgisSrid( 3112 ); crs2.createFromPostgisSrid( 3112 );
QVERIFY( crs2.isValid() ); QVERIFY( crs2.isValid() );
QCOMPARE( crs2.authid(), QStringLiteral( "EPSG:3112" ) ); QCOMPARE( crs2.authid(), QStringLiteral( "EPSG:3112" ) );
// invalid // invalid
QgsCoordinateReferenceSystem crs3; QgsCoordinateReferenceSystem crs3;
crs3.createFromPostgisSrid( -3141 ); QVERIFY( !crs3.createFromPostgisSrid( -3141 ) );
QVERIFY( !crs3.isValid() ); QVERIFY( !crs3.isValid() );
QVERIFY( QgsCoordinateReferenceSystem::sSrIdCache.contains( -3141 ) ); QVERIFY( QgsCoordinateReferenceSystem::sSrIdCache.contains( -3141 ) );
// a second time, so invalid crs is fetched from cache // a second time, so invalid crs is fetched from cache
QgsCoordinateReferenceSystem crs4; QgsCoordinateReferenceSystem crs4;
crs4.createFromPostgisSrid( -3141 ); QVERIFY( !crs4.createFromPostgisSrid( -3141 ) );
QVERIFY( !crs4.isValid() ); QVERIFY( !crs4.isValid() );
QgsCoordinateReferenceSystem::invalidateCache(); QgsCoordinateReferenceSystem::invalidateCache();
QVERIFY( !QgsCoordinateReferenceSystem::sSrIdCache.contains( 3112 ) ); QVERIFY( !QgsCoordinateReferenceSystem::sSrIdCache.contains( 3112 ) );
} }
void TestQgsCoordinateReferenceSystem::createFromWkt() void TestQgsCoordinateReferenceSystem::createFromWkt()
{ {
QgsCoordinateReferenceSystem myCrs; QgsCoordinateReferenceSystem myCrs;
myCrs.createFromWkt( GEOWKT ); myCrs.createFromWkt( GEOWKT );
skipping to change at line 530 skipping to change at line 534
QVERIFY( myCrs.isValid() ); QVERIFY( myCrs.isValid() );
QCOMPARE( myCrs.srsid(), GEOCRS_ID ); QCOMPARE( myCrs.srsid(), GEOCRS_ID );
myCrs = QgsCoordinateReferenceSystem::fromWkt( QStringLiteral( "not wkt" ) ); myCrs = QgsCoordinateReferenceSystem::fromWkt( QStringLiteral( "not wkt" ) );
QVERIFY( !myCrs.isValid() ); QVERIFY( !myCrs.isValid() );
} }
void TestQgsCoordinateReferenceSystem::wktCache() void TestQgsCoordinateReferenceSystem::wktCache()
{ {
// test that crs can be retrieved correctly from cache // test that crs can be retrieved correctly from cache
QgsCoordinateReferenceSystem crs; QgsCoordinateReferenceSystem crs;
crs.createFromWkt( GEOWKT ); QVERIFY( crs.createFromWkt( GEOWKT ) );
QVERIFY( crs.isValid() ); QVERIFY( crs.isValid() );
QCOMPARE( crs.srsid(), GEOCRS_ID ); QCOMPARE( crs.srsid(), GEOCRS_ID );
QVERIFY( QgsCoordinateReferenceSystem::sWktCache.contains( GEOWKT ) ); QVERIFY( QgsCoordinateReferenceSystem::sWktCache.contains( GEOWKT ) );
// a second time, so crs is fetched from cache // a second time, so crs is fetched from cache
QgsCoordinateReferenceSystem crs2; QgsCoordinateReferenceSystem crs2;
crs2.createFromWkt( GEOWKT ); QVERIFY( crs2.createFromWkt( GEOWKT ) );
QVERIFY( crs2.isValid() ); QVERIFY( crs2.isValid() );
QCOMPARE( crs2.srsid(), GEOCRS_ID ); QCOMPARE( crs2.srsid(), GEOCRS_ID );
// invalid // invalid
QgsCoordinateReferenceSystem crs3; QgsCoordinateReferenceSystem crs3;
crs3.createFromWkt( QStringLiteral( "bad wkt" ) ); QVERIFY( !crs3.createFromWkt( QStringLiteral( "bad wkt" ) ) );
QVERIFY( !crs3.isValid() ); QVERIFY( !crs3.isValid() );
QVERIFY( QgsCoordinateReferenceSystem::sWktCache.contains( QStringLiteral( "ba d wkt" ) ) ); QVERIFY( QgsCoordinateReferenceSystem::sWktCache.contains( QStringLiteral( "ba d wkt" ) ) );
// a second time, so invalid crs is fetched from cache // a second time, so invalid crs is fetched from cache
QgsCoordinateReferenceSystem crs4; QgsCoordinateReferenceSystem crs4;
crs4.createFromWkt( QStringLiteral( "bad wkt" ) ); QVERIFY( !crs4.createFromWkt( QStringLiteral( "bad wkt" ) ) );
QVERIFY( !crs4.isValid() ); QVERIFY( !crs4.isValid() );
QgsCoordinateReferenceSystem::invalidateCache(); QgsCoordinateReferenceSystem::invalidateCache();
QVERIFY( !QgsCoordinateReferenceSystem::sWktCache.contains( GEOWKT ) ); QVERIFY( !QgsCoordinateReferenceSystem::sWktCache.contains( GEOWKT ) );
} }
QString TestQgsCoordinateReferenceSystem::testESRIWkt( int i, QgsCoordinateRefer enceSystem &myCrs ) QString TestQgsCoordinateReferenceSystem::testESRIWkt( int i, QgsCoordinateRefer enceSystem &myCrs )
{ {
debugPrint( myCrs ); debugPrint( myCrs );
skipping to change at line 687 skipping to change at line 691
QVERIFY( myCrs.isValid() ); QVERIFY( myCrs.isValid() );
QCOMPARE( myCrs.srsid(), GEOCRS_ID ); QCOMPARE( myCrs.srsid(), GEOCRS_ID );
myCrs = QgsCoordinateReferenceSystem::fromSrsId( -9999 ); myCrs = QgsCoordinateReferenceSystem::fromSrsId( -9999 );
QVERIFY( !myCrs.isValid() ); QVERIFY( !myCrs.isValid() );
} }
void TestQgsCoordinateReferenceSystem::srsIdCache() void TestQgsCoordinateReferenceSystem::srsIdCache()
{ {
// test that crs can be retrieved correctly from cache // test that crs can be retrieved correctly from cache
QgsCoordinateReferenceSystem crs; QgsCoordinateReferenceSystem crs;
crs.createFromSrsId( GEOCRS_ID ); QVERIFY( crs.createFromSrsId( GEOCRS_ID ) );
QVERIFY( crs.isValid() ); QVERIFY( crs.isValid() );
QCOMPARE( crs.srsid(), GEOCRS_ID ); QCOMPARE( crs.srsid(), GEOCRS_ID );
QVERIFY( QgsCoordinateReferenceSystem::sSrsIdCache.contains( GEOCRS_ID ) ); QVERIFY( QgsCoordinateReferenceSystem::sSrsIdCache.contains( GEOCRS_ID ) );
// a second time, so crs is fetched from cache // a second time, so crs is fetched from cache
QgsCoordinateReferenceSystem crs2; QgsCoordinateReferenceSystem crs2;
crs2.createFromSrsId( GEOCRS_ID ); QVERIFY( crs2.createFromSrsId( GEOCRS_ID ) );
QVERIFY( crs2.isValid() ); QVERIFY( crs2.isValid() );
QCOMPARE( crs2.srsid(), GEOCRS_ID ); QCOMPARE( crs2.srsid(), GEOCRS_ID );
// invalid // invalid
QgsCoordinateReferenceSystem crs3; QgsCoordinateReferenceSystem crs3;
crs3.createFromSrsId( -5141 ); QVERIFY( !crs3.createFromSrsId( -5141 ) );
QVERIFY( !crs3.isValid() ); QVERIFY( !crs3.isValid() );
QVERIFY( QgsCoordinateReferenceSystem::sSrsIdCache.contains( -5141 ) ); QVERIFY( QgsCoordinateReferenceSystem::sSrsIdCache.contains( -5141 ) );
// a second time, so invalid crs is fetched from cache // a second time, so invalid crs is fetched from cache
QgsCoordinateReferenceSystem crs4; QgsCoordinateReferenceSystem crs4;
crs4.createFromSrsId( -5141 ); QVERIFY( !crs4.createFromSrsId( -5141 ) );
QVERIFY( !crs4.isValid() ); QVERIFY( !crs4.isValid() );
QgsCoordinateReferenceSystem::invalidateCache(); QgsCoordinateReferenceSystem::invalidateCache();
QVERIFY( !QgsCoordinateReferenceSystem::sSrsIdCache.contains( GEOCRS_ID ) ); QVERIFY( !QgsCoordinateReferenceSystem::sSrsIdCache.contains( GEOCRS_ID ) );
} }
void TestQgsCoordinateReferenceSystem::createFromProj() void TestQgsCoordinateReferenceSystem::createFromProj()
{ {
QgsCoordinateReferenceSystem myCrs; QgsCoordinateReferenceSystem myCrs;
QVERIFY( !myCrs.createFromProj( QString() ) ); QVERIFY( !myCrs.createFromProj( QString() ) );
skipping to change at line 743 skipping to change at line 747
QVERIFY( myCrs.isValid() ); QVERIFY( myCrs.isValid() );
QCOMPARE( myCrs.srsid(), GEOCRS_ID ); QCOMPARE( myCrs.srsid(), GEOCRS_ID );
myCrs = QgsCoordinateReferenceSystem::fromProj( QString() ); myCrs = QgsCoordinateReferenceSystem::fromProj( QString() );
QVERIFY( !myCrs.isValid() ); QVERIFY( !myCrs.isValid() );
} }
void TestQgsCoordinateReferenceSystem::proj4Cache() void TestQgsCoordinateReferenceSystem::proj4Cache()
{ {
// test that crs can be retrieved correctly from cache // test that crs can be retrieved correctly from cache
QgsCoordinateReferenceSystem crs; QgsCoordinateReferenceSystem crs;
crs.createFromProj( GEOPROJ4 ); QVERIFY( crs.createFromProj( GEOPROJ4 ) );
QVERIFY( crs.isValid() ); QVERIFY( crs.isValid() );
QCOMPARE( crs.srsid(), GEOCRS_ID ); QCOMPARE( crs.srsid(), GEOCRS_ID );
QVERIFY( QgsCoordinateReferenceSystem::sProj4Cache.contains( GEOPROJ4 ) ); QVERIFY( QgsCoordinateReferenceSystem::sProj4Cache.contains( GEOPROJ4 ) );
// a second time, so crs is fetched from cache // a second time, so crs is fetched from cache
QgsCoordinateReferenceSystem crs2; QgsCoordinateReferenceSystem crs2;
crs2.createFromProj( GEOPROJ4 ); QVERIFY( crs2.createFromProj( GEOPROJ4 ) );
QVERIFY( crs2.isValid() ); QVERIFY( crs2.isValid() );
QCOMPARE( crs2.srsid(), GEOCRS_ID ); QCOMPARE( crs2.srsid(), GEOCRS_ID );
// invalid // invalid
QgsCoordinateReferenceSystem crs3; QgsCoordinateReferenceSystem crs3;
crs3.createFromProj( QStringLiteral( "bad proj4" ) ); QVERIFY( !crs3.createFromProj( QStringLiteral( "bad proj4" ) ) );
QVERIFY( !crs3.isValid() ); QVERIFY( !crs3.isValid() );
QVERIFY( QgsCoordinateReferenceSystem::sProj4Cache.contains( QStringLiteral( " bad proj4" ) ) ); QVERIFY( QgsCoordinateReferenceSystem::sProj4Cache.contains( QStringLiteral( " bad proj4" ) ) );
// a second time, so invalid crs is fetched from cache // a second time, so invalid crs is fetched from cache
QgsCoordinateReferenceSystem crs4; QgsCoordinateReferenceSystem crs4;
crs4.createFromProj( QStringLiteral( "bad proj4" ) ); QVERIFY( !crs4.createFromProj( QStringLiteral( "bad proj4" ) ) );
QVERIFY( !crs4.isValid() ); QVERIFY( !crs4.isValid() );
QgsCoordinateReferenceSystem::invalidateCache(); QgsCoordinateReferenceSystem::invalidateCache();
QVERIFY( !QgsCoordinateReferenceSystem::sProj4Cache.contains( GEOPROJ4 ) ); QVERIFY( !QgsCoordinateReferenceSystem::sProj4Cache.contains( GEOPROJ4 ) );
} }
void TestQgsCoordinateReferenceSystem::fromString() void TestQgsCoordinateReferenceSystem::fromString()
{ {
QgsCoordinateReferenceSystem crs; QgsCoordinateReferenceSystem crs;
crs.createFromString( QStringLiteral( "woohooo" ) ); crs.createFromString( QStringLiteral( "woohooo" ) );
skipping to change at line 812 skipping to change at line 816
crs.createFromString( QStringLiteral( "IAU2000:69918" ) ); crs.createFromString( QStringLiteral( "IAU2000:69918" ) );
QVERIFY( crs.isValid() ); QVERIFY( crs.isValid() );
QCOMPARE( crs.authid(), QStringLiteral( "IAU2000:69918" ) ); QCOMPARE( crs.authid(), QStringLiteral( "IAU2000:69918" ) );
#endif #endif
} }
void TestQgsCoordinateReferenceSystem::fromStringCache() void TestQgsCoordinateReferenceSystem::fromStringCache()
{ {
// test that crs can be retrieved correctly from cache // test that crs can be retrieved correctly from cache
QgsCoordinateReferenceSystem crs; QgsCoordinateReferenceSystem crs;
crs.createFromString( QStringLiteral( "EPSG:3113" ) ); QVERIFY( crs.createFromString( QStringLiteral( "EPSG:3113" ) ) );
QVERIFY( crs.isValid() ); QVERIFY( crs.isValid() );
QCOMPARE( crs.authid(), QStringLiteral( "EPSG:3113" ) ); QCOMPARE( crs.authid(), QStringLiteral( "EPSG:3113" ) );
QVERIFY( QgsCoordinateReferenceSystem::sStringCache.contains( QStringLiteral( "EPSG:3113" ) ) ); QVERIFY( QgsCoordinateReferenceSystem::sStringCache.contains( QStringLiteral( "EPSG:3113" ) ) );
// a second time, so crs is fetched from cache // a second time, so crs is fetched from cache
QgsCoordinateReferenceSystem crs2; QgsCoordinateReferenceSystem crs2;
crs2.createFromString( QStringLiteral( "EPSG:3113" ) ); QVERIFY( crs2.createFromString( QStringLiteral( "EPSG:3113" ) ) );
QVERIFY( crs2.isValid() ); QVERIFY( crs2.isValid() );
QCOMPARE( crs2.authid(), QStringLiteral( "EPSG:3113" ) ); QCOMPARE( crs2.authid(), QStringLiteral( "EPSG:3113" ) );
// invalid // invalid
QgsCoordinateReferenceSystem crs3; QgsCoordinateReferenceSystem crs3;
crs3.createFromString( QStringLiteral( "bad string" ) ); QVERIFY( !crs3.createFromString( QStringLiteral( "bad string" ) ) );
QVERIFY( !crs3.isValid() ); QVERIFY( !crs3.isValid() );
QVERIFY( QgsCoordinateReferenceSystem::sStringCache.contains( QStringLiteral( "bad string" ) ) ); QVERIFY( QgsCoordinateReferenceSystem::sStringCache.contains( QStringLiteral( "bad string" ) ) );
// a second time, so invalid crs is fetched from cache // a second time, so invalid crs is fetched from cache
QgsCoordinateReferenceSystem crs4; QgsCoordinateReferenceSystem crs4;
crs4.createFromString( QStringLiteral( "bad string" ) ); QVERIFY( !crs4.createFromString( QStringLiteral( "bad string" ) ) );
QVERIFY( !crs4.isValid() ); QVERIFY( !crs4.isValid() );
QgsCoordinateReferenceSystem::invalidateCache(); QgsCoordinateReferenceSystem::invalidateCache();
QVERIFY( !QgsCoordinateReferenceSystem::sStringCache.contains( QStringLiteral( "EPSG:3113" ) ) ); QVERIFY( !QgsCoordinateReferenceSystem::sStringCache.contains( QStringLiteral( "EPSG:3113" ) ) );
} }
void TestQgsCoordinateReferenceSystem::isValid() void TestQgsCoordinateReferenceSystem::isValid()
{ {
QgsCoordinateReferenceSystem crs( QStringLiteral( "EPSG:4326" ) ); QgsCoordinateReferenceSystem crs( QStringLiteral( "EPSG:4326" ) );
QVERIFY( crs.isValid() ); QVERIFY( crs.isValid() );
 End of changes. 22 change blocks. 
26 lines changed or deleted 26 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)