QGIS API Documentation  3.6.0-Noosa (5873452)
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 
40 class 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 
100  static QString format( const QgsPointXY &point, Format format, int precision = 12, FormatFlags flags = FlagDegreesUseStringSuffix );
101 
106  static QString asPair( double x, double y, int precision = 12 );
107 
108  private:
109 
110  static QString formatAsPair( double val, int precision );
111 
112  static QString formatXAsDegreesMinutesSeconds( double val, int precision, FormatFlags flags );
113  static QString formatYAsDegreesMinutesSeconds( double val, int precision, FormatFlags flags );
114 
115  static QString formatXAsDegreesMinutes( double val, int precision, FormatFlags flags );
116  static QString formatYAsDegreesMinutes( double val, int precision, FormatFlags flags );
117 
118  static QString formatXAsDegrees( double val, int precision, FormatFlags flags );
119  static QString formatYAsDegrees( double val, int precision, FormatFlags flags );
120 };
121 
122 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsCoordinateFormatter::FormatFlags )
123 
124 #endif // QGSCOORDINATEFORMATTER_H
int precision
Decimal degrees, eg 30.7555 degrees.
Formats coordinates as an "x,y" pair.
A class to represent a 2D point.
Definition: qgspointxy.h:43
Format
Available formats for displaying coordinates.
Contains methods for converting coordinates for display in various formats.
Degrees and decimal minutes, eg 30degrees 45.55&#39;.
FormatFlag
Flags for controlling formatting of coordinates.
Degrees, minutes and seconds, eg 30 degrees 45&#39;30".