void QgsOptions::on_pbnSelectOtfProjection_clicked() { QSettings settings; QgsGenericProjectionSelector * mySelector = new QgsGenericProjectionSelector( this ); //find out crs id of current proj4 string mySelector->setSelectedCrsId( mDefaultCrs.srsid() ); if ( mySelector->exec() ) { mDefaultCrs.createFromOgcWmsCrs( mySelector->selectedAuthId() ); QgsDebugMsg( QString( "Setting default project CRS to : %1" ).arg( mySelector->selectedAuthId() ) ); leProjectGlobalCrs->setText( mDefaultCrs.authid() + " - " + mDefaultCrs.description() ); QgsDebugMsg( QString( "------ Global OTF Projection Selection set to ----------\n%1" ).arg( leProjectGlobalCrs->text() ) ); } else { QgsDebugMsg( "------ Global OTF Projection Selection change cancelled ----------" ); QApplication::restoreOverrideCursor(); } }
void QgsNewVectorLayerDialog::on_pbnChangeSpatialRefSys_clicked() { QgsGenericProjectionSelector *mySelector = new QgsGenericProjectionSelector( this ); mySelector->setMessage(); mySelector->setSelectedCrsId( mCrsId ); if ( mySelector->exec() ) { QgsCoordinateReferenceSystem srs; srs.createFromOgcWmsCrs( mySelector->selectedAuthId() ); mCrsId = srs.srsid(); leSpatialRefSys->setText( srs.authid() + " - " + srs.description() ); } else { QApplication::restoreOverrideCursor(); } delete mySelector; }
void QgsCustomProjectionDialog::on_pbnCopyCRS_clicked() { QgsGenericProjectionSelector *mySelector = new QgsGenericProjectionSelector( this ); if ( mySelector->exec() ) { QgsCoordinateReferenceSystem srs; QString id = mySelector->selectedAuthId(); srs.createFromOgcWmsCrs( id ); if ( leNameList->topLevelItemCount() == 0 ) { on_pbnAdd_clicked(); } teParameters->setPlainText( srs.toProj4() ); customCRSparameters[leNameList->currentIndex().row()] = srs.toProj4(); leNameList->currentItem()->setText( QGIS_CRS_PARAMETERS_COLUMN, srs.toProj4() ); } delete mySelector; }
void QgsNewSpatialiteLayerDialog::on_pbnFindSRID_clicked() { // first get list of supported SRID from the selected Spatialite database // to build filter for projection selector sqlite3 *db = 0; bool status = true; int rc = sqlite3_open_v2( mDatabaseComboBox->currentText().toUtf8(), &db, SQLITE_OPEN_READONLY, NULL ); if ( rc != SQLITE_OK ) { QMessageBox::warning( this, tr( "SpatiaLite Database" ), tr( "Unable to open the database" ) ); return; } // load up the srid table const char *pzTail; sqlite3_stmt *ppStmt; QString sql = "select auth_name || ':' || auth_srid from spatial_ref_sys order by srid asc"; QSet<QString> myCRSs; rc = sqlite3_prepare( db, sql.toUtf8(), sql.toUtf8().length(), &ppStmt, &pzTail ); // XXX Need to free memory from the error msg if one is set if ( rc == SQLITE_OK ) { // get the first row of the result set while ( sqlite3_step( ppStmt ) == SQLITE_ROW ) { myCRSs.insert( QString::fromUtf8(( const char * )sqlite3_column_text( ppStmt, 0 ) ) ); } } else { // XXX query failed -- warn the user some how QMessageBox::warning( 0, tr( "Error" ), tr( "Failed to load SRIDS: %1" ).arg( sqlite3_errmsg( db ) ) ); status = false; } // close the statement sqlite3_finalize( ppStmt ); sqlite3_close( db ); if ( !status ) { return; } // prepare projection selector QgsGenericProjectionSelector *mySelector = new QgsGenericProjectionSelector( this ); mySelector->setMessage(); mySelector->setOgcWmsCrsFilter( myCRSs ); mySelector->setSelectedAuthId( mCrsId ); if ( mySelector->exec() ) { QgsCoordinateReferenceSystem srs; srs.createFromOgcWmsCrs( mySelector->selectedAuthId() ); QString crsId = srs.authid(); if ( crsId != mCrsId ) { mCrsId = crsId; leSRID->setText( srs.authid() + " - " + srs.description() ); } } delete mySelector; }