Skip to content

Commit

Permalink
Further api updates in core
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@9478 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed Oct 16, 2008
1 parent 6596a2c commit 874a7c2
Show file tree
Hide file tree
Showing 33 changed files with 180 additions and 244 deletions.
4 changes: 2 additions & 2 deletions python/core/qgis.sip
Expand Up @@ -98,8 +98,8 @@ public:
const long GEOSRID;
/** Magic number for a geographic coord sys in QGIS srs.db tbl_srs.srs_id */
const long GEOCRS_ID;
/** Magic number for a geographic coord sys in EPSG ID format */
const long GEOEPSG_ID;
/** Magic number for a geographic coord sys in EpsgCrsId ID format */
const long GEO_EPSG_CRS_ID;
/** The length of teh string "+proj=" */
const int PROJ_PREFIX_LEN;
/** The length of teh string "+ellps=" */
Expand Down
78 changes: 20 additions & 58 deletions python/core/qgscoordinatereferencesystem.sip
Expand Up @@ -12,10 +12,10 @@ class QgsCoordinateReferenceSystem

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

enum CRS_TYPE {
QGIS_CRSID,
POSTGIS_SRID,
EPSG
enum CrsType {
InternalCrsId,
PostgisCrsId,
EpsgCrsId
};

//! Default constructor
Expand All @@ -30,24 +30,24 @@ class QgsCoordinateReferenceSystem
explicit QgsCoordinateReferenceSystem(QString theWkt);

/*! Use this constructor when you want to create a CRS object using
* a postgis SRID, an EPSG id or a QGIS CRS_ID.
* a postgis SRID, an Epsg Id 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 QgsCoordinateReferenceSystem::CRS_TYPE
* @param theType One of the types described in QgsCoordinateReferenceSystem::CrsType
*/
QgsCoordinateReferenceSystem(const long theId, CRS_TYPE theType=POSTGIS_SRID);
QgsCoordinateReferenceSystem(const long theId, CrsType theType=PostgisCrsId);

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

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

/**
* \brief Set up this CRS from the given OGC CRS
*
* Sets this CRS to the given OGC WMS-format Coordinate Reference Systems.
*
* \note This function only deals with EPSG labels only at this time.
* \note This function only deals with Epsg Id labels only at this time.
*
* \retval FALSE if not given an EPSG label
* \retval FALSE if not given an Epsg Id label
*/
bool createFromOgcWmsCrs(QString theCrs);

Expand All @@ -65,7 +65,7 @@ class QgsCoordinateReferenceSystem
* 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.
* @note SRID and EPSG may be blank if no match can be found on srs db.
* @note SRID and EpsgCrsId may be blank if no match can be found on srs db.
* @param theWkt The WKT for the desired spatial reference system.
* @return bool TRUE if sucess else false
*/
Expand All @@ -75,7 +75,7 @@ class QgsCoordinateReferenceSystem
* 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.
* @param theEpsg The EPSG for the desired spatial reference system.
* @param theEpsg The EpsgCrsId for the desired spatial reference system.
* @return bool TRUE if sucess else false
*/
bool createFromEpsg(const long theEpsg);
Expand Down Expand Up @@ -206,10 +206,14 @@ class QgsCoordinateReferenceSystem
* @return long theSrsId The internal sqlite3 srs.db primary key for this srs
*/
long srsid() const;
/*! Get the Postgis SRID - if possible.
* @return long theSRID The internal postgis SRID for this CRS
*/
long srid() const;
/*! Get the postgis srid for this srs
* @return long theSRID the Postgis spatial_ref_sys identifier for this srs (defaults to 0)
*/
long postgisSrid () const;
/*! Get the EpsgCrsId identifier for this srs
* @return long theEpsg the ESPG identifier for this srs (defaults to 0)
*/
long epsg () const;
/*! Get the Description
* @return QString the Description A textual description of the srs.
* @note A zero length string will be returned if the description is uninitialised
Expand Down Expand Up @@ -241,49 +245,7 @@ class QgsCoordinateReferenceSystem
*/
QGis::UnitType mapUnits() const;

/*! Set the postgis srid for this srs
* @return long theSRID the Postgis spatial_ref_sys identifier for this srs (defaults to 0)
*/
long postgisSrid () const;
/*! Set the EPSG identifier for this srs
* @return long theEpsg the ESPG identifier for this srs (defaults to 0)
*/
long epsg () const;

// Mutators -----------------------------------

/*! Set the QGIS SrsId
* @param long theSrsId The internal sqlite3 srs.db primary key for this srs
*/
void setSrsId(long theSrsId);
/*! Set the postgis srid
* @param long theSrsId The postgis spatial_ref_sys key for this srs
*/
void setSrid(long theSrid);
/*! Set the Description
* @param QString the Description A textual description of the srs.
*/
void setDescription (QString theDescription);
/* Set the Proj Proj4String.
* @param QString theProj4String Proj4 format specifies (excluding proj and ellips) that define this srs.
*/
void setProj4String (QString theProj4String);
/*! Set this Geographic? flag
* @param bool theGeoFlag Whether this is a geographic or projected coordinate system
*/
void setGeographicFlag (bool theGeoFlag);
/*! Set the EPSG identifier for this srs
* @param long theEpsg the ESPG identifier for this srs (defaults to 0)
*/
void setEpsg (long theEpsg);
/*! Set the projection acronym
* @param QString the acronym (must be a valid proj4 projection acronym)
*/
void setProjectionAcronym(QString theProjectionAcronym);
/*! Set the ellipsoid acronym
* @param QString the acronym (must be a valid proj4 ellipsoid acronym)
*/
void setEllipsoidAcronym(QString theEllipsoidAcronym);
};


40 changes: 20 additions & 20 deletions python/core/qgscoordinatetransform.sip
Expand Up @@ -45,18 +45,18 @@ 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 theSourceCRSType On of the enum members defined in QgsCoordinateReferenceSystem::CRS_TYPE
* @param theSourceCRSType On of the enum members defined in QgsCoordinateReferenceSystem::CrsType
*/
QgsCoordinateTransform(long theSourceSrid,
QString theDestWKT,
QgsCoordinateReferenceSystem::CRS_TYPE theSourceCRSType = QgsCoordinateReferenceSystem::POSTGIS_SRID );
QgsCoordinateReferenceSystem::CrsType theSourceCRSType = QgsCoordinateReferenceSystem::PostgisCrsId );

//! destructor
~QgsCoordinateTransform();

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

Expand Down Expand Up @@ -85,63 +85,63 @@ class QgsCoordinateTransform : QObject
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,
* If the direction is ForwardTransform then coordinates are transformed from layer CS --> map canvas CS,
* otherwise points are transformed from map canvas CS to layerCS.
* @param p Point to transform
* @param direction TransformDirection (defaults to FORWARD)
* @param direction TransformDirection (defaults to ForwardTransform)
* @return QgsPoint in Destination Coordinate System
*/
QgsPoint transform(const QgsPoint p,TransformDirection direction=FORWARD);
QgsPoint transform(const QgsPoint p,TransformDirection direction=ForwardTransform);

/*! Transform the point specified by x,y from Source Coordinate System to Destination Coordinate System
* If the direction is FORWARD then coordinates are transformed from layer CS --> map canvas CS,
* If the direction is ForwardTransform then coordinates are transformed from layer CS --> map canvas CS,
* otherwise points are transformed from map canvas CS to layerCS.
* @param x x cordinate of point to transform
* @param y y coordinate of point to transform
* @param direction TransformDirection (defaults to FORWARD)
* @param direction TransformDirection (defaults to ForwardTransform)
* @return QgsPoint in Destination Coordinate System
*/
QgsPoint transform(const double x, const double y,TransformDirection direction=FORWARD);
QgsPoint transform(const double x, const double y,TransformDirection direction=ForwardTransform);

/*! Transform a QgsRect to the dest Coordinate system
* If the direction is FORWARD then coordinates are transformed from layer CS --> map canvas CS,
* If the direction is ForwardTransform then coordinates are transformed from layer CS --> map canvas CS,
* otherwise points are transformed from map canvas CS to layerCS.
* It assumes that rect is a bounding box, and creates a bounding box
* in the proejcted CS, so that all points in source rectangle is within
* returned rectangle.
* @param QgsRect rect to transform
* @param direction TransformDirection (defaults to FORWARD)
* @param direction TransformDirection (defaults to ForwardTransform)
* @return QgsRect in Destination Coordinate System
*/
QgsRect transformBoundingBox(const QgsRect theRect,TransformDirection direction=FORWARD);
QgsRect transformBoundingBox(const QgsRect theRect,TransformDirection direction=ForwardTransform);

// Same as for the other transform() functions, but alters the x
// and y variables in place. The second one works with good old-fashioned
// C style arrays.
void transformInPlace(double& x, double& y, double &z, TransformDirection direction = FORWARD);
void transformInPlace(double& x, double& y, double &z, TransformDirection direction = ForwardTransform);

// TODO: argument not supported
//void transformInPlace(std::vector<double>& x, std::vector<double>& y, std::vector<double>& z,
// TransformDirection direction = FORWARD);
// TransformDirection direction = ForwardTransform);

/*! Transform a QgsRect to the dest Coordinate system
* If the direction is FORWARD then coordinates are transformed from layer CS --> map canvas CS,
* If the direction is ForwardTransform then coordinates are transformed from layer CS --> map canvas CS,
* otherwise points are transformed from map canvas CS to layerCS.
* @param QgsRect rect to transform
* @param direction TransformDirection (defaults to FORWARD)
* @param direction TransformDirection (defaults to ForwardTransform)
* @return QgsRect in Destination Coordinate System
*/
QgsRect transform(const QgsRect theRect,TransformDirection direction=FORWARD);
QgsRect transform(const QgsRect theRect,TransformDirection direction=ForwardTransform);

/*! Transform an array of coordinates to a different Coordinate System
* If the direction is FORWARD then coordinates are transformed from layer CS --> map canvas CS,
* If the direction is ForwardTransform then coordinates are transformed from layer CS --> map canvas CS,
* otherwise points are transformed from map canvas CS to layerCS.
* @param x x cordinate of point to transform
* @param y y coordinate of point to transform
* @param direction TransformDirection (defaults to FORWARD)
* @param direction TransformDirection (defaults to ForwardTransform)
* @return QgsRect in Destination Coordinate System
*/
void transformCoords( const int &numPoint, double *x, double *y, double *z,TransformDirection direction=FORWARD);
void transformCoords( const int &numPoint, double *x, double *y, double *z,TransformDirection direction=ForwardTransform);

/*!
* Flag to indicate whether the coordinate systems have been initialised
Expand Down
4 changes: 2 additions & 2 deletions python/core/qgsdistancearea.sip
Expand Up @@ -22,8 +22,8 @@ class QgsDistanceArea
//! sets source spatial reference system (by QGIS CRS)
void setSourceCRS(long srsid);

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

//! returns source spatial reference system
long sourceCRS();
Expand Down
2 changes: 1 addition & 1 deletion python/gui/qgsgenericprojectionselector.sip
Expand Up @@ -43,7 +43,7 @@ class QgsGenericProjectionSelector : QDialog //, private Ui::QgsGenericProjectio
* list of projections by. This is useful in (e.g.) WMS situations
* where you just want to offer what the WMS server can support.
*
* \note This function only deals with EPSG labels only at this time.
* \note This function only deals with EpsgCrsId labels only at this time.
*
* \warning This function's behaviour is undefined if it is called after the dialog is shown.
*/
Expand Down
4 changes: 2 additions & 2 deletions python/gui/qgsprojectionselector.sip
Expand Up @@ -53,7 +53,7 @@ class QgsProjectionSelector: QWidget //, private Ui::QgsProjectionSelectorBase
*/
const QString sqlSafeString(const QString theSQL);

//! Gets the current EPSG-style projection identifier
//! Gets the current EpsgCrsId-style projection identifier
long selectedEpsg();

public slots:
Expand Down Expand Up @@ -83,7 +83,7 @@ class QgsProjectionSelector: QWidget //, private Ui::QgsProjectionSelectorBase
* list of projections by. This is useful in (e.g.) WMS situations
* where you just want to offer what the WMS server can support.
*
* \note This function only deals with EPSG labels only at this time.
* \note This function only deals with EpsgCrsId labels only at this time.
*
* \warning This function's behaviour is undefined if it is called after the widget is shown.
*/
Expand Down
Binary file modified resources/qgis_help.db
Binary file not shown.
4 changes: 2 additions & 2 deletions src/app/legend/qgslegendlayerfile.cpp
Expand Up @@ -282,9 +282,9 @@ void QgsLegendLayerFile::saveAsShapefileGeneral( bool saveOnlySelection )

if ( mySelector->exec() )
{
QgsCoordinateReferenceSystem srs( mySelector->selectedCrsId(), QgsCoordinateReferenceSystem::QGIS_CRSID );
QgsCoordinateReferenceSystem srs( mySelector->selectedCrsId(), QgsCoordinateReferenceSystem::InternalCrsId );
destCRS = srs;
// destCRS->createFromId(mySelector->selectedCrsId(), QgsCoordinateReferenceSystem::QGIS_CRSID)
// destCRS->createFromId(mySelector->selectedCrsId(), QgsCoordinateReferenceSystem::InternalCrsId)
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsprojectproperties.cpp
Expand Up @@ -248,7 +248,7 @@ void QgsProjectProperties::apply()
long myCRSID = projectionSelector->selectedCrsId();
if ( myCRSID )
{
QgsCoordinateReferenceSystem srs( myCRSID, QgsCoordinateReferenceSystem::QGIS_CRSID );
QgsCoordinateReferenceSystem srs( myCRSID, QgsCoordinateReferenceSystem::InternalCrsId );
myRender->setDestinationSrs( srs );

// write the currently selected projections _proj string_ to project settings
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsrasterlayerproperties.cpp
Expand Up @@ -1687,7 +1687,7 @@ void QgsRasterLayerProperties::on_pbnChangeSpatialRefSys_clicked()
mySelector->setSelectedCrsId( mRasterLayer->srs().srsid() );
if ( mySelector->exec() )
{
QgsCoordinateReferenceSystem srs( mySelector->selectedCrsId(), QgsCoordinateReferenceSystem::QGIS_CRSID );
QgsCoordinateReferenceSystem srs( mySelector->selectedCrsId(), QgsCoordinateReferenceSystem::InternalCrsId );
mRasterLayer->setSrs( srs );
}
else
Expand Down
12 changes: 6 additions & 6 deletions src/app/qgsserversourceselect.cpp
Expand Up @@ -38,14 +38,14 @@
#include <QMap>
#include <QImageReader>
#include "qgslogger.h"
#include "qgis.h" // GEO_EPSG_CRS_ID


static long DEFAULT_WMS_EPSG = 4326; // WGS 84


QgsServerSourceSelect::QgsServerSourceSelect( QWidget * parent, Qt::WFlags fl )
: QDialog( parent, fl ),
m_Epsg( DEFAULT_WMS_EPSG ),
m_Epsg( GEO_EPSG_CRS_ID ),
mWmsProvider( 0 )
{
setupUi( this );
Expand Down Expand Up @@ -97,7 +97,7 @@ QgsServerSourceSelect::QgsServerSourceSelect( QWidget * parent, Qt::WFlags fl )
if ( currentCRS != -1 )
{
//convert CRS id to epsg
QgsCoordinateReferenceSystem currentRefSys( currentCRS, QgsCoordinateReferenceSystem::QGIS_CRSID );
QgsCoordinateReferenceSystem currentRefSys( currentCRS, QgsCoordinateReferenceSystem::InternalCrsId );
if ( currentRefSys.isValid() )
{
m_Epsg = currentRefSys.epsg();
Expand Down Expand Up @@ -496,8 +496,8 @@ void QgsServerSourceSelect::on_lstLayers_itemSelectionChanged()
// save first CRS in case we current m_Epsg is not available
if ( i == crsFilter.begin() )
defaultEpsg = epsg;
// prefer value of DEFAULT_WMS_EPSG if available
if ( epsg == DEFAULT_WMS_EPSG )
// prefer value of DEFAULT_GEO_EPSG_CRS_ID if available
if ( epsg == GEO_EPSG_CRS_ID )
defaultEpsg = epsg;
}
}
Expand Down Expand Up @@ -653,7 +653,7 @@ QString QgsServerSourceSelect::descriptionForEpsg( long epsg )
// We'll assume this function isn't called very often,
// so please forgive the lack of caching of results

QgsCoordinateReferenceSystem qgisSrs = QgsCoordinateReferenceSystem( epsg, QgsCoordinateReferenceSystem::EPSG );
QgsCoordinateReferenceSystem qgisSrs = QgsCoordinateReferenceSystem( epsg, QgsCoordinateReferenceSystem::EpsgCrsId );

return qgisSrs.description();
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsserversourceselect.h
Expand Up @@ -140,7 +140,7 @@ class QgsServerSourceSelect : public QDialog, private Ui::QgsServerSourceSelectB
//! Populate the image encoding button group - private for now.
void populateImageEncodingGroup( QgsWmsProvider* wmsProvider );

//! Returns a textual description for the EPSG number
//! Returns a textual description for the EpsgCrsId number
QString descriptionForEpsg( long epsg );

//! Name for selected connection
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsvectorlayerproperties.cpp
Expand Up @@ -866,7 +866,7 @@ void QgsVectorLayerProperties::on_pbnChangeSpatialRefSys_clicked()
mySelector->setSelectedCrsId( layer->srs().srsid() );
if ( mySelector->exec() )
{
QgsCoordinateReferenceSystem srs( mySelector->selectedCrsId(), QgsCoordinateReferenceSystem::QGIS_CRSID );
QgsCoordinateReferenceSystem srs( mySelector->selectedCrsId(), QgsCoordinateReferenceSystem::InternalCrsId );
layer->setSrs( srs );
}
else
Expand Down
4 changes: 2 additions & 2 deletions src/core/qgis.h
Expand Up @@ -131,8 +131,8 @@ const QString GEOPROJ4 = "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs";
const long GEOSRID = 4326;
/** Magic number for a geographic coord sys in QGIS srs.db tbl_srs.srs_id */
const long GEOCRS_ID = 3344;
/** Magic number for a geographic coord sys in EPSG ID format */
const long GEOEPSG_ID = 4326;
/** Magic number for a geographic coord sys in EpsgCrsId ID format */
const long GEO_EPSG_CRS_ID = 4326;
/** The length of the string "+proj=" */
const int PROJ_PREFIX_LEN = 6;
/** The length of the string "+ellps=" */
Expand Down

0 comments on commit 874a7c2

Please sign in to comment.