Skip to content

Commit 9dd8b2f

Browse files
committed
Merge branch 'customCRS' of https://github.com/leyan/Quantum-GIS
2 parents 8012065 + 6e3e89b commit 9dd8b2f

8 files changed

+433
-888
lines changed

src/app/qgscustomprojectiondialog.cpp

Lines changed: 256 additions & 697 deletions
Large diffs are not rendered by default.

src/app/qgscustomprojectiondialog.h

Lines changed: 30 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
#include "ui_qgscustomprojectiondialogbase.h"
2222
#include "qgscontexthelp.h"
23+
#include "qgscoordinatereferencesystem.h"
2324

2425
class QDir;
2526

@@ -34,45 +35,41 @@ class QgsCustomProjectionDialog : public QDialog, private Ui::QgsCustomProjectio
3435
public:
3536
QgsCustomProjectionDialog( QWidget *parent = 0, Qt::WFlags fl = 0 );
3637
~QgsCustomProjectionDialog();
37-
//a recursive function to make a directory and its ancestors
38+
3839
public slots:
3940
void on_pbnCalculate_clicked();
40-
void on_pbnDelete_clicked();
41-
//
42-
// Database navigation controles
43-
//
44-
long getRecordCount();
45-
void on_pbnFirst_clicked();
46-
void on_pbnPrevious_clicked();
47-
void on_pbnNext_clicked();
48-
void on_pbnLast_clicked();
49-
void on_pbnNew_clicked();
50-
void on_pbnSave_clicked();
41+
void on_pbnAdd_clicked();
42+
void on_pbnRemove_clicked();
43+
void on_pbnCopyCRS_clicked();
44+
void on_leNameList_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem *prev );
5145

5246
void on_buttonBox_helpRequested() { QgsContextHelp::run( metaObject()->className() ); }
53-
54-
//
55-
// Control population
56-
//
57-
/* These two methods will be deprecated
58-
void getProjList();
59-
void getEllipsoidList();
60-
*/
61-
QString getProjectionFamilyName( QString theProjectionFamilyAcronym );
62-
QString getEllipsoidName( QString theEllipsoidAcronym );
63-
QString getProjectionFamilyAcronym( QString theProjectionFamilyName );
64-
QString getEllipsoidAcronym( QString theEllipsoidName );
47+
void on_buttonBox_accepted();
48+
6549
private:
66-
QString getProjFromParameters();
67-
QString getEllipseFromParameters();
68-
69-
QString mCurrentRecordId;
70-
long mCurrentRecordLong;
71-
//the record previous to starting an insert operation
72-
//so that we can return to it if the record insert is aborted
73-
long mLastRecordLong;
74-
long mRecordCountLong;
50+
51+
//helper functions
52+
void populateList();
7553
QString quotedValue( QString value );
54+
bool deleteCRS( QString id );
55+
bool saveCRS( QgsCoordinateReferenceSystem myParameters, QString myName, QString myId, bool newEntry );
56+
void insertProjection( QString myProjectionAcronym );
57+
58+
//These two QMap store the values as they are on the database when loading
59+
QMap <QString, QString> existingCRSparameters;
60+
QMap <QString, QString> existingCRSnames;
61+
62+
//These three vectors store the value updated with the current modifications
63+
std::vector<QString> customCRSnames;
64+
std::vector<QString> customCRSids;
65+
std::vector<QString> customCRSparameters;
66+
67+
//vector saving the CRS to be deleted
68+
std::vector<QString> deletedCRSs;
69+
70+
//Columns in the tree widget
71+
enum columns { QGIS_CRS_NAME_COLUMN, QGIS_CRS_ID_COLUMN, QGIS_CRS_PARAMETERS_COLUMN };
7672
};
7773

74+
7875
#endif

src/core/qgscoordinatereferencesystem.cpp

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <QRegExp>
2828
#include <QTextStream>
2929
#include <QFile>
30+
#include <QSettings>
3031

