Quantum GIS API Documentation  1.8
Public Types | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes
QgsCoordinateReferenceSystem Class Reference

Class for storing a coordinate reference system (CRS) More...

#include <qgscoordinatereferencesystem.h>

List of all members.

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
QgsCoordinateReferenceSystemoperator= (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)
Q_DECL_DEPRECATED bool createFromEpsg (const long theEpsg)
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
Q_DECL_DEPRECATED bool equals (QString theProj4String)
bool readXML (QDomNode &theNode)
bool writeXML (QDomNode &theNode, QDomDocument &theDoc) const
long srsid () const
long postgisSrid () const
Q_DECL_DEPRECATED long epsg () 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 ()

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.
bool saveAsUserCRS ()
 Save the proj4-string as a custom CRS.
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.

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
 Wehter this srs is properly defined and valid.
void * mCRS
QString mValidationHint
QString mWkt
int mAxisInverted
 Whether this is a coordinate system has inverted axis.

Static Private Attributes

static CUSTOM_CRS_VALIDATION mCustomSrsValidation = NULL

Detailed Description

Class for storing a coordinate reference system (CRS)

Definition at line 43 of file qgscoordinatereferencesystem.h.


Member Typedef Documentation

typedef QMap<QString, QString> QgsCoordinateReferenceSystem::RecordMap [private]

A string based associative array used for passing records around

Definition at line 426 of file qgscoordinatereferencesystem.h.


Member Enumeration Documentation

Enumerator:
InternalCrsId 
PostgisCrsId 
EpsgCrsId 

Definition at line 47 of file qgscoordinatereferencesystem.h.


Constructor & Destructor Documentation

Default constructor.

Definition at line 48 of file qgscoordinatereferencesystem.cpp.

References mCRS.

Definition at line 75 of file qgscoordinatereferencesystem.cpp.

References mCRS.

QgsCoordinateReferenceSystem::QgsCoordinateReferenceSystem ( QString  theDefinition) [explicit]

Constructs a CRS object from a string definition as defined in the createFromString member function (by default a WKT definition).

Parameters:
theDefinitionA String containing a coordinate reference system definition.

Definition at line 56 of file qgscoordinatereferencesystem.cpp.

References createFromString(), and mCRS.

Use this constructor when you want to create a CRS object using a postgis SRID, an EpsgCrsId id or a QGIS CRS_ID.

Note:
We encourage you to use EpsgCrsId, Wkt or Proj4 to describe CRS's in your code wherever possible. QGSI CRS_IDs are not guaranteed to be permanent / involatile.
Parameters:
theIdThe ID no valid for the chosen coordinate system id type
theTypeOne of the types described in QgsCoordinateReferenceSystem::CrsType

Definition at line 66 of file qgscoordinatereferencesystem.cpp.

References createFromId(), and mCRS.

copy constructor

Definition at line 202 of file qgscoordinatereferencesystem.cpp.

References mCRS.


Member Function Documentation

return if axis is inverted (eg. for WMS 1.3)

Returns:
bool Whether this is crs axis is inverted
Note:
added in 1.9.90

Definition at line 352 of file qgscoordinatereferencesystem.cpp.

References mAxisInverted, mCRS, mGeoFlag, mSRID, and QgsDebugMsg.

bool QgsCoordinateReferenceSystem::createFromEpsg ( const long  theEpsg)

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.

Note:
Any members will be overwritten during this process.
Parameters:
theEpsgThe EpsgCrsId for the desired spatial reference system.
Returns:
bool TRUE if success else false
Deprecated:
use createFromOgcWmsCrs()

Definition at line 256 of file qgscoordinatereferencesystem.cpp.

References createFromOgcWmsCrs().

bool QgsCoordinateReferenceSystem::createFromId ( const long  theId,
CrsType  theType = PostgisCrsId 
)
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 ellpse and proj elements stripped out is hepful to speed up globbing queries (see below).

We try to match the proj string to and srsid using the following logic:

  • perform a whole text search on srs name (if not null). The srs name will have been set if this method has been delegated to from createFromWkt.
  • if the above does not match perform a whole text search on proj4 string (if not null)
  • if none of the above match convert the proj4 string to an OGR CRS then check if its a geocs or a proj cs (using ogr isGeographic) then sequentially walk through the database (first users qgis.db srs tbl then system srs.db tbl), converting each entry into an ogr srs and using isSame or isSameGeocs (essentially calling the == overloaded operator). We'll try to be smart about this and first parse out the proj and ellpse strings and only check for a match in entities that have the same ellps and proj entries so that it doesn't munch yer cpu so much.
