Skip to content

Commit 1a961e8

Browse files
committedSep 6, 2017
Template based referenced geometry class
1 parent 9502022 commit 1a961e8

File tree

3 files changed

+216
-0
lines changed

3 files changed

+216
-0
lines changed
 
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
/************************************************************************
2+
* This file has been generated automatically from *
3+
* *
4+
* src/core/geometry/qgsreferencedgeometry.h *
5+
* *
6+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
7+
************************************************************************/
8+
9+
10+
11+
12+
template<T>
13+
class QgsReferencedGeometryPrimitive
14+
{
15+
%Docstring
16+
A template based class for storing geometry primitives with an associated reference system.
17+
18+
QgsReferencedGeometryPrimitive classes represent some form of geometry primitive
19+
(such as rectangles) which have an optional coordinate reference system
20+
associated with them.
21+
22+
.. versionadded:: 3.0
23+
.. seealso:: QgsReferencedRectangle
24+
.. note::
25+
26+
Not available in Python bindings (although SIP file is present for specific implementations).
27+
%End
28+
29+
%TypeHeaderCode
30+
#include "qgsreferencedgeometry.h"
31+
%End
32+
public:
33+
34+
QgsReferencedGeometryPrimitive( T primitive, const QgsCoordinateReferenceSystem &crs = QgsCoordinateReferenceSystem() );
35+
%Docstring
36+
Constructor for QgsReferencedGeometryPrimitive, for the specified ``primitive`` and ``crs``.
37+
%End
38+
39+
T primitive() const;
40+
%Docstring
41+
Returns the geometry primitive.
42+
:rtype: T
43+
%End
44+
45+
T &primitive();
46+
%Docstring
47+
Returns the geometry primitive.
48+
:rtype: T
49+
%End
50+
51+
QgsCoordinateReferenceSystem crs() const;
52+
%Docstring
53+
Returns the associated coordinate reference system, or an invalid CRS if
54+
no reference system is set.
55+
.. seealso:: setCrs()
56+
:rtype: QgsCoordinateReferenceSystem
57+
%End
58+
59+
void setCrs( const QgsCoordinateReferenceSystem &crs );
60+
%Docstring
61+
Sets the associated ``crs``. Set to an invalid CRS if
62+
no reference system is required.
63+
.. seealso:: crs()
64+
%End
65+
66+
};
67+
68+
69+
typedef QgsReferencedGeometryPrimitive<QgsRectangle> QgsReferencedGeometryPrimitiveQgsRectangleBase;
70+
71+
class QgsReferencedRectangle : QgsReferencedGeometryPrimitiveQgsRectangleBase
72+
{
73+
%Docstring
74+
A QgsRectangle with associated coordinate reference system.
75+
.. versionadded:: 3.0
76+
%End
77+
78+
%TypeHeaderCode
79+
#include "qgsreferencedgeometry.h"
80+
typedef QgsReferencedGeometryPrimitive<QgsRectangle> QgsReferencedGeometryPrimitiveQgsRectangleBase;
81+
%End
82+
public:
83+
84+
QgsReferencedRectangle();
85+
%Docstring
86+
Construct a default optional expression.
87+
It will be disabled and with an empty expression.
88+
%End
89+
90+
QgsRectangle &rect();
91+
%Docstring
92+
:rtype: QgsRectangle
93+
%End
94+
95+
96+
};
97+
98+
99+
100+
101+
102+
/************************************************************************
103+
* This file has been generated automatically from *
104+
* *
105+
* src/core/geometry/qgsreferencedgeometry.h *
106+
* *
107+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
108+
************************************************************************/

‎src/core/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,6 +1059,7 @@ SET(QGIS_CORE_HDRS
10591059
geometry/qgsmultisurface.h
10601060
geometry/qgspolygon.h
10611061
geometry/qgsrectangle.h
1062+
geometry/qgsreferencedgeometry.h
10621063
geometry/qgsregularpolygon.h
10631064
geometry/qgstriangle.h
10641065
geometry/qgssurface.h
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
/***************************************************************************
2+
qgsreferencedgeometry.h
3+
----------------------
4+
begin : June 2017
5+
copyright : (C) 2017 by Nyall Dawson
6+
email : nyall dot dawson at gmail dot com
7+
***************************************************************************/
8+
9+
/***************************************************************************
10+
* *
11+
* This program is free software; you can redistribute it and/or modify *
12+
* it under the terms of the GNU General Public License as published by *
13+
* the Free Software Foundation; either version 2 of the License, or *
14+
* (at your option) any later version. *
15+
* *
16+
***************************************************************************/
17+
18+
#ifndef QGSREFERENCEDGEOMETRY_H
19+
#define QGSREFERENCEDGEOMETRY_H
20+
21+
#include "qgis.h"
22+
#include "qgis_sip.h"
23+
#include "qgis_core.h"
24+
#include "qgscoordinatereferencesystem.h"
25+
#include "qgsrectangle.h"
26+
27+
/**
28+
* \class QgsReferencedGeometryPrimitive
29+
* \ingroup core
30+
* A template based class for storing geometry primitives with an associated reference system.
31+
*
32+
* QgsReferencedGeometryPrimitive classes represent some form of geometry primitive
33+
* (such as rectangles) which have an optional coordinate reference system
34+
* associated with them.
35+
*
36+
* \since QGIS 3.0
37+
* \see QgsReferencedRectangle
38+
* \note Not available in Python bindings (although SIP file is present for specific implementations).
39+
*/
40+
template<typename T>
41+
class CORE_EXPORT QgsReferencedGeometryPrimitive
42+
{
43+
public:
44+
45+
/**
46+
* Constructor for QgsReferencedGeometryPrimitive, for the specified \a primitive and \a crs.
47+
*/
48+
QgsReferencedGeometryPrimitive( T primitive, const QgsCoordinateReferenceSystem &crs = QgsCoordinateReferenceSystem() )
49+
: mPrimitive( primitive )
50+
, mCrs( crs )
51+
{}
52+
53+
/**
54+
* Returns the geometry primitive.
55+
*/
56+
T primitive() const { return mPrimitive; }
57+
58+
/**
59+
* Returns the geometry primitive.
60+
*/
61+
T &primitive() { return mPrimitive; }
62+
63+
/**
64+
* Returns the associated coordinate reference system, or an invalid CRS if
65+
* no reference system is set.
66+
* \see setCrs()
67+
*/
68+
QgsCoordinateReferenceSystem crs() const { return mCrs; }
69+
70+
/**
71+
* Sets the associated \a crs. Set to an invalid CRS if
72+
* no reference system is required.
73+
* \see crs()
74+
*/
75+
void setCrs( const QgsCoordinateReferenceSystem &crs ) { mCrs = crs; }
76+
77+
private:
78+
79+
T mPrimitive;
80+
QgsCoordinateReferenceSystem mCrs;
81+
82+
};
83+
84+
/**
85+
* A QgsRectangle with associated coordinate reference system.
86+
* \since QGIS 3.0
87+
*/
88+
class CORE_EXPORT QgsReferencedRectangle : public QgsReferencedGeometryPrimitive< QgsRectangle >
89+
{
90+
public:
91+
92+
/**
93+
* Construct a default optional expression.
94+
* It will be disabled and with an empty expression.
95+
*/
96+
QgsReferencedRectangle();
97+
98+
QgsRectangle &rect() { return primitive(); }
99+
100+
101+
};
102+
103+
#endif // QGSREFERENCEDGEOMETRY_H
104+
105+
106+
107+

0 commit comments

Comments
 (0)
Please sign in to comment.