mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-22 00:06:12 -05:00
move SegmentCalculationMethod to qgis.h
This commit is contained in:
parent
157383300c
commit
e637eb3df2
@ -11161,6 +11161,23 @@ Qgis.PointCloudZoomOutRenderBehavior.__doc__ = """Point cloud zoom out options
|
||||
"""
|
||||
# --
|
||||
Qgis.PointCloudZoomOutRenderBehavior.baseClass = Qgis
|
||||
# monkey patching scoped based enum
|
||||
Qgis.SegmentCalculationMethod.Standard.__doc__ = "Standard sagitta-based calculation"
|
||||
Qgis.SegmentCalculationMethod.Adaptive.__doc__ = "Adaptive calculation based on radius size"
|
||||
Qgis.SegmentCalculationMethod.AreaError.__doc__ = "Calculation based on area error"
|
||||
Qgis.SegmentCalculationMethod.ConstantDensity.__doc__ = "Simple calculation with constant segment density"
|
||||
Qgis.SegmentCalculationMethod.__doc__ = """brief Method used to calculate the number of segments for circle approximation
|
||||
|
||||
.. versionadded:: 3.44
|
||||
|
||||
* ``Standard``: Standard sagitta-based calculation
|
||||
* ``Adaptive``: Adaptive calculation based on radius size
|
||||
* ``AreaError``: Calculation based on area error
|
||||
* ``ConstantDensity``: Simple calculation with constant segment density
|
||||
|
||||
"""
|
||||
# --
|
||||
Qgis.SegmentCalculationMethod.baseClass = Qgis
|
||||
try:
|
||||
Qgis.__attribute_docs__ = {'QGIS_DEV_VERSION': 'The development version', 'DEFAULT_SEARCH_RADIUS_MM': 'Identify search radius in mm', 'DEFAULT_MAPTOPIXEL_THRESHOLD': 'Default threshold between map coordinates and device coordinates for map2pixel simplification', 'DEFAULT_HIGHLIGHT_COLOR': 'Default highlight color. The transparency is expected to only be applied to polygon\nfill. Lines and outlines are rendered opaque.', 'DEFAULT_HIGHLIGHT_BUFFER_MM': 'Default highlight buffer in mm.', 'DEFAULT_HIGHLIGHT_MIN_WIDTH_MM': 'Default highlight line/stroke minimum width in mm.', 'SCALE_PRECISION': 'Fudge factor used to compare two scales. The code is often going from scale to scale\ndenominator. So it looses precision and, when a limit is inclusive, can lead to errors.\nTo avoid that, use this factor instead of using <= or >=.\n\n.. deprecated:: 3.40\n\n No longer used by QGIS and will be removed in QGIS 4.0.', 'DEFAULT_Z_COORDINATE': 'Default Z coordinate value.\nThis value have to be assigned to the Z coordinate for the vertex.', 'DEFAULT_M_COORDINATE': 'Default M coordinate value.\nThis value have to be assigned to the M coordinate for the vertex.\n\n.. versionadded:: 3.20', 'UI_SCALE_FACTOR': 'UI scaling factor. This should be applied to all widget sizes obtained from font metrics,\nto account for differences in the default font sizes across different platforms.', 'DEFAULT_SNAP_TOLERANCE': 'Default snapping distance tolerance.', 'DEFAULT_SNAP_UNITS': 'Default snapping distance units.'}
|
||||
Qgis.version = staticmethod(Qgis.version)
|
||||
|
@ -1,20 +1,4 @@
|
||||
# The following has been generated automatically from src/core/geometry/qgscircle.h
|
||||
# monkey patching scoped based enum
|
||||
QgsCircle.SegmentCalculationMethod.Standard.__doc__ = "Standard sagitta-based calculation"
|
||||
QgsCircle.SegmentCalculationMethod.Adaptive.__doc__ = "Adaptive calculation based on radius size"
|
||||
QgsCircle.SegmentCalculationMethod.AreaError.__doc__ = "Calculation based on area error"
|
||||
QgsCircle.SegmentCalculationMethod.ConstantDensity.__doc__ = "Simple calculation with constant segment density"
|
||||
QgsCircle.SegmentCalculationMethod.__doc__ = """Method used to calculate the number of segments for circle approximation
|
||||
|
||||
.. versionadded:: 3.44
|
||||
|
||||
* ``Standard``: Standard sagitta-based calculation
|
||||
* ``Adaptive``: Adaptive calculation based on radius size
|
||||
* ``AreaError``: Calculation based on area error
|
||||
* ``ConstantDensity``: Simple calculation with constant segment density
|
||||
|
||||
"""
|
||||
# --
|
||||
try:
|
||||
QgsCircle.from2Points = staticmethod(QgsCircle.from2Points)
|
||||
QgsCircle.from3Points = staticmethod(QgsCircle.from3Points)
|
||||
@ -25,6 +9,7 @@ try:
|
||||
QgsCircle.fromExtent = staticmethod(QgsCircle.fromExtent)
|
||||
QgsCircle.minimalCircleFrom3Points = staticmethod(QgsCircle.minimalCircleFrom3Points)
|
||||
QgsCircle.calculateSegments = staticmethod(QgsCircle.calculateSegments)
|
||||
QgsCircle.calculateSegmentsStandard = staticmethod(QgsCircle.calculateSegmentsStandard)
|
||||
QgsCircle.calculateSegmentsAdaptive = staticmethod(QgsCircle.calculateSegmentsAdaptive)
|
||||
QgsCircle.calculateSegmentsByAreaError = staticmethod(QgsCircle.calculateSegmentsByAreaError)
|
||||
QgsCircle.calculateSegmentsByConstant = staticmethod(QgsCircle.calculateSegmentsByConstant)
|
||||
|
@ -377,15 +377,7 @@ Coordinates are taken from quadrant North, East and South.
|
||||
.. seealso:: :py:func:`asGml2`
|
||||
%End
|
||||
|
||||
enum class SegmentCalculationMethod
|
||||
{
|
||||
Standard,
|
||||
Adaptive,
|
||||
AreaError,
|
||||
ConstantDensity
|
||||
};
|
||||
|
||||
static int calculateSegments( double radius, double parameter, int minSegments, SegmentCalculationMethod method );
|
||||
static int calculateSegments( double radius, double parameter, int minSegments, Qgis::SegmentCalculationMethod method );
|
||||
%Docstring
|
||||
Calculates the number of segments needed to approximate a circle.
|
||||
|
||||
@ -414,7 +406,7 @@ Calculates the number of segments needed to approximate a circle.
|
||||
|
||||
private :
|
||||
|
||||
static int
|
||||
static int calculateSegmentsStandard( double radius, double tolerance, int minSegments );
|
||||
%Docstring
|
||||
Calculate the number of segments needed to approximate a circle within a given tolerance.
|
||||
|
||||
@ -445,7 +437,6 @@ cos(θ/2) = 1 - tolerance/radius
|
||||
|
||||
This is a private helper method
|
||||
%End
|
||||
calculateSegmentsStandard( double radius, double tolerance, int minSegments );
|
||||
|
||||
static int calculateSegmentsAdaptive( double radius, double tolerance, int minSegments );
|
||||
%Docstring
|
||||
|
@ -3271,6 +3271,14 @@ The development version
|
||||
RenderOverviewAndExtents
|
||||
};
|
||||
|
||||
enum class SegmentCalculationMethod /BaseType=IntEnum/
|
||||
{
|
||||
Standard,
|
||||
Adaptive,
|
||||
AreaError,
|
||||
ConstantDensity
|
||||
};
|
||||
|
||||
static const double DEFAULT_SEARCH_RADIUS_MM;
|
||||
|
||||
static const float DEFAULT_MAPTOPIXEL_THRESHOLD;
|
||||
|
@ -11070,6 +11070,23 @@ Qgis.PointCloudZoomOutRenderBehavior.__doc__ = """Point cloud zoom out options
|
||||
"""
|
||||
# --
|
||||
Qgis.PointCloudZoomOutRenderBehavior.baseClass = Qgis
|
||||
# monkey patching scoped based enum
|
||||
Qgis.SegmentCalculationMethod.Standard.__doc__ = "Standard sagitta-based calculation"
|
||||
Qgis.SegmentCalculationMethod.Adaptive.__doc__ = "Adaptive calculation based on radius size"
|
||||
Qgis.SegmentCalculationMethod.AreaError.__doc__ = "Calculation based on area error"
|
||||
Qgis.SegmentCalculationMethod.ConstantDensity.__doc__ = "Simple calculation with constant segment density"
|
||||
Qgis.SegmentCalculationMethod.__doc__ = """brief Method used to calculate the number of segments for circle approximation
|
||||
|
||||
.. versionadded:: 3.44
|
||||
|
||||
* ``Standard``: Standard sagitta-based calculation
|
||||
* ``Adaptive``: Adaptive calculation based on radius size
|
||||
* ``AreaError``: Calculation based on area error
|
||||
* ``ConstantDensity``: Simple calculation with constant segment density
|
||||
|
||||
"""
|
||||
# --
|
||||
Qgis.SegmentCalculationMethod.baseClass = Qgis
|
||||
from enum import Enum
|
||||
|
||||
|
||||
|
@ -1,20 +1,4 @@
|
||||
# The following has been generated automatically from src/core/geometry/qgscircle.h
|
||||
# monkey patching scoped based enum
|
||||
QgsCircle.SegmentCalculationMethod.Standard.__doc__ = "Standard sagitta-based calculation"
|
||||
QgsCircle.SegmentCalculationMethod.Adaptive.__doc__ = "Adaptive calculation based on radius size"
|
||||
QgsCircle.SegmentCalculationMethod.AreaError.__doc__ = "Calculation based on area error"
|
||||
QgsCircle.SegmentCalculationMethod.ConstantDensity.__doc__ = "Simple calculation with constant segment density"
|
||||
QgsCircle.SegmentCalculationMethod.__doc__ = """Method used to calculate the number of segments for circle approximation
|
||||
|
||||
.. versionadded:: 3.44
|
||||
|
||||
* ``Standard``: Standard sagitta-based calculation
|
||||
* ``Adaptive``: Adaptive calculation based on radius size
|
||||
* ``AreaError``: Calculation based on area error
|
||||
* ``ConstantDensity``: Simple calculation with constant segment density
|
||||
|
||||
"""
|
||||
# --
|
||||
try:
|
||||
QgsCircle.from2Points = staticmethod(QgsCircle.from2Points)
|
||||
QgsCircle.from3Points = staticmethod(QgsCircle.from3Points)
|
||||
@ -25,6 +9,7 @@ try:
|
||||
QgsCircle.fromExtent = staticmethod(QgsCircle.fromExtent)
|
||||
QgsCircle.minimalCircleFrom3Points = staticmethod(QgsCircle.minimalCircleFrom3Points)
|
||||
QgsCircle.calculateSegments = staticmethod(QgsCircle.calculateSegments)
|
||||
QgsCircle.calculateSegmentsStandard = staticmethod(QgsCircle.calculateSegmentsStandard)
|
||||
QgsCircle.calculateSegmentsAdaptive = staticmethod(QgsCircle.calculateSegmentsAdaptive)
|
||||
QgsCircle.calculateSegmentsByAreaError = staticmethod(QgsCircle.calculateSegmentsByAreaError)
|
||||
QgsCircle.calculateSegmentsByConstant = staticmethod(QgsCircle.calculateSegmentsByConstant)
|
||||
|
@ -377,15 +377,7 @@ Coordinates are taken from quadrant North, East and South.
|
||||
.. seealso:: :py:func:`asGml2`
|
||||
%End
|
||||
|
||||
enum class SegmentCalculationMethod
|
||||
{
|
||||
Standard,
|
||||
Adaptive,
|
||||
AreaError,
|
||||
ConstantDensity
|
||||
};
|
||||
|
||||
static int calculateSegments( double radius, double parameter, int minSegments, SegmentCalculationMethod method );
|
||||
static int calculateSegments( double radius, double parameter, int minSegments, Qgis::SegmentCalculationMethod method );
|
||||
%Docstring
|
||||
Calculates the number of segments needed to approximate a circle.
|
||||
|
||||
@ -414,7 +406,7 @@ Calculates the number of segments needed to approximate a circle.
|
||||
|
||||
private :
|
||||
|
||||
static int
|
||||
static int calculateSegmentsStandard( double radius, double tolerance, int minSegments );
|
||||
%Docstring
|
||||
Calculate the number of segments needed to approximate a circle within a given tolerance.
|
||||
|
||||
@ -445,7 +437,6 @@ cos(θ/2) = 1 - tolerance/radius
|
||||
|
||||
This is a private helper method
|
||||
%End
|
||||
calculateSegmentsStandard( double radius, double tolerance, int minSegments );
|
||||
|
||||
static int calculateSegmentsAdaptive( double radius, double tolerance, int minSegments );
|
||||
%Docstring
|
||||
|
@ -3271,6 +3271,14 @@ The development version
|
||||
RenderOverviewAndExtents
|
||||
};
|
||||
|
||||
enum class SegmentCalculationMethod
|
||||
{
|
||||
Standard,
|
||||
Adaptive,
|
||||
AreaError,
|
||||
ConstantDensity
|
||||
};
|
||||
|
||||
static const double DEFAULT_SEARCH_RADIUS_MM;
|
||||
|
||||
static const float DEFAULT_MAPTOPIXEL_THRESHOLD;
|
||||
|
@ -485,7 +485,7 @@ QDomElement QgsCircle::asGml3( QDomDocument &doc, int precision, const QString &
|
||||
return elemCircle;
|
||||
}
|
||||
|
||||
int QgsCircle::calculateSegments( double radius, double parameter, int minSegments, SegmentCalculationMethod method )
|
||||
int QgsCircle::calculateSegments( double radius, double parameter, int minSegments, Qgis::SegmentCalculationMethod method )
|
||||
{
|
||||
if ( radius <= 0.0 )
|
||||
{
|
||||
@ -504,13 +504,13 @@ int QgsCircle::calculateSegments( double radius, double parameter, int minSegmen
|
||||
|
||||
switch ( method )
|
||||
{
|
||||
case SegmentCalculationMethod::Standard:
|
||||
case Qgis::SegmentCalculationMethod::Standard:
|
||||
return calculateSegmentsStandard( radius, parameter, minSegments );
|
||||
case SegmentCalculationMethod::Adaptive:
|
||||
case Qgis::SegmentCalculationMethod::Adaptive:
|
||||
return calculateSegmentsAdaptive( radius, parameter, minSegments );
|
||||
case SegmentCalculationMethod::AreaError:
|
||||
case Qgis::SegmentCalculationMethod::AreaError:
|
||||
return calculateSegmentsByAreaError( radius, parameter, minSegments );
|
||||
case SegmentCalculationMethod::ConstantDensity:
|
||||
case Qgis::SegmentCalculationMethod::ConstantDensity:
|
||||
return calculateSegmentsByConstant( radius, parameter, minSegments );
|
||||
default:
|
||||
return calculateSegmentsStandard( radius, parameter, minSegments );
|
||||
|
@ -356,19 +356,6 @@ class CORE_EXPORT QgsCircle : public QgsEllipse
|
||||
*/
|
||||
QDomElement asGml3( QDomDocument &doc, int precision = 17, const QString &ns = "gml", QgsAbstractGeometry::AxisOrder axisOrder = QgsAbstractGeometry::AxisOrder::XY ) const;
|
||||
|
||||
/**
|
||||
* \brief Method used to calculate the number of segments for circle approximation
|
||||
* \ingroup core
|
||||
* \since QGIS 3.44
|
||||
*/
|
||||
enum class SegmentCalculationMethod
|
||||
{
|
||||
Standard = 0, //!< Standard sagitta-based calculation
|
||||
Adaptive, //!< Adaptive calculation based on radius size
|
||||
AreaError, //!< Calculation based on area error
|
||||
ConstantDensity //!< Simple calculation with constant segment density
|
||||
};
|
||||
|
||||
/**
|
||||
* Calculates the number of segments needed to approximate a circle.
|
||||
*
|
||||
@ -385,7 +372,7 @@ class CORE_EXPORT QgsCircle : public QgsEllipse
|
||||
*
|
||||
* \since QGIS 3.44
|
||||
*/
|
||||
static int calculateSegments( double radius, double parameter, int minSegments, SegmentCalculationMethod method );
|
||||
static int calculateSegments( double radius, double parameter, int minSegments, Qgis::SegmentCalculationMethod method );
|
||||
|
||||
|
||||
#ifdef SIP_RUN
|
||||
@ -425,8 +412,7 @@ class CORE_EXPORT QgsCircle : public QgsEllipse
|
||||
* \returns The number of segments needed
|
||||
* \note This is a private helper method
|
||||
*/
|
||||
static int
|
||||
calculateSegmentsStandard( double radius, double tolerance, int minSegments )
|
||||
static int calculateSegmentsStandard( double radius, double tolerance, int minSegments )
|
||||
{
|
||||
if ( tolerance >= radius )
|
||||
{
|
||||
|
@ -5766,6 +5766,19 @@ class CORE_EXPORT Qgis
|
||||
};
|
||||
Q_ENUM( PointCloudZoomOutRenderBehavior )
|
||||
|
||||
/**
|
||||
* brief Method used to calculate the number of segments for circle approximation
|
||||
* \since QGIS 3.44
|
||||
*/
|
||||
enum class SegmentCalculationMethod : int
|
||||
{
|
||||
Standard = 0, //!< Standard sagitta-based calculation
|
||||
Adaptive, //!< Adaptive calculation based on radius size
|
||||
AreaError, //!< Calculation based on area error
|
||||
ConstantDensity //!< Simple calculation with constant segment density
|
||||
};
|
||||
Q_ENUM( SegmentCalculationMethod )
|
||||
|
||||
/**
|
||||
* Identify search radius in mm
|
||||
*/
|
||||
|
@ -12,7 +12,7 @@ __copyright__ = "Copyright 2025, The QGIS Project"
|
||||
|
||||
import qgis # NOQA
|
||||
|
||||
from qgis.core import QgsCircle, QgsPoint
|
||||
from qgis.core import Qgis, QgsCircle, QgsPoint
|
||||
import unittest
|
||||
from qgis.testing import start_app, QgisTestCase
|
||||
|
||||
@ -55,25 +55,25 @@ class TestQgsCircularString(QgisTestCase):
|
||||
radius,
|
||||
tolerance,
|
||||
min_segments,
|
||||
QgsCircle.SegmentCalculationMethod.Standard,
|
||||
Qgis.SegmentCalculationMethod.Standard,
|
||||
)
|
||||
adaptive_segments = circle.calculateSegments(
|
||||
radius,
|
||||
tolerance,
|
||||
min_segments,
|
||||
QgsCircle.SegmentCalculationMethod.Adaptive,
|
||||
Qgis.SegmentCalculationMethod.Adaptive,
|
||||
)
|
||||
area_segments = circle.calculateSegments(
|
||||
radius,
|
||||
tolerance,
|
||||
min_segments,
|
||||
QgsCircle.SegmentCalculationMethod.AreaError,
|
||||
Qgis.SegmentCalculationMethod.AreaError,
|
||||
)
|
||||
constant_segments = circle.calculateSegments(
|
||||
radius,
|
||||
constant,
|
||||
min_segments,
|
||||
QgsCircle.SegmentCalculationMethod.ConstantDensity,
|
||||
Qgis.SegmentCalculationMethod.ConstantDensity,
|
||||
)
|
||||
|
||||
# Store current results
|
||||
|
Loading…
x
Reference in New Issue
Block a user