Skip to content

Commit

Permalink
deprecated special handling of EPSG - just one authority
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15246 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Feb 22, 2011
1 parent baa7dee commit cde8250
Show file tree
Hide file tree
Showing 28 changed files with 226 additions and 179 deletions.
16 changes: 9 additions & 7 deletions python/core/qgscoordinatereferencesystem.sip
Expand Up @@ -68,7 +68,7 @@ class QgsCoordinateReferenceSystem
* @note Any members will be overwritten during this process.
* @note SRID and EpsgCrsId may be blank if no match can be found on srs db.
* @param theWkt The Wkt for the desired spatial reference system.
* @return bool TRUE if sucess else false
* @return bool TRUE if success else false
*/
bool createFromWkt(const QString theWkt);

Expand All @@ -86,17 +86,18 @@ class QgsCoordinateReferenceSystem
* and then the users ~/.qgis/qgis.db database will be checked for a match.
* @note Any members will be overwritten during this process.
* @param theEpsg The EpsgCrsId for the desired spatial reference system.
* @return bool TRUE if sucess else false
* @return bool TRUE if success else false
* @deprecated use createFromOgcWmsCrs()
*/
bool createFromEpsg(const long theEpsg);
bool createFromEpsg(const long theEpsg) /Deprecated/;

/*! Set up this srs by fetching the appropriate information from the
* sqlite backend. If the srsid is < 100000, only the system srs.db
* will be checked. If the srsid > 100000 the srs will be retrieved from
* the ~/.qgis/qgis.db
* @note Any members will be overwritten during this process.
* @param theSrsId The QGIS SrsId for the desired spatial reference system.
* @return bool TRUE if sucess else false
* @return bool TRUE if success else false
*/
bool createFromSrsId (const long theSrsId);

Expand Down Expand Up @@ -127,7 +128,7 @@ class QgsCoordinateReferenceSystem
* for this srs.
*
* @param theProjString A proj4 format string
* @return bool TRUE if sucess else false
* @return bool TRUE if success else false
*/
bool createFromProj4 (const QString theProjString);