Note:
If the srs was not matched, we will create a new entry on the users tbl_srs for this srs.
Parameters:
theProjStringA proj4 format string
Returns:
bool TRUE if success else false

Definition at line 437 of file qgscoordinatereferencesystem.cpp.

References createFromSrsId(), findMatchingProj(), getRecord(), LAT_PREFIX_LEN, mEllipsoidAcronym, mIsValidFlag, mProjectionAcronym, mWkt, QgsDebugMsg, quotedValue(), saveAsUserCRS(), setProj4String(), and toProj4().

Referenced by createFromString(), createFromWkt(), equals(), 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.

Note:
Any members will be overwritten during this process.
Parameters:
theSridThe postgis SRID for the desired spatial reference system.

Definition at line 251 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

Note:
Any members will be overwritten during this process.
Parameters:
theSrsIdThe QGIS SrsId for the desired spatial reference system.
Returns:
bool TRUE if success else false

Definition at line 261 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.

Parameters:
theDefinitionA String containing a coordinate reference system definition.

Definition at line 101 of file qgscoordinatereferencesystem.cpp.

References createFromId(), createFromProj4(), createFromWkt(), EpsgCrsId, InternalCrsId, and PostgisCrsId.

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.
Parameters:
theDefinitionA String containing a coordinate reference system definition.

Definition at line 134 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.

Note:
Any members will be overwritten during this process.
SRID and EpsgCrsId may be blank if no match can be found on srs db.
Parameters:
theWktThe Wkt for the desired spatial reference system.
Returns:
bool TRUE if success else false

Definition at line 368 of file qgscoordinatereferencesystem.cpp.

References authid(), createFromOgcWmsCrs(), createFromProj4(), mCRS, mIsValidFlag, mWkt, and QgsDebugMsg.

Referenced by createFromString(), createFromUserInput(), and QgsCoordinateTransform::QgsCoordinateTransform().

Gets custom function.

Definition at line 1348 of file qgscoordinatereferencesystem.cpp.

References mCustomSrsValidation.

Referenced by QgsMapLayer::readXML().

Print the description if debugging

Definition at line 1353 of file qgscoordinatereferencesystem.cpp.

References QGis::Degrees, QGis::Feet, mapUnits(), mDescription, QGis::Meters, mIsValidFlag, mSrsId, QgsDebugMsg, toProj4(), and toWkt().

Referenced by setProj4String().

Get the Description

Returns:
QString the Description A textual description of the srs.
Note:
A zero length string will be returned if the description is uninitialised

Definition at line 778 of file qgscoordinatereferencesystem.cpp.

References mDescription.

Referenced by QgsNewVectorLayerDialog::on_pbnChangeSpatialRefSys_clicked(), operator<<(), QgsNewVectorLayerDialog::QgsNewVectorLayerDialog(), and writeXML().

Get the Ellipsoid Acronym

Returns:
QString theEllipsoidAcronym The official proj4 acronym for the ellipoid
Note:
A zero length string will be returned if the ellipsoidAcronym is uninitialised

Definition at line 802 of file qgscoordinatereferencesystem.cpp.

References mEllipsoidAcronym.

Referenced by operator<<(), saveAsUserCRS(), and writeXML().

Get the EpsgCrsId identifier for this srs

Returns:
long theEpsg the EPSG identifier for this srs (defaults to 0)
Deprecated:
there are other authorities - use authid()

Definition at line 765 of file qgscoordinatereferencesystem.cpp.

References mAuthId.

bool QgsCoordinateReferenceSystem::equals ( QString  theProj4String)

Overloaded == operator used to compare to CRS's. Internally it will use OGR isSameCRS() or isSameGeoCRS() methods as appropriate. Additionally logic may also be applied if the result from the OGR methods is inconclusive.

Deprecated:
in 1.8 as the same proj.4 string not necessarily means the same CRS

Definition at line 1074 of file qgscoordinatereferencesystem.cpp.

References createFromProj4().

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.

Note:
The ellipsoid and projection acronyms must be set as well as the proj4string!
Returns:
long the SrsId of the matched CRS

Definition at line 961 of file qgscoordinatereferencesystem.cpp.

References mEllipsoidAcronym, mIsValidFlag, mProjectionAcronym, openDb(), QgsApplication::qgisUserDbFilePath(), QgsDebugMsg, quotedValue(), QgsApplication::srsDbFilePath(), and toProj4().

