Skip to content

Commit 6adf0f8

Browse files
committedApr 6, 2012
[BACKPORT] in progress test updates / fixes
1 parent 845856e commit 6adf0f8

9 files changed

+99
-81
lines changed
 

‎src/core/qgscoordinatereferencesystem.cpp

Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,8 @@ bool QgsCoordinateReferenceSystem::createFromEpsg( long id )
211211

212212
bool QgsCoordinateReferenceSystem::createFromSrsId( long id )
213213
{
214-
return loadFromDb( id < USER_CRS_START_ID ? QgsApplication::srsDbFilePath() : QgsApplication::qgisUserDbFilePath(),
214+
return loadFromDb( id < USER_CRS_START_ID ? QgsApplication::srsDbFilePath() :
215+
QgsApplication::qgisUserDbFilePath(),
215216
"srs_id", QString::number( id ) );
216217
}
217218

@@ -252,13 +253,19 @@ bool QgsCoordinateReferenceSystem::loadFromDb( QString db, QString expression, Q
252253
is_geo integer NOT NULL);
253254
*/
254255

255-
QString mySql = "select srs_id,description,projection_acronym,ellipsoid_acronym,parameters,srid,auth_name||':'||auth_id,is_geo from tbl_srs where " + expression + "=" + quotedValue( value ) + " order by deprecated";
256-
myResult = sqlite3_prepare( myDatabase, mySql.toUtf8(), mySql.toUtf8().length(), &myPreparedStatement, &myTail );
256+
QString mySql = "select srs_id,description,projection_acronym,"
257+
"ellipsoid_acronym,parameters,srid,auth_name||':'||auth_id,is_geo "
258+
"from tbl_srs where " + expression + "=" + quotedValue( value );
259+
myResult = sqlite3_prepare( myDatabase, mySql.toUtf8(),
260+
mySql.toUtf8().length(),
261+
&myPreparedStatement, &myTail );
257262
// XXX Need to free memory from the error msg if one is set
258263
if ( myResult == SQLITE_OK && sqlite3_step( myPreparedStatement ) == SQLITE_ROW )
259264
{
260-
mSrsId = QString::fromUtf8(( char * )sqlite3_column_text( myPreparedStatement, 0 ) ).toLong();
261-
mDescription = QString::fromUtf8(( char * )sqlite3_column_text( myPreparedStatement, 1 ) );
265+
mSrsId = QString::fromUtf8(( char * )sqlite3_column_text(
266+
myPreparedStatement, 0 ) ).toLong();
267+
mDescription = QString::fromUtf8(( char * )sqlite3_column_text(
268+
myPreparedStatement, 1 ) );
262269
mProjectionAcronym = QString::fromUtf8(( char * )sqlite3_column_text( myPreparedStatement, 2 ) );
263270
mEllipsoidAcronym = QString::fromUtf8(( char * )sqlite3_column_text( myPreparedStatement, 3 ) );
264271
QString toProj4 = QString::fromUtf8(( char * )sqlite3_column_text( myPreparedStatement, 4 ) );
@@ -436,7 +443,7 @@ bool QgsCoordinateReferenceSystem::createFromProj4( const QString theProj4String
436443
* - if the above does not match perform a whole text search on proj4 string (if not null)
437444
*/
438445
// QgsDebugMsg( "wholetext match on name failed, trying proj4string match" );
439-
myRecord = getRecord( "select * from tbl_srs where parameters=" + quotedValue( theProj4String.trimmed() ) + " order by deprecated" );
446+
myRecord = getRecord( "select * from tbl_srs where parameters=" + quotedValue( theProj4String.trimmed() ) );
440447
if ( myRecord.empty() )
441448
{
442449
// Ticket #722 - aaronr
@@ -471,7 +478,7 @@ bool QgsCoordinateReferenceSystem::createFromProj4( const QString theProj4String
471478
myStart2 = myLat2RegExp.indexIn( theProj4String, myStart2 );
472479
theProj4StringModified.replace( myStart2 + LAT_PREFIX_LEN, myLength2 - LAT_PREFIX_LEN, lat1Str );
473480
QgsDebugMsg( "trying proj4string match with swapped lat_1,lat_2" );
474-
myRecord = getRecord( "select * from tbl_srs where parameters=" + quotedValue( theProj4StringModified.trimmed() ) + " order by deprecated" );
481+
myRecord = getRecord( "select * from tbl_srs where parameters=" + quotedValue( theProj4StringModified.trimmed() ) );
475482
}
476483
}
477484

@@ -504,13 +511,13 @@ bool QgsCoordinateReferenceSystem::createFromProj4( const QString theProj4String
504511

505512
if ( !datum.isEmpty() )
506513
{
507-
myRecord = getRecord( sql + delim + datum + " order by deprecated" );
514+
myRecord = getRecord( sql + delim + datum );
508515
}
509516

510517
if ( myRecord.empty() )
511518
{
512519
// datum might have disappeared in definition - retry without it
513-
myRecord = getRecord( sql + " order by deprecated" );
520+
myRecord = getRecord( sql );
514521
}
515522
}
516523

@@ -550,7 +557,7 @@ bool QgsCoordinateReferenceSystem::createFromProj4( const QString theProj4String
550557
if ( mIsValidFlag )
551558
{
552559
// but the proj.4 parsed string might already be in our database
553-
myRecord = getRecord( "select * from tbl_srs where parameters=" + quotedValue( toProj4() ) + " order by deprecated" );
560+
myRecord = getRecord( "select * from tbl_srs where parameters=" + quotedValue( toProj4() ) );
554561
if ( myRecord.empty() )
555562
{
556563
// It's not, so try to add it
@@ -560,7 +567,7 @@ bool QgsCoordinateReferenceSystem::createFromProj4( const QString theProj4String
560567
if ( mIsValidFlag )
561568
{
562569
// but validate that it's there afterwards
563-
myRecord = getRecord( "select * from tbl_srs where parameters=" + quotedValue( toProj4() ) + " order by deprecated" );
570+
myRecord = getRecord( "select * from tbl_srs where parameters=" + quotedValue( toProj4() ) );
564571
}
565572
}
566573

@@ -805,7 +812,9 @@ void QgsCoordinateReferenceSystem::setProj4String( QString theProj4String )
805812
setlocale( LC_NUMERIC, "C" );
806813
OSRDestroySpatialReference( mCRS );
807814
mCRS = OSRNewSpatialReference( NULL );
808-
mIsValidFlag = OSRImportFromProj4( mCRS, theProj4String.toLatin1().constData() ) == OGRERR_NONE;
815+
mIsValidFlag =
816+
OSRImportFromProj4( mCRS, theProj4String.toLatin1().constData() )
817+
== OGRERR_NONE;
809818
mWkt.clear();
810819
setMapUnits();
811820

@@ -901,9 +910,11 @@ void QgsCoordinateReferenceSystem::setMapUnits()
901910
long QgsCoordinateReferenceSystem::findMatchingProj()
902911
{
903912
QgsDebugMsg( "entered." );
904-
if ( mEllipsoidAcronym.isNull() || mProjectionAcronym.isNull() || !mIsValidFlag )
913+
if ( mEllipsoidAcronym.isNull() || mProjectionAcronym.isNull()
914+
|| !mIsValidFlag )
905915
{
906-
QgsDebugMsg( "QgsCoordinateReferenceSystem::findMatchingProj will only work if prj acr ellipsoid acr and proj4string are set"
916+
QgsDebugMsg( "QgsCoordinateReferenceSystem::findMatchingProj will only "
917+
"work if prj acr ellipsoid acr and proj4string are set"
907918
" and the current projection is valid!" );
908919
return 0;
909920
}
@@ -913,8 +924,10 @@ long QgsCoordinateReferenceSystem::findMatchingProj()
913924
sqlite3_stmt *myPreparedStatement;
914925
int myResult;
915926

916-
// Set up the query to retrieve the projection information needed to populate the list
917-
QString mySql = QString( "select srs_id,parameters from tbl_srs where projection_acronym=%1 and ellipsoid_acronym=%2 order by deprecated" )
927+
// Set up the query to retrieve the projection information
928+
// needed to populate the list
929+
QString mySql = QString( "select srs_id,parameters from tbl_srs where "
930+
"projection_acronym=%1 and ellipsoid_acronym=%2" )
918931
.arg( quotedValue( mProjectionAcronym ) )
919932
.arg( quotedValue( mEllipsoidAcronym ) );
920933
// Get the full path name to the sqlite3 spatial reference database.
@@ -999,7 +1012,9 @@ long QgsCoordinateReferenceSystem::findMatchingProj()
9991012

10001013
bool QgsCoordinateReferenceSystem::operator==( const QgsCoordinateReferenceSystem &theSrs ) const
10011014
{
1002-
return mIsValidFlag && theSrs.mIsValidFlag && toWkt() == theSrs.toWkt();
1015+
QString myWkt = toWkt();
1016+
QString theirWkt = theSrs.toWkt();
1017+
return mIsValidFlag && theSrs.mIsValidFlag && myWkt == theirWkt;
10031018
}
10041019

10051020
bool QgsCoordinateReferenceSystem::operator!=( const QgsCoordinateReferenceSystem &theSrs ) const
@@ -1187,7 +1202,7 @@ QString QgsCoordinateReferenceSystem::proj4FromSrsId( const int theSrsId )
11871202

11881203
QString myDatabaseFileName;
11891204
QString myProjString;
1190-
QString mySql = QString( "select parameters from tbl_srs where srs_id = %1 order by deprecated" ).arg( theSrsId );
1205+
QString mySql = QString( "select parameters from tbl_srs where srs_id = %1" ).arg( theSrsId );
11911206

11921207
QgsDebugMsg( "mySrsId = " + QString::number( theSrsId ) );
11931208
QgsDebugMsg( "USER_CRS_START_ID = " + QString::number( USER_CRS_START_ID ) );
@@ -1419,7 +1434,7 @@ int QgsCoordinateReferenceSystem::syncDb()
14191434

14201435
const char *tail;
14211436
sqlite3_stmt *select;
1422-
QString sql = "select auth_name,auth_id,parameters from tbl_srs WHERE auth_name IS NOT NULL AND auth_id IS NOT NULL order by deprecated";
1437+
QString sql = "select auth_name,auth_id,parameters from tbl_srs WHERE auth_name IS NOT NULL AND auth_id IS NOT NULL";
14231438
if ( sqlite3_prepare( database, sql.toAscii(), sql.size(), &select, &tail ) != SQLITE_OK )
14241439
{
14251440
qCritical( "Could not prepare: %s [%s]\n", sql.toAscii().constData(), sqlite3_errmsg( database ) );

‎tests/src/core/qgsrenderchecker.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ QgsRenderChecker::QgsRenderChecker( ) :
3434
{
3535

3636
}
37-
bool QgsRenderChecker::runTest( QString theTestName )
37+
bool QgsRenderChecker::runTest( QString theTestName,
38+
unsigned int theMismatchCount )
3839
{
3940
if ( mExpectedImageFile.isEmpty() )
4041
{
@@ -53,11 +54,16 @@ bool QgsRenderChecker::runTest( QString theTestName )
5354
//
5455
// Now render our layers onto a pixmap
5556
//
56-
QImage myImage( myExpectedImage.width(), myExpectedImage.height(), QImage::Format_RGB32 );
57+
QImage myImage( myExpectedImage.width(),
58+
myExpectedImage.height(),
59+
QImage::Format_RGB32 );
5760
myImage.fill( qRgb( 152, 219, 249 ) );
5861
QPainter myPainter( &myImage );
62+
myPainter.setRenderHint( QPainter::Antialiasing );
5963
mpMapRenderer->setOutputSize( QSize(
60-
myExpectedImage.width(), myExpectedImage.height() ), myExpectedImage.logicalDpiX() );
64+
myExpectedImage.width(),
65+
myExpectedImage.height() ),
66+
myExpectedImage.logicalDpiX() );
6167
QTime myTime;
6268
myTime.start();
6369
mpMapRenderer->render( &myPainter );
@@ -69,12 +75,13 @@ bool QgsRenderChecker::runTest( QString theTestName )
6975
//
7076
mRenderedImageFile = QDir::tempPath() + QDir::separator() + theTestName + "_result.png";
7177
myImage.save( mRenderedImageFile );
72-
return compareImages( theTestName );
78+
return compareImages( theTestName, theMismatchCount );
7379

7480
}
7581

7682

77-
bool QgsRenderChecker::compareImages( QString theTestName )
83+
bool QgsRenderChecker::compareImages( QString theTestName,
84+
unsigned int theMismatchCount )
7885
{
7986
if ( mExpectedImageFile.isEmpty() )
8087
{
@@ -190,7 +197,7 @@ bool QgsRenderChecker::compareImages( QString theTestName )
190197
mReport += "</td></tr>";
191198

192199

193-
if ( mMismatchCount == 0 )
200+
if ( mMismatchCount <= theMismatchCount )
194201
{
195202
mReport += "<tr><td colspan = 3>\n";
196203
mReport += "Test image and result image for " + theTestName + " are matched<br>";

‎tests/src/core/qgsrenderchecker.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,25 @@ class QgsRenderChecker
4949
* Test using renderer to generate the image to be compared.
5050
* @param theTestName - to be used as the basis for writing a file to
5151
* e.g. /tmp/theTestName.png
52+
* @param theMismatchCount - defaults to 0 - the number of pixels that
53+
* are allowed to be different from the control image. In some cases
54+
* rendering may be non-deterministic. This parameter allows you to account
55+
* for that by providing a tolerance.
5256
* @note make sure to call setExpectedImage and setMapRenderer first
5357
*/
54-
bool runTest( QString theTestName );
58+
bool runTest( QString theTestName, unsigned int theMismatchCount=0 );
5559

5660
/**
5761
* Test using two arbitary images (map renderer will not be used)
5862
* @param theTestName - to be used as the basis for writing a file to
5963
* e.g. /tmp/theTestName.png
64+
* @param theMismatchCount - defaults to 0 - the number of pixels that
65+
* are allowed to be different from the control image. In some cases
66+
* rendering may be non-deterministic. This parameter allows you to account
67+
* for that by providing a tolerance.
6068
* @note: make sure to call setExpectedImage and setRenderedImage first.
6169
*/
62-
bool compareImages( QString theTestName );
70+
bool compareImages( QString theTestName, unsigned int theMismatchCount=0 );
6371
private:
6472
QString mReport;
6573
QString mExpectedImageFile;

‎tests/src/core/regression1141.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ void Regression1141::diacriticalTest()
9797
mEncoding = "UTF-8";
9898
QgsField myField( "ąęćń", QVariant::Int, "int", 10, 0, "Value on lon" );
9999
mFields.insert( 0, myField );
100-
mCRS = QgsCoordinateReferenceSystem( GEOWkt );
100+
mCRS = QgsCoordinateReferenceSystem( GEOWKT );
101101

102102
qDebug( "Checking test dataset exists...\n%s", mFileName.toLocal8Bit().constData() );
103103

‎tests/src/core/regression992.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ void Regression992::regression992()
110110
QgsRenderChecker myChecker;
111111
myChecker.setExpectedImage( myTestDataDir + "expected_rgbwcmyk01_YeGeo.jp2.png" );
112112
myChecker.setMapRenderer( mpMapRenderer );
113-
bool myResultFlag = myChecker.runTest( "regression992" );
113+
// allow up to 300 mismatched pixels
114+
bool myResultFlag = myChecker.runTest( "regression992", 300 );
114115
mReport += "\n\n\n" + myChecker.report();
115116
QVERIFY( myResultFlag );
116117
}

‎tests/src/core/testqgscoordinatereferencesystem.cpp

Lines changed: 37 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Email : sherman at mrcc dot com
2222

2323
//header for class being tested
2424
#include <qgscoordinatereferencesystem.h>
25+
#include <qgis.h>
2526

2627
class TestQgsCoordinateReferenceSystem: public QObject
2728
{
@@ -40,15 +41,13 @@ class TestQgsCoordinateReferenceSystem: public QObject
4041
void createFromProj4();
4142
void isValid();
4243
void validate();
43-
void findMatchingProj();
4444
void equality();
4545
void noEquality();
4646
void equals();
4747
void readXML();
4848
void writeXML();
4949
void setCustomSrsValidation();
5050
void customSrsValidation();
51-
void srsid();
5251
void postgisSrid();
5352
void ellipsoidAcronym();
5453
void toWkt();
@@ -75,35 +74,38 @@ void TestQgsCoordinateReferenceSystem::initTestCase()
7574

7675
void TestQgsCoordinateReferenceSystem::wktCtor()
7776
{
78-
QString myWkt( "GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9108\"]],AUTHORITY[\"EPSG\",\"4326\"]]" ) ;
77+
QString myWkt = GEOWKT;
7978
QgsCoordinateReferenceSystem myCrs( myWkt );
8079
debugPrint( myCrs );
8180
QVERIFY( myCrs.isValid() );
8281
}
8382
void TestQgsCoordinateReferenceSystem::idCtor()
8483
{
85-
QgsCoordinateReferenceSystem myCrs( 4326, QgsCoordinateReferenceSystem::EpsgCrsId );
84+
QgsCoordinateReferenceSystem myCrs( GEOSRID,
85+
QgsCoordinateReferenceSystem::EpsgCrsId );
8686
debugPrint( myCrs );
8787
QVERIFY( myCrs.isValid() );
8888
}
8989
void TestQgsCoordinateReferenceSystem::copyCtor()
9090
{
91-
QgsCoordinateReferenceSystem myCrs( 4326, QgsCoordinateReferenceSystem::EpsgCrsId );
91+
QgsCoordinateReferenceSystem myCrs( GEOSRID,
92+
QgsCoordinateReferenceSystem::EpsgCrsId );
9293
QgsCoordinateReferenceSystem myCrs2( myCrs );
9394
debugPrint( myCrs2 );
9495
QVERIFY( myCrs2.isValid() );
9596
}
9697
void TestQgsCoordinateReferenceSystem::assignmentCtor()
9798
{
98-
QgsCoordinateReferenceSystem myCrs( 4326, QgsCoordinateReferenceSystem::EpsgCrsId );
99+
QgsCoordinateReferenceSystem myCrs( GEOSRID,
100+
QgsCoordinateReferenceSystem::EpsgCrsId );
99101
QgsCoordinateReferenceSystem myCrs2 = myCrs;
100102
debugPrint( myCrs2 );
101103
QVERIFY( myCrs2.isValid() );
102104
}
103105
void TestQgsCoordinateReferenceSystem::createFromId()
104106
{
105107
QgsCoordinateReferenceSystem myCrs;
106-
myCrs.createFromId( 4326, QgsCoordinateReferenceSystem::EpsgCrsId );
108+
myCrs.createFromId( GEOSRID, QgsCoordinateReferenceSystem::EpsgCrsId );
107109
debugPrint( myCrs );
108110
QVERIFY( myCrs.isValid() );
109111
}
@@ -117,80 +119,71 @@ void TestQgsCoordinateReferenceSystem::createFromOgcWmsCrs()
117119
void TestQgsCoordinateReferenceSystem::createFromSrid()
118120
{
119121
QgsCoordinateReferenceSystem myCrs;
120-
myCrs.createFromSrid( 4326 );
122+
myCrs.createFromSrid( GEOSRID );
121123
debugPrint( myCrs );
122124
QVERIFY( myCrs.isValid() );
123125
}
124126
void TestQgsCoordinateReferenceSystem::createFromWkt()
125127
{
126128
QgsCoordinateReferenceSystem myCrs;
127-
QString myWkt = "GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9108\"]],AUTHORITY[\"EPSG\",\"4326\"]]" ;
128-
QVERIFY( !myCrs.createFromWkt( myWkt ) );
129+
QVERIFY( !myCrs.createFromWkt( GEOWKT ) );
129130
}
130131
void TestQgsCoordinateReferenceSystem::createFromSrsId()
131132
{
132133
QgsCoordinateReferenceSystem myCrs;
133-
QVERIFY( myCrs.createFromSrsId( 4326 ) );
134+
QVERIFY( myCrs.createFromSrid( GEOSRID ) );
134135
debugPrint( myCrs );
135136
}
136137
void TestQgsCoordinateReferenceSystem::createFromProj4()
137138
{
138139
QgsCoordinateReferenceSystem myCrs;
139-
QVERIFY( myCrs.createFromProj4( "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs" ) );
140+
QVERIFY( myCrs.createFromProj4( GEOPROJ4 ) );
140141
debugPrint( myCrs );
141142
}
142143
void TestQgsCoordinateReferenceSystem::isValid()
143144
{
144145
QgsCoordinateReferenceSystem myCrs;
145-
myCrs.createFromSrsId( 4326 );
146+
myCrs.createFromSrid( GEOSRID );
146147
QVERIFY( myCrs.isValid() );
147148
debugPrint( myCrs );
148149
}
149150
void TestQgsCoordinateReferenceSystem::validate()
150151
{
151152
QgsCoordinateReferenceSystem myCrs;
152-
myCrs.createFromSrsId( 4326 );
153+
myCrs.createFromSrid( GEOSRID );
153154
myCrs.validate();
154155
QVERIFY( myCrs.isValid() );
155156
debugPrint( myCrs );
156157
}
157-
void TestQgsCoordinateReferenceSystem::findMatchingProj()
158-
{
159-
QgsCoordinateReferenceSystem myCrs;
160-
myCrs.createFromSrsId( 4326 );
161-
int myLong = myCrs.findMatchingProj();
162-
QVERIFY( myLong == 4326 );
163-
debugPrint( myCrs );
164-
}
165158
void TestQgsCoordinateReferenceSystem::equality()
166159
{
167160
QgsCoordinateReferenceSystem myCrs;
168-
myCrs.createFromSrsId( 4326 );
161+
myCrs.createFromSrid( GEOSRID );
169162
QgsCoordinateReferenceSystem myCrs2;
170-
myCrs2.createFromSrsId( 4326 );
171-
QVERIFY( myCrs == myCrs2 );
163+
myCrs2.createFromSrsId( GEOSRID );
172164
debugPrint( myCrs );
165+
QVERIFY( myCrs == myCrs2 );
173166
}
174167
void TestQgsCoordinateReferenceSystem::noEquality()
175168
{
176169
QgsCoordinateReferenceSystem myCrs;
177-
myCrs.createFromSrsId( 4326 );
170+
myCrs.createFromSrid( GEOSRID );
178171
QgsCoordinateReferenceSystem myCrs2;
179172
myCrs2.createFromSrsId( 4327 );
180-
QVERIFY( myCrs != myCrs2 );
181173
debugPrint( myCrs );
174+
QVERIFY( myCrs != myCrs2 );
182175
}
183176
void TestQgsCoordinateReferenceSystem::equals()
184177
{
185178
QgsCoordinateReferenceSystem myCrs;
186-
myCrs.createFromSrsId( 4326 );
187-
QVERIFY( myCrs.equals( "proj4 string" ) );
179+
myCrs.createFromSrid( GEOSRID );
188180
debugPrint( myCrs );
181+
QVERIFY( myCrs.equals( GEOPROJ4 ) );
189182
}
190183
void TestQgsCoordinateReferenceSystem::readXML()
191184
{
192185
//QgsCoordinateReferenceSystem myCrs;
193-
//myCrs.createFromSrsId( 4326 );
186+
//myCrs.createFromSrid( GEOSRID );
194187
//QgsCoordinateReferenceSystem myCrs2;
195188
//QVERIFY( myCrs2.readXML( QDomNode & theNode ) );
196189
}
@@ -215,54 +208,47 @@ void TestQgsCoordinateReferenceSystem::customSrsValidation()
215208
QVERIFY( myCrs.isValid() );
216209
*/
217210
}
218-
void TestQgsCoordinateReferenceSystem::srsid()
219-
{
220-
QgsCoordinateReferenceSystem myCrs;
221-
myCrs.createFromSrsId( 4326 );
222-
QVERIFY( myCrs.srsid() == 4326 );
223-
debugPrint( myCrs );
224-
}
225211
void TestQgsCoordinateReferenceSystem::postgisSrid()
226212
{
227213
QgsCoordinateReferenceSystem myCrs;
228-
myCrs.createFromSrsId( 4326 );
229-
QVERIFY( myCrs.postgisSrid() == 4326 );
214+
myCrs.createFromSrid( GEOSRID );
215+
QVERIFY( myCrs.postgisSrid() == GEOSRID );
230216
debugPrint( myCrs );
231217
}
232218
void TestQgsCoordinateReferenceSystem::ellipsoidAcronym()
233219
{
234220
QgsCoordinateReferenceSystem myCrs;
235-
myCrs.createFromSrsId( 4326 );
221+
myCrs.createFromSrid( GEOSRID );
236222
QString myAcronym = myCrs.ellipsoidAcronym();
237-
QVERIFY( myAcronym == "foo" );
238223
debugPrint( myCrs );
224+
QVERIFY( myAcronym == "WGS84" );
239225
}
240226
void TestQgsCoordinateReferenceSystem::toWkt()
241227
{
242228
QgsCoordinateReferenceSystem myCrs;
243-
myCrs.createFromSrsId( 4326 );
229+
myCrs.createFromSrid( GEOSRID );
244230
QString myWkt = myCrs.toWkt();
245-
QVERIFY( myWkt == "GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9108\"]],AUTHORITY[\"EPSG\",\"4326\"]]" );
246231
debugPrint( myCrs );
232+
QVERIFY( myWkt == GEOWKT );
247233
}
248234
void TestQgsCoordinateReferenceSystem::toProj4()
249235
{
250236
QgsCoordinateReferenceSystem myCrs;
251-
myCrs.createFromSrsId( 4326 );
252-
QVERIFY( myCrs.toProj4() == "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs" );
237+
myCrs.createFromSrid( GEOSRID );
253238
debugPrint( myCrs );
239+
QVERIFY( myCrs.toProj4() == GEOPROJ4 );
254240
}
255241
void TestQgsCoordinateReferenceSystem::geographicFlag()
256242
{
257243
QgsCoordinateReferenceSystem myCrs;
258-
myCrs.createFromSrsId( 4326 );
244+
myCrs.createFromSrid( GEOSRID );
259245
QVERIFY( myCrs.geographicFlag() );
260246
debugPrint( myCrs );
261247
}
262248
void TestQgsCoordinateReferenceSystem::mapUnits()
263249
{
264250
QgsCoordinateReferenceSystem myCrs;
265-
myCrs.createFromSrsId( 4326 );
251+
myCrs.createFromSrid( GEOSRID );
266252
QVERIFY( myCrs.mapUnits() == QGis::Degrees );
267253
debugPrint( myCrs );
268254
}
@@ -274,10 +260,12 @@ void TestQgsCoordinateReferenceSystem::setValidationHint()
274260
debugPrint( myCrs );
275261
}
276262

277-
void TestQgsCoordinateReferenceSystem::debugPrint( QgsCoordinateReferenceSystem &theCrs )
263+
void TestQgsCoordinateReferenceSystem::debugPrint(
264+
QgsCoordinateReferenceSystem &theCrs )
278265
{
279266
QgsDebugMsg( "***SpatialRefSystem***" );
280-
QgsDebugMsg( "* Valid : " + ( theCrs.isValid() ? QString( "true" ) : QString( "false" ) ) );
267+
QgsDebugMsg( "* Valid : " + ( theCrs.isValid() ? QString( "true" ) :
268+
QString( "false" ) ) );
281269
QgsDebugMsg( "* SrsId : " + QString::number( theCrs.srsid() ) );
282270
QgsDebugMsg( "* Proj4 : " + theCrs.toProj4() );
283271
QgsDebugMsg( "* WKT : " + theCrs.toWkt() );
@@ -298,4 +286,3 @@ void TestQgsCoordinateReferenceSystem::debugPrint( QgsCoordinateReferenceSystem
298286

299287
QTEST_MAIN( TestQgsCoordinateReferenceSystem )
300288
#include "moc_testqgscoordinatereferencesystem.cxx"
301-

‎tests/src/core/testqgsmaprenderer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ void TestQgsMapRenderer::initTestCase()
8989
mEncoding = "UTF-8";
9090
QgsField myField1( "Value", QVariant::Int, "int", 10, 0, "Value on lon" );
9191
mFields.insert( 0, myField1 );
92-
mCRS = QgsCoordinateReferenceSystem( GEOWkt );
92+
mCRS = QgsCoordinateReferenceSystem( GEOWKT );
9393
//
9494
// Create the test dataset if it doesnt exist
9595
//

‎tests/src/core/testqgsvectorfilewriter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ void TestQgsVectorFileWriter::initTestCase()
100100
mEncoding = "UTF-8";
101101
QgsField myField1( "Field1", QVariant::String, "String", 10, 0, "Field 1 comment" );
102102
mFields.insert( 0, myField1 );
103-
mCRS = QgsCoordinateReferenceSystem( GEOWkt );
103+
mCRS = QgsCoordinateReferenceSystem( GEOWKT );
104104
mPoint1 = QgsPoint( 10.0, 10.0 );
105105
mPoint2 = QgsPoint( 15.0, 10.0 );
106106
mPoint3 = QgsPoint( 15.0, 12.0 );
11.3 KB
Loading

0 commit comments

Comments
 (0)
Please sign in to comment.