QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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 
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 
133 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsCoordinateFormatter::FormatFlags )
134 
135 #endif // QGSCOORDINATEFORMATTER_H
QgsCoordinateFormatter::FormatDecimalDegrees
@ FormatDecimalDegrees
Decimal degrees, eg 30.7555 degrees.
Definition: qgscoordinateformatter.h:52
QgsCoordinateFormatter
Contains methods for converting coordinates for display in various formats.
Definition: qgscoordinateformatter.h:40
QgsCoordinateFormatter::FormatDegreesMinutes
@ FormatDegreesMinutes
Degrees and decimal minutes, eg 30degrees 45.55'.
Definition: qgscoordinateformatter.h:51
precision
int precision
Definition: qgswfsgetfeature.cpp:103
QgsCoordinateFormatter::FormatFlag
FormatFlag
Flags for controlling formatting of coordinates.
Definition: qgscoordinateformatter.h:58
qgis_sip.h
Q_DECLARE_OPERATORS_FOR_FLAGS
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.
Qgis::CoordinateOrder::XY
@ XY
Easting/Northing (or Longitude/Latitude for geographic CRS)
QgsPointXY
A class to represent a 2D point.
Definition: qgspointxy.h:58
QgsCoordinateFormatter::FormatPair
@ FormatPair
Formats coordinates as an "x,y" pair.
Definition: qgscoordinateformatter.h:49
QgsCoordinateFormatter::FormatDegreesMinutesSeconds
@ FormatDegreesMinutesSeconds
Degrees, minutes and seconds, eg 30 degrees 45'30".
Definition: qgscoordinateformatter.h:50
QgsCoordinateFormatter::Format
Format
Available formats for displaying coordinates.
Definition: qgscoordinateformatter.h:47
Qgis::CoordinateOrder
CoordinateOrder
Order of coordinates.
Definition: qgis.h:1101
qgspointxy.h