Skip to content

Commit cde8250

Browse files
author
jef
committed
deprecated special handling of EPSG - just one authority
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15246 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent baa7dee commit cde8250

28 files changed

+226
-179
lines changed

python/core/qgscoordinatereferencesystem.sip

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class QgsCoordinateReferenceSystem
6868
* @note Any members will be overwritten during this process.
6969
* @note SRID and EpsgCrsId may be blank if no match can be found on srs db.
7070
* @param theWkt The Wkt for the desired spatial reference system.
71-
* @return bool TRUE if sucess else false
71+
* @return bool TRUE if success else false
7272
*/
7373
bool createFromWkt(const QString theWkt);
7474

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

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

@@ -127,7 +128,7 @@ class QgsCoordinateReferenceSystem
127128
* for this srs.
128129
*
129130
* @param theProjString A proj4 format string
130-
* @return bool TRUE if sucess else false
131+
* @return bool TRUE if success else false
131132
*/
132133
bool createFromProj4 (const QString theProjString);
133134

@@ -211,9 +212,10 @@ class QgsCoordinateReferenceSystem
211212
*/
212213
long postgisSrid () const;
213214
/*! Get the EpsgCrsId identifier for this srs
214-
* @return long theEpsg the ESPG identifier for this srs (defaults to 0)
215+
* @return long theEpsg the EPGG identifier for this srs (defaults to 0)
216+
* @deprecated use authid()
215217
*/
216-
long epsg () const;
218+
long epsg () const /Deprecated/;
217219
/*! Get the Description
218220
* @return QString the Description A textual description of the srs.
219221
* @note A zero length string will be returned if the description is uninitialised

python/core/qgsdistancearea.sip

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ class QgsDistanceArea
2323
void setSourceCrs(long srsid);
2424

2525
//! sets source spatial reference system (by EpsgCrsId)
26-
void setSourceEpsgCrsId(long epsgId);
26+
// @deprecated use setSourceAuthid()
27+
void setSourceEpsgCrsId(long epsgId) /Deprecated/;
28+
29+
//! sets source spatial reference system by authid
30+
void setSourceAuthId( QString authid );
2731

2832
//! returns source spatial reference system
2933
long sourceCrs();

src/app/gps/qgsgpsinformationwidget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ QgsGPSInformationWidget::QgsGPSInformationWidget( QgsMapCanvas * thepCanvas, QWi
189189
}
190190
// Set up the rubber band to show digitising
191191
createRubberBand();
192-
mWgs84CRS.createFromEpsg( 4326 );
192+
mWgs84CRS.createFromOgcWmsCrs( "EPSG:4326" );
193193
//for now I am hiding accuracy and date widgets
194194
mDateTime->hide();
195195
mVerticalAccuracy->hide();

src/app/gps/qgsgpsmarker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ QgsGpsMarker::QgsGpsMarker( QgsMapCanvas* mapCanvas )
2727
: QgsMapCanvasItem( mapCanvas )
2828
{
2929
mSize = 16;
30-
mWgs84CRS.createFromEpsg( 4326 );
30+
mWgs84CRS.createFromOgcWmsCrs( "EPSG:4326" );
3131
}
3232

3333
void QgsGpsMarker::setSize( int theSize )

src/app/qgsprojectproperties.cpp

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -189,12 +189,29 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa
189189
mWMSExtMaxY->setText( values[3] );
190190
}
191191

192-
values = QgsProject::instance()->readListEntry( "WMSEpsgList", "/", &ok );
192+
values = QgsProject::instance()->readListEntry( "WMSCrsList", "/", &ok );
193193
grpWMSList->setChecked( ok && values.size() > 0 );
194194
if ( grpWMSList->isChecked() )
195195
{
196196
mWMSList->addItems( values );
197197
}
198+
else
199+
{
200+
values = QgsProject::instance()->readListEntry( "WMSEpsgList", "/", &ok );
201+
grpWMSList->setChecked( ok && values.size() > 0 );
202+
if ( grpWMSList->isChecked() )
203+
{
204+
QStringList list;
205+
foreach( QString value, values )
206+
{
207+
list << QString( "EPSG:%1" ).arg( value );
208+
}
209+
210+
mWMSList->addItems( list );
211+
}
212+
}
213+
214+
grpWMSList->setChecked( mWMSList->count() > 0 );
198215

199216
restoreState();
200217
}
@@ -375,6 +392,8 @@ void QgsProjectProperties::apply()
375392
grpWMSList->setChecked( false );
376393
}
377394

395+
QgsProject::instance()->removeEntry( "WMSEpsgList", "/" );
396+
378397
if ( grpWMSList->isChecked() )
379398
{
380399
QStringList crslist;
@@ -383,11 +402,11 @@ void QgsProjectProperties::apply()
383402
crslist << mWMSList->item( i )->text();
384403
}
385404

386-
QgsProject::instance()->writeEntry( "WMSEpsgList", "/", crslist );
405+
QgsProject::instance()->writeEntry( "WMSCrsList", "/", crslist );
387406
}
388407
else
389408
{
390-
QgsProject::instance()->removeEntry( "WMSEpsgList", "/" );
409+
QgsProject::instance()->removeEntry( "WMSCrsList", "/" );
391410
}
392411

393412
//todo XXX set canvas color
@@ -498,23 +517,16 @@ void QgsProjectProperties::on_pbnWMSAddSRS_clicked()
498517
mySelector->setMessage();
499518
if ( mySelector->exec() )
500519
{
501-
long crs = mySelector->selectedEpsg();
520+
QString authid = mySelector->selectedAuthId();
502521

503-
if ( crs > 0 )
522+
QList<QListWidgetItem *> items = mWMSList->findItems( authid.mid( 5 ), Qt::MatchFixedString );
523+
if ( items.size() == 0 )
504524
{
505-
QList<QListWidgetItem *> items = mWMSList->findItems( QString::number( crs ), Qt::MatchFixedString );
506-
if ( items.size() == 0 )
507-
{
508-
mWMSList->addItem( QString::number( crs ) );
509-
}
510-
else
511-
{
512-
QMessageBox::information( this, tr( "Coordinate System Restriction" ), tr( "CRS %1 was already selected" ).arg( crs ) );
513-
}
525+
mWMSList->addItem( authid );
514526
}
515527
else
516528
{
517-
QMessageBox::information( this, tr( "Coordinate System Restriction" ), tr( "Selected CRS is not a EPSG coordinate system." ) );
529+
QMessageBox::information( this, tr( "Coordinate System Restriction" ), tr( "CRS %1 was already selected" ).arg( authid ) );
518530
}
519531
}
520532

@@ -542,16 +554,13 @@ void QgsProjectProperties::on_pbnWMSSetUsedSRS_clicked()
542554
if ( cbxProjectionEnabled->isChecked() )
543555
{
544556
QgsCoordinateReferenceSystem srs( projectionSelector->selectedCrsId(), QgsCoordinateReferenceSystem::InternalCrsId );
545-
if ( srs.epsg() > 0 )
546-
crsList << QString::number( srs.epsg() );
557+
crsList << srs.authid();
547558
}
548559

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

557566
mWMSList->clear();

src/app/qgsrasterlayerproperties.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer* lyr, QgsMapCanv
250250
tabPageHistogram->setEnabled( false );
251251
}
252252

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

256256
// Set text for pyramid info box
@@ -1640,7 +1640,7 @@ void QgsRasterLayerProperties::on_pbnChangeSpatialRefSys_clicked()
16401640
}
16411641
delete mySelector;
16421642

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

src/app/qgsvectorlayerproperties.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(
127127

128128
updateButtons();
129129

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

133133
leEditForm->setText( layer->editForm() );
@@ -989,7 +989,7 @@ void QgsVectorLayerProperties::on_pbnChangeSpatialRefSys_clicked()
989989
}
990990
delete mySelector;
991991

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

src/core/qgscoordinatereferencesystem.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ bool QgsCoordinateReferenceSystem::createFromId( const long theId, CrsType theTy
8787
result = createFromSrid( theId );
8888
break;
8989
case EpsgCrsId:
90-
result = createFromEpsg( theId );
90+
result = createFromOgcWmsCrs( QString( "EPSG:%1" ).arg( theId ) );
9191
break;
9292
default:
9393
//THIS IS BAD...THIS PART OF CODE SHOULD NEVER BE REACHED...
@@ -993,7 +993,7 @@ bool QgsCoordinateReferenceSystem::readXML( QDomNode & theNode )
993993
{
994994
myNode = srsNode.namedItem( "epsg" );
995995
if ( !myNode.isNull() )
996-
initialized = createFromEpsg( myNode.toElement().text().toLong() );
996+
initialized = createFromOgcWmsCrs( QString( "EPSG:%1" ).arg( myNode.toElement().text().toLong() ) );
997997
}
998998

999999
if ( initialized )

src/core/qgscoordinatereferencesystem.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ class CORE_EXPORT QgsCoordinateReferenceSystem
109109
* @note Any members will be overwritten during this process.
110110
* @note SRID and EpsgCrsId may be blank if no match can be found on srs db.
111111
* @param theWkt The Wkt for the desired spatial reference system.
112-
* @return bool TRUE if sucess else false
112+
* @return bool TRUE if success else false
113113
*/
114114
bool createFromWkt( const QString theWkt );
115115

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

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

