Skip to content

Commit

Permalink
use float precision for screen coordinates
Browse files Browse the repository at this point in the history
this should fix rounding error when the map canvas has an odd pixel size
  • Loading branch information
3nids committed Sep 29, 2018
1 parent 1a61885 commit 110c8a0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/quickgui/qgsquickmapsettings.cpp
Expand Up @@ -118,7 +118,10 @@ QPointF QgsQuickMapSettings::coordinateToScreen( const QgsPoint &point ) const

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

Expand Down

0 comments on commit 110c8a0

Please sign in to comment.