Expand Down Expand Up @@ -211,9 +212,10 @@ class QgsCoordinateReferenceSystem
*/
long postgisSrid () const;
/*! Get the EpsgCrsId identifier for this srs
* @return long theEpsg the ESPG identifier for this srs (defaults to 0)
* @return long theEpsg the EPGG identifier for this srs (defaults to 0)
* @deprecated use authid()
*/
long epsg () const;
long epsg () const /Deprecated/;
/*! Get the Description
* @return QString the Description A textual description of the srs.
* @note A zero length string will be returned if the description is uninitialised
Expand Down
6 changes: 5 additions & 1 deletion python/core/qgsdistancearea.sip
Expand Up @@ -23,7 +23,11 @@ class QgsDistanceArea
void setSourceCrs(long srsid);

//! sets source spatial reference system (by EpsgCrsId)
void setSourceEpsgCrsId(long epsgId);
// @deprecated use setSourceAuthid()
void setSourceEpsgCrsId(long epsgId) /Deprecated/;

//! sets source spatial reference system by authid
void setSourceAuthId( QString authid );

//! returns source spatial reference system
long sourceCrs();
Expand Down
2 changes: 1 addition & 1 deletion src/app/gps/qgsgpsinformationwidget.cpp
Expand Up @@ -189,7 +189,7 @@ QgsGPSInformationWidget::QgsGPSInformationWidget( QgsMapCanvas * thepCanvas, QWi
}
// Set up the rubber band to show digitising
createRubberBand();
mWgs84CRS.createFromEpsg( 4326 );
mWgs84CRS.createFromOgcWmsCrs( "EPSG:4326" );
//for now I am hiding accuracy and date widgets
mDateTime->hide();
mVerticalAccuracy->hide();
Expand Down
2 changes: 1 addition & 1 deletion src/app/gps/qgsgpsmarker.cpp
Expand Up @@ -27,7 +27,7 @@ QgsGpsMarker::QgsGpsMarker( QgsMapCanvas* mapCanvas )
: QgsMapCanvasItem( mapCanvas )
{
mSize = 16;
mWgs84CRS.createFromEpsg( 4326 );
mWgs84CRS.createFromOgcWmsCrs( "EPSG:4326" );
}

void QgsGpsMarker::setSize( int theSize )
Expand Down
49 changes: 29 additions & 20 deletions src/app/qgsprojectproperties.cpp
Expand Up @@ -189,12 +189,29 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa
mWMSExtMaxY->setText( values[3] );
}

values = QgsProject::instance()->readListEntry( "WMSEpsgList", "/", &ok );
values = QgsProject::instance()->readListEntry( "WMSCrsList", "/", &ok );
grpWMSList->setChecked( ok && values.size() > 0 );
if ( grpWMSList->isChecked() )
{
mWMSList->addItems( values );
}
else
{
values = QgsProject::instance()->readListEntry( "WMSEpsgList", "/", &ok );
grpWMSList->setChecked( ok && values.size() > 0 );
if ( grpWMSList->isChecked() )
{
QStringList list;
foreach( QString value, values )
{
list << QString( "EPSG:%1" ).arg( value );
}

mWMSList->addItems( list );
}
}

grpWMSList->setChecked( mWMSList->count() > 0 );

restoreState();
}
Expand Down Expand Up @@ -375,6 +392,8 @@ void QgsProjectProperties::apply()
grpWMSList->setChecked( false );
}

QgsProject::instance()->removeEntry( "WMSEpsgList", "/" );

if ( grpWMSList->isChecked() )
{
QStringList crslist;
Expand All @@ -383,11 +402,11 @@ void QgsProjectProperties::apply()
crslist << mWMSList->item( i )->text();
}

QgsProject::instance()->writeEntry( "WMSEpsgList", "/", crslist );
QgsProject::instance()->writeEntry( "WMSCrsList", "/", crslist );
}
else
{
QgsProject::instance()->removeEntry( "WMSEpsgList", "/" );
QgsProject::instance()->removeEntry( "WMSCrsList", "/" );
}

//todo XXX set canvas color
Expand Down Expand Up @@ -498,23 +517,16 @@ void QgsProjectProperties::on_pbnWMSAddSRS_clicked()
mySelector->setMessage();
if ( mySelector->exec() )
{
long crs = mySelector->selectedEpsg();
QString authid = mySelector->selectedAuthId();

if ( crs > 0 )
QList<QListWidgetItem *> items = mWMSList->findItems( authid.mid( 5 ), Qt::MatchFixedString );
if ( items.size() == 0 )
{
QList<QListWidgetItem *> items = mWMSList->findItems( QString::number( crs ), Qt::MatchFixedString );
if ( items.size() == 0 )
{
mWMSList->addItem( QString::number( crs ) );
}
else
{
QMessageBox::information( this, tr( "Coordinate System Restriction" ), tr( "CRS %1 was already selected" ).arg( crs ) );
}
mWMSList->addItem( authid );
}
else
{
QMessageBox::information( this, tr( "Coordinate System Restriction" ), tr( "Selected CRS is not a EPSG coordinate system." ) );
QMessageBox::information( this, tr( "Coordinate System Restriction" ), tr( "CRS %1 was already selected" ).arg( authid ) );
}
}

Expand Down Expand Up @@ -542,16 +554,13 @@ void QgsProjectProperties::on_pbnWMSSetUsedSRS_clicked()
if ( cbxProjectionEnabled->isChecked() )
{
QgsCoordinateReferenceSystem srs( projectionSelector->selectedCrsId(), QgsCoordinateReferenceSystem::InternalCrsId );
if ( srs.epsg() > 0 )
crsList << QString::number( srs.epsg() );
crsList << srs.authid();
}

const QMap<QString, QgsMapLayer*> &mapLayers = QgsMapLayerRegistry::instance()->mapLayers();
for ( QMap<QString, QgsMapLayer*>::const_iterator it = mapLayers.constBegin(); it != mapLayers.constEnd(); it++ )
{
long crs = it.value()->crs().epsg();
if ( crs > 0 )
crsList << QString::number( crs );
crsList << it.value()->crs().authid();
}

mWMSList->clear();
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsrasterlayerproperties.cpp
Expand Up @@ -250,7 +250,7 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer* lyr, QgsMapCanv
tabPageHistogram->setEnabled( false );
}

leSpatialRefSys->setText( "EPSG:" + QString::number( mRasterLayer->crs().epsg() ) + " - " + mRasterLayer->crs().description() );
leSpatialRefSys->setText( mRasterLayer->crs().authid() + " - " + mRasterLayer->crs().description() );
leSpatialRefSys->setCursorPosition( 0 );

// Set text for pyramid info box
Expand Down Expand Up @@ -1640,7 +1640,7 @@ void QgsRasterLayerProperties::on_pbnChangeSpatialRefSys_clicked()
}
delete mySelector;

leSpatialRefSys->setText( "EPSG:" + QString::number( mRasterLayer->crs().epsg() ) + " - " + mRasterLayer->crs().description() );
leSpatialRefSys->setText( mRasterLayer->crs().authid() + " - " + mRasterLayer->crs().description() );
leSpatialRefSys->setCursorPosition( 0 );
}

Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsvectorlayerproperties.cpp
Expand Up @@ -127,7 +127,7 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(

updateButtons();

leSpatialRefSys->setText( "EPSG:" + QString::number( layer->crs().epsg() ) + " - " + layer->crs().description() );
leSpatialRefSys->setText( layer->crs().authid() + " - " + layer->crs().description() );
leSpatialRefSys->setCursorPosition( 0 );

leEditForm->setText( layer->editForm() );
Expand Down Expand Up @@ -989,7 +989,7 @@ void QgsVectorLayerProperties::on_pbnChangeSpatialRefSys_clicked()
}
delete mySelector;

leSpatialRefSys->setText( "EPSG:" + QString::number( layer->crs().epsg() ) + " - " + layer->crs().description() );
leSpatialRefSys->setText( layer->crs().authid() + " - " + layer->crs().description() );
leSpatialRefSys->setCursorPosition( 0 );
}

Expand Down
4 changes: 2 additions & 2 deletions src/core/qgscoordinatereferencesystem.cpp
Expand Up @@ -87,7 +87,7 @@ bool QgsCoordinateReferenceSystem::createFromId( const long theId, CrsType theTy
result = createFromSrid( theId );
break;
case EpsgCrsId:
result = createFromEpsg( theId );
result = createFromOgcWmsCrs( QString( "EPSG:%1" ).arg( theId ) );
break;
default:
//THIS IS BAD...THIS PART OF CODE SHOULD NEVER BE REACHED...
Expand Down Expand Up @@ -993,7 +993,7 @@ bool QgsCoordinateReferenceSystem::readXML( QDomNode & theNode )
{
myNode = srsNode.namedItem( "epsg" );
if ( !myNode.isNull() )
initialized = createFromEpsg( myNode.toElement().text().toLong() );
initialized = createFromOgcWmsCrs( QString( "EPSG:%1" ).arg( myNode.toElement().text().toLong() ) );
}

if ( initialized )
Expand Down
14 changes: 8 additions & 6 deletions src/core/qgscoordinatereferencesystem.h
Expand Up @@ -109,7 +109,7 @@ class CORE_EXPORT QgsCoordinateReferenceSystem
* @note Any members will be overwritten during this process.
* @note SRID and EpsgCrsId may be blank if no match can be found on srs db.
* @param theWkt The Wkt for the desired spatial reference system.
* @return bool TRUE if sucess else false
* @return bool TRUE if success else false
*/
bool createFromWkt( const QString theWkt );