@@ -159,7 +160,7 @@ class CORE_EXPORT QgsCoordinateReferenceSystem
159160
* for this srs.
160161
*
161162
* @param theProjString A proj4 format string
162-
* @return bool TRUE if sucess else false
163+
* @return bool TRUE if success else false
163164
*/
164165
bool createFromProj4( const QString theProjString );
165166

@@ -262,8 +263,9 @@ class CORE_EXPORT QgsCoordinateReferenceSystem
262263

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

268270
/*! Get the authority identifier for this srs
269271
* @return QString the Authority identifier for this srs

src/core/qgsdistancearea.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,14 @@ void QgsDistanceArea::setSourceCrs( long srsid )
6969
void QgsDistanceArea::setSourceEpsgCrsId( long epsgId )
7070
{
7171
QgsCoordinateReferenceSystem srcCRS;
72-
srcCRS.createFromEpsg( epsgId );
72+
srcCRS.createFromOgcWmsCrs( QString( "EPSG:%1" ).arg( epsgId ) );
73+
mCoordTransform->setSourceCrs( srcCRS );
74+
}
75+
76+
void QgsDistanceArea::setSourceAuthId( QString authId )
77+
{
78+
QgsCoordinateReferenceSystem srcCRS;
79+
srcCRS.createFromOgcWmsCrs( authId );
7380
mCoordTransform->setSourceCrs( srcCRS );
7481
}
7582

src/core/qgsdistancearea.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ class CORE_EXPORT QgsDistanceArea
5151
void setSourceCrs( long srsid );
5252

5353
//! sets source spatial reference system (by EpsgCrsId)
54-
void setSourceEpsgCrsId( long epsgId );
54+
QGISDEPRECATED void setSourceEpsgCrsId( long epsgId );
55+
56+
//! sets source spatial reference system by authid
57+
void setSourceAuthId( QString authid );
5558

5659
//! returns source spatial reference system
5760
long sourceCrs() { return mSourceRefSys; }

src/gui/CMakeLists.txt

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,19 @@ IF (WIN32)
137137
ENDIF (MSVC)
138138
ENDIF (WIN32)
139139

140-
# disable deprecation warnings for qgisinterface (re-exporting deprecated methods)
140+
# disable deprecation warnings for classes re-exporting deprecated methods
141141
IF(MSVC)
142-
SET_SOURCE_FILES_PROPERTIES(${CMAKE_BINARY_DIR}/src/gui/moc_qgisinterface.cxx PROPERTIES COMPILE_FLAGS "-wd4996")
142+
SET_SOURCE_FILES_PROPERTIES(
143+
${CMAKE_BINARY_DIR}/src/gui/moc_qgisinterface.cxx
144+
${CMAKE_BINARY_DIR}/src/gui/moc_qgsgenericprojectionselector.cxx
145+
${CMAKE_BINARY_DIR}/src/gui/moc_qgsprojectionselector.cxx
146+
PROPERTIES COMPILE_FLAGS "-wd4996")
143147
ELSE(MSVC)
144-
SET_SOURCE_FILES_PROPERTIES(${CMAKE_BINARY_DIR}/src/gui/moc_qgisinterface.cxx PROPERTIES COMPILE_FLAGS "-w")
148+
SET_SOURCE_FILES_PROPERTIES(
149+
${CMAKE_BINARY_DIR}/src/gui/moc_qgisinterface.cxx
150+
${CMAKE_BINARY_DIR}/src/gui/moc_qgsgenericprojectionselector.cxx
151+
${CMAKE_BINARY_DIR}/src/gui/moc_qgsprojectionselector.cxx
152+
PROPERTIES COMPILE_FLAGS "-w")
145153
ENDIF(MSVC)
146154

147155
#############################################################

src/gui/qgsgenericprojectionselector.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ QgsGenericProjectionSelector::~QgsGenericProjectionSelector()
6060

6161
void QgsGenericProjectionSelector::setSelectedEpsg( long theId )
6262
{
63-
projectionSelector->setSelectedEpsg( theId );
63+
projectionSelector->setSelectedAuthId( QString( "EPSG:%1" ).arg( theId ) );
6464
}
6565

6666
void QgsGenericProjectionSelector::setSelectedCrsName( QString theName )
@@ -92,7 +92,11 @@ long QgsGenericProjectionSelector::selectedCrsId()
9292

9393
long QgsGenericProjectionSelector::selectedEpsg()
9494
{
95-
return projectionSelector->selectedEpsg();
95+
QString authid = projectionSelector->selectedAuthId();
96+
if ( authid.startsWith( "EPSG:", Qt::CaseInsensitive ) )
97+
return authid.mid( 5 ).toLong();
98+
else
99+
return 0;
96100
}
97101

98102
QString QgsGenericProjectionSelector::selectedAuthId()

src/gui/qgsgenericprojectionselector.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,19 @@ class GUI_EXPORT QgsGenericProjectionSelector : public QDialog, private Ui::QgsG
6464
QString selectedProj4String();
6565
long selectedCrsId();
6666
QString selectedAuthId();
67+
68+
#ifndef Q_MOC_RUN
69+
QGISDEPRECATED
70+
#endif
6771
long selectedEpsg();
6872

6973
void setSelectedCrsName( QString theName );
7074
void setSelectedCrsId( long theID );
7175
void setSelectedAuthId( QString authId );
76+
77+
#ifndef Q_MOC_RUN
78+
QGISDEPRECATED
79+
#endif
7280
void setSelectedEpsg( long theID );
7381

7482
/**

0 commit comments

Comments
 (0)