QGIS API Documentation 3.32.0-Lima (311a8cb8a6)
qgscoordinateformatter.h
Go to the documentation of this file.
1/***************************************************************************
2 qgscoordinateformatter.h
3 ------------------------
4 begin : Decemeber 2015
5 copyright : (C) 2015 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 QGSCOORDINATEFORMATTER_H
19#define QGSCOORDINATEFORMATTER_H
20
21#include <QString>
22#include "qgis_sip.h"
23#include "qgspointxy.h"
24
40class CORE_EXPORT QgsCoordinateFormatter
41{
42 public:
43
47 enum Format
48 {
53 };
54
59 {
60 FlagDegreesUseStringSuffix = 1 << 1,
61 FlagDegreesPadMinutesSeconds = 1 << 2,
62 };
63 Q_DECLARE_FLAGS( FormatFlags, FormatFlag )
64
65
76 static QString formatX( double x, Format format, int precision = 12, FormatFlags flags = FlagDegreesUseStringSuffix );
77
89 static QString formatY( double y, Format format, int precision = 12, FormatFlags flags = FlagDegreesUseStringSuffix );
90
102 static QString format( const QgsPointXY &point, Format format, int precision = 12, FormatFlags flags = FlagDegreesUseStringSuffix, Qgis::CoordinateOrder order = Qgis::CoordinateOrder::XY );
103
110 static QString asPair( double x, double y, int precision = 12, Qgis::CoordinateOrder order = Qgis::CoordinateOrder::XY );
111
117 static QChar separator( );
118
119 private:
120
121 static QString formatAsPair( double val, int precision );
122
123 static QString formatXAsDegreesMinutesSeconds( double val, int precision, FormatFlags flags );
124 static QString formatYAsDegreesMinutesSeconds( double val, int precision, FormatFlags flags );
125
126 static QString formatXAsDegreesMinutes( double val, int precision, FormatFlags flags );
127 static QString formatYAsDegreesMinutes( double val, int precision, FormatFlags flags );
128
129 static QString formatXAsDegrees( double val, int precision, FormatFlags flags );
130 static QString formatYAsDegrees( double val, int precision, FormatFlags flags );
131
132 friend class QgsCoordinateUtils;
133};
134
135Q_DECLARE_OPERATORS_FOR_FLAGS( QgsCoordinateFormatter::FormatFlags )
136
137#endif // QGSCOORDINATEFORMATTER_H
CoordinateOrder
Order of coordinates.
Definition: qgis.h:1636
@ XY
Easting/Northing (or Longitude/Latitude for geographic CRS)
Contains methods for converting coordinates for display in various formats.
Format
Available formats for displaying coordinates.
@ FormatDecimalDegrees
Decimal degrees, eg 30.7555 degrees.
@ FormatPair
Formats coordinates as an "x,y" pair.
@ FormatDegreesMinutes
Degrees and decimal minutes, eg 30degrees 45.55'.
@ FormatDegreesMinutesSeconds
Degrees, minutes and seconds, eg 30 degrees 45'30".
FormatFlag
Flags for controlling formatting of coordinates.
A class to represent a 2D point.
Definition: qgspointxy.h:59
Q_DECLARE_OPERATORS_FOR_FLAGS(QgsField::ConfigurationFlags) CORE_EXPORT QDataStream &operator<<(QDataStream &out
Writes the field to stream out. QGIS version compatibility is not guaranteed.
int precision