Expand All @@ -118,17 +118,18 @@ class CORE_EXPORT QgsCoordinateReferenceSystem
* and then the users ~/.qgis/qgis.db database will be checked for a match.
* @note Any members will be overwritten during this process.
* @param theEpsg The EpsgCrsId for the desired spatial reference system.
* @return bool TRUE if sucess else false
* @return bool TRUE if success else false
* @deprecated use createFromOgcWmsCrs()
*/
bool createFromEpsg( const long theEpsg );
QGISDEPRECATED bool createFromEpsg( const long theEpsg );

/*! Set up this srs by fetching the appropriate information from the
* sqlite backend. If the srsid is < 100000, only the system srs.db
* will be checked. If the srsid > 100000 the srs will be retrieved from
* the ~/.qgis/qgis.db
* @note Any members will be overwritten during this process.
* @param theSrsId The QGIS SrsId for the desired spatial reference system.
* @return bool TRUE if sucess else false
* @return bool TRUE if success else false
*/
bool createFromSrsId( const long theSrsId );

Expand Down Expand Up @@ -159,7 +160,7 @@ class CORE_EXPORT QgsCoordinateReferenceSystem
* for this srs.
*
* @param theProjString A proj4 format string
* @return bool TRUE if sucess else false
* @return bool TRUE if success else false
*/
bool createFromProj4( const QString theProjString );

Expand Down Expand Up @@ -262,8 +263,9 @@ class CORE_EXPORT QgsCoordinateReferenceSystem

/*! Get the EpsgCrsId identifier for this srs
* @return long theEpsg the EPSG identifier for this srs (defaults to 0)
* @deprecated there are other authorities - use authid()
*/
long epsg() const;
QGISDEPRECATED long epsg() const;

