Skip to content
Permalink
Browse files

Fix incorrect display of coordinates in status bar

(cherry-picked from 66c8a85)
  • Loading branch information
nyalldawson committed Mar 21, 2018
1 parent bffc699 commit 4a5801b2436a6c87c1c3df3b274fdcd1319fa47a
Showing with 7 additions and 2 deletions.
  1. +1 −1 src/core/qgscoordinateformatter.cpp
  2. +6 −1 tests/src/python/test_qgscoordinateformatter.py
@@ -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 )
@@ -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):
@@ -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"""

0 comments on commit 4a5801b

Please sign in to comment.
You can’t perform that action at this time.