From 5a71ab27d9a7be195c1b2d889d40bf53e0c13820 Mon Sep 17 00:00:00 2001 From: timlinux Date: Sat, 7 May 2005 07:11:19 +0000 Subject: [PATCH] Gui enhancements for search by srid or epsg git-svn-id: http://svn.osgeo.org/qgis/trunk@3328 c8812cc2-4d05-0410-92ff-de0c093fc19c --- .../qgsprojectionselector.cpp | 59 ++------- .../qgsprojectionselector.h | 3 +- .../qgsprojectionselectorbase.ui | 115 ++++++++++-------- .../qgsprojectionselectorbase.ui.h | 8 +- 4 files changed, 79 insertions(+), 106 deletions(-) diff --git a/widgets/projectionselector/qgsprojectionselector.cpp b/widgets/projectionselector/qgsprojectionselector.cpp index 0acee672841..84121ca9b5c 100644 --- a/widgets/projectionselector/qgsprojectionselector.cpp +++ b/widgets/projectionselector/qgsprojectionselector.cpp @@ -33,7 +33,7 @@ #include #include #include - +#include //gdal and ogr includes // XXX DO WE NEED THESE? #include @@ -548,11 +548,11 @@ void QgsProjectionSelector::coordinateSystemSelected( QListViewItem * theItem ) } } -void QgsProjectionSelector::pbnFindSRID_clicked() +void QgsProjectionSelector::pbnFind_clicked() { #ifdef QGISDEBUG - std::cout << "pbnFindSRID_clicked..." << std::endl; + std::cout << "pbnFind..." << std::endl; #endif @@ -574,9 +574,17 @@ void QgsProjectionSelector::pbnFindSRID_clicked() } // Set up the query to retreive the projection information needed to populate the list - QString mySql = "select srs_id from tbl_srs where srid=" + leSRID->text(); + QString mySql; + if (radSRID->isChecked()) + { + mySql= "select srs_id from tbl_srs where srid=" + leSearch->text(); + } + else + { + mySql= "select srs_id from tbl_srs where epsg=" + leSearch->text(); + } #ifdef QGISDEBUG - std::cout << "SRID Search sql" << mySql << std::endl; + std::cout << " Search sql" << mySql << std::endl; #endif myResult = sqlite3_prepare(myDatabase, (const char *)mySql, mySql.length(), &myPreparedStatement, &myTail); // XXX Need to free memory from the error msg if one is set @@ -593,44 +601,3 @@ void QgsProjectionSelector::pbnFindSRID_clicked() } -void QgsProjectionSelector::pbnFindEPSG_clicked() -{ -#ifdef QGISDEBUG - std::cout << "pbnFindEPSG_clicked..." << std::endl; -#endif - - - sqlite3 *myDatabase; - char *myErrorMessage = 0; - const char *myTail; - sqlite3_stmt *myPreparedStatement; - int myResult; - //check the db is available - myResult = sqlite3_open(mSrsDatabaseFileName, &myDatabase); - if(myResult) - { - std::cout << "Can't open database: " << sqlite3_errmsg(myDatabase) << std::endl; - // XXX This will likely never happen since on open, sqlite creates the - // database if it does not exist. But we checked earlier for its existance - // and aborted in that case. This is because we may be runnig from read only - // media such as live cd and dont want to force trying to create a db. - assert(myResult == 0); - } - - // Set up the query to retreive the projection information needed to populate the list - QString mySql = "select srs_id from tbl_srs where epsg=" + leEPSG->text(); -#ifdef QGISDEBUG - std::cout << "SRID Search sql" << mySql << std::endl; -#endif - myResult = sqlite3_prepare(myDatabase, (const char *)mySql, mySql.length(), &myPreparedStatement, &myTail); - // XXX Need to free memory from the error msg if one is set - if(myResult == SQLITE_OK) - { - sqlite3_step(myPreparedStatement); - QString mySrsId ((char *)sqlite3_column_text(myPreparedStatement, 0)); - setSelectedSRSID(mySrsId.toLong()); - } - // close the sqlite3 statement - sqlite3_finalize(myPreparedStatement); - sqlite3_close(myDatabase); -} \ No newline at end of file diff --git a/widgets/projectionselector/qgsprojectionselector.h b/widgets/projectionselector/qgsprojectionselector.h index d8c6d91e674..c2ce1f8e126 100644 --- a/widgets/projectionselector/qgsprojectionselector.h +++ b/widgets/projectionselector/qgsprojectionselector.h @@ -43,8 +43,7 @@ public slots: QString getCurrentProj4String(); long getCurrentSRID(); //posgis style projection identifier long getCurrentSRSID();//qgis projection identfier - void pbnFindSRID_clicked(); - void pbnFindEPSG_clicked(); + void pbnFind_clicked(); private: diff --git a/widgets/projectionselector/qgsprojectionselectorbase.ui b/widgets/projectionselector/qgsprojectionselectorbase.ui index b9403a4e39c..0d8354b12ee 100644 --- a/widgets/projectionselector/qgsprojectionselectorbase.ui +++ b/widgets/projectionselector/qgsprojectionselectorbase.ui @@ -33,7 +33,7 @@ unnamed - + Coordinate Systems @@ -66,14 +66,14 @@ true - + teProjection 7 - 0 + 7 0 0 @@ -88,47 +88,67 @@ true - + - leSRID + buttonGroup2_2 - - - - pbnFindSRID - - - Find - - - - - textLabel1 - - - Postgis SRID: - - - - - leEPSG - - - - - pbnFindEPSG - - - Find - - - - - textLabel1_2 - - - EPSG ID: + + Search + + + unnamed + + + + leSearch + + + + + pbnFind + + + Find + + + + + radSRID + + + Postgis SRID + + + true + + + + + radEPSGID + + + EPSG ID + + + + + spacer1 + + + Horizontal + + + Expanding + + + + 81 + 21 + + + + @@ -147,16 +167,10 @@ coordinateSystemSelected(QListViewItem*) - pbnFindSRID + pbnFind clicked() QgsProjectionSelectorBase - pbnFindSRID_clicked() - - - pbnFindEPSG - clicked() - QgsProjectionSelectorBase - pbnFindEPSG_clicked() + pbnFind_clicked() @@ -165,8 +179,7 @@ projectionChanged( const QString & ) coordinateSystemSelected( QListViewItem * ) - pbnFindSRID_clicked() - pbnFindEPSG_clicked() + pbnFind_clicked() diff --git a/widgets/projectionselector/qgsprojectionselectorbase.ui.h b/widgets/projectionselector/qgsprojectionselectorbase.ui.h index 288bfea9bce..411af524c37 100644 --- a/widgets/projectionselector/qgsprojectionselectorbase.ui.h +++ b/widgets/projectionselector/qgsprojectionselectorbase.ui.h @@ -24,13 +24,7 @@ void QgsProjectionSelectorBase::coordinateSystemSelected( QListViewItem * ) } -void QgsProjectionSelectorBase::pbnFindSRID_clicked() -{ - -} - - -void QgsProjectionSelectorBase::pbnFindEPSG_clicked() +void QgsProjectionSelectorBase::pbnFind_clicked() { }