Skip to content

Commit 4dc85e4

Browse files
committed
Removed ellipsoid settings from QgsOptions
1 parent 3e91d38 commit 4dc85e4

File tree

3 files changed

+25
-260
lines changed

3 files changed

+25
-260
lines changed

src/app/qgsoptions.cpp

-183
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@
5858
#include <cpl_conv.h> // for setting gdal options
5959

6060
#include "qgsconfig.h"
61-
const char * QgsOptions::GEO_NONE_DESC = QT_TRANSLATE_NOOP( "QgsOptions", "None / Planimetric" );
6261

6362
/**
6463
* \class QgsOptions - Set user options and preferences
@@ -82,8 +81,6 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
8281
connect( mFontFamilyRadioCustom, SIGNAL( released() ), this, SLOT( updateAppStyleSheet() ) );
8382
connect( mFontFamilyComboBox, SIGNAL( currentFontChanged( const QFont& ) ), this, SLOT( updateAppStyleSheet() ) );
8483

85-
connect( cmbEllipsoid, SIGNAL( currentIndexChanged( int ) ), this, SLOT( updateEllipsoidUI( int ) ) );
86-
8784
#ifdef Q_WS_X11
8885
connect( chkEnableBackbuffer, SIGNAL( stateChanged( int ) ), this, SLOT( toggleEnableBackbuffer( int ) ) );
8986
#endif
@@ -286,34 +283,6 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
286283
//display the crs as friendly text rather than in wkt
287284
leProjectGlobalCrs->setText( mDefaultCrs.authid() + " - " + mDefaultCrs.description() );
288285

289-
// populate combo box with ellipsoids
290-
291-
QgsDebugMsg( "Setting upp ellipsoid" );
292-
293-
mEllipsoidIndex = 0;
294-
populateEllipsoidList();
295-
296-
// Reading ellipsoid from setttings
297-
QStringList mySplitEllipsoid = settings.value( "/qgis/measure/ellipsoid", GEO_NONE ).toString().split( ':' );
298-
299-
int myIndex = 0;
300-
int i;
301-
for ( i = 0; i < mEllipsoidList.length(); i++ )
302-
{
303-
if ( mEllipsoidList[ i ].acronym.startsWith( mySplitEllipsoid[ 0 ] ) )
304-
{
305-
myIndex = i;
306-
break;
307-
}
308-
}
309-
// Update paramaters if present.
310-
if ( mySplitEllipsoid.length() >= 3 )
311-
{
312-
mEllipsoidList[ myIndex ].semiMajor = mySplitEllipsoid[ 1 ].toDouble();
313-
mEllipsoidList[ myIndex ].semiMinor = mySplitEllipsoid[ 2 ].toDouble();
314-
}
315-
316-
updateEllipsoidUI( myIndex );
317286

318287
// Set the units for measuring
319288
QGis::UnitType myDisplayUnits = QGis::fromLiteral( settings.value( "/qgis/measure/displayunits", QGis::toLiteral( QGis::Meters ) ).toString() );
@@ -1000,26 +969,6 @@ void QgsOptions::saveOptions()
1000969
settings.setValue( "/Projections/otfTransformEnabled", chkOtfTransform->isChecked() );
1001970
settings.setValue( "/Projections/projectDefaultCrs", mDefaultCrs.authid() );
1002971

1003-
if ( mEllipsoidList[ mEllipsoidIndex ].acronym.startsWith( "PARAMETER" ) )
1004-
{
1005-
double major = mEllipsoidList[ mEllipsoidIndex ].semiMajor;
1006-
double minor = mEllipsoidList[ mEllipsoidIndex ].semiMinor;
1007-
// If the user fields have changed, use them instead.
1008-
if ( leSemiMajor->isModified() || leSemiMinor->isModified() )
1009-
{
1010-
QgsDebugMsg( "Using paramteric major/minor" );
1011-
major = QLocale::system().toDouble( leSemiMajor->text() );
1012-
minor = QLocale::system().toDouble( leSemiMinor->text() );
1013-
}
1014-
settings.setValue( "/qgis/measure/ellipsoid", QString( "PARAMETER:%1:%2" )
1015-
.arg( major, 0, 'g', 17 )
1016-
.arg( minor, 0, 'g', 17 ) );
1017-
}
1018-
else
1019-
{
1020-
settings.setValue( "/qgis/measure/ellipsoid", mEllipsoidList[ mEllipsoidIndex ].acronym );
1021-
}
1022-
1023972
if ( radFeet->isChecked() )
1024973
{
1025974
settings.setValue( "/qgis/measure/displayunits", QGis::toLiteral( QGis::Feet ) );
@@ -1245,88 +1194,6 @@ bool QgsOptions::newVisible()
12451194
{
12461195
return chkAddedVisibility->isChecked();
12471196
}
1248-
void QgsOptions::populateEllipsoidList()
1249-
{
1250-
//
1251-
// Populate the ellipsoid list
1252-
//
1253-
sqlite3 *myDatabase;
1254-
const char *myTail;
1255-
sqlite3_stmt *myPreparedStatement;
1256-
int myResult;
1257-
EllipsoidDefs myItem, i;
1258-
1259-
myItem.acronym = GEO_NONE;
1260-
myItem.description = tr( GEO_NONE_DESC );
1261-
myItem.semiMajor = 0.0;
1262-
myItem.semiMinor = 0.0;
1263-
mEllipsoidList.append( myItem );
1264-
1265-
myItem.acronym = QString( "PARAMETER:6370997:6370997" );
1266-
myItem.description = tr( "Parameters :" );
1267-
myItem.semiMajor = 6370997.0;
1268-
myItem.semiMinor = 6370997.0;
1269-
mEllipsoidList.append( myItem );
1270-
1271-
//check the db is available
1272-
myResult = sqlite3_open_v2( QgsApplication::srsDbFilePath().toUtf8().data(), &myDatabase, SQLITE_OPEN_READONLY, NULL );
1273-
if ( myResult )
1274-
{
1275-
QgsDebugMsg( QString( "Can't open database: %1" ).arg( sqlite3_errmsg( myDatabase ) ) );
1276-
// XXX This will likely never happen since on open, sqlite creates the
1277-
// database if it does not exist.
1278-
Q_ASSERT( myResult == 0 );
1279-
}
1280-
1281-
// Set up the query to retrieve the projection information needed to populate the ELLIPSOID list
1282-
QString mySql = "select acronym, name, radius, parameter2 from tbl_ellipsoid order by name";
1283-
myResult = sqlite3_prepare( myDatabase, mySql.toUtf8(), mySql.toUtf8().length(), &myPreparedStatement, &myTail );
1284-
// XXX Need to free memory from the error msg if one is set
1285-
if ( myResult == SQLITE_OK )
1286-
{
1287-
while ( sqlite3_step( myPreparedStatement ) == SQLITE_ROW )
1288-
{
1289-
QString para1, para2;
1290-
myItem.acronym = ( const char * )sqlite3_column_text( myPreparedStatement, 0 );
1291-
myItem.description = ( const char * )sqlite3_column_text( myPreparedStatement, 1 );
1292-
1293-
// Copied from QgsDistanecArea. Should perhaps be moved there somehow?
1294-
// No error checking, this values are for show only, never used in calculations.
1295-
1296-
// Fall-back values
1297-
myItem.semiMajor = 0.0;
1298-
myItem.semiMinor = 0.0;
1299-
// Crash if no column?
1300-
para1 = ( const char * )sqlite3_column_text( myPreparedStatement, 2 );
1301-
para2 = ( const char * )sqlite3_column_text( myPreparedStatement, 3 );
1302-
myItem.semiMajor = para1.mid( 2 ).toDouble();
1303-
if ( para2.left( 2 ) == "b=" )
1304-
{
1305-
myItem.semiMinor = para2.mid( 2 ).toDouble();
1306-
}
1307-
else if ( para2.left( 3 ) == "rf=" )
1308-
{
1309-
double invFlattening = para2.mid( 3 ).toDouble();
1310-
if ( invFlattening != 0.0 )
1311-
{
1312-
myItem.semiMinor = myItem.semiMajor - ( myItem.semiMajor / invFlattening );
1313-
}
1314-
}
1315-
mEllipsoidList.append( myItem );
1316-
}
1317-
}
1318-
1319-
// close the sqlite3 statement
1320-
sqlite3_finalize( myPreparedStatement );
1321-
sqlite3_close( myDatabase );
1322-
1323-
// Add all items to selector
1324-
1325-
foreach ( i, mEllipsoidList )
1326-
{
1327-
cmbEllipsoid->addItem( i.description );
1328-
}
1329-
}
13301197

13311198
QStringList QgsOptions::i18nList()
13321199
{
@@ -1736,53 +1603,3 @@ void QgsOptions::saveContrastEnhancement( QComboBox *cbox, QString name )
17361603
settings.setValue( "/Raster/defaultContrastEnhancementAlgorithm/" + name, value );
17371604
}
17381605

1739-
void QgsOptions::updateEllipsoidUI( int newIndex )
1740-
{
1741-
// Called whenever settings change, adjusts the UI accordingly
1742-
// Pre-select current ellipsoid
1743-
1744-
// Check if CRS transformation is on, or else turn everything off
1745-
double myMajor = mEllipsoidList[ newIndex ].semiMajor;
1746-
double myMinor = mEllipsoidList[ newIndex ].semiMinor;
1747-
1748-
// If user has modified the radii (only possible if parametric!), before
1749-
// changing ellipsoid, save the modified coordinates
1750-
if ( leSemiMajor->isModified() || leSemiMinor->isModified() )
1751-
{
1752-
QgsDebugMsg( "Saving major/minor" );
1753-
mEllipsoidList[ mEllipsoidIndex ].semiMajor = QLocale::system().toDouble( leSemiMajor->text() );
1754-
mEllipsoidList[ mEllipsoidIndex ].semiMinor = QLocale::system().toDouble( leSemiMinor->text() );
1755-
}
1756-
1757-
mEllipsoidIndex = newIndex;
1758-
leSemiMajor->setEnabled( false );
1759-
leSemiMinor->setEnabled( false );
1760-
leSemiMajor->setText( "" );
1761-
leSemiMinor->setText( "" );
1762-
if ( QgisApp::instance()->mapCanvas()->mapRenderer()->hasCrsTransformEnabled() )
1763-
{
1764-
cmbEllipsoid->setEnabled( true );
1765-
cmbEllipsoid->setToolTip( "" );
1766-
if ( mEllipsoidList[ mEllipsoidIndex ].acronym.startsWith( "PARAMETER:" ) )
1767-
{
1768-
leSemiMajor->setEnabled( true );
1769-
leSemiMinor->setEnabled( true );
1770-
}
1771-
else
1772-
{
1773-
leSemiMajor->setToolTip( QString( "Select %1 from pull-down menu to adjust radii" ).arg( tr( "Parameters:" ) ) );
1774-
leSemiMinor->setToolTip( QString( "Select %1 from pull-down menu to adjust radii" ).arg( tr( "Parameters:" ) ) );
1775-
}
1776-
cmbEllipsoid->setCurrentIndex( mEllipsoidIndex ); // Not always necessary
1777-
if ( mEllipsoidList[ mEllipsoidIndex ].acronym != GEO_NONE )
1778-
{
1779-
leSemiMajor->setText( QLocale::system().toString( myMajor, 'f', 3 ) );
1780-
leSemiMinor->setText( QLocale::system().toString( myMinor, 'f', 3 ) );
1781-
}
1782-
}
1783-
else
1784-
{
1785-
cmbEllipsoid->setEnabled( false );
1786-
cmbEllipsoid->setToolTip( tr( "Can only use ellipsoidal calculations when CRS transformation is enabled" ) );
1787-
}
1788-
}

src/app/qgsoptions.h

-21
Original file line numberDiff line numberDiff line change
@@ -189,12 +189,6 @@ class QgsOptions : public QDialog, private Ui::QgsOptionsBase
189189
*/
190190
void saveGdalDriverList();
191191

192-
/* Update ComboBox accorindg to the selected new index
193-
* Also sets the new selected Ellipsoid.
194-
* @note added in 2.0
195-
*/
196-
void updateEllipsoidUI( int newIndex );
197-
198192
private:
199193
QStringList i18nList();
200194
void initContrastEnhancement( QComboBox *cbox, QString name, QString defaultVal );
@@ -203,21 +197,6 @@ class QgsOptions : public QDialog, private Ui::QgsOptionsBase
203197
QgsCoordinateReferenceSystem mLayerDefaultCrs;
204198
bool mLoadedGdalDriverList;
205199

206-
// List for all ellispods, also None and Custom
207-
struct EllipsoidDefs
208-
{
209-
QString acronym;
210-
QString description;
211-
double semiMajor;
212-
double semiMinor;
213-
};
214-
QList<EllipsoidDefs> mEllipsoidList;
215-
int mEllipsoidIndex;
216-
217-
//! Populates list with ellipsoids from Sqlite3 db
218-
void populateEllipsoidList();
219-
220-
static const char * GEO_NONE_DESC;
221200
};
222201

223202
#endif // #ifndef QGSOPTIONS_H

0 commit comments

Comments
 (0)