Skip to content
Permalink
Browse files

deprecated special handling of EPSG - just one authority

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15246 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef
jef committed Feb 22, 2011
1 parent baa7dee commit cde825096405741329e062121950e8e91231f58f
@@ -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);

@@ -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);

@@ -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);

@@ -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
@@ -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();
@@ -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();
@@ -27,7 +27,7 @@ QgsGpsMarker::QgsGpsMarker( QgsMapCanvas* mapCanvas )
: QgsMapCanvasItem( mapCanvas )
{
mSize = 16;
mWgs84CRS.createFromEpsg( 4326 );
mWgs84CRS.createFromOgcWmsCrs( "EPSG:4326" );
}

void QgsGpsMarker::setSize( int theSize )
@@ -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();
}
@@ -375,6 +392,8 @@ void QgsProjectProperties::apply()
grpWMSList->setChecked( false );
}

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

if ( grpWMSList->isChecked() )
{
QStringList crslist;
@@ -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
@@ -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 ) );
}
}

@@ -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();
@@ -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
@@ -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 );
}

@@ -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() );
@@ -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 );
}

@@ -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...
@@ -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 )
@@ -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 );

@@ -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 );

@@ -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 );

@@ -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
@@ -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 );
}

@@ -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; }
@@ -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)

#############################################################
@@ -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 )
@@ -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()
@@ -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 );

/**

0 comments on commit cde8250

Please sign in to comment.
You can’t perform that action at this time.