Skip to content

Commit 110c8a0

Browse files
committedSep 29, 2018
use float precision for screen coordinates
this should fix rounding error when the map canvas has an odd pixel size
1 parent 1a61885 commit 110c8a0

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed
 

‎src/quickgui/qgsquickmapsettings.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,10 @@ QPointF QgsQuickMapSettings::coordinateToScreen( const QgsPoint &point ) const
118118

119119
QgsPoint QgsQuickMapSettings::screenToCoordinate( const QPointF &point ) const
120120
{
121-
const QgsPointXY pp = mMapSettings.mapToPixel().toMapCoordinates( point.toPoint() );
121+
// use floating point precision with mapToCoordinatesF
122+
// this is to avoid rounding errors with an odd screen width or height
123+
// and the point being set to the exact center of it
124+
const QgsPointXY pp = mMapSettings.mapToPixel().toMapCoordinatesF( point.x(), point.y() );
122125
return QgsPoint( pp );
123126
}
124127

0 commit comments

Comments
 (0)
Please sign in to comment.