Rename _ol_style_IconAnchorUnits_ to IconAnchorUnits

This commit is contained in:
Frederic Junod
2017-12-18 10:58:16 +01:00
parent e4446d4cb3
commit bbd8a3f6ae
3 changed files with 22 additions and 24 deletions

View File

@@ -22,7 +22,7 @@ import _ol_math_ from '../math.js';
import {get as getProjection} from '../proj.js';
import _ol_style_Fill_ from '../style/Fill.js';
import _ol_style_Icon_ from '../style/Icon.js';
import _ol_style_IconAnchorUnits_ from '../style/IconAnchorUnits.js';
import IconAnchorUnits from '../style/IconAnchorUnits.js';
import IconOrigin from '../style/IconOrigin.js';
import _ol_style_Stroke_ from '../style/Stroke.js';
import _ol_style_Style_ from '../style/Style.js';
@@ -161,16 +161,14 @@ KML.createStyleDefaults_ = function() {
* @type {ol.style.IconAnchorUnits}
* @private
*/
KML.DEFAULT_IMAGE_STYLE_ANCHOR_X_UNITS_ =
_ol_style_IconAnchorUnits_.PIXELS;
KML.DEFAULT_IMAGE_STYLE_ANCHOR_X_UNITS_ = IconAnchorUnits.PIXELS;
/**
* @const
* @type {ol.style.IconAnchorUnits}
* @private
*/
KML.DEFAULT_IMAGE_STYLE_ANCHOR_Y_UNITS_ =
_ol_style_IconAnchorUnits_.PIXELS;
KML.DEFAULT_IMAGE_STYLE_ANCHOR_Y_UNITS_ = IconAnchorUnits.PIXELS;
/**
* @const
@@ -280,9 +278,9 @@ KML.createStyleDefaults_ = function() {
* @private
*/
KML.ICON_ANCHOR_UNITS_MAP_ = {
'fraction': _ol_style_IconAnchorUnits_.FRACTION,
'pixels': _ol_style_IconAnchorUnits_.PIXELS,
'insetPixels': _ol_style_IconAnchorUnits_.PIXELS
'fraction': IconAnchorUnits.FRACTION,
'pixels': IconAnchorUnits.PIXELS,
'insetPixels': IconAnchorUnits.PIXELS
};
@@ -593,8 +591,8 @@ KML.IconStyleParser_ = function(node, objectStack) {
anchorYUnits = KML.DEFAULT_IMAGE_STYLE_ANCHOR_Y_UNITS_;
} else if (/^http:\/\/maps\.(?:google|gstatic)\.com\//.test(src)) {
anchor = [0.5, 0];
anchorXUnits = _ol_style_IconAnchorUnits_.FRACTION;
anchorYUnits = _ol_style_IconAnchorUnits_.FRACTION;
anchorXUnits = IconAnchorUnits.FRACTION;
anchorYUnits = IconAnchorUnits.FRACTION;
}
var offset;
@@ -2279,9 +2277,9 @@ KML.writeIconStyle_ = function(node, style, objectStack) {
if (anchor && (anchor[0] !== size[0] / 2 || anchor[1] !== size[1] / 2)) {
var /** @type {ol.KMLVec2_} */ hotSpot = {
x: anchor[0],
xunits: _ol_style_IconAnchorUnits_.PIXELS,
xunits: IconAnchorUnits.PIXELS,
y: size[1] - anchor[1],
yunits: _ol_style_IconAnchorUnits_.PIXELS
yunits: IconAnchorUnits.PIXELS
};
properties['hotSpot'] = hotSpot;
}

View File

@@ -7,7 +7,7 @@ import {assert} from '../asserts.js';
import _ol_color_ from '../color.js';
import _ol_events_ from '../events.js';
import EventType from '../events/EventType.js';
import _ol_style_IconAnchorUnits_ from '../style/IconAnchorUnits.js';
import IconAnchorUnits from '../style/IconAnchorUnits.js';
import _ol_style_IconImage_ from '../style/IconImage.js';
import IconOrigin from '../style/IconOrigin.js';
import _ol_style_Image_ from '../style/Image.js';
@@ -49,14 +49,14 @@ var _ol_style_Icon_ = function(opt_options) {
* @type {ol.style.IconAnchorUnits}
*/
this.anchorXUnits_ = options.anchorXUnits !== undefined ?
options.anchorXUnits : _ol_style_IconAnchorUnits_.FRACTION;
options.anchorXUnits : IconAnchorUnits.FRACTION;
/**
* @private
* @type {ol.style.IconAnchorUnits}
*/
this.anchorYUnits_ = options.anchorYUnits !== undefined ?
options.anchorYUnits : _ol_style_IconAnchorUnits_.FRACTION;
options.anchorYUnits : IconAnchorUnits.FRACTION;
/**
* @private
@@ -212,16 +212,16 @@ _ol_style_Icon_.prototype.getAnchor = function() {
}
var anchor = this.anchor_;
var size = this.getSize();
if (this.anchorXUnits_ == _ol_style_IconAnchorUnits_.FRACTION ||
this.anchorYUnits_ == _ol_style_IconAnchorUnits_.FRACTION) {
if (this.anchorXUnits_ == IconAnchorUnits.FRACTION ||
this.anchorYUnits_ == IconAnchorUnits.FRACTION) {
if (!size) {
return null;
}
anchor = this.anchor_.slice();
if (this.anchorXUnits_ == _ol_style_IconAnchorUnits_.FRACTION) {
if (this.anchorXUnits_ == IconAnchorUnits.FRACTION) {
anchor[0] *= size[0];
}
if (this.anchorYUnits_ == _ol_style_IconAnchorUnits_.FRACTION) {
if (this.anchorYUnits_ == IconAnchorUnits.FRACTION) {
anchor[1] *= size[1];
}
}

View File

@@ -16,7 +16,7 @@ import {remove as removeTransform} from '../../../../src/ol/proj/transforms.js';
import _ol_style_Circle_ from '../../../../src/ol/style/Circle.js';
import _ol_style_Fill_ from '../../../../src/ol/style/Fill.js';
import _ol_style_Icon_ from '../../../../src/ol/style/Icon.js';
import _ol_style_IconAnchorUnits_ from '../../../../src/ol/style/IconAnchorUnits.js';
import IconAnchorUnits from '../../../../src/ol/style/IconAnchorUnits.js';
import IconOrigin from '../../../../src/ol/style/IconOrigin.js';
import _ol_style_Stroke_ from '../../../../src/ol/style/Stroke.js';
import _ol_style_Style_ from '../../../../src/ol/style/Style.js';
@@ -1844,13 +1844,13 @@ describe('ol.format.KML', function() {
expect(imageStyle.anchor_[0]).to.be(0.5);
expect(imageStyle.anchor_[1]).to.be(0.5);
expect(imageStyle.anchorOrigin_).to.be(IconOrigin.BOTTOM_LEFT);
expect(imageStyle.anchorXUnits_).to.be(_ol_style_IconAnchorUnits_.FRACTION);
expect(imageStyle.anchorYUnits_).to.be(_ol_style_IconAnchorUnits_.FRACTION);
expect(imageStyle.anchorXUnits_).to.be(IconAnchorUnits.FRACTION);
expect(imageStyle.anchorYUnits_).to.be(IconAnchorUnits.FRACTION);
} else {
expect(imageStyle.anchor_[0]).to.be(5);
expect(imageStyle.anchor_[1]).to.be(5);
expect(imageStyle.anchorXUnits_).to.be(_ol_style_IconAnchorUnits_.PIXELS);
expect(imageStyle.anchorYUnits_).to.be(_ol_style_IconAnchorUnits_.PIXELS);
expect(imageStyle.anchorXUnits_).to.be(IconAnchorUnits.PIXELS);
expect(imageStyle.anchorYUnits_).to.be(IconAnchorUnits.PIXELS);
if (f.getId() == 2) {
expect(imageStyle.anchorOrigin_).to.be(IconOrigin.BOTTOM_LEFT);
}