QGIS API Documentation
2.2.0-Valmiera
|
Class for storing a coordinate reference system (CRS) More...
#include <qgscoordinatereferencesystem.h>
Public Types | |
enum | CrsType { InternalCrsId, PostgisCrsId, EpsgCrsId } |
Public Member Functions | |
QgsCoordinateReferenceSystem () | |
Default constructor. | |
~QgsCoordinateReferenceSystem () | |
QgsCoordinateReferenceSystem (QString theDefinition) | |
QgsCoordinateReferenceSystem (const long theId, CrsType theType=PostgisCrsId) | |
QgsCoordinateReferenceSystem (const QgsCoordinateReferenceSystem &srs) | |
copy constructor | |
QgsCoordinateReferenceSystem & | operator= (const QgsCoordinateReferenceSystem &srs) |
Assignment operator. | |
bool | createFromId (const long theId, CrsType theType=PostgisCrsId) |
bool | createFromOgcWmsCrs (QString theCrs) |
Set up this CRS from the given OGC CRS. | |
bool | createFromSrid (const long theSrid) |
bool | createFromWkt (const QString &theWkt) |
bool | createFromSrsId (const long theSrsId) |
bool | createFromProj4 (const QString &theProjString) |
bool | createFromString (const QString &theDefinition) |
bool | createFromUserInput (const QString &theDefinition) |
bool | isValid () const |
void | validate () |
long | findMatchingProj () |
bool | operator== (const QgsCoordinateReferenceSystem &theSrs) const |
bool | operator!= (const QgsCoordinateReferenceSystem &theSrs) const |
bool | readXML (QDomNode &theNode) |
bool | writeXML (QDomNode &theNode, QDomDocument &theDoc) const |
long | srsid () const |
long | postgisSrid () const |
QString | authid () const |
QString | description () const |
QString | projectionAcronym () const |
QString | ellipsoidAcronym () const |
QString | toWkt () const |
QString | toProj4 () const |
Get the Proj Proj4 string representation of this srs. | |
bool | geographicFlag () const |
bool | axisInverted () const |
QGis::UnitType | mapUnits () const |
void | setValidationHint (QString html) |
QString | validationHint () |
bool | saveAsUserCRS (QString name) |
Copied from QgsCustomProjectionDialog /// Please refactor into SQL handler !!! ///. | |
QString | geographicCRSAuthId () const |
Returns auth id of related geographic CRS. |
Static Public Member Functions | |
static void | setupESRIWktFix () |
static void | setCustomSrsValidation (CUSTOM_CRS_VALIDATION f) |
Sets custom function to force valid CRS QGIS uses implementation in QgisGui::customSrsValidation. | |
static CUSTOM_CRS_VALIDATION | customSrsValidation () |
Gets custom function. | |
static int | syncDb () |
Private Types | |
typedef QMap< QString, QString > | RecordMap |
Private Member Functions | |
void | setInternalId (long theSrsId) |
void | setSrid (long theSrid) |
void | setDescription (QString theDescription) |
void | setProj4String (QString theProj4String) |
void | setGeographicFlag (bool theGeoFlag) |
void | setEpsg (long theEpsg) |
void | setAuthId (QString theID) |
void | setProjectionAcronym (QString theProjectionAcronym) |
void | setEllipsoidAcronym (QString theEllipsoidAcronym) |
void | debugPrint () |
RecordMap | getRecord (QString theSql) |
void | setMapUnits () |
Work out the projection units and set the appropriate local variable. | |
long | getRecordCount () |
Helper for getting number of user CRS already in db. | |
bool | loadFromDb (QString db, QString expression, QString value) |
Static Private Member Functions | |
static QString | proj4FromSrsId (const int theSrsId) |
A static helper function to find out the proj4 string for a srsid. | |
static int | openDb (QString path, sqlite3 **db, bool readonly=true) |
static QString | quotedValue (QString value) |
Helper for sql-safe value quoting. | |
static bool | loadIDs (QHash< int, QString > &wkts) |
static bool | loadWkts (QHash< int, QString > &wkts, const char *filename) |
static bool | syncDatumTransform (const QString &dbPath) |
Private Attributes | |
long | mSrsId |
The internal sqlite3 srs.db primary key for this srs. | |
QString | mDescription |
A textual description of the srs. | |
QString | mProjectionAcronym |
The official proj4 acronym for the projection family. | |
QString | mEllipsoidAcronym |
The official proj4 acronym for the ellipoid. | |
bool | mGeoFlag |
Whether this is a geographic or projected coordinate system. | |
QGis::UnitType | mMapUnits |
The map units. | |
long | mSRID |
If available, the Postgis spatial_ref_sys identifier for this srs (defaults to 0) | |
QString | mAuthId |
If available the authority identifier for this srs. | |
bool | mIsValidFlag |
Whether this srs is properly defined and valid. | |
OGRSpatialReferenceH | mCRS |
QString | mValidationHint |
QString | mWkt |
QString | mProj4 |
int | mAxisInverted |
Whether this is a coordinate system has inverted axis. |
Static Private Attributes | |
static CUSTOM_CRS_VALIDATION | mCustomSrsValidation = NULL |
Class for storing a coordinate reference system (CRS)
Definition at line 50 of file qgscoordinatereferencesystem.h.
|
private |
A string based associative array used for passing records around
Definition at line 421 of file qgscoordinatereferencesystem.h.
Definition at line 54 of file qgscoordinatereferencesystem.h.
QgsCoordinateReferenceSystem::QgsCoordinateReferenceSystem | ( | ) |
Default constructor.
Definition at line 51 of file qgscoordinatereferencesystem.cpp.
References mCRS.
QgsCoordinateReferenceSystem::~QgsCoordinateReferenceSystem | ( | ) |
Definition at line 90 of file qgscoordinatereferencesystem.cpp.
References mCRS.
|
explicit |
Constructs a CRS object from a string definition as defined in the createFromString member function (by default a WKT definition).
theDefinition | A String containing a coordinate reference system definition. |
Definition at line 63 of file qgscoordinatereferencesystem.cpp.
References createFromString(), and mCRS.
QgsCoordinateReferenceSystem::QgsCoordinateReferenceSystem | ( | const long | theId, |
CrsType | theType = PostgisCrsId |
||
) |
Use this constructor when you want to create a CRS object using a postgis SRID, an EpsgCrsId id or a QGIS CRS_ID.
theId | The ID no valid for the chosen coordinate system id type |
theType | One of the types described in QgsCoordinateReferenceSystem::CrsType |
Definition at line 77 of file qgscoordinatereferencesystem.cpp.
References createFromId(), and mCRS.
QgsCoordinateReferenceSystem::QgsCoordinateReferenceSystem | ( | const QgsCoordinateReferenceSystem & | srs | ) |
QString QgsCoordinateReferenceSystem::authid | ( | ) | const |
Get the authority identifier for this srs
Definition at line 833 of file qgscoordinatereferencesystem.cpp.
References mAuthId.
Referenced by QgsCoordinateTransform::addNullGridShifts(), QgsRasterProjector::block(), QgsRasterProjector::calc(), QgsOfflineEditing::copyVectorLayer(), createFromWkt(), QgsCoordinateTransform::initialise(), QgsNewVectorLayerDialog::on_pbnChangeSpatialRefSys_clicked(), operator==(), QgsMapRenderer::outputExtentToLayerExtent(), QgsRasterCalculator::processCalculation(), QgsNewVectorLayerDialog::QgsNewVectorLayerDialog(), QgsOWSSourceSelect::QgsOWSSourceSelect(), saveAsUserCRS(), QgsMapRenderer::transformation(), QgsRasterLayerSaveAsDialog::updateCrsGroup(), and writeXML().
bool QgsCoordinateReferenceSystem::axisInverted | ( | ) | const |
return if axis is inverted (eg. for WMS 1.3)
Definition at line 404 of file qgscoordinatereferencesystem.cpp.
References mAuthId, mAxisInverted, and mCRS.
bool QgsCoordinateReferenceSystem::createFromId | ( | const long | theId, |
CrsType | theType = PostgisCrsId |
||
) |
Definition at line 95 of file qgscoordinatereferencesystem.cpp.
References createFromOgcWmsCrs(), createFromSrid(), createFromSrsId(), EpsgCrsId, InternalCrsId, PostgisCrsId, and QgsDebugMsg.
Referenced by createFromString(), QgsRasterLayerSaveAsDialog::on_mChangeCrsPushButton_clicked(), QgsCoordinateReferenceSystem(), QgsCoordinateTransform::QgsCoordinateTransform(), and readXML().
bool QgsCoordinateReferenceSystem::createFromOgcWmsCrs | ( | QString | theCrs | ) |
Set up this CRS from the given OGC CRS.
Sets this CRS to the given OGC WMS-format Coordinate Reference Systems.
false | if not given an valid label |
Definition at line 210 of file qgscoordinatereferencesystem.cpp.
References createFromSrsId(), loadFromDb(), mAxisInverted, mIsValidFlag, and QgsApplication::srsDbFilePath().
Referenced by createFromId(), createFromWkt(), QgsGml::crs(), QgsCRSCache::crsByAuthId(), QgsCoordinateTransform::datumTransformCrsInfo(), QgsOWSSourceSelect::descriptionForAuthId(), QgsOWSSourceSelect::on_mChangeCRSButton_clicked(), QgsNewVectorLayerDialog::on_pbnChangeSpatialRefSys_clicked(), QgsNewVectorLayerDialog::QgsNewVectorLayerDialog(), QgsProjectionSelector::QgsProjectionSelector(), QgsRasterLayerSaveAsDialog::QgsRasterLayerSaveAsDialog(), QgsDistanceArea::setSourceAuthId(), and QgsCRSCache::updateCRSCache().
bool QgsCoordinateReferenceSystem::createFromProj4 | ( | const QString & | theProjString | ) |
Set up this srs by passing it a proj4 style formatted string. The string will be parsed and the projection and ellipsoid members set and the remainder of the proj4 string will be stored 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 srs.bs sqlite 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:
theProjString | A proj4 format string |
Definition at line 511 of file qgscoordinatereferencesystem.cpp.
References createFromSrsId(), findMatchingProj(), getRecord(), LAT_PREFIX_LEN, mEllipsoidAcronym, mIsValidFlag, mProjectionAcronym, mWkt, QgsDebugMsg, quotedValue(), and setProj4String().
Referenced by createFromString(), createFromWkt(), QgsProjectionSelector::QgsProjectionSelector(), readXML(), and QgsDistanceArea::setEllipsoid().
bool QgsCoordinateReferenceSystem::createFromSrid | ( | const long | theSrid | ) |
Set up this srs by fetching the appropriate information from the sqlite backend. First the system level read only srs.db will be checked and then the users ~/.qgis/qgis.db database will be checked for a match.
theSrid | The postgis SRID for the desired spatial reference system. |
Definition at line 308 of file qgscoordinatereferencesystem.cpp.
References loadFromDb(), and QgsApplication::srsDbFilePath().
Referenced by createFromId().
bool QgsCoordinateReferenceSystem::createFromSrsId | ( | const long | theSrsId | ) |
Set up this srs by fetching the appropriate information from the sqlite backend. If the srsid is < 100000, only the system srs.db will be checked. If the srsid > 100000 the srs will be retrieved from the ~/.qgis/qgis.db
theSrsId | The QGIS SrsId for the desired spatial reference system. |
Definition at line 313 of file qgscoordinatereferencesystem.cpp.
References loadFromDb(), QgsApplication::qgisUserDbFilePath(), QgsApplication::srsDbFilePath(), and USER_CRS_START_ID.
Referenced by createFromId(), createFromOgcWmsCrs(), createFromProj4(), QgsCoordinateTransform::setDestCRSID(), and QgsDistanceArea::setSourceCrs().
bool QgsCoordinateReferenceSystem::createFromString | ( | const QString & | theDefinition | ) |
Set up this srs from a string definition, by default a WKT definition. Otherwise the string defines a authority, followed by a colon, followed by the definition. The authority can be one of "epsg", "postgis", "internal" for integer definitions, and "wkt" or "proj4" for string definitions. The implementation of each authority uses the corresponding createFrom... function.
theDefinition | A String containing a coordinate reference system definition. |
Definition at line 116 of file qgscoordinatereferencesystem.cpp.
References createFromId(), createFromProj4(), createFromWkt(), EpsgCrsId, InternalCrsId, PostgisCrsId, saveAsUserCRS(), srsid(), toProj4(), and tr.
Referenced by QgsCoordinateReferenceSystem().
bool QgsCoordinateReferenceSystem::createFromUserInput | ( | const QString & | theDefinition | ) |
Set up this srs from a various text formats.
Valid formats: WKT string, "EPSG:n", "EPSGA:n", "AUTO:proj_id,unit_id,lon0,lat0", "urn:ogc:def:crs:EPSG::n", PROJ.4 string, filename (with WKT, XML or PROJ.4 string), well known name (such as NAD27, NAD83, WGS84 or WGS72), ESRI::[WKT string] (directly or in a file), "IGNF:xxx" For more details on supported formats see OGRSpatialReference::SetFromUserInput() ( http://www.gdal.org/ogr/classOGRSpatialReference.html#aec3c6a49533fe457ddc763d699ff8796 ) @note this function generates a WKT string using OSRSetFromUserInput() and passes it to createFromWkt() function. @param theDefinition A String containing a coordinate reference system definition. @note added in 1.8
Definition at line 160 of file qgscoordinatereferencesystem.cpp.
References createFromWkt(), and setupESRIWktFix().
bool QgsCoordinateReferenceSystem::createFromWkt | ( | const QString & | theWkt | ) |
Set up this srs using a Wkt spatial ref sys definition. The wkt will be converted to a proj4 string using OGR helper functions. After this the srs databasses will be searched for matches. First the system level read only srs.db will be checked and then the users ~/.qgis/qgis.db database will be checked for a match.
theWkt | The Wkt for the desired spatial reference system. |
Definition at line 430 of file qgscoordinatereferencesystem.cpp.
References authid(), createFromOgcWmsCrs(), createFromProj4(), mCRS, mIsValidFlag, mProj4, mSrsId, mWkt, QgsDebugMsg, saveAsUserCRS(), toProj4(), and tr.
Referenced by createFromString(), createFromUserInput(), and QgsCoordinateTransform::QgsCoordinateTransform().
|
static |
Gets custom function.
Definition at line 1420 of file qgscoordinatereferencesystem.cpp.
References mCustomSrsValidation.
Referenced by QgsMapLayer::readLayerXML().
|
private |
Print the description if debugging
Definition at line 1425 of file qgscoordinatereferencesystem.cpp.
References QGis::Degrees, QGis::Feet, mapUnits(), mDescription, QGis::Meters, mIsValidFlag, mSrsId, QgsDebugMsg, toProj4(), and toWkt().
Referenced by setProj4String().
QString QgsCoordinateReferenceSystem::description | ( | ) | const |
Get the Description
Definition at line 838 of file qgscoordinatereferencesystem.cpp.
References mDescription.
Referenced by QgsCoordinateTransform::datumTransformCrsInfo(), QgsOWSSourceSelect::descriptionForAuthId(), QgsNewVectorLayerDialog::on_pbnChangeSpatialRefSys_clicked(), operator<<(), QgsNewVectorLayerDialog::QgsNewVectorLayerDialog(), QgsRasterLayerSaveAsDialog::updateCrsGroup(), and writeXML().
QString QgsCoordinateReferenceSystem::ellipsoidAcronym | ( | ) | const |
Get the Ellipsoid Acronym
Definition at line 862 of file qgscoordinatereferencesystem.cpp.
References mEllipsoidAcronym.
Referenced by operator<<(), saveAsUserCRS(), and writeXML().
long QgsCoordinateReferenceSystem::findMatchingProj | ( | ) |
This is a globbing function to try to find a record in the database that matches a CRS defined only by a proj4string. The goal is to learn what the tbl_srs.srs_id value is for the CRS. Internally the source CRS is converted to an OGR srs object using the proj4string call and then every record in the database that matches projection and ellipsoid will be converted to an OGR srs in turn and compared to the source CRS. There are some gotchas with using ogr isSame() srs comparison, but its more effective than using straight string comparison of proj4params.
Definition at line 1028 of file qgscoordinatereferencesystem.cpp.
References mEllipsoidAcronym, mIsValidFlag, mProjectionAcronym, openDb(), QgsApplication::qgisUserDbFilePath(), QgsDebugMsg, quotedValue(), QgsApplication::srsDbFilePath(), and toProj4().
Referenced by createFromProj4().
QString QgsCoordinateReferenceSystem::geographicCRSAuthId | ( | ) | const |
Returns auth id of related geographic CRS.
Definition at line 2156 of file qgscoordinatereferencesystem.cpp.
References geographicFlag(), mAuthId, and mCRS.
Referenced by QgsCoordinateTransform::datumTransformations().
bool QgsCoordinateReferenceSystem::geographicFlag | ( | ) | const |
Get this Geographic? flag
Definition at line 891 of file qgscoordinatereferencesystem.cpp.
References mGeoFlag.
Referenced by QgsVectorLayer::draw(), geographicCRSAuthId(), QgsMapRenderer::splitLayersExtent(), and writeXML().
|
private |
Get a record from the srs.db or qgis.db backends, given an sql statment.
theSql | The sql query to execute |
Definition at line 708 of file qgscoordinatereferencesystem.cpp.
References openDb(), QgsApplication::qgisUserDbFilePath(), QgsDebugMsg, QgsDebugMsgLevel, and QgsApplication::srsDbFilePath().
Referenced by createFromProj4().
|
private |
Helper for getting number of user CRS already in db.
Definition at line 1542 of file qgscoordinatereferencesystem.cpp.
References QgsApplication::qgisUserDbFilePath(), and QgsDebugMsg.
Referenced by saveAsUserCRS().
bool QgsCoordinateReferenceSystem::isValid | ( | ) | const |
Find out whether this CRS is correctly initialised and usable
Definition at line 506 of file qgscoordinatereferencesystem.cpp.
References mIsValidFlag.
Referenced by QgsRasterProjector::block(), QgsVectorLayerImport::importLayer(), QgsCoordinateTransform::initialise(), QgsOWSSourceSelect::QgsOWSSourceSelect(), QgsProjectionSelector::QgsProjectionSelector(), readXML(), QgsMapLayer::setCrs(), and QgsCoordinateTransform::transformCoords().
|
private |
Definition at line 320 of file qgscoordinatereferencesystem.cpp.
References mAuthId, mAxisInverted, mCRS, mDescription, mEllipsoidAcronym, mGeoFlag, mIsValidFlag, mProj4, mProjectionAcronym, mSRID, mSrsId, mWkt, openDb(), QgsDebugMsg, QgsDebugMsgLevel, quotedValue(), setMapUnits(), setProj4String(), and USER_CRS_START_ID.
Referenced by createFromOgcWmsCrs(), createFromSrid(), and createFromSrsId().
|
staticprivate |
Definition at line 1629 of file qgscoordinatereferencesystem.cpp.
Referenced by syncDb().
|
staticprivate |
Definition at line 1581 of file qgscoordinatereferencesystem.cpp.
Referenced by syncDb().
QGis::UnitType QgsCoordinateReferenceSystem::mapUnits | ( | ) | const |
Get the units that the projection is in
Definition at line 896 of file qgscoordinatereferencesystem.cpp.
References mMapUnits.
Referenced by QgsVectorLayerEditUtils::addTopologicalPoints(), QgsDistanceArea::convertMeasurement(), QgsTransectSample::createSample(), QgsVectorFileWriter::createSymbolLayerTable(), debugPrint(), QgsVectorFileWriter::exportFeaturesSymbolLevels(), and QgsVectorFileWriter::writeAsVectorFormat().
|
staticprivate |
Definition at line 1394 of file qgscoordinatereferencesystem.cpp.
References QgsMessageLog::logMessage(), QgsDebugMsg, QgsDebugMsgLevel, and tr.
Referenced by findMatchingProj(), getRecord(), loadFromDb(), and proj4FromSrsId().
bool QgsCoordinateReferenceSystem::operator!= | ( | const QgsCoordinateReferenceSystem & | theSrs | ) | const |
Overloaded != operator used to compare to CRS's. Returns opposite bool value to operator ==
Definition at line 1136 of file qgscoordinatereferencesystem.cpp.
QgsCoordinateReferenceSystem & QgsCoordinateReferenceSystem::operator= | ( | const QgsCoordinateReferenceSystem & | srs | ) |
Assignment operator.
Definition at line 264 of file qgscoordinatereferencesystem.cpp.
References mAuthId, mAxisInverted, mCRS, mDescription, mEllipsoidAcronym, mGeoFlag, mIsValidFlag, mMapUnits, mProj4, mProjectionAcronym, mSRID, mSrsId, mValidationHint, and mWkt.
Referenced by readXML().
bool QgsCoordinateReferenceSystem::operator== | ( | const QgsCoordinateReferenceSystem & | theSrs | ) | const |
Overloaded == operator used to compare to CRS's. Internally it will delegate to the equals method described below
Definition at line 1131 of file qgscoordinatereferencesystem.cpp.
References authid(), and mIsValidFlag.
long QgsCoordinateReferenceSystem::postgisSrid | ( | ) | const |
Get the postgis srid for this srs
Definition at line 828 of file qgscoordinatereferencesystem.cpp.
References mSRID.
Referenced by writeXML().
|
staticprivate |
A static helper function to find out the proj4 string for a srsid.
theSrsId | The srsid used for the lookup |
Definition at line 1332 of file qgscoordinatereferencesystem.cpp.
References openDb(), QgsApplication::qgisUserDbFilePath(), QgsDebugMsg, QgsApplication::srsDbFilePath(), and USER_CRS_START_ID.
QString QgsCoordinateReferenceSystem::projectionAcronym | ( | ) | const |
Get the Projection Acronym
Definition at line 850 of file qgscoordinatereferencesystem.cpp.
References mProjectionAcronym.
Referenced by operator<<(), saveAsUserCRS(), and writeXML().
|
staticprivate |
Helper for sql-safe value quoting.
Definition at line 1574 of file qgscoordinatereferencesystem.cpp.
Referenced by createFromProj4(), findMatchingProj(), loadFromDb(), saveAsUserCRS(), syncDatumTransform(), and syncDb().
bool QgsCoordinateReferenceSystem::readXML | ( | QDomNode & | theNode | ) |
Restores state from the given Dom node.
theNode | The node from which state will be restored |
Definition at line 1155 of file qgscoordinatereferencesystem.cpp.
References createFromId(), createFromProj4(), GEOCRS_ID, QgsCRSCache::instance(), InternalCrsId, isValid(), mIsValidFlag, mSrsId, operator=(), QgsDebugMsg, saveAsUserCRS(), setAuthId(), setDescription(), setEllipsoidAcronym(), setGeographicFlag(), setInternalId(), setMapUnits(), setProj4String(), setProjectionAcronym(), setSrid(), srsid(), toProj4(), tr, and USER_CRS_START_ID.
Referenced by QgsMapLayer::readLayerXML(), QgsCoordinateTransform::readXML(), and QgsMapRenderer::readXML().
bool QgsCoordinateReferenceSystem::saveAsUserCRS | ( | QString | name | ) |
Copied from QgsCustomProjectionDialog /// Please refactor into SQL handler !!! ///.
Save the proj4-string as a custom CRS
Definition at line 1460 of file qgscoordinatereferencesystem.cpp.
References authid(), ellipsoidAcronym(), getRecordCount(), QgsMessageLog::logMessage(), mIsValidFlag, mProj4, projectionAcronym(), QgsApplication::qgisUserDbFilePath(), QgsDebugMsg, quotedValue(), setInternalId(), toProj4(), tr, and USER_CRS_START_ID.
Referenced by createFromString(), createFromWkt(), readXML(), and QgsDistanceArea::setEllipsoid().
|
private |
Set the authority identifier for this srs
theID | the authority identifier for this srs (defaults to 0) |
Definition at line 909 of file qgscoordinatereferencesystem.cpp.
References mAuthId.
Referenced by readXML().
|
static |
Sets custom function to force valid CRS QGIS uses implementation in QgisGui::customSrsValidation.
Definition at line 1415 of file qgscoordinatereferencesystem.cpp.
References mCustomSrsValidation.
Referenced by QgsMapLayer::readLayerXML().
|
private |
Set the Description
theDescription | A textual description of the srs. |
Definition at line 917 of file qgscoordinatereferencesystem.cpp.
References mDescription.
Referenced by readXML().
|
private |
Set the ellipsoid acronym
theEllipsoidAcronym | the acronym (must be a valid proj4 ellipsoid acronym) |
Definition at line 957 of file qgscoordinatereferencesystem.cpp.
References mEllipsoidAcronym.
Referenced by readXML().
|
private |
Set the EpsgCrsId identifier for this srs
theEpsg | the ESPG identifier for this srs (defaults to 0) |
Definition at line 949 of file qgscoordinatereferencesystem.cpp.
References mAuthId.
|
private |
Set this Geographic? flag
theGeoFlag | Whether this is a geographic or projected coordinate system |
Definition at line 945 of file qgscoordinatereferencesystem.cpp.
References mGeoFlag.
Referenced by readXML().
|
private |
Set the QGIS SrsId
theSrsId | The internal sqlite3 srs.db primary key for this srs |
Definition at line 905 of file qgscoordinatereferencesystem.cpp.
References mSrsId.
Referenced by readXML(), and saveAsUserCRS().
|
private |
Work out the projection units and set the appropriate local variable.
Definition at line 962 of file qgscoordinatereferencesystem.cpp.
References QGis::Degrees, QGis::Feet, mCRS, QGis::Meters, mIsValidFlag, mMapUnits, QgsDebugMsg, QgsDebugMsgLevel, qgsDoubleNear(), and QGis::UnknownUnit.
Referenced by loadFromDb(), readXML(), and setProj4String().
|
private |
Definition at line 921 of file qgscoordinatereferencesystem.cpp.
References debugPrint(), mCRS, mIsValidFlag, mProj4, mWkt, and setMapUnits().
Referenced by createFromProj4(), loadFromDb(), and readXML().
|
private |
Set the projection acronym
theProjectionAcronym | the acronym (must be a valid proj4 projection acronym) |
Definition at line 953 of file qgscoordinatereferencesystem.cpp.
References mProjectionAcronym.
Referenced by readXML().
|
private |
Set the postgis srid
theSrid | The postgis spatial_ref_sys key for this srs |
Definition at line 913 of file qgscoordinatereferencesystem.cpp.
References mSRID.
Referenced by readXML().
|
static |
Make sure that ESRI WKT import is done properly. This is required for proper shapefile CRS import when using gdal>= 1.9.
Definition at line 187 of file qgscoordinatereferencesystem.cpp.
References QgsDebugMsg, and QgsLogger::warning().
Referenced by createFromUserInput().
void QgsCoordinateReferenceSystem::setValidationHint | ( | QString | html | ) |
Set user hint for validation
Definition at line 1447 of file qgscoordinatereferencesystem.cpp.
References mValidationHint.
Referenced by QgsMapLayer::readLayerXML(), and QgsMapLayer::setCrs().
long QgsCoordinateReferenceSystem::srsid | ( | ) | const |
Get the SrsId - if possible
Definition at line 823 of file qgscoordinatereferencesystem.cpp.
References mSrsId.
Referenced by createFromString(), QgsTransectSample::createSample(), QgsMapRenderer::destinationCrs(), QgsMapToolIdentify::featureDerivedAttributes(), QgsComposerScaleBar::mapWidth(), QgsOWSSourceSelect::on_mChangeCRSButton_clicked(), QgsRasterLayerSaveAsDialog::on_mChangeCrsPushButton_clicked(), QgsNewVectorLayerDialog::on_pbnChangeSpatialRefSys_clicked(), QgsNewVectorLayerDialog::QgsNewVectorLayerDialog(), QgsProjectionSelector::QgsProjectionSelector(), readXML(), QgsMapRenderer::setDestinationCrs(), QgsDistanceArea::setEllipsoid(), and writeXML().
|
staticprivate |
Definition at line 1962 of file qgscoordinatereferencesystem.cpp.
References QgsDebugMsgLevel, qgsDoubleToString(), quotedValue(), and QgsApplication::srsDbFilePath().
Referenced by syncDb().
|
static |
Update proj.4 parameters in our database from proj.4
Definition at line 1698 of file qgscoordinatereferencesystem.cpp.
References loadIDs(), loadWkts(), QgsDebugMsg, QgsDebugMsgLevel, quotedValue(), QgsApplication::srsDbFilePath(), syncDatumTransform(), and tr.
QString QgsCoordinateReferenceSystem::toProj4 | ( | ) | const |
Get the Proj Proj4 string representation of this srs.
If proj and ellps keys are found in the parameters, they will be stripped out and the Projection and ellipsoid acronyms will be overridden with these.
Definition at line 874 of file qgscoordinatereferencesystem.cpp.
References mCRS, mIsValidFlag, and mProj4.
Referenced by createFromString(), createFromWkt(), debugPrint(), QgsMapRenderer::destinationCrs(), findMatchingProj(), QgsCoordinateTransform::initialise(), QgsDistanceArea::measureLine(), QgsRasterLayer::metadata(), QgsVectorLayer::metadata(), operator<<(), readXML(), saveAsUserCRS(), QgsMapRenderer::setDestinationCrs(), QgsDistanceArea::setEllipsoid(), QgsCoordinateTransform::transformCoords(), writeXML(), and QgsProjectionSelector::~QgsProjectionSelector().
QString QgsCoordinateReferenceSystem::toWkt | ( | ) | const |
A helper to get an wkt representation of this srs
Definition at line 1141 of file qgscoordinatereferencesystem.cpp.
Referenced by QgsRasterFileWriter::createVRT(), debugPrint(), QgsRasterCalculator::processCalculation(), QgsVectorFileWriter::QgsVectorFileWriter(), and QgsRasterLayer::setDataProvider().
void QgsCoordinateReferenceSystem::validate | ( | ) |
Perform some validation on this CRS. If the sts doesn't validate the default behaviour settings for layers with unknown CRS will be consulted and acted on accordingly. By hell or high water this method will do its best to make sure that this CRS is valid - even if that involves resorting to a hard coded default of geocs:wgs84.
Definition at line 293 of file qgscoordinatereferencesystem.cpp.
References QgsCRSCache::crsByAuthId(), GEO_EPSG_CRS_AUTHID, QgsCRSCache::instance(), mCustomSrsValidation, and mIsValidFlag.
Referenced by QgsNewVectorLayerDialog::QgsNewVectorLayerDialog(), QgsMapLayer::readLayerXML(), and QgsMapLayer::setCrs().
QString QgsCoordinateReferenceSystem::validationHint | ( | ) |
Get user hint for validation
Definition at line 1452 of file qgscoordinatereferencesystem.cpp.
References mValidationHint.
bool QgsCoordinateReferenceSystem::writeXML | ( | QDomNode & | theNode, |
QDomDocument & | theDoc | ||
) | const |
Stores state to the given Dom node in the given document. Below is an example of the generated tag.
<spatialrefsys> <proj4>+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs </proj4> <srsid>2585</srsid> <srid>4326</srid> <epsg>4326</epsg> <description>WGS 84</description> <projectionacronym>longlat</projectionacronym> <ellipsoidacronym>WGS84</ellipsoidacronym> </spatialrefsys>
theNode | The node in which state will be restored |
theDoc | The document in which state will be stored |
Definition at line 1274 of file qgscoordinatereferencesystem.cpp.
References authid(), description(), ellipsoidAcronym(), geographicFlag(), postgisSrid(), projectionAcronym(), srsid(), and toProj4().
Referenced by QgsMapLayer::writeLayerXML(), QgsCoordinateTransform::writeXML(), and QgsMapRenderer::writeXML().
|
private |
If available the authority identifier for this srs.
Definition at line 449 of file qgscoordinatereferencesystem.h.
Referenced by authid(), axisInverted(), geographicCRSAuthId(), loadFromDb(), operator=(), setAuthId(), and setEpsg().
|
mutableprivate |
Whether this is a coordinate system has inverted axis.
Definition at line 475 of file qgscoordinatereferencesystem.h.
Referenced by axisInverted(), createFromOgcWmsCrs(), loadFromDb(), and operator=().
|
private |
Definition at line 462 of file qgscoordinatereferencesystem.h.
Referenced by axisInverted(), createFromWkt(), geographicCRSAuthId(), loadFromDb(), operator=(), QgsCoordinateReferenceSystem(), setMapUnits(), setProj4String(), toProj4(), toWkt(), and ~QgsCoordinateReferenceSystem().
|
staticprivate |
Definition at line 477 of file qgscoordinatereferencesystem.h.
Referenced by customSrsValidation(), setCustomSrsValidation(), and validate().
|
private |
A textual description of the srs.
Definition at line 437 of file qgscoordinatereferencesystem.h.
Referenced by debugPrint(), description(), loadFromDb(), operator=(), and setDescription().
|
private |
The official proj4 acronym for the ellipoid.
Definition at line 441 of file qgscoordinatereferencesystem.h.
Referenced by createFromProj4(), ellipsoidAcronym(), findMatchingProj(), loadFromDb(), operator=(), and setEllipsoidAcronym().
|
private |
Whether this is a geographic or projected coordinate system.
Definition at line 443 of file qgscoordinatereferencesystem.h.
Referenced by geographicFlag(), loadFromDb(), operator=(), and setGeographicFlag().
|
private |
Whether this srs is properly defined and valid.
Definition at line 451 of file qgscoordinatereferencesystem.h.
Referenced by createFromOgcWmsCrs(), createFromProj4(), createFromWkt(), debugPrint(), findMatchingProj(), isValid(), loadFromDb(), operator=(), operator==(), readXML(), saveAsUserCRS(), setMapUnits(), setProj4String(), toProj4(), and validate().
|
private |
The map units.
Definition at line 445 of file qgscoordinatereferencesystem.h.
Referenced by mapUnits(), operator=(), and setMapUnits().
|
mutableprivate |
Definition at line 468 of file qgscoordinatereferencesystem.h.
Referenced by createFromWkt(), loadFromDb(), operator=(), saveAsUserCRS(), setProj4String(), and toProj4().
|
private |
The official proj4 acronym for the projection family.
Definition at line 439 of file qgscoordinatereferencesystem.h.
Referenced by createFromProj4(), findMatchingProj(), loadFromDb(), operator=(), projectionAcronym(), and setProjectionAcronym().
|
private |
If available, the Postgis spatial_ref_sys identifier for this srs (defaults to 0)
Definition at line 447 of file qgscoordinatereferencesystem.h.
Referenced by loadFromDb(), operator=(), postgisSrid(), and setSrid().
|
private |
The internal sqlite3 srs.db primary key for this srs.
Definition at line 435 of file qgscoordinatereferencesystem.h.
Referenced by createFromWkt(), debugPrint(), loadFromDb(), operator=(), readXML(), setInternalId(), and srsid().
|
private |
Definition at line 466 of file qgscoordinatereferencesystem.h.
Referenced by operator=(), setValidationHint(), and validationHint().
|
mutableprivate |
Definition at line 467 of file qgscoordinatereferencesystem.h.
Referenced by createFromProj4(), createFromWkt(), loadFromDb(), operator=(), setProj4String(), and toWkt().