Skip to content

Commit

Permalink
Refactor spatial reference system to coordinate reference system (fin…
Browse files Browse the repository at this point in the history
…alise fix of ticket #15). Also updated some more core api docs / module assignments.

git-svn-id: http://svn.osgeo.org/qgis/trunk@9108 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed Aug 21, 2008
1 parent 6be8471 commit a4bd78c
Show file tree
Hide file tree
Showing 93 changed files with 793 additions and 778 deletions.
2 changes: 1 addition & 1 deletion python/core/core.sip
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
%Include qgssinglesymbolrenderer.sip
%Include qgssnapper.sip
%Include qgsspatialindex.sip
%Include qgsspatialrefsys.sip
%Include qgscoordinatereferencesystem.sip
%Include qgssymbol.sip
%Include qgssymbologyutils.sip
%Include qgsuniquevaluerenderer.sip
Expand Down
2 changes: 1 addition & 1 deletion python/core/qgis.sip
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public:
/** Magic number for a geographic coord sys in POSTGIS SRID */
const long GEOSRID;
/** Magic number for a geographic coord sys in QGIS srs.db tbl_srs.srs_id */
const long GEOSRS_ID;
const long GEOCRS_ID;
/** Magic number for a geographic coord sys in EPSG ID format */
const long GEOEPSG_ID;
/** The length of teh string "+proj=" */
Expand Down
48 changes: 24 additions & 24 deletions python/core/qgscoordinatetransform.sip
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ class QgsCoordinateTransform : QObject
/*! Default constructor. Make sure you use initialised() manually if you use this one! */
QgsCoordinateTransform() ;

/** Constructs a QgsCoordinateTransform using QgsSpatialRefSys objects.
* @param theSource SRS, typically of the layer's coordinate system
* @param theDest SRS, typically of the map canvas coordinate system
/** Constructs a QgsCoordinateTransform using QgsCoordinateReferenceSystem objects.
* @param theSource CRS, typically of the layer's coordinate system
* @param theDest CRS, typically of the map canvas coordinate system
*/
QgsCoordinateTransform(const QgsSpatialRefSys& theSource,
const QgsSpatialRefSys& theDest);
QgsCoordinateTransform(const QgsCoordinateReferenceSystem& theSource,
const QgsCoordinateReferenceSystem& theDest);

/** Constructs a QgsCoordinateTransform using SRS ID of source and destination SRS */
/** Constructs a QgsCoordinateTransform using CRS ID of source and destination CRS */
QgsCoordinateTransform(long theSourceSrsId, long theDestSrsId);

/*!
Expand All @@ -45,44 +45,44 @@ class QgsCoordinateTransform : QObject
* of the layer and map canvas coordinate system as Wkt
* @param theSourceSrid Spatial Ref Id of the layer's coordinate system
* @param theSourceWKT WKT of the map canvas coordinate system
* @param theSourceSRSType On of the enum members defined in QgsSpatialRefSys::SRS_TYPE
* @param theSourceCRSType On of the enum members defined in QgsCoordinateReferenceSystem::CRS_TYPE
*/
QgsCoordinateTransform(long theSourceSrid,
QString theDestWKT,
QgsSpatialRefSys::SRS_TYPE theSourceSRSType = QgsSpatialRefSys::POSTGIS_SRID );
QgsCoordinateReferenceSystem::CRS_TYPE theSourceCRSType = QgsCoordinateReferenceSystem::POSTGIS_SRID );

//! destructor
~QgsCoordinateTransform();

//! Enum used to indicate the direction (forward or inverse) of the transform
enum TransformDirection{
FORWARD, /*!< Transform from source to destination SRS. */
INVERSE /*!< Transform from destination to source SRS. */
FORWARD, /*!< Transform from source to destination CRS. */
INVERSE /*!< Transform from destination to source CRS. */
};

/*!
* Set the source (layer) QgsSpatialRefSys
* @param theSRS QgsSpatialRefSys representation of the layer's coordinate system
* Set the source (layer) QgsCoordinateReferenceSystem
* @param theCRS QgsCoordinateReferenceSystem representation of the layer's coordinate system
*/
void setSourceSRS(const QgsSpatialRefSys& theSRS);
void setSourceCRS(const QgsCoordinateReferenceSystem& theCRS);

