Skip to content

Commit

Permalink
Fix incorrect display of coordinates in status bar
Browse files Browse the repository at this point in the history
(cherry-picked from 66c8a85)
  • Loading branch information
nyalldawson committed Mar 22, 2018
1 parent bffc699 commit 4a5801b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/core/qgscoordinateformatter.cpp
Expand Up @@ -61,7 +61,7 @@ QString QgsCoordinateFormatter::formatY( double y, QgsCoordinateFormatter::Forma
QString QgsCoordinateFormatter::format( const QgsPointXY &point, QgsCoordinateFormatter::Format format, int precision, FormatFlags flags )
{
return QStringLiteral( "%1,%2" ).arg( formatX( point.x(), format, precision, flags ),
formatY( point.x(), format, precision, flags ) );
formatY( point.y(), format, precision, flags ) );
}

QString QgsCoordinateFormatter::asPair( double x, double y, int precision )
Expand Down
7 changes: 6 additions & 1 deletion tests/src/python/test_qgscoordinateformatter.py
Expand Up @@ -14,7 +14,7 @@

import qgis
from qgis.testing import unittest
from qgis.core import QgsCoordinateFormatter
from qgis.core import QgsCoordinateFormatter, QgsPointXY


class TestQgsCoordinateFormatter(unittest.TestCase):
Expand Down Expand Up @@ -48,6 +48,11 @@ def testAsPair(self):
self.assertEqual(QgsCoordinateFormatter.asPair(20, 10, 2), '20.00,10.00')
self.assertEqual(QgsCoordinateFormatter.asPair(20, -10, 2), '20.00,-10.00')

def testFormat(self):
self.assertEqual(QgsCoordinateFormatter.format(QgsPointXY(20.1, 30.2), QgsCoordinateFormatter.FormatPair, 0), '20,30')
self.assertEqual(QgsCoordinateFormatter.format(QgsPointXY(20.1, 30.2), QgsCoordinateFormatter.FormatPair, 1), '20.1,30.2')
self.assertEqual(QgsCoordinateFormatter.format(QgsPointXY(20, 30), QgsCoordinateFormatter.FormatDegreesMinutesSeconds, 0), '20°0′0″E,30°0′0″N')

def testFormatXFormatDegreesMinutesSeconds(self):
"""Test formatting x as DMS"""

Expand Down

0 comments on commit 4a5801b

Please sign in to comment.