Skip to content
Browse files
Merge branch 'customCRS' of
  • Loading branch information
timlinux committed May 12, 2013
2 parents 8012065 + 6e3e89b commit 9dd8b2ff6e1db9c6c9c67d7e6ee51f624762c0f1

Large diffs are not rendered by default.

@@ -20,6 +20,7 @@

#include "ui_qgscustomprojectiondialogbase.h"
#include "qgscontexthelp.h"
#include "qgscoordinatereferencesystem.h"

class QDir;

@@ -34,45 +35,41 @@ class QgsCustomProjectionDialog : public QDialog, private Ui::QgsCustomProjectio
QgsCustomProjectionDialog( QWidget *parent = 0, Qt::WFlags fl = 0 );
//a recursive function to make a directory and its ancestors

public slots:
void on_pbnCalculate_clicked();
void on_pbnDelete_clicked();
// Database navigation controles
long getRecordCount();
void on_pbnFirst_clicked();
void on_pbnPrevious_clicked();
void on_pbnNext_clicked();
void on_pbnLast_clicked();
void on_pbnNew_clicked();
void on_pbnSave_clicked();
void on_pbnAdd_clicked();
void on_pbnRemove_clicked();
void on_pbnCopyCRS_clicked();
void on_leNameList_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem *prev );

void on_buttonBox_helpRequested() { QgsContextHelp::run( metaObject()->className() ); }

// Control population
/* These two methods will be deprecated
void getProjList();
void getEllipsoidList();
QString getProjectionFamilyName( QString theProjectionFamilyAcronym );
QString getEllipsoidName( QString theEllipsoidAcronym );
QString getProjectionFamilyAcronym( QString theProjectionFamilyName );
QString getEllipsoidAcronym( QString theEllipsoidName );
void on_buttonBox_accepted();

QString getProjFromParameters();
QString getEllipseFromParameters();

QString mCurrentRecordId;
long mCurrentRecordLong;
//the record previous to starting an insert operation
//so that we can return to it if the record insert is aborted
long mLastRecordLong;
long mRecordCountLong;

//helper functions
void populateList();
QString quotedValue( QString value );
bool deleteCRS( QString id );
bool saveCRS( QgsCoordinateReferenceSystem myParameters, QString myName, QString myId, bool newEntry );
void insertProjection( QString myProjectionAcronym );

//These two QMap store the values as they are on the database when loading
QMap <QString, QString> existingCRSparameters;
QMap <QString, QString> existingCRSnames;

//These three vectors store the value updated with the current modifications
std::vector<QString> customCRSnames;
std::vector<QString> customCRSids;
std::vector<QString> customCRSparameters;

//vector saving the CRS to be deleted
std::vector<QString> deletedCRSs;

//Columns in the tree widget

@@ -27,6 +27,7 @@
#include <QRegExp>
#include <QTextStream>
#include <QFile>
#include <QSettings>

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

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

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

// XXX Need to free memory from the error msg if one is set
return myResult == SQLITE_OK;
int return_id;
if(myResult == SQLITE_OK)
return_id = sqlite3_last_insert_rowid( myDatabase );

//We add the just created user CRS to the list of recently used CRS
QSettings settings;
//QStringList recentProjections = settings.value( "/UI/recentProjections" ).toStringList();
QStringList projectionsProj4 = settings.value( "/UI/recentProjectionsProj4" ).toStringList();
QStringList projectionsAuthId = settings.value( "/UI/recentProjectionsAuthId" ).toStringList();
//settings.setValue( "/UI/recentProjections", recentProjections );
settings.setValue( "/UI/recentProjectionsProj4", projectionsProj4 );
settings.setValue( "/UI/recentProjectionsAuthId", projectionsAuthId );

return_id = -1;
return return_id;

long QgsCoordinateReferenceSystem::getRecordCount()
@@ -134,7 +134,7 @@ class CORE_EXPORT QgsCoordinateReferenceSystem
* in the parameters member. The reason for this is so that we
* can easily present the user with 'natural language' representation
* of the projection and ellipsoid by looking them up in the sqlite
* database. Also having the ellpse and proj elements stripped out
* database. Also having the ellipse and proj elements stripped out
* is helpful to speed up globbing queries (see below).
* We try to match the proj string to and srsid using the following logic:
@@ -444,7 +444,7 @@ class CORE_EXPORT QgsCoordinateReferenceSystem
long mSRID;
//!If available the authority identifier for this srs
QString mAuthId;
//! Wehter this srs is properly defined and valid
//! Wheter this srs is properly defined and valid
bool mIsValidFlag;

//! Work out the projection units and set the appropriate local variable
@@ -81,19 +81,10 @@ QgsProjectionSelector::QgsProjectionSelector( QWidget* parent, const char *name,
// No? Skip this entry
//If the CRS can be created but do not correspond to a CRS in the database, skip it (for example a deleted custom CRS)
if ( crs.srsid() == 0 )
//TODO: createFromProj4 used to save to the user database any new CRS
// this behavior was changed in order to separate creation and saving.
// Not sure if it necessary to save it here, should be checked by someone
// familiar with the code (should also give a more descriptive name to the generated CRS)
if ( crs.srsid() == 0 )
QString myName = QString( " * %1 (%2)" )
.arg( QObject::tr( "Generated CRS", "A CRS automatically generated from layer info get this prefix for description" ) )
.arg( crs.toProj4() );
crs.saveAsUserCRS( myName );
mRecentProjections << QString::number( crs.srsid() );
@@ -277,7 +268,7 @@ void QgsProjectionSelector::applySelection( int column, QString value )
QgsDebugMsg( "nothing found" );
QgsDebugMsg( QString("nothing found for %1,%2" ).arg( column ).arg( value ) );
// unselect the selected item to avoid confusing the user
@@ -556,7 +556,7 @@ void QgsWcsProvider::readBlock( int bandNo, QgsRectangle const & viewExtent, in
// It may happen (Geoserver) that if requested BBOX is larger than coverage
// extent, the returned data cover intersection of requested BBOX and coverage
// extent scaled to requested WIDTH/HEIGHT => check extent
// Unfortunately if received raster does not hac CRS, the extent is raster size
// Unfortunately if the received raster does not have a CRS, the extent is the raster size
// and in that case it cannot be used to verify extent
QgsCoordinateReferenceSystem cacheCrs;
if ( !cacheCrs.createFromWkt( GDALGetProjectionRef( mCachedGdalDataset ) ) &&

0 comments on commit 9dd8b2f

Please sign in to comment.