@@ -76,8 +76,7 @@ QgsNewSpatialiteLayerDialog::QgsNewSpatialiteLayerDialog( QWidget *parent, Qt::W
76
76
QgsCoordinateReferenceSystem srs;
77
77
srs.createFromOgcWmsCrs ( GEO_EPSG_CRS_AUTHID );
78
78
srs.validate ();
79
- bool ok;
80
- mCrsId = srs.authid ().split ( ' :' ).at ( 1 ).toInt ( &ok );
79
+ mCrsId = srs.authid ();
81
80
leSRID->setText ( srs.authid () + " - " + srs.description () );
82
81
83
82
pbnFindSRID->setEnabled ( mDatabaseComboBox ->count () );
@@ -210,7 +209,7 @@ void QgsNewSpatialiteLayerDialog::on_pbnFindSRID_clicked()
210
209
// load up the srid table
211
210
const char *pzTail;
212
211
sqlite3_stmt *ppStmt;
213
- QString sql = " select auth_srid, auth_name, ref_sys_name from spatial_ref_sys order by srid asc" ;
212
+ QString sql = " select auth_name || ':' || auth_srid from spatial_ref_sys order by srid asc" ;
214
213
215
214
QSet<QString> myCRSs;
216
215
@@ -221,8 +220,7 @@ void QgsNewSpatialiteLayerDialog::on_pbnFindSRID_clicked()
221
220
// get the first row of the result set
222
221
while ( sqlite3_step ( ppStmt ) == SQLITE_ROW )
223
222
{
224
- myCRSs.insert ( QString::fromUtf8 (( const char * )sqlite3_column_text ( ppStmt, 1 ) ) +
225
- " :" + QString::fromUtf8 (( const char * )sqlite3_column_text ( ppStmt, 0 ) ) );
223
+ myCRSs.insert ( QString::fromUtf8 (( const char * )sqlite3_column_text ( ppStmt, 0 ) ) );
226
224
}
227
225
}
228
226
else
@@ -244,14 +242,13 @@ void QgsNewSpatialiteLayerDialog::on_pbnFindSRID_clicked()
244
242
QgsGenericProjectionSelector *mySelector = new QgsGenericProjectionSelector ( this );
245
243
mySelector->setMessage ();
246
244
mySelector->setOgcWmsCrsFilter ( myCRSs );
247
- mySelector->setSelectedCrsId ( mCrsId );
245
+ mySelector->setSelectedAuthId ( mCrsId );
248
246
249
247
if ( mySelector->exec () )
250
248
{
251
249
QgsCoordinateReferenceSystem srs;
252
250
srs.createFromOgcWmsCrs ( mySelector->selectedAuthId () );
253
- bool ok;
254
- int crsId = srs.authid ().split ( ' :' ).value ( 1 , QString::number ( mCrsId ) ).toInt ( &ok );
251
+ QString crsId = srs.authid ();
255
252
if ( crsId != mCrsId )
256
253
{
257
254
mCrsId = crsId;
@@ -375,7 +372,7 @@ bool QgsNewSpatialiteLayerDialog::apply()
375
372
QString sqlAddGeom = QString ( " select AddGeometryColumn(%1,%2,%3,%4,2)" )
376
373
.arg ( quotedValue ( leLayerName->text () ) )
377
374
.arg ( quotedValue ( leGeometryColumn->text () ) )
378
- .arg ( mCrsId )
375
+ .arg ( mCrsId . split ( ' : ' ). value ( 1 , " 0 " ). toInt () )
379
376
.arg ( quotedValue ( selectedType () ) );
380
377
QgsDebugMsg ( sqlAddGeom ); // OK
381
378
0 commit comments