Skip to content

Commit

Permalink
Snap center to pixel to avoid floating point issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ahocevar committed Jul 28, 2015
1 parent 5e4474c commit 5e505f2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/ol/view.js
Expand Up @@ -400,7 +400,11 @@ ol.View.prototype.getState = function() {
var resolution = /** @type {number} */ (this.getResolution());
var rotation = this.getRotation();
return /** @type {olx.ViewState} */ ({
center: center.slice(),
// Snap center to closest pixel
center: [
Math.round(center[0] / resolution) * resolution,
Math.round(center[1] / resolution) * resolution
],
projection: goog.isDef(projection) ? projection : null,
resolution: resolution,
rotation: rotation
Expand Down
Binary file modified test_rendering/spec/ol/layer/expected/image-webgl.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 5e505f2

Please sign in to comment.