/*! Get the authority identifier for this srs
* @return QString the Authority identifier for this srs
Expand Down
9 changes: 8 additions & 1 deletion src/core/qgsdistancearea.cpp
Expand Up @@ -69,7 +69,14 @@ void QgsDistanceArea::setSourceCrs( long srsid )
void QgsDistanceArea::setSourceEpsgCrsId( long epsgId )
{
QgsCoordinateReferenceSystem srcCRS;
srcCRS.createFromEpsg( epsgId );
srcCRS.createFromOgcWmsCrs( QString( "EPSG:%1" ).arg( epsgId ) );
mCoordTransform->setSourceCrs( srcCRS );
}

void QgsDistanceArea::setSourceAuthId( QString authId )
{
QgsCoordinateReferenceSystem srcCRS;
srcCRS.createFromOgcWmsCrs( authId );
mCoordTransform->setSourceCrs( srcCRS );
}

Expand Down
5 changes: 4 additions & 1 deletion src/core/qgsdistancearea.h
Expand Up @@ -51,7 +51,10 @@ class CORE_EXPORT QgsDistanceArea
void setSourceCrs( long srsid );

//! sets source spatial reference system (by EpsgCrsId)
void setSourceEpsgCrsId( long epsgId );
QGISDEPRECATED void setSourceEpsgCrsId( long epsgId );

//! sets source spatial reference system by authid
void setSourceAuthId( QString authid );

//! returns source spatial reference system
long sourceCrs() { return mSourceRefSys; }
Expand Down
14 changes: 11 additions & 3 deletions src/gui/CMakeLists.txt
Expand Up @@ -137,11 +137,19 @@ IF (WIN32)
ENDIF (MSVC)
ENDIF (WIN32)

# disable deprecation warnings for qgisinterface (re-exporting deprecated methods)
# disable deprecation warnings for classes re-exporting deprecated methods
IF(MSVC)
SET_SOURCE_FILES_PROPERTIES(${CMAKE_BINARY_DIR}/src/gui/moc_qgisinterface.cxx PROPERTIES COMPILE_FLAGS "-wd4996")
SET_SOURCE_FILES_PROPERTIES(
${CMAKE_BINARY_DIR}/src/gui/moc_qgisinterface.cxx
${CMAKE_BINARY_DIR}/src/gui/moc_qgsgenericprojectionselector.cxx
${CMAKE_BINARY_DIR}/src/gui/moc_qgsprojectionselector.cxx
PROPERTIES COMPILE_FLAGS "-wd4996")
ELSE(MSVC)
SET_SOURCE_FILES_PROPERTIES(${CMAKE_BINARY_DIR}/src/gui/moc_qgisinterface.cxx PROPERTIES COMPILE_FLAGS "-w")
SET_SOURCE_FILES_PROPERTIES(
${CMAKE_BINARY_DIR}/src/gui/moc_qgisinterface.cxx
${CMAKE_BINARY_DIR}/src/gui/moc_qgsgenericprojectionselector.cxx
${CMAKE_BINARY_DIR}/src/gui/moc_qgsprojectionselector.cxx
PROPERTIES COMPILE_FLAGS "-w")
ENDIF(MSVC)

#############################################################
Expand Down
8 changes: 6 additions & 2 deletions src/gui/qgsgenericprojectionselector.cpp
Expand Up @@ -60,7 +60,7 @@ QgsGenericProjectionSelector::~QgsGenericProjectionSelector()

void QgsGenericProjectionSelector::setSelectedEpsg( long theId )
{
projectionSelector->setSelectedEpsg( theId );
projectionSelector->setSelectedAuthId( QString( "EPSG:%1" ).arg( theId ) );
}

void QgsGenericProjectionSelector::setSelectedCrsName( QString theName )
Expand Down Expand Up @@ -92,7 +92,11 @@ long QgsGenericProjectionSelector::selectedCrsId()

long QgsGenericProjectionSelector::selectedEpsg()
{
return projectionSelector->selectedEpsg();
QString authid = projectionSelector->selectedAuthId();
if ( authid.startsWith( "EPSG:", Qt::CaseInsensitive ) )
return authid.mid( 5 ).toLong();
else
return 0;
}

QString QgsGenericProjectionSelector::selectedAuthId()
Expand Down
8 changes: 8 additions & 0 deletions src/gui/qgsgenericprojectionselector.h
Expand Up @@ -64,11 +64,19 @@ class GUI_EXPORT QgsGenericProjectionSelector : public QDialog, private Ui::QgsG
QString selectedProj4String();
long selectedCrsId();
QString selectedAuthId();

#ifndef Q_MOC_RUN
QGISDEPRECATED
#endif
long selectedEpsg();

void setSelectedCrsName( QString theName );
void setSelectedCrsId( long theID );
void setSelectedAuthId( QString authId );

#ifndef Q_MOC_RUN
QGISDEPRECATED
#endif
void setSelectedEpsg( long theID );

/**
Expand Down

0 comments on commit cde8250

Please sign in to comment.