/*!
* Mutator for dest QgsSpatialRefSys
* @param theSRS of the destination coordinate system
* Mutator for dest QgsCoordinateReferenceSystem
* @param theCRS of the destination coordinate system
*/
void setDestSRS(const QgsSpatialRefSys& theSRS);
void setDestCRS(const QgsCoordinateReferenceSystem& theCRS);

/*!
* Get the QgsSpatialRefSys representation of the layer's coordinate system
* @return QgsSpatialRefSys of the layer's coordinate system
* Get the QgsCoordinateReferenceSystem representation of the layer's coordinate system
* @return QgsCoordinateReferenceSystem of the layer's coordinate system
*/
QgsSpatialRefSys& sourceSRS();
QgsCoordinateReferenceSystem& sourceCRS();

/*!
* Get the QgsSpatialRefSys representation of the map canvas coordinate system
* @return QgsSpatialRefSys of the map canvas coordinate system
* Get the QgsCoordinateReferenceSystem representation of the map canvas coordinate system
* @return QgsCoordinateReferenceSystem of the map canvas coordinate system
*/
QgsSpatialRefSys& destSRS();
QgsCoordinateReferenceSystem& destCRS();

/*! Transform the point from Source Coordinate System to Destination Coordinate System
* If the direction is FORWARD then coordinates are transformed from layer CS --> map canvas CS,
Expand Down Expand Up @@ -162,8 +162,8 @@ class QgsCoordinateTransform : QObject
* selected.
* @note This coord transform will be reinitialised when this slot is called
* to check if short circuiting is needed or not etc.
* @param theSRSID - A long representing the srsid of the srs to be used */
void setDestSRSID (long theSRSID);
* @param theCRSID - A long representing the srsid of the srs to be used */
void setDestCRSID (long theCRSID);

public slots:
//!initialise is used to actually create the Transformer instance
Expand Down
4 changes: 2 additions & 2 deletions python/core/qgsdataprovider.sip
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ class QgsDataProvider : QObject
*/
virtual ~QgsDataProvider();

/*! Get the QgsSpatialRefSys for this layer
/*! Get the QgsCoordinateReferenceSystem for this layer
* @note Must be reimplemented by each provider.
* If the provider isn't capable of returning
* its projection an empty srs will be return, ti will return 0
*/
virtual QgsSpatialRefSys getSRS() = 0;
virtual QgsCoordinateReferenceSystem getCRS() = 0;


/**
Expand Down
6 changes: 3 additions & 3 deletions python/core/qgsdistancearea.sip
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ class QgsDistanceArea
//! returns projections enabled flag
bool projectionsEnabled();

//! sets source spatial reference system (by QGIS SRS)
void setSourceSRS(long srsid);
//! sets source spatial reference system (by QGIS CRS)
void setSourceCRS(long srsid);

//! sets source spatial reference system (by EPSG)
void setSourceEPSG(long epsgId);

//! returns source spatial reference system
long sourceSRS();
long sourceCRS();
//! What sort of coordinate system is being used?
bool geographic();

Expand Down
4 changes: 2 additions & 2 deletions python/core/qgsmaplayer.sip
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,10 @@ public:
virtual QString errorString();

/** Returns layer's spatial reference system */
const QgsSpatialRefSys& srs();
const QgsCoordinateReferenceSystem& srs();

/** Sets layer's spatial reference system */
void setSrs(const QgsSpatialRefSys& srs);
void setSrs(const QgsCoordinateReferenceSystem& srs);

/** A convenience function to capitalise the layer name */
static QString capitaliseLayerName(const QString name);
Expand Down
18 changes: 9 additions & 9 deletions python/core/qgsmaprenderer.sip
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,16 @@ class QgsMapRenderer : QObject
//!accessor for output size
QSize outputSize();

//! transform extent in layer's SRS to extent in output SRS
//! transform extent in layer's CRS to extent in output CRS
QgsRect layerExtentToOutputExtent(QgsMapLayer* theLayer, QgsRect extent);

//! transform coordinates from layer's SRS to output SRS
//! transform coordinates from layer's CRS to output CRS
QgsPoint layerCoordsToOutputCoords(QgsMapLayer* theLayer, QgsPoint point);

//! transform coordinates from output SRS to layer's SRS
//! transform coordinates from output CRS to layer's CRS
QgsPoint outputCoordsToLayerCoords(QgsMapLayer* theLayer, QgsPoint point);

//! transform rect's coordinates from output SRS to layer's SRS
//! transform rect's coordinates from output CRS to layer's CRS
QgsRect outputCoordsToLayerCoords(QgsMapLayer* theLayer, QgsRect rect);

//! sets whether to use projections for this layer set
Expand All @@ -72,10 +72,10 @@ class QgsMapRenderer : QObject
bool projectionsEnabled();

//! sets destination spatial reference system
void setDestinationSrs(const QgsSpatialRefSys& srs);
void setDestinationSrs(const QgsCoordinateReferenceSystem& srs);

//! returns SRS ID of destination spatial reference system
const QgsSpatialRefSys& destinationSrs();
//! returns CRS ID of destination spatial reference system
const QgsCoordinateReferenceSystem& destinationSrs();

//! returns current extent of layer set
QgsRect fullExtent();
Expand Down Expand Up @@ -121,9 +121,9 @@ class QgsMapRenderer : QObject
void adjustExtentToSize();

/** Convenience function to project an extent into the layer source
* SRS, but also split it into two extents if it crosses
* CRS, but also split it into two extents if it crosses
* the +/- 180 degree line. Modifies the given extent to be in the
* source SRS coordinates, and if it was split, returns true, and
* source CRS coordinates, and if it was split, returns true, and
* also sets the contents of the r2 parameter
*/
bool splitLayersExtent(QgsMapLayer* layer, QgsRect& extent, QgsRect& r2);
Expand Down
74 changes: 37 additions & 37 deletions python/core/qgsspatialrefsys.sip
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@

/*!
* \class QgsSpatialRefSys
* \brief Class for storing a spatial reference system (SRS)
* \class QgsCoordinateReferenceSystem
* \brief Class for storing a spatial reference system (CRS)
*/
class QgsSpatialRefSys
class QgsCoordinateReferenceSystem
{
%TypeHeaderCode
#include <qgsspatialrefsys.h>
#include <qgscoordinatereferencesystem.h>
%End
public:

// typedef void (*CUSTOM_SRS_VALIDATION)(QgsSpatialRefSys*);
// typedef void (*CUSTOM_CRS_VALIDATION)(QgsCoordinateReferenceSystem*);

enum SRS_TYPE {
QGIS_SRSID,
enum CRS_TYPE {
QGIS_CRSID,
POSTGIS_SRID,
EPSG
};

//! Default constructor
QgsSpatialRefSys();
QgsCoordinateReferenceSystem();

~QgsSpatialRefSys();
~QgsCoordinateReferenceSystem();

/*!
* Constructs a SRS object from a WKT string
* Constructs a CRS object from a WKT string
* @param theWkt A String containing a valid Wkt def
*/
explicit QgsSpatialRefSys(QString theWkt);
explicit QgsCoordinateReferenceSystem(QString theWkt);

/*! Use this constructor when you want to create a SRS object using
* a postgis SRID, an EPSG id or a QGIS SRS_ID.
/*! Use this constructor when you want to create a CRS object using
* a postgis SRID, an EPSG id or a QGIS CRS_ID.
* @param theId The ID no valid for the chosen coordinate system id type
* @param theType One of the types described in QgsSpatialRefSys::SRS_TYPE
* @param theType One of the types described in QgsCoordinateReferenceSystem::CRS_TYPE
*/
QgsSpatialRefSys(const long theId, SRS_TYPE theType=POSTGIS_SRID);
QgsCoordinateReferenceSystem(const long theId, CRS_TYPE theType=POSTGIS_SRID);

// Misc helper functions -----------------------

void createFromId(const long theId, SRS_TYPE theType=POSTGIS_SRID);
void createFromId(const long theId, CRS_TYPE theType=POSTGIS_SRID);

/**
* \brief Set up this SRS from the given OGC CRS
* \brief Set up this CRS from the given OGC CRS
*
* Sets this SRS to the given OGC WMS-format Coordinate Reference Systems.
* Sets this CRS to the given OGC WMS-format Coordinate Reference Systems.
*
* \note This function only deals with EPSG labels only at this time.
*
Expand Down Expand Up @@ -104,7 +104,7 @@ class QgsSpatialRefSys
* - 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 SRS
* - 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
Expand All @@ -121,12 +121,12 @@ class QgsSpatialRefSys
*/
bool createFromProj4 (const QString theProjString);

/*! Find out whether this SRS is correctly initialised and useable */
/*! Find out whether this CRS is correctly initialised and useable */
bool isValid() const;
/*! Perform some validation on this SRS. If the sts doesnt validate the
* default behaviour settings for layers with unknown SRS will be
/*! Perform some validation on this CRS. If the sts doesnt 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 SRS is valid - even
* 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 neccessary to use this function, unless you
Expand All @@ -135,15 +135,15 @@ class QgsSpatialRefSys
void validate();

/*! This is a globbing function to try to find a record in the database
* that matches a SRS defined only by a proj4string. The goal is to
* learn what the tbl_srs.srs_id value is for the SRS. Internally
* the source SRS is converted to and OGR srs object using the proj4string
* 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 and OGR srs object using the proj4string
* 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 SRS.
* 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!
* @return lomg the SrsId of the matched SRS
* @return lomg the SrsId of the matched CRS
*/
long findMatchingProj();

Expand All @@ -156,16 +156,16 @@ class QgsSpatialRefSys
* @return QMap An associative array of field name <-> value pairs
*/
RecordMap getRecord(QString theSql);
/*! Overloaded == operator used to compare to SRS's.
/*! Overloaded == operator used to compare to CRS's.
* Internally it will delegate to the equals method described below
*/
bool operator==(const QgsSpatialRefSys &theSrs);
/*! Overloaded != operator used to compare to SRS's.
bool operator==(const QgsCoordinateReferenceSystem &theSrs);
/*! Overloaded != operator used to compare to CRS's.
* Returns opposite bool value to operator ==
*/
bool operator!=(const QgsSpatialRefSys &theSrs);
/*! Overloaded == operator used to compare to SRS's.
* Internally it will use OGR isSameSRS() or isSameGeoSRS() methods as appropriate.
bool operator!=(const QgsCoordinateReferenceSystem &theSrs);
/*! 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.
*/
Expand Down Expand Up @@ -203,11 +203,11 @@ class QgsSpatialRefSys
*/
static QString getProj4FromSrsId(const int theSrsId);

/** Sets custom function to force valid SRS
/** Sets custom function to force valid CRS
* QGIS uses implementation in QgisGui::customSrsValidation
*/
// TODO: disabled for now, needs usage of %Method directive to pass the function
//static void setCustomSrsValidation(CUSTOM_SRS_VALIDATION f);
//static void setCustomSrsValidation(CUSTOM_CRS_VALIDATION f);

// Accessors -----------------------------------

Expand All @@ -216,7 +216,7 @@ class QgsSpatialRefSys
*/
long srsid() const;
/*! Get the Postgis SRID - if possible.
* @return long theSRID The internal postgis SRID for this SRS
* @return long theSRID The internal postgis SRID for this CRS
*/
long srid() const;
/*! Get the Description
Expand Down
2 changes: 1 addition & 1 deletion python/core/qgsvectorfilewriter.sip
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public:
const QString& fileEncoding,
const QMap<int, QgsField>& fields,
QGis::WKBTYPE geometryType,
const QgsSpatialRefSys* srs);
const QgsCoordinateReferenceSystem* srs);

/** checks whether there were any errors in constructor */
WriterError hasError();
Expand Down
6 changes: 3 additions & 3 deletions python/gui/qgsgenericprojectionselector.sip
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ class QgsGenericProjectionSelector : QDialog //, private Ui::QgsGenericProjectio
void setMessage(QString theMessage="");

QString getSelectedProj4String();
long getSelectedSRSID();
long getSelectedCRSID();
long getSelectedEpsg();

void setSelectedSRSName(QString theName);
void setSelectedSRSID(long theID);
void setSelectedCRSName(QString theName);
void setSelectedCRSID(long theID);
void setSelectedEpsg(long theID);

/**
Expand Down
Loading

0 comments on commit a4bd78c

Please sign in to comment.