Referenced by createFromProj4().

Get this Geographic? flag

Returns:
bool theGeoFlag Whether this is a geographic or projected coordinate system

Definition at line 829 of file qgscoordinatereferencesystem.cpp.

References mGeoFlag.

Referenced by QgsMapRenderer::splitLayersExtent(), and writeXML().

Get a record from the srs.db or qgis.db backends, given an sql statment.

Note:
only handles queries that return a single record.
it will first try the system srs.db then the users qgis.db!
Parameters:
theSqlThe sql query to execute
Returns:
An associative array of field name <-> value pairs

Definition at line 652 of file qgscoordinatereferencesystem.cpp.

References openDb(), QgsApplication::qgisUserDbFilePath(), QgsDebugMsg, QgsDebugMsgLevel, and QgsApplication::srsDbFilePath().

Referenced by createFromProj4().

Helper for getting number of user CRS already in db.

Definition at line 1447 of file qgscoordinatereferencesystem.cpp.

References QgsApplication::qgisUserDbFilePath(), and QgsDebugMsg.

Referenced by saveAsUserCRS().

bool QgsCoordinateReferenceSystem::loadFromDb ( QString  db,
QString  expression,
QString  value 
) [private]

Get the units that the projection is in

Returns:
QGis::UnitType that gives the units for the coordinate system

Definition at line 834 of file qgscoordinatereferencesystem.cpp.

References mMapUnits.

Referenced by debugPrint().

int QgsCoordinateReferenceSystem::openDb ( QString  path,
sqlite3 **  db,
bool  readonly = true 
) [static, private]
bool QgsCoordinateReferenceSystem::operator!= ( const QgsCoordinateReferenceSystem theSrs) const

Overloaded != operator used to compare to CRS's. Returns opposite bool value to operator ==

Definition at line 1069 of file qgscoordinatereferencesystem.cpp.

QgsCoordinateReferenceSystem & QgsCoordinateReferenceSystem::operator= ( const QgsCoordinateReferenceSystem srs)
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 1064 of file qgscoordinatereferencesystem.cpp.

References authid(), and mIsValidFlag.

Get the postgis srid for this srs

Returns:
long theSRID the Postgis spatial_ref_sys identifier for this srs (defaults to 0)

Definition at line 758 of file qgscoordinatereferencesystem.cpp.

References mSRID.

Referenced by writeXML().

QString QgsCoordinateReferenceSystem::proj4FromSrsId ( const int  theSrsId) [static, private]

A static helper function to find out the proj4 string for a srsid.

Parameters:
theSrsIdThe srsid used for the lookup
Returns:
QString The proj4 string

Definition at line 1260 of file qgscoordinatereferencesystem.cpp.

References openDb(), QgsApplication::qgisUserDbFilePath(), QgsDebugMsg, QgsApplication::srsDbFilePath(), and USER_CRS_START_ID.

Get the Projection Acronym

Returns:
QString theProjectionAcronym The official proj4 acronym for the projection family
Note:
A zero length string will be returned if the projectionAcronym is uninitialised

Definition at line 790 of file qgscoordinatereferencesystem.cpp.

References mProjectionAcronym.

Referenced by operator<<(), saveAsUserCRS(), and writeXML().

QString QgsCoordinateReferenceSystem::quotedValue ( QString  value) [static, private]

Helper for sql-safe value quoting.

Definition at line 1479 of file qgscoordinatereferencesystem.cpp.

Referenced by createFromProj4(), findMatchingProj(), loadFromDb(), saveAsUserCRS(), and syncDb().

bool QgsCoordinateReferenceSystem::readXML ( QDomNode &  theNode)

Save the proj4-string as a custom CRS.

Copied from QgsCustomProjectionDialog /// Please refactor into SQL handler !!! ///.

Definition at line 1388 of file qgscoordinatereferencesystem.cpp.

References ellipsoidAcronym(), getRecordCount(), QgsMessageLog::logMessage(), mIsValidFlag, projectionAcronym(), QgsApplication::qgisUserDbFilePath(), QgsDebugMsg, quotedValue(), toProj4(), and USER_CRS_START_ID.

Referenced by createFromProj4().

void QgsCoordinateReferenceSystem::setAuthId ( QString  theID) [private]

Set the authority identifier for this srs

Parameters:
theIDthe authority identifier for this srs (defaults to 0)