3132
#include "qgsapplication.h"
3233
#include "qgscrscache.h"
@@ -662,6 +663,7 @@ bool QgsCoordinateReferenceSystem::createFromProj4( const QString theProj4String
662663
if ( !mIsValidFlag )
663664
{
664665
QgsDebugMsg( "Projection is not found in databases." );
666+
//setProj4String will set mIsValidFlag to true if there is no issue
665667
setProj4String( myProj4String );
666668
}
667669

@@ -1472,8 +1474,28 @@ bool QgsCoordinateReferenceSystem::saveAsUserCRS( QString name )
14721474

14731475
QgsMessageLog::logMessage( QObject::tr( "Saved user CRS [%1]" ).arg( toProj4() ), QObject::tr( "CRS" ) );
14741476

1475-
// XXX Need to free memory from the error msg if one is set
1476-
return myResult == SQLITE_OK;
1477+
int return_id;
1478+
if(myResult == SQLITE_OK)
1479+
{
1480+
return_id = sqlite3_last_insert_rowid( myDatabase );
1481+
setInternalId(return_id);
1482+
1483+
//We add the just created user CRS to the list of recently used CRS
1484+
QSettings settings;
1485+
//QStringList recentProjections = settings.value( "/UI/recentProjections" ).toStringList();
1486+
QStringList projectionsProj4 = settings.value( "/UI/recentProjectionsProj4" ).toStringList();
1487+
QStringList projectionsAuthId = settings.value( "/UI/recentProjectionsAuthId" ).toStringList();
1488+
//recentProjections.append();
1489+
//settings.setValue( "/UI/recentProjections", recentProjections );
1490+
projectionsProj4.append(toProj4());
1491+
projectionsAuthId.append(authid());
1492+
settings.setValue( "/UI/recentProjectionsProj4", projectionsProj4 );
1493+
settings.setValue( "/UI/recentProjectionsAuthId", projectionsAuthId );
1494+
1495+
}
1496+
else
1497+
return_id = -1;
1498+
return return_id;
14771499
}
14781500

14791501
long QgsCoordinateReferenceSystem::getRecordCount()

src/core/qgscoordinatereferencesystem.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ class CORE_EXPORT QgsCoordinateReferenceSystem
134134
* in the parameters member. The reason for this is so that we
135135
* can easily present the user with 'natural language' representation
136136
* of the projection and ellipsoid by looking them up in the srs.bs sqlite
137-
* database. Also having the ellpse and proj elements stripped out
137+
* database. Also having the ellipse and proj elements stripped out
138138
* is helpful to speed up globbing queries (see below).
139139
*
140140
* We try to match the proj string to and srsid using the following logic:
@@ -444,7 +444,7 @@ class CORE_EXPORT QgsCoordinateReferenceSystem
444444
long mSRID;
445445
//!If available the authority identifier for this srs
446446
QString mAuthId;
447-
//! Wehter this srs is properly defined and valid
447+
//! Wheter this srs is properly defined and valid
448448
bool mIsValidFlag;
449449

450450
//! Work out the projection units and set the appropriate local variable

src/gui/qgsprojectionselector.cpp

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -81,19 +81,10 @@ QgsProjectionSelector::QgsProjectionSelector( QWidget* parent, const char *name,
8181
// No? Skip this entry
8282
continue;
8383
}
84-
else
84+
//If the CRS can be created but do not correspond to a CRS in the database, skip it (for example a deleted custom CRS)
85+
if ( crs.srsid() == 0 )
8586
{
86-
//TODO: createFromProj4 used to save to the user database any new CRS
87-
// this behavior was changed in order to separate creation and saving.
88-
// Not sure if it necessary to save it here, should be checked by someone
89-
// familiar with the code (should also give a more descriptive name to the generated CRS)
90-
if ( crs.srsid() == 0 )
91-
{
92-
QString myName = QString( " * %1 (%2)" )
93-
.arg( QObject::tr( "Generated CRS", "A CRS automatically generated from layer info get this prefix for description" ) )
94-
.arg( crs.toProj4() );
95-
crs.saveAsUserCRS( myName );
96-
}
87+
continue;
9788
}
9889
}
9990
mRecentProjections << QString::number( crs.srsid() );
@@ -277,7 +268,7 @@ void QgsProjectionSelector::applySelection( int column, QString value )
277268
}
278269
else
279270
{
280-
QgsDebugMsg( "nothing found" );
271+
QgsDebugMsg( QString("nothing found for %1,%2" ).arg( column ).arg( value ) );
281272
// unselect the selected item to avoid confusing the user
282273
lstCoordinateSystems->clearSelection();
283274
lstRecent->clearSelection();

src/providers/wcs/qgswcsprovider.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ void QgsWcsProvider::readBlock( int bandNo, QgsRectangle const & viewExtent, in
556556
// It may happen (Geoserver) that if requested BBOX is larger than coverage
557557
// extent, the returned data cover intersection of requested BBOX and coverage
558558
// extent scaled to requested WIDTH/HEIGHT => check extent
559-
// Unfortunately if received raster does not hac CRS, the extent is raster size
559+
// Unfortunately if the received raster does not have a CRS, the extent is the raster size
560560
// and in that case it cannot be used to verify extent
561561
QgsCoordinateReferenceSystem cacheCrs;
562562
if ( !cacheCrs.createFromWkt( GDALGetProjectionRef( mCachedGdalDataset ) ) &&

0 commit comments

Comments
 (0)