QGIS API Documentation 3.36.0-Maidenhead (09951dc0acf)
Loading...
Searching...
No Matches
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
39class CORE_EXPORT QgsCoordinateFormatter
40{
41 public:
42
53
58 {
59 FlagDegreesUseStringSuffix = 1 << 1,
60 FlagDegreesPadMinutesSeconds = 1 << 2,
61 };
62 Q_DECLARE_FLAGS( FormatFlags, FormatFlag )
63
64
75 static QString formatX( double x, Format format, int precision = 12, FormatFlags flags = FlagDegreesUseStringSuffix );
76
88 static QString formatY( double y, Format format, int precision = 12, FormatFlags flags = FlagDegreesUseStringSuffix );
89
101 static QString format( const QgsPointXY &point, Format format, int precision = 12, FormatFlags flags = FlagDegreesUseStringSuffix, Qgis::CoordinateOrder order = Qgis::CoordinateOrder::XY );
102
109 static QString asPair( double x, double y, int precision = 12, Qgis::CoordinateOrder order = Qgis::CoordinateOrder::XY );
110
116 static QChar separator( );
117
118 private:
119
120 static QString formatAsPair( double val, int precision );
121
122 static QString formatXAsDegreesMinutesSeconds( double val, int precision, FormatFlags flags );
123 static QString formatYAsDegreesMinutesSeconds( double val, int precision, FormatFlags flags );
124
125 static QString formatXAsDegreesMinutes( double val, int precision, FormatFlags flags );
126 static QString formatYAsDegreesMinutes( double val, int precision, FormatFlags flags );
127
128 static QString formatXAsDegrees( double val, int precision, FormatFlags flags );
129 static QString formatYAsDegrees( double val, int precision, FormatFlags flags );
130
131 friend class QgsCoordinateUtils;
132};
133
134Q_DECLARE_OPERATORS_FOR_FLAGS( QgsCoordinateFormatter::FormatFlags )
135
136#endif // QGSCOORDINATEFORMATTER_H
CoordinateOrder
Order of coordinates.
Definition qgis.h:1919
@ 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:60
#define SIP_ENUM_BASETYPE(type)
Definition qgis_sip.h:278
Q_DECLARE_OPERATORS_FOR_FLAGS(QgsTextRendererUtils::CurvedTextFlags)
int precision