Definition at line 847 of file qgscoordinatereferencesystem.cpp.

References mAuthId.

Referenced by readXML().

Sets custom function to force valid CRS QGIS uses implementation in QgisGui::customSrsValidation.

Definition at line 1343 of file qgscoordinatereferencesystem.cpp.

References mCustomSrsValidation.

Referenced by QgsMapLayer::readXML().

void QgsCoordinateReferenceSystem::setDescription ( QString  theDescription) [private]

Set the Description

Parameters:
theDescriptionA textual description of the srs.

Definition at line 855 of file qgscoordinatereferencesystem.cpp.

References mDescription.

Referenced by readXML().

void QgsCoordinateReferenceSystem::setEllipsoidAcronym ( QString  theEllipsoidAcronym) [private]

Set the ellipsoid acronym

Parameters:
theEllipsoidAcronymthe acronym (must be a valid proj4 ellipsoid acronym)

Definition at line 890 of file qgscoordinatereferencesystem.cpp.

References mEllipsoidAcronym.

Referenced by readXML().

void QgsCoordinateReferenceSystem::setEpsg ( long  theEpsg) [private]

Set the EpsgCrsId identifier for this srs

Parameters:
theEpsgthe ESPG identifier for this srs (defaults to 0)

Definition at line 882 of file qgscoordinatereferencesystem.cpp.

References mAuthId.

void QgsCoordinateReferenceSystem::setGeographicFlag ( bool  theGeoFlag) [private]

Set this Geographic? flag

Parameters:
theGeoFlagWhether this is a geographic or projected coordinate system

Definition at line 878 of file qgscoordinatereferencesystem.cpp.

References mGeoFlag.

Referenced by readXML().

void QgsCoordinateReferenceSystem::setInternalId ( long  theSrsId) [private]

Set the QGIS SrsId

Parameters:
theSrsIdThe internal sqlite3 srs.db primary key for this srs

Definition at line 843 of file qgscoordinatereferencesystem.cpp.

References mSrsId.

Referenced by readXML().

Work out the projection units and set the appropriate local variable.

Definition at line 895 of file qgscoordinatereferencesystem.cpp.

References QGis::Degrees, doubleNear(), QGis::Feet, mCRS, QGis::Meters, mIsValidFlag, mMapUnits, QgsDebugMsg, QgsDebugMsgLevel, and QGis::UnknownUnit.

Referenced by loadFromDb(), readXML(), and setProj4String().

void QgsCoordinateReferenceSystem::setProj4String ( QString  theProj4String) [private]

Definition at line 859 of file qgscoordinatereferencesystem.cpp.

References debugPrint(), mCRS, mIsValidFlag, mWkt, and setMapUnits().

Referenced by createFromProj4(), loadFromDb(), and readXML().

void QgsCoordinateReferenceSystem::setProjectionAcronym ( QString  theProjectionAcronym) [private]

Set the projection acronym

Parameters:
theProjectionAcronymthe acronym (must be a valid proj4 projection acronym)

Definition at line 886 of file qgscoordinatereferencesystem.cpp.

References mProjectionAcronym.

Referenced by readXML().

void QgsCoordinateReferenceSystem::setSrid ( long  theSrid) [private]

Set the postgis srid

Parameters:
theSridThe postgis spatial_ref_sys key for this srs

Definition at line 851 of file qgscoordinatereferencesystem.cpp.

References mSRID.

Referenced by readXML().

Make sure that ESRI WKT import is done properly. This is required for proper shapefile CRS import when using gdal>= 1.9.

Note:
This function is called by createFromUserInput() and QgsOgrProvider::crs(), there is usually no need to call it from elsewhere.
This function sets CPL config option GDAL_FIX_ESRI_WKT to a proper value, unless it has been set by the user through the commandline or an environment variable. For more details refer to OGRSpatialReference::morphFromESRI() .
added in 1.8

Definition at line 161 of file qgscoordinatereferencesystem.cpp.

References QgsDebugMsg, and QgsLogger::warning().

Referenced by createFromUserInput().

Set user hint for validation

Definition at line 1375 of file qgscoordinatereferencesystem.cpp.

References mValidationHint.

Referenced by QgsMapLayer::readXML(), and QgsMapLayer::setCrs().

Update proj.4 parameters in our database from proj.4

Returns:
number of updated CRS on success and negative number of failed updates in case of errors.
Note:
added in 1.8

Definition at line 1485 of file qgscoordinatereferencesystem.cpp.

References QgsDebugMsg, QgsDebugMsgLevel, quotedValue(), and QgsApplication::srsDbFilePath().

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.

Returns:
QString theProj4String Proj4 format specifies that define this srs.
Note:
A zero length string will be returned if the toProj4 is uninitialised

Definition at line 814 of file qgscoordinatereferencesystem.cpp.

References mCRS, and mIsValidFlag.

Referenced by createFromProj4(), debugPrint(), QgsMapRenderer::destinationCrs(), findMatchingProj(), QgsCoordinateTransform::initialise(), loadFromDb(), QgsRasterLayer::metadata(), QgsVectorLayer::metadata(), operator<<(), saveAsUserCRS(), QgsMapRenderer::setDestinationCrs(), QgsCoordinateTransform::transformCoords(), writeXML(), and QgsProjectionSelector::~QgsProjectionSelector().

A helper to get an wkt representation of this srs

Returns:
string containing Wkt of the srs

Definition at line 1081 of file qgscoordinatereferencesystem.cpp.

References mCRS, and mWkt.

Referenced by debugPrint(), QgsRasterCalculator::processCalculation(), QgsRasterLayer::projectionWkt(), QgsVectorFileWriter::QgsVectorFileWriter(), and QgsRasterLayer::setDataProvider().

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.

Note:
It is not usually necessary to use this function, unless you are trying to force this srs to be valid.

Definition at line 237 of file qgscoordinatereferencesystem.cpp.

References createFromOgcWmsCrs(), GEO_EPSG_CRS_AUTHID, mCustomSrsValidation, and mIsValidFlag.

Referenced by QgsNewVectorLayerDialog::QgsNewVectorLayerDialog(), QgsMapLayer::readXML(), and QgsMapLayer::setCrs().

Get user hint for validation

Definition at line 1380 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>
     
Parameters:
theNodeThe node in which state will be restored
theDocThe document in which state will be stored
Returns:
bool True on success, False on failure

Definition at line 1202 of file qgscoordinatereferencesystem.cpp.

References authid(), description(), ellipsoidAcronym(), geographicFlag(), postgisSrid(), projectionAcronym(), srsid(), and toProj4().

Referenced by QgsMapLayer::writeXML(), QgsMapRenderer::writeXML(), and QgsCoordinateTransform::writeXML().


Member Data Documentation

If available the authority identifier for this srs.

Definition at line 454 of file qgscoordinatereferencesystem.h.

Referenced by authid(), epsg(), loadFromDb(), operator=(), setAuthId(), and setEpsg().

Whether this is a coordinate system has inverted axis.

Definition at line 478 of file qgscoordinatereferencesystem.h.

Referenced by axisInverted(), loadFromDb(), and operator=().

A textual description of the srs.

Definition at line 442 of file qgscoordinatereferencesystem.h.

Referenced by debugPrint(), description(), loadFromDb(), operator=(), and setDescription().

The official proj4 acronym for the ellipoid.

Definition at line 446 of file qgscoordinatereferencesystem.h.

Referenced by createFromProj4(), ellipsoidAcronym(), findMatchingProj(), loadFromDb(), operator=(), and setEllipsoidAcronym().

Whether this is a geographic or projected coordinate system.

Definition at line 448 of file qgscoordinatereferencesystem.h.

Referenced by axisInverted(), geographicFlag(), loadFromDb(), operator=(), and setGeographicFlag().

The map units.

Definition at line 450 of file qgscoordinatereferencesystem.h.

Referenced by mapUnits(), operator=(), and setMapUnits().

The official proj4 acronym for the projection family.

Definition at line 444 of file qgscoordinatereferencesystem.h.

Referenced by createFromProj4(), findMatchingProj(), loadFromDb(), operator=(), projectionAcronym(), and setProjectionAcronym().

If available, the Postgis spatial_ref_sys identifier for this srs (defaults to 0)

Definition at line 452 of file qgscoordinatereferencesystem.h.

Referenced by axisInverted(), loadFromDb(), operator=(), postgisSrid(), and setSrid().

The internal sqlite3 srs.db primary key for this srs.

Definition at line 440 of file qgscoordinatereferencesystem.h.

Referenced by debugPrint(), loadFromDb(), operator=(), setInternalId(), and srsid().

Definition at line 474 of file qgscoordinatereferencesystem.h.

Referenced by operator=(), setValidationHint(), and validationHint().

QString QgsCoordinateReferenceSystem::mWkt [mutable, private]

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines