mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
deprecated QgsCoordinateReferenceSystem::equals: as it might return false
eventhough the proj.4 string is equal. PROJ.4 string isn't unique to CRSes.
This commit is contained in:
parent
991c7ba1d0
commit
71d0e4dd19
@ -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
|
||||
|
@ -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";
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
@ -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 )
|
||||
|
Loading…
x
Reference in New Issue
Block a user