21
21
#define SIP_NO_FILE
22
22
23
23
#include < QString>
24
+ #include < QObject>
24
25
25
26
#include " qgis_core.h"
26
27
@@ -39,27 +40,32 @@ class QgsProject;
39
40
*/
40
41
class CORE_EXPORT QgsCoordinateUtils
41
42
{
43
+ Q_GADGET
44
+
42
45
public:
43
46
44
47
/* *
45
- * Returns the precision to use for displaying coordinates to the user, respecting
46
- * the user's project settings. If the user has set the project to use "automatic"
47
- * precision, this function tries to calculate an optimal coordinate precision for a given
48
- * map units per pixel by calculating the number of decimal places for the coordinates
49
- * with the aim of always having enough decimal places to show the difference in position
50
- * between adjacent pixels.
51
- * \param mapUnitsPerPixel number of map units per pixel
52
- * \param mapCrs CRS of map
53
- * \returns optimal number of decimal places for coordinates
48
+ * Returns the precision to use for displaying coordinates in \a mapCrs to the user.
49
+ * It respects the user's \a project settings.
50
+ * If the user has set the project to use "automatic" precision, this function tries
51
+ * to calculate an optimal coordinate precision for a given \a mapUnitsPerPixel by
52
+ * calculating the number of decimal places for the coordinates with the aim of always
53
+ * having enough decimal places to show the difference in position between adjacent
54
+ * pixels.
55
+ *
56
+ * \note Since QGIS 3.6 a new \a project parameter is available. Using the method without this
57
+ * a \a project parameter is deprecated and will be removed with QGIS 4.
58
+ * For backward compatibility, QgsProject.instance() will be used if the \a project
59
+ * parameter is not specified.
54
60
*/
55
- static int calculateCoordinatePrecision ( double mapUnitsPerPixel, const QgsCoordinateReferenceSystem &mapCrs );
61
+ Q_INVOKABLE static int calculateCoordinatePrecision ( double mapUnitsPerPixel, const QgsCoordinateReferenceSystem &mapCrs, QgsProject *project = nullptr );
56
62
57
63
/* *
58
64
* Formats a \a point coordinate for use with the specified \a project, respecting the project's
59
65
* coordinate display settings.
60
66
* \since QGIS 3.2
61
67
*/
62
- static QString formatCoordinateForProject ( QgsProject *project, const QgsPointXY &point, const QgsCoordinateReferenceSystem &destCrs, int precision );
68
+ Q_INVOKABLE static QString formatCoordinateForProject ( QgsProject *project, const QgsPointXY &point, const QgsCoordinateReferenceSystem &destCrs, int precision );
63
69
64
70
};
65
71
0 commit comments