Skip to content
Permalink
Browse files
Refactor spatial reference system to coordinate reference system (fin…
…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 a4bd78c9f881b4f267e51ad4a66eaeb438e03079
Showing with 793 additions and 778 deletions.
  1. +1 −1 python/core/core.sip
  2. +1 −1 python/core/qgis.sip
  3. +24 −24 python/core/qgscoordinatetransform.sip
  4. +2 −2 python/core/qgsdataprovider.sip
  5. +3 −3 python/core/qgsdistancearea.sip
  6. +2 −2 python/core/qgsmaplayer.sip
  7. +9 −9 python/core/qgsmaprenderer.sip
  8. +37 −37 python/core/qgsspatialrefsys.sip
  9. +1 −1 python/core/qgsvectorfilewriter.sip
  10. +3 −3 python/gui/qgsgenericprojectionselector.sip
  11. +3 −3 python/gui/qgsprojectionselector.sip
  12. +18 −18 src/app/qgisapp.cpp
  13. +2 −2 src/app/qgsmaptoolidentify.cpp
  14. +1 −1 src/app/qgsmeasuredialog.cpp
  15. +3 −3 src/app/qgsmeasuretool.cpp
  16. +4 −4 src/app/qgsoptions.cpp
  17. +1 −1 src/app/qgsoptions.h
  18. +8 −8 src/app/qgsprojectproperties.cpp
  19. +2 −2 src/app/qgsrasterlayerproperties.cpp
  20. +1 −1 src/app/qgsrasterlayerproperties.h
  21. +10 −10 src/app/qgsserversourceselect.cpp
  22. +3 −3 src/app/qgsvectorlayerproperties.cpp
  23. +2 −2 src/core/CMakeLists.txt
  24. +1 −1 src/core/qgis.h
  25. +113 −113 src/core/{qgsspatialrefsys.cpp → qgscoordinatereferencesystem.cpp}
  26. +46 −47 src/core/{qgsspatialrefsys.h → qgscoordinatereferencesystem.h}
  27. +48 −48 src/core/qgscoordinatetransform.cpp
  28. +33 −33 src/core/qgscoordinatetransform.h
  29. +3 −3 src/core/qgsdataprovider.h
  30. +12 −12 src/core/qgsdistancearea.cpp
  31. +6 −6 src/core/qgsdistancearea.h
  32. +12 −12 src/core/qgsmaplayer.cpp
  33. +4 −4 src/core/qgsmaplayer.h
  34. +27 −27 src/core/qgsmaprenderer.cpp
  35. +11 −11 src/core/qgsmaprenderer.h
  36. +2 −1 src/core/qgsproject.h
  37. +8 −8 src/core/qgsprojectfiletransform.cpp
  38. +2 −1 src/core/qgsprojectfiletransform.h
  39. +2 −2 src/core/qgsprojectproperty.h
  40. +6 −0 src/core/qgsprojectversion.h
  41. +1 −1 src/core/qgsprovidercountcalcevent.h
  42. +2 −2 src/core/qgsproviderextentcalcevent.h
  43. +2 −2 src/core/qgsprovidermetadata.h
  44. +2 −1 src/core/qgsproviderregistry.h
  45. +2 −1 src/core/qgsrasterdataprovider.h
  46. +2 −2 src/core/qgsrect.h
  47. +6 −1 src/core/qgsrendercontext.h
  48. +3 −2 src/core/qgsrunprocess.h
  49. +2 −3 src/core/qgsscalecalculator.h
  50. +2 −3 src/core/qgssearchstring.h
  51. +2 −2 src/core/qgssearchtreenode.h
  52. +3 −1 src/core/qgssnapper.h
  53. +2 −2 src/core/qgsvectorfilewriter.cpp
  54. +1 −1 src/core/qgsvectorfilewriter.h
  55. +6 −6 src/core/qgsvectorlayer.cpp
  56. +20 −20 src/core/raster/qgsrasterlayer.cpp
  57. +6 −6 src/gui/qgsgenericprojectionselector.cpp
  58. +3 −3 src/gui/qgsgenericprojectionselector.h
  59. +1 −1 src/gui/qgsmapoverviewcanvas.cpp
  60. +53 −53 src/gui/qgsprojectionselector.cpp
  61. +17 −17 src/gui/qgsprojectionselector.h
  62. +2 −2 src/plugins/coordinate_capture/coordinatecapture.cpp
  63. +1 −1 src/plugins/coordinate_capture/coordinatecapturemaptool.cpp
  64. +6 −6 src/plugins/georeferencer/plugingui.cpp
  65. +2 −2 src/plugins/georeferencer/plugingui.h
  66. +34 −34 src/plugins/grass/qgsgrassnewmapset.cpp
  67. +2 −2 src/plugins/grass/qgsgrassnewmapset.h
  68. +3 −3 src/plugins/grid_maker/graticulecreator.cpp
  69. +2 −2 src/plugins/grid_maker/graticulecreator.h
  70. +8 −8 src/plugins/north_arrow/plugin.cpp
  71. +27 −27 src/plugins/wfs/qgswfssourceselect.cpp
  72. +3 −3 src/providers/delimitedtext/qgsdelimitedtextprovider.cpp
  73. +1 −1 src/providers/delimitedtext/qgsdelimitedtextprovider.h
  74. +3 −3 src/providers/gpx/qgsgpxprovider.cpp
  75. +1 −1 src/providers/gpx/qgsgpxprovider.h
  76. +4 −4 src/providers/grass/qgsgrassprovider.cpp
  77. +1 −1 src/providers/grass/qgsgrassprovider.h
  78. +3 −3 src/providers/memory/memoryprovider.cpp
  79. +1 −1 src/providers/memory/memoryprovider.h
  80. +6 −6 src/providers/ogr/qgsogrprovider.cpp
  81. +1 −1 src/providers/ogr/qgsogrprovider.h
  82. +3 −3 src/providers/postgres/qgspostgresprovider.cpp
  83. +2 −2 src/providers/postgres/qgspostgresprovider.h
  84. +2 −2 src/providers/wfs/qgswfsdata.cpp
  85. +3 −3 src/providers/wfs/qgswfsdata.h
  86. +11 −11 src/providers/wfs/qgswfsprovider.cpp
  87. +6 −6 src/providers/wfs/qgswfsprovider.h
  88. +15 −15 src/providers/wms/qgswmsprovider.cpp
  89. +2 −2 src/providers/wms/qgswmsprovider.h
  90. +4 −4 tests/algorithms/projections/projectioncshandlingtest.h
  91. +4 −4 tests/src/core/regression1141.cpp
  92. +4 −4 tests/src/core/testqgsmaprenderer.cpp
  93. +11 −11 tests/src/core/testqgsvectorfilewriter.cpp
@@ -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
@@ -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=" */
@@ -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);

/*!
@@ -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,
@@ -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
@@ -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;


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

@@ -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);
@@ -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
@@ -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();
@@ -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);
@@ -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.
*
@@ -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
@@ -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
@@ -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();

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

@@ -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
@@ -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();
@@ -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);

/**

0 comments on commit a4bd78c

Please sign in to comment.