Merge pull request #2047 from elemoine/snaptopixel

Set snapToPixel to true by default
This commit is contained in:
Éric Lemoine
2014-05-07 23:02:09 +02:00
7 changed files with 52 additions and 23 deletions

View File

@@ -886,13 +886,8 @@ ol.render.canvas.Immediate.prototype.setImageStyle = function(imageStyle) {
var imageAnchor = imageStyle.getAnchor();
// FIXME pixel ratio
var imageImage = imageStyle.getImage(1);
var imageOpacity = imageStyle.getOpacity();
var imageOrigin = imageStyle.getOrigin();
var imageRotateWithView = imageStyle.getRotateWithView();
var imageRotation = imageStyle.getRotation();
var imageScale = imageStyle.getScale();
var imageSize = imageStyle.getSize();
var imageSnapToPixel = imageStyle.getSnapToPixel();
goog.asserts.assert(!goog.isNull(imageAnchor));
goog.asserts.assert(!goog.isNull(imageImage));
goog.asserts.assert(!goog.isNull(imageOrigin));
@@ -901,15 +896,13 @@ ol.render.canvas.Immediate.prototype.setImageStyle = function(imageStyle) {
this.imageAnchorY_ = imageAnchor[1];
this.imageHeight_ = imageSize[1];
this.image_ = imageImage;
this.imageOpacity_ = goog.isDef(imageOpacity) ? imageOpacity : 1;
this.imageOpacity_ = imageStyle.getOpacity();
this.imageOriginX_ = imageOrigin[0];
this.imageOriginY_ = imageOrigin[1];
this.imageRotateWithView_ = goog.isDef(imageRotateWithView) ?
imageRotateWithView : false;
this.imageRotation_ = goog.isDef(imageRotation) ? imageRotation : 0;
this.imageScale_ = goog.isDef(imageScale) ? imageScale : 1;
this.imageSnapToPixel_ = goog.isDef(imageSnapToPixel) ?
imageSnapToPixel : false;
this.imageRotateWithView_ = imageStyle.getRotateWithView();
this.imageRotation_ = imageStyle.getRotation();
this.imageScale_ = imageStyle.getScale();
this.imageSnapToPixel_ = imageStyle.getSnapToPixel();
this.imageWidth_ = imageSize[0];
}
};

View File

@@ -1,4 +1,3 @@
// FIXME decide default snapToPixel behaviour
// FIXME add option to apply snapToPixel to all coordinates?
// FIXME can eliminate empty set styles and strokes (when all geoms skipped)
@@ -291,7 +290,7 @@ ol.render.canvas.Replay.prototype.replay_ = function(
var rotateWithView = /** @type {boolean} */ (instruction[10]);
var rotation = /** @type {number} */ (instruction[11]);
var scale = /** @type {number} */ (instruction[12]);
var snapToPixel = /** @type {boolean|undefined} */ (instruction[13]);
var snapToPixel = /** @type {boolean} */ (instruction[13]);
var width = /** @type {number} */ (instruction[14]) * pixelRatio;
if (rotateWithView) {
rotation += viewRotation;

View File

@@ -1,5 +1,3 @@
// FIXME decide default value for snapToPixel
goog.provide('ol.style.Circle');
goog.require('goog.dom');
@@ -68,13 +66,19 @@ ol.style.Circle = function(opt_options) {
*/
this.size_ = [size, size];
/**
* @type {boolean}
*/
var snapToPixel = goog.isDef(options.snapToPixel) ?
options.snapToPixel : true;
goog.base(this, {
opacity: 1,
origin: [0, 0],
rotateWithView: false,
rotation: 0,
scale: 1,
snapToPixel: undefined
snapToPixel: snapToPixel
});
};

View File

@@ -1,5 +1,3 @@
// FIXME decide default value for snapToPixel
goog.provide('ol.style.Icon');
goog.provide('ol.style.IconAnchorOrigin');
goog.provide('ol.style.IconAnchorUnits');
@@ -124,12 +122,18 @@ ol.style.Icon = function(opt_options) {
*/
var scale = goog.isDef(options.scale) ? options.scale : 1;
/**
* @type {boolean}
*/
var snapToPixel = goog.isDef(options.snapToPixel) ?
options.snapToPixel : true;
goog.base(this, {
opacity: opacity,
origin: origin,
rotation: rotation,
scale: scale,
snapToPixel: undefined,
snapToPixel: snapToPixel,
rotateWithView: rotateWithView
});

View File

@@ -21,7 +21,7 @@ ol.style.ImageState = {
* rotateWithView: boolean,
* rotation: number,
* scale: number,
* snapToPixel: (boolean|undefined)}}
* snapToPixel: boolean}}
*/
ol.style.ImageOptions;
@@ -66,7 +66,7 @@ ol.style.Image = function(options) {
/**
* @private
* @type {boolean|undefined}
* @type {boolean}
*/
this.snapToPixel_ = options.snapToPixel;
@@ -116,7 +116,7 @@ ol.style.Image.prototype.getScale = function() {
/**
* @return {boolean|undefined} Snap to pixel?
* @return {boolean} Snap to pixel?
*/
ol.style.Image.prototype.getSnapToPixel = function() {
return this.snapToPixel_;