diff --git a/python/core/qgscoordinatereferencesystem.sip b/python/core/qgscoordinatereferencesystem.sip index 613ec264b2c7..a430b7ec4d06 100644 --- a/python/core/qgscoordinatereferencesystem.sip +++ b/python/core/qgscoordinatereferencesystem.sip @@ -169,7 +169,7 @@ class QgsCoordinateReferenceSystem * Additionally logic may also be applied if the result from the OGR methods * is inconclusive. */ - bool equals(QString theProj4String); + bool equals(QString theProj4String) /Deprecated/; /*! Restores state from the given Dom node. * @param theNode The node from which state will be restored diff --git a/src/core/qgis.cpp b/src/core/qgis.cpp index 0dcc03376bfc..6d6e30bf5f82 100644 --- a/src/core/qgis.cpp +++ b/src/core/qgis.cpp @@ -40,7 +40,7 @@ const int QGis::QGIS_VERSION_INT = VERSION_INT; // Release name const char* QGis::QGIS_RELEASE_NAME = RELEASE_NAME; -#if GDAL_VERSION_NUM > 1800 +#if GDAL_VERSION_NUM >= 1800 const QString GEOPROJ4 = "+proj=longlat +datum=WGS84 +no_defs"; #else const QString GEOPROJ4 = "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs"; diff --git a/src/core/qgscoordinatereferencesystem.cpp b/src/core/qgscoordinatereferencesystem.cpp index 960cfefbf6b4..ee1040da8d40 100644 --- a/src/core/qgscoordinatereferencesystem.cpp +++ b/src/core/qgscoordinatereferencesystem.cpp @@ -950,7 +950,7 @@ long QgsCoordinateReferenceSystem::findMatchingProj() { QString mySrsId = QString::fromUtf8(( char * )sqlite3_column_text( myPreparedStatement, 0 ) ); QString myProj4String = QString::fromUtf8(( char * )sqlite3_column_text( myPreparedStatement, 1 ) ); - if ( equals( myProj4String ) ) + if ( toProj4() == myProj4String.trimmed() ) { QgsDebugMsg( "-------> MATCH FOUND in srs.db srsid: " + mySrsId ); // close the sqlite3 statement @@ -989,7 +989,7 @@ long QgsCoordinateReferenceSystem::findMatchingProj() { QString mySrsId = QString::fromUtf8(( char * )sqlite3_column_text( myPreparedStatement, 0 ) ); QString myProj4String = QString::fromUtf8(( char * )sqlite3_column_text( myPreparedStatement, 1 ) ); - if ( equals( myProj4String ) ) + if ( toProj4() == myProj4String.trimmed() ) { QgsDebugMsg( "-------> MATCH FOUND in user qgis.db srsid: " + mySrsId ); // close the sqlite3 statement diff --git a/src/core/qgscoordinatereferencesystem.h b/src/core/qgscoordinatereferencesystem.h index de9feaf6f1b2..fb206cea0296 100644 --- a/src/core/qgscoordinatereferencesystem.h +++ b/src/core/qgscoordinatereferencesystem.h @@ -210,8 +210,9 @@ class CORE_EXPORT QgsCoordinateReferenceSystem * Internally it will use OGR isSameCRS() or isSameGeoCRS() methods as appropriate. * Additionally logic may also be applied if the result from the OGR methods * is inconclusive. + * @deprecated in 1.8 as the same proj.4 string not necessarily means the same CRS */ - bool equals( QString theProj4String ); + Q_DECL_DEPRECATED bool equals( QString theProj4String ); /*! Restores state from the given Dom node. * @param theNode The node from which state will be restored diff --git a/src/providers/postgres/qgspgtablemodel.cpp b/src/providers/postgres/qgspgtablemodel.cpp index 3857b8f3a330..899b91295211 100644 --- a/src/providers/postgres/qgspgtablemodel.cpp +++ b/src/providers/postgres/qgspgtablemodel.cpp @@ -332,7 +332,7 @@ bool QgsPgTableModel::setData( const QModelIndex &idx, const QVariant &value, in bool ok = geomType != QGis::WKBUnknown; - if ( ok && geomType != QGis::NoGeometry ) + if ( ok && geomType != QGis::WKBNoGeometry ) idx.sibling( idx.row(), dbtmSrid ).data().toInt( &ok ); QStringList pkCols = idx.sibling( idx.row(), dbtmPkCol ).data( Qt::UserRole + 1 ).toStringList(); diff --git a/tests/src/core/testqgscoordinatereferencesystem.cpp b/tests/src/core/testqgscoordinatereferencesystem.cpp index 93a17c05cd2e..02e04f802d85 100644 --- a/tests/src/core/testqgscoordinatereferencesystem.cpp +++ b/tests/src/core/testqgscoordinatereferencesystem.cpp @@ -46,7 +46,6 @@ class TestQgsCoordinateReferenceSystem: public QObject void validate(); void equality(); void noEquality(); - void equals(); void readXML(); void writeXML(); void setCustomSrsValidation(); @@ -71,6 +70,10 @@ void TestQgsCoordinateReferenceSystem::initTestCase() // init QGIS's paths - true means that all path will be inited from prefix QgsApplication::init(); QgsApplication::showSettings(); + qDebug() << "GEOPROJ4 constant: " << GEOPROJ4; + qDebug() << "GDAL version (build): " << GDAL_RELEASE_NAME; + qDebug() << "GDAL version (runtime): " << GDALVersionInfo("RELEASE_NAME"); + qDebug() << "PROJ.4 version: " << PJ_VERSION; } void TestQgsCoordinateReferenceSystem::wktCtor() @@ -177,15 +180,6 @@ void TestQgsCoordinateReferenceSystem::noEquality() debugPrint( myCrs ); QVERIFY( myCrs != myCrs2 ); } -void TestQgsCoordinateReferenceSystem::equals() -{ - QgsCoordinateReferenceSystem myCrs; - myCrs.createFromSrid( GEOSRID ); - debugPrint( myCrs ); - //Note: OSRImportFromProj4 (used internally by equals) - //drops the TOWGS from the WKT which causes this test to fail - QVERIFY( myCrs.equals( GEOPROJ4 ) ); -} void TestQgsCoordinateReferenceSystem::readXML() { //QgsCoordinateReferenceSystem myCrs; @@ -235,23 +229,24 @@ void TestQgsCoordinateReferenceSystem::toWkt() myCrs.createFromSrid( GEOSRID ); QString myWkt = myCrs.toWkt(); debugPrint( myCrs ); +#if GDAL_VERSION_NUM >= 1800 //Note: this is not the same as GEOWKT as OGR strips off the TOWGS clause... QString myStrippedWkt( "GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID" "[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]]," "AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY" "[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY" "[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4326\"]]" ); - // for GDAL 1.7 - QString myAltStrippedWkt( "GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID" +#else + // for GDAL <1.8 + QString myStrippedWkt( "GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID" "[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]]," "AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY" "[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.01745329251994328,AUTHORITY" "[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4326\"]]" ); - qDebug() << "myWkt:\n"; - qDebug() << myWkt; - qDebug() << "myStrippedWkt:\n"; - qDebug() << myStrippedWkt; - QVERIFY( myWkt == myStrippedWkt || myWkt == myAltStrippedWkt ); +#endif + qDebug() << "wkt: " << myWkt; + qDebug() << "stripped: " << myStrippedWkt; + QVERIFY( myWkt == myStrippedWkt ); } void TestQgsCoordinateReferenceSystem::toProj4() { @@ -308,9 +303,6 @@ void TestQgsCoordinateReferenceSystem::debugPrint( { QgsDebugMsg( "* Units : degrees" ); } - - QgsDebugMsg( QString( "** GDAL version: %1" ).arg( GDAL_RELEASE_NAME ) ); - QgsDebugMsg( QString( "** PROJ.4 version: %1" ).arg( PJ_VERSION ) ); } QTEST_MAIN( TestQgsCoordinateReferenceSystem )