Skip to content
Permalink
Browse files
Further api updates in core
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 874a7c20f97a17d451feb3ee538ef51512dda0b5
Showing with 180 additions and 244 deletions.
  1. +2 −2 python/core/qgis.sip
  2. +20 −58 python/core/qgscoordinatereferencesystem.sip
  3. +20 −20 python/core/qgscoordinatetransform.sip
  4. +2 −2 python/core/qgsdistancearea.sip
  5. +1 −1 python/gui/qgsgenericprojectionselector.sip
  6. +2 −2 python/gui/qgsprojectionselector.sip
  7. BIN resources/qgis_help.db
  8. +2 −2 src/app/legend/qgslegendlayerfile.cpp
  9. +1 −1 src/app/qgsprojectproperties.cpp
  10. +1 −1 src/app/qgsrasterlayerproperties.cpp
  11. +6 −6 src/app/qgsserversourceselect.cpp
  12. +1 −1 src/app/qgsserversourceselect.h
  13. +1 −1 src/app/qgsvectorlayerproperties.cpp
  14. +2 −2 src/core/qgis.h
  15. +27 −52 src/core/qgscoordinatereferencesystem.cpp
  16. +33 −34 src/core/qgscoordinatereferencesystem.h
  17. +7 −7 src/core/qgscoordinatetransform.cpp
  18. +20 −20 src/core/qgscoordinatetransform.h
  19. +2 −2 src/core/qgsdistancearea.cpp
  20. +2 −2 src/core/qgsdistancearea.h
  21. +2 −2 src/core/qgsmaprenderer.cpp
  22. +1 −1 src/gui/qgsgenericprojectionselector.h
  23. +3 −3 src/gui/qgsprojectionselector.cpp
  24. +3 −3 src/gui/qgsprojectionselector.h
  25. +1 −1 src/plugins/coordinate_capture/coordinatecapture.cpp
  26. +8 −8 src/plugins/grass/qgsgrassnewmapset.cpp
  27. +1 −1 src/plugins/wfs/qgswfssourceselect.cpp
  28. +1 −1 src/providers/wfs/qgswfsdata.h
  29. +2 −2 src/providers/wfs/qgswfsprovider.cpp
  30. +1 −1 src/providers/wms/qgswmsprovider.cpp
  31. +1 −1 src/ui/qgsprojectionselectorbase.ui
  32. +3 −3 tests/algorithms/projections/projectioncshandlingtest.h
  33. +1 −1 tests/src/core/testqgsvectorfilewriter.cpp
@@ -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=" */
@@ -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
@@ -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);

@@ -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
*/
@@ -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);
@@ -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
@@ -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);
};


@@ -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. */
};

@@ -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
@@ -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();
@@ -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.
*/
@@ -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:
@@ -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.
*/
BIN +10 Bytes (100%) resources/qgis_help.db
Binary file not shown.
@@ -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
{
@@ -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
@@ -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
@@ -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 );
@@ -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();
@@ -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;
}
}
@@ -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();
}
@@ -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
@@ -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
@@ -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=" */
Loading

0 comments on commit 874a7c2

Please sign in to comment.