-
-
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.
New geometry class: QgsRegularPolygon (#4502)
- Loading branch information
1 parent
55cb855
commit 13c1318
Showing
16 changed files
with
1,095 additions
and
18 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,232 @@ | ||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/core/geometry/qgsregularpolygon.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ | ||
|
||
|
||
|
||
|
||
|
||
|
||
class QgsRegularPolygon | ||
{ | ||
%Docstring | ||
Regular Polygon geometry type. | ||
|
||
A regular polygon is a polygon that is equiangular (all angles are equal in measure) and equilateral (all sides have the same length). | ||
The regular polygon is defined by a center point with a number of sides/vertices, a radius and the first vertex. | ||
|
||
.. versionadded:: 3.0 | ||
%End | ||
|
||
%TypeHeaderCode | ||
#include "qgsregularpolygon.h" | ||
%End | ||
public: | ||
|
||
enum ConstructionOption | ||
{ | ||
InscribedCircle, | ||
CircumscribedCircle | ||
}; | ||
|
||
QgsRegularPolygon(); | ||
|
||
QgsRegularPolygon( const QgsPointV2 ¢er, const double radius, const double azimuth, const int numberSides, const ConstructionOption circle ); | ||
%Docstring | ||
Constructs a regular polygon by ``center`` and parameters for the first vertex. An empty regular polygon is returned if ``numberSides`` < 3 or ``ConstructionOption`` isn't valid. | ||
\param center The center of the regular polygon. | ||
\param radius Distance from the center and the first vertex or sides (see ``ConstructionOption``). | ||
\param azimuth Angle in degrees started from the North to the first vertex. | ||
\param numberSides Number of sides of the regular polygon. | ||
.. seealso:: ConstructionOption | ||
%End | ||
|
||
QgsRegularPolygon( const QgsPointV2 ¢er, const QgsPointV2 &pt1, const int numberSides, const ConstructionOption circle ); | ||
%Docstring | ||
Constructs a regular polygon by ``center`` and another point. | ||
\param center The center of the regular polygon. | ||
\param pt1 The first vertex if the polygon is inscribed in circle or the midpoint of a side if the polygon is circumscribed about circle. | ||
\param numberSides Number of sides of the regular polygon. | ||
\param circle Option to create the polygon inscribed in circle (the radius is the distance between the center and vertices) or circumscribed about circle (the radius is the distance from the center to the midpoints of the sides). | ||
%End | ||
|
||
QgsRegularPolygon( const QgsPointV2 &pt1, const QgsPointV2 &pt2, const int numberSides ); | ||
%Docstring | ||
Constructs a regular polygon by two points of the first side. | ||
\param pt1 The first vertex of the first side, also first vertex of the regular polygon. | ||
\param pt2 The second vertex of the first side. | ||
\param numberSides Number of sides of the regular polygon. | ||
%End | ||
|
||
bool operator ==( const QgsRegularPolygon &rp ) const; | ||
bool operator !=( const QgsRegularPolygon &rp ) const; | ||
|
||
bool isEmpty() const; | ||
%Docstring | ||
A regular polygon is empty if radius equal to 0 or number of sides < 3 | ||
:rtype: bool | ||
%End | ||
|
||
QgsPointV2 center() const; | ||
%Docstring | ||
Returns the center point of the regular polygon. | ||
.. seealso:: setCenter() | ||
:rtype: QgsPointV2 | ||
%End | ||
|
||
double radius() const; | ||
%Docstring | ||
Returns the radius. | ||
This is also the radius of the circumscribing circle. | ||
.. seealso:: apothem() | ||
.. seealso:: setRadius() | ||
:rtype: float | ||
%End | ||
|
||
QgsPointV2 firstVertex() const; | ||
%Docstring | ||
Returns the first vertex (corner) of the regular polygon. | ||
.. seealso:: setFirstVertex() | ||
:rtype: QgsPointV2 | ||
%End | ||
|
||
double apothem() const; | ||
%Docstring | ||
Returns the apothem of the regular polygon. | ||
The apothem is the radius of the inscribed circle. | ||
.. seealso:: radius() | ||
:rtype: float | ||
%End | ||
|
||
int numberSides() const; | ||
%Docstring | ||
Returns the number of sides of the regular polygon. | ||
.. seealso:: setNumberSides() | ||
:rtype: int | ||
%End | ||
|
||
void setCenter( const QgsPointV2 ¢er ); | ||
%Docstring | ||
Sets the center point. | ||
Radius is unchanged. The first vertex is reprojected from the new center. | ||
.. seealso:: center() | ||
%End | ||
|
||
void setRadius( const double radius ); | ||
%Docstring | ||
Sets the radius. | ||
Center is unchanged. The first vertex is reprojected from the center with the new radius. | ||
.. seealso:: radius() | ||
%End | ||
|
||
void setFirstVertex( const QgsPointV2 &firstVertex ); | ||
%Docstring | ||
Sets the first vertex. | ||
Radius is unchanged. The center is reprojected from the new first vertex. | ||
.. seealso:: firstVertex() | ||
%End | ||
|
||
void setNumberSides( const int numberSides ); | ||
%Docstring | ||
Sets the number of sides. | ||
If numberSides < 3, the number of sides is unchanged. | ||
.. seealso:: numberSides() | ||
%End | ||
|
||
QgsPointSequence points( ) const; | ||
%Docstring | ||
Returns a list including the vertices of the regular polygon. | ||
:rtype: QgsPointSequence | ||
%End | ||
|
||
QgsPolygonV2 *toPolygon( ) const /Factory/; | ||
%Docstring | ||
Returns as a polygon. | ||
:rtype: QgsPolygonV2 | ||
%End | ||
|
||
QgsLineString *toLineString( ) const /Factory/; | ||
%Docstring | ||
Returns as a linestring. | ||
:rtype: QgsLineString | ||
%End | ||
|
||
QgsTriangle toTriangle( ) const; | ||
%Docstring | ||
Returns as a triangle. | ||
An empty triangle is returned if the regular polygon is empty or if the number of sides is different from 3. | ||
:rtype: QgsTriangle | ||
%End | ||
|
||
QList<QgsTriangle> triangulate( ) const; | ||
%Docstring | ||
Returns a triangulation (vertices from sides to the center) of the regular polygon. | ||
An empty list is returned if the regular polygon is empty. | ||
:rtype: list of QgsTriangle | ||
%End | ||
|
||
QgsCircle inscribedCircle( ) const; | ||
%Docstring | ||
Returns the inscribed circle | ||
:rtype: QgsCircle | ||
%End | ||
|
||
QgsCircle circumscribedCircle( ) const; | ||
%Docstring | ||
Returns the circumscribed circle | ||
:rtype: QgsCircle | ||
%End | ||
|
||
QString toString( int pointPrecision = 17, int radiusPrecision = 17, int anglePrecision = 2 ) const; | ||
%Docstring | ||
Returns a string representation of the regular polygon. | ||
Members will be truncated to the specified precision. | ||
:rtype: str | ||
%End | ||
|
||
double interiorAngle( ) const; | ||
%Docstring | ||
Returns the measure of the interior angles in degrees. | ||
:rtype: float | ||
%End | ||
|
||
double centralAngle( ) const; | ||
%Docstring | ||
Returns the measure of the central angle (the angle subtended at the center of the polygon by one of its sides) in degrees. | ||
:rtype: float | ||
%End | ||
|
||
double area( ) const; | ||
%Docstring | ||
Returns the area. | ||
Returns 0 if the regular polygon is empty. | ||
:rtype: float | ||
%End | ||
|
||
double perimeter( ) const; | ||
%Docstring | ||
Returns the perimeter. | ||
Returns 0 if the regular polygon is empty. | ||
:rtype: float | ||
%End | ||
|
||
double length( ) const; | ||
%Docstring | ||
Returns the length of a side. | ||
Returns 0 if the regular polygon is empty. | ||
:rtype: float | ||
%End | ||
|
||
}; | ||
|
||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/core/geometry/qgsregularpolygon.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "make_regular_polygon", | ||
"type": "function", | ||
"description": "Creates a regular polygon.", | ||
"variableLenArguments": true, | ||
"arguments": [ | ||
{"arg":"center", "description": "center of the regular polygon"}, | ||
{"arg":"radius", "description": "second point. The first if the regular polygon is inscribed. The midpoint of the first side if the regular polygon is circumscribed."}, | ||
{"arg":"number_sides", "description": "Number of sides/edges of the regular polygon"}, | ||
{"arg":"circle", "description": "Optional argument to construct the regular polygon. By default this value is 0. Value can be 0 (inscribed) or 1 (circumscribed)"}], | ||
"examples": [ { "expression":"geom_to_wkt(make_regular_polygon(make_point(0,0), make_point(0,5), 5))", "returns":"'Polygon ((0 5, 4.76 1.55, 2.94 -4.05, -2.94 -4.05, -4.76 1.55, 0 5))'"}, | ||
{ "expression":"geom_to_wkt(make_regular_polygon(make_point(0,0), project(make_point(0,0), 4.0451, radians(36)), 5))", "returns":"'Polygon ((0 5, 4.76 1.55, 2.94 -4.05, -2.94 -4.05, -4.76 1.55, 0 5))'"} | ||
] | ||
} |
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
Oops, something went wrong.