-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4720 from nyalldawson/ref_geom
Template based referenced geometry class
- Loading branch information
Showing
13 changed files
with
492 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/core/geometry/qgsreferencedgeometry.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ | ||
|
||
|
||
|
||
|
||
class QgsReferencedGeometryBase | ||
{ | ||
%Docstring | ||
A base class for geometry primitives which are stored with an associated reference system. | ||
|
||
QgsReferencedGeometryBase classes represent some form of geometry primitive | ||
(such as rectangles) which have an optional coordinate reference system | ||
associated with them. | ||
|
||
.. versionadded:: 3.0 | ||
.. seealso:: QgsReferencedRectangle | ||
%End | ||
|
||
%TypeHeaderCode | ||
#include "qgsreferencedgeometry.h" | ||
%End | ||
public: | ||
|
||
QgsReferencedGeometryBase( const QgsCoordinateReferenceSystem &crs = QgsCoordinateReferenceSystem() ); | ||
%Docstring | ||
Constructor for QgsReferencedGeometryBase, with the specified ``crs``. | ||
%End | ||
|
||
QgsCoordinateReferenceSystem crs() const; | ||
%Docstring | ||
Returns the associated coordinate reference system, or an invalid CRS if | ||
no reference system is set. | ||
.. seealso:: setCrs() | ||
:rtype: QgsCoordinateReferenceSystem | ||
%End | ||
|
||
void setCrs( const QgsCoordinateReferenceSystem &crs ); | ||
%Docstring | ||
Sets the associated ``crs``. Set to an invalid CRS if | ||
no reference system is required. | ||
.. seealso:: crs() | ||
%End | ||
|
||
}; | ||
|
||
class QgsReferencedRectangle : QgsRectangle, QgsReferencedGeometryBase | ||
{ | ||
%Docstring | ||
A QgsRectangle with associated coordinate reference system. | ||
.. versionadded:: 3.0 | ||
%End | ||
|
||
%TypeHeaderCode | ||
#include "qgsreferencedgeometry.h" | ||
%End | ||
public: | ||
|
||
QgsReferencedRectangle( const QgsRectangle &rectangle, const QgsCoordinateReferenceSystem &crs ); | ||
%Docstring | ||
Constructor for QgsReferencedRectangle, with the specified initial ``rectangle`` | ||
and ``crs``. | ||
%End | ||
|
||
QgsReferencedRectangle(); | ||
%Docstring | ||
Constructor for QgsReferencedRectangle. | ||
%End | ||
|
||
operator QVariant() const; | ||
%Docstring | ||
Allows direct construction of QVariants from rectangle. | ||
%End | ||
|
||
}; | ||
|
||
|
||
class QgsReferencedPointXY : QgsPointXY, QgsReferencedGeometryBase | ||
{ | ||
%Docstring | ||
A QgsPointXY with associated coordinate reference system. | ||
.. versionadded:: 3.0 | ||
%End | ||
|
||
%TypeHeaderCode | ||
#include "qgsreferencedgeometry.h" | ||
%End | ||
public: | ||
|
||
QgsReferencedPointXY( const QgsPointXY &point, const QgsCoordinateReferenceSystem &crs ); | ||
%Docstring | ||
Constructor for QgsReferencedPointXY, with the specified initial ``point`` | ||
and ``crs``. | ||
%End | ||
|
||
QgsReferencedPointXY(); | ||
%Docstring | ||
Constructor for QgsReferencedPointXY. | ||
%End | ||
|
||
operator QVariant() const; | ||
%Docstring | ||
Allows direct construction of QVariants from point. | ||
%End | ||
|
||
}; | ||
|
||
|
||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/core/geometry/qgsreferencedgeometry.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/*************************************************************************** | ||
qgsreferencedgeometry.cpp | ||
------------------------ | ||
begin : June 2017 | ||
copyright : (C) 2017 by Nyall Dawson | ||
email : nyall dot dawson at gmail dot com | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include "qgsreferencedgeometry.h" | ||
|
||
QgsReferencedGeometryBase::QgsReferencedGeometryBase( const QgsCoordinateReferenceSystem &crs ) | ||
: mCrs( crs ) | ||
{} | ||
|
||
QgsReferencedRectangle::QgsReferencedRectangle( const QgsRectangle &rect, const QgsCoordinateReferenceSystem &crs ) | ||
: QgsRectangle( rect ) | ||
, QgsReferencedGeometryBase( crs ) | ||
{} | ||
|
||
QgsReferencedPointXY::QgsReferencedPointXY( const QgsPointXY &point, const QgsCoordinateReferenceSystem &crs ) | ||
: QgsPointXY( point ) | ||
, QgsReferencedGeometryBase( crs ) | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
/*************************************************************************** | ||
qgsreferencedgeometry.h | ||
---------------------- | ||
begin : June 2017 | ||
copyright : (C) 2017 by Nyall Dawson | ||
email : nyall dot dawson at gmail dot com | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#ifndef QGSREFERENCEDGEOMETRY_H | ||
#define QGSREFERENCEDGEOMETRY_H | ||
|
||
#include "qgis.h" | ||
#include "qgis_sip.h" | ||
#include "qgis_core.h" | ||
#include "qgscoordinatereferencesystem.h" | ||
#include "qgsrectangle.h" | ||
|
||
/** | ||
* \class QgsReferencedGeometryBase | ||
* \ingroup core | ||
* A base class for geometry primitives which are stored with an associated reference system. | ||
* | ||
* QgsReferencedGeometryBase classes represent some form of geometry primitive | ||
* (such as rectangles) which have an optional coordinate reference system | ||
* associated with them. | ||
* | ||
* \since QGIS 3.0 | ||
* \see QgsReferencedRectangle | ||
*/ | ||
class CORE_EXPORT QgsReferencedGeometryBase | ||
{ | ||
public: | ||
|
||
/** | ||
* Constructor for QgsReferencedGeometryBase, with the specified \a crs. | ||
*/ | ||
QgsReferencedGeometryBase( const QgsCoordinateReferenceSystem &crs = QgsCoordinateReferenceSystem() ); | ||
|
||
/** | ||
* Returns the associated coordinate reference system, or an invalid CRS if | ||
* no reference system is set. | ||
* \see setCrs() | ||
*/ | ||
QgsCoordinateReferenceSystem crs() const { return mCrs; } | ||
|
||
/** | ||
* Sets the associated \a crs. Set to an invalid CRS if | ||
* no reference system is required. | ||
* \see crs() | ||
*/ | ||
void setCrs( const QgsCoordinateReferenceSystem &crs ) { mCrs = crs; } | ||
|
||
private: | ||
|
||
QgsCoordinateReferenceSystem mCrs; | ||
|
||
}; | ||
|
||
/** | ||
* \ingroup core | ||
* A QgsRectangle with associated coordinate reference system. | ||
* \since QGIS 3.0 | ||
*/ | ||
class CORE_EXPORT QgsReferencedRectangle : public QgsRectangle, public QgsReferencedGeometryBase | ||
{ | ||
public: | ||
|
||
/** | ||
* Constructor for QgsReferencedRectangle, with the specified initial \a rectangle | ||
* and \a crs. | ||
*/ | ||
QgsReferencedRectangle( const QgsRectangle &rectangle, const QgsCoordinateReferenceSystem &crs ); | ||
|
||
/** | ||
* Constructor for QgsReferencedRectangle. | ||
*/ | ||
QgsReferencedRectangle() = default; | ||
|
||
//! Allows direct construction of QVariants from rectangle. | ||
operator QVariant() const | ||
{ | ||
return QVariant::fromValue( *this ); | ||
} | ||
|
||
}; | ||
|
||
Q_DECLARE_METATYPE( QgsReferencedRectangle ) | ||
|
||
/** | ||
* \ingroup core | ||
* A QgsPointXY with associated coordinate reference system. | ||
* \since QGIS 3.0 | ||
*/ | ||
class CORE_EXPORT QgsReferencedPointXY : public QgsPointXY, public QgsReferencedGeometryBase | ||
{ | ||
public: | ||
|
||
/** | ||
* Constructor for QgsReferencedPointXY, with the specified initial \a point | ||
* and \a crs. | ||
*/ | ||
QgsReferencedPointXY( const QgsPointXY &point, const QgsCoordinateReferenceSystem &crs ); | ||
|
||
/** | ||
* Constructor for QgsReferencedPointXY. | ||
*/ | ||
QgsReferencedPointXY() = default; | ||
|
||
//! Allows direct construction of QVariants from point. | ||
operator QVariant() const | ||
{ | ||
return QVariant::fromValue( *this ); | ||
} | ||
|
||
}; | ||
|
||
Q_DECLARE_METATYPE( QgsReferencedPointXY ) | ||
|
||
#endif // QGSREFERENCEDGEOMETRY_H |
Oops, something went wrong.