Separate literals from symbolizers

This commit is contained in:
Tim Schaub
2013-08-12 13:43:19 -04:00
parent 90fb37c220
commit 36bcd26305
24 changed files with 716 additions and 677 deletions

View File

@@ -0,0 +1,53 @@
goog.provide('ol.style.IconLiteral');
goog.provide('ol.style.IconType');
goog.require('ol.style.PointLiteral');
/**
* @typedef {{url: (string),
* width: (number|undefined),
* height: (number|undefined),
* opacity: (number),
* rotation: (number)}}
*/
ol.style.IconLiteralOptions;
/**
* @constructor
* @extends {ol.style.PointLiteral}
* @param {ol.style.IconLiteralOptions} options Icon literal options.
*/
ol.style.IconLiteral = function(options) {
/** @type {string} */
this.url = options.url;
/** @type {number|undefined} */
this.width = options.width;
/** @type {number|undefined} */
this.height = options.height;
/** @type {number} */
this.opacity = options.opacity;
/** @type {number} */
this.rotation = options.rotation;
};
goog.inherits(ol.style.IconLiteral, ol.style.PointLiteral);
/**
* @inheritDoc
*/
ol.style.IconLiteral.prototype.equals = function(iconLiteral) {
return this.url == iconLiteral.url &&
this.width == iconLiteral.width &&
this.height == iconLiteral.height &&
this.opacity == iconLiteral.opacity &&
this.rotation == iconLiteral.rotation;
};

View File

@@ -1,64 +1,15 @@
goog.provide('ol.style.Icon');
goog.provide('ol.style.IconLiteral');
goog.provide('ol.style.IconType');
goog.require('goog.asserts');
goog.require('ol.expr');
goog.require('ol.expr.Expression');
goog.require('ol.expr.Literal');
goog.require('ol.style.IconLiteral');
goog.require('ol.style.IconType');
goog.require('ol.style.Point');
goog.require('ol.style.PointLiteral');
/**
* @typedef {{url: (string),
* width: (number|undefined),
* height: (number|undefined),
* opacity: (number),
* rotation: (number)}}
*/
ol.style.IconLiteralOptions;
/**
* @constructor
* @extends {ol.style.PointLiteral}
* @param {ol.style.IconLiteralOptions} options Icon literal options.
*/
ol.style.IconLiteral = function(options) {
/** @type {string} */
this.url = options.url;
/** @type {number|undefined} */
this.width = options.width;
/** @type {number|undefined} */
this.height = options.height;
/** @type {number} */
this.opacity = options.opacity;
/** @type {number} */
this.rotation = options.rotation;
};
goog.inherits(ol.style.IconLiteral, ol.style.PointLiteral);
/**
* @inheritDoc
*/
ol.style.IconLiteral.prototype.equals = function(iconLiteral) {
return this.url == iconLiteral.url &&
this.width == iconLiteral.width &&
this.height == iconLiteral.height &&
this.opacity == iconLiteral.opacity &&
this.rotation == iconLiteral.rotation;
};
/**
* @constructor

View File

@@ -0,0 +1,50 @@
goog.provide('ol.style.LineLiteral');
goog.require('goog.asserts');
goog.require('ol.style.Literal');
/**
* @typedef {{strokeColor: (string),
* strokeOpacity: (number),
* strokeWidth: (number)}}
*/
ol.style.LineLiteralOptions;
/**
* @constructor
* @extends {ol.style.Literal}
* @param {ol.style.LineLiteralOptions} options Line literal options.
*/
ol.style.LineLiteral = function(options) {
goog.base(this);
goog.asserts.assertString(
options.strokeColor, 'strokeColor must be a string');
/** @type {string} */
this.strokeColor = options.strokeColor;
goog.asserts.assertNumber(
options.strokeOpacity, 'strokeOpacity must be a number');
/** @type {number} */
this.strokeOpacity = options.strokeOpacity;
goog.asserts.assertNumber(
options.strokeWidth, 'strokeWidth must be a number');
/** @type {number} */
this.strokeWidth = options.strokeWidth;
};
goog.inherits(ol.style.LineLiteral, ol.style.Literal);
/**
* @inheritDoc
*/
ol.style.LineLiteral.prototype.equals = function(lineLiteral) {
return this.strokeColor == lineLiteral.strokeColor &&
this.strokeOpacity == lineLiteral.strokeOpacity &&
this.strokeWidth == lineLiteral.strokeWidth;
};

View File

@@ -1,60 +1,14 @@
goog.provide('ol.style.Line');
goog.provide('ol.style.LineLiteral');
goog.require('goog.asserts');
goog.require('ol.expr');
goog.require('ol.expr.Expression');
goog.require('ol.expr.Literal');
goog.require('ol.style.LineLiteral');
goog.require('ol.style.Symbolizer');
goog.require('ol.style.Literal');
/**
* @typedef {{strokeColor: (string),
* strokeOpacity: (number),
* strokeWidth: (number)}}
*/
ol.style.LineLiteralOptions;
/**
* @constructor
* @extends {ol.style.Literal}
* @param {ol.style.LineLiteralOptions} options Line literal options.
*/
ol.style.LineLiteral = function(options) {
goog.base(this);
goog.asserts.assertString(
options.strokeColor, 'strokeColor must be a string');
/** @type {string} */
this.strokeColor = options.strokeColor;
goog.asserts.assertNumber(
options.strokeOpacity, 'strokeOpacity must be a number');
/** @type {number} */
this.strokeOpacity = options.strokeOpacity;
goog.asserts.assertNumber(
options.strokeWidth, 'strokeWidth must be a number');
/** @type {number} */
this.strokeWidth = options.strokeWidth;
};
goog.inherits(ol.style.LineLiteral, ol.style.Literal);
/**
* @inheritDoc
*/
ol.style.LineLiteral.prototype.equals = function(lineLiteral) {
return this.strokeColor == lineLiteral.strokeColor &&
this.strokeOpacity == lineLiteral.strokeOpacity &&
this.strokeWidth == lineLiteral.strokeWidth;
};
/**
* @constructor

16
src/ol/style/literal.js Normal file
View File

@@ -0,0 +1,16 @@
goog.provide('ol.style.Literal');
/**
* @constructor
*/
ol.style.Literal = function() {};
/**
* @param {ol.style.Literal} symbolizerLiteral Symbolizer literal to
* compare to.
* @return {boolean} Is the passed symbolizer literal equal to this instance?
*/
ol.style.Literal.prototype.equals = goog.abstractMethod;

View File

@@ -0,0 +1,14 @@
goog.provide('ol.style.PointLiteral');
goog.require('ol.style.Literal');
/**
* @constructor
* @extends {ol.style.Literal}
*/
ol.style.PointLiteral = function() {
goog.base(this);
};
goog.inherits(ol.style.PointLiteral, ol.style.Literal);

View File

@@ -1,19 +1,6 @@
goog.provide('ol.style.Point');
goog.provide('ol.style.PointLiteral');
goog.require('ol.style.Symbolizer');
goog.require('ol.style.Literal');
/**
* @constructor
* @extends {ol.style.Literal}
*/
ol.style.PointLiteral = function() {
goog.base(this);
};
goog.inherits(ol.style.PointLiteral, ol.style.Literal);

View File

@@ -0,0 +1,82 @@
goog.provide('ol.style.PolygonLiteral');
goog.require('goog.asserts');
goog.require('ol.style.Literal');
/**
* @typedef {{fillColor: (string|undefined),
* fillOpacity: (number|undefined),
* strokeColor: (string|undefined),
* strokeOpacity: (number|undefined),
* strokeWidth: (number|undefined)}}
*/
ol.style.PolygonLiteralOptions;
/**
* @constructor
* @extends {ol.style.Literal}
* @param {ol.style.PolygonLiteralOptions} options Polygon literal options.
*/
ol.style.PolygonLiteral = function(options) {
goog.base(this);
/** @type {string|undefined} */
this.fillColor = options.fillColor;
if (goog.isDef(options.fillColor)) {
goog.asserts.assertString(options.fillColor, 'fillColor must be a string');
}
/** @type {number|undefined} */
this.fillOpacity = options.fillOpacity;
if (goog.isDef(options.fillOpacity)) {
goog.asserts.assertNumber(
options.fillOpacity, 'fillOpacity must be a number');
}
/** @type {string|undefined} */
this.strokeColor = options.strokeColor;
if (goog.isDef(this.strokeColor)) {
goog.asserts.assertString(
this.strokeColor, 'strokeColor must be a string');
}
/** @type {number|undefined} */
this.strokeOpacity = options.strokeOpacity;
if (goog.isDef(this.strokeOpacity)) {
goog.asserts.assertNumber(
this.strokeOpacity, 'strokeOpacity must be a number');
}
/** @type {number|undefined} */
this.strokeWidth = options.strokeWidth;
if (goog.isDef(this.strokeWidth)) {
goog.asserts.assertNumber(
this.strokeWidth, 'strokeWidth must be a number');
}
// fill and/or stroke properties must be defined
var fillDef = goog.isDef(this.fillColor) && goog.isDef(this.fillOpacity);
var strokeDef = goog.isDef(this.strokeColor) &&
goog.isDef(this.strokeOpacity) &&
goog.isDef(this.strokeWidth);
goog.asserts.assert(fillDef || strokeDef,
'Either fillColor and fillOpacity or ' +
'strokeColor and strokeOpacity and strokeWidth must be set');
};
goog.inherits(ol.style.PolygonLiteral, ol.style.Literal);
/**
* @inheritDoc
*/
ol.style.PolygonLiteral.prototype.equals = function(polygonLiteral) {
return this.fillColor == polygonLiteral.fillColor &&
this.fillOpacity == polygonLiteral.fillOpacity &&
this.strokeColor == polygonLiteral.strokeColor &&
this.strokeOpacity == polygonLiteral.strokeOpacity &&
this.strokeWidth == polygonLiteral.strokeWidth;
};

View File

@@ -1,90 +1,11 @@
goog.provide('ol.style.Polygon');
goog.provide('ol.style.PolygonLiteral');
goog.require('goog.asserts');
goog.require('ol.expr');
goog.require('ol.expr.Expression');
goog.require('ol.expr.Literal');
goog.require('ol.style.PolygonLiteral');
goog.require('ol.style.Symbolizer');
goog.require('ol.style.Literal');
/**
* @typedef {{fillColor: (string|undefined),
* fillOpacity: (number|undefined),
* strokeColor: (string|undefined),
* strokeOpacity: (number|undefined),
* strokeWidth: (number|undefined)}}
*/
ol.style.PolygonLiteralOptions;
/**
* @constructor
* @extends {ol.style.Literal}
* @param {ol.style.PolygonLiteralOptions} options Polygon literal options.
*/
ol.style.PolygonLiteral = function(options) {
goog.base(this);
/** @type {string|undefined} */
this.fillColor = options.fillColor;
if (goog.isDef(options.fillColor)) {
goog.asserts.assertString(options.fillColor, 'fillColor must be a string');
}
/** @type {number|undefined} */
this.fillOpacity = options.fillOpacity;
if (goog.isDef(options.fillOpacity)) {
goog.asserts.assertNumber(
options.fillOpacity, 'fillOpacity must be a number');
}
/** @type {string|undefined} */
this.strokeColor = options.strokeColor;
if (goog.isDef(this.strokeColor)) {
goog.asserts.assertString(
this.strokeColor, 'strokeColor must be a string');
}
/** @type {number|undefined} */
this.strokeOpacity = options.strokeOpacity;
if (goog.isDef(this.strokeOpacity)) {
goog.asserts.assertNumber(
this.strokeOpacity, 'strokeOpacity must be a number');
}
/** @type {number|undefined} */
this.strokeWidth = options.strokeWidth;
if (goog.isDef(this.strokeWidth)) {
goog.asserts.assertNumber(
this.strokeWidth, 'strokeWidth must be a number');
}
// fill and/or stroke properties must be defined
var fillDef = goog.isDef(this.fillColor) && goog.isDef(this.fillOpacity);
var strokeDef = goog.isDef(this.strokeColor) &&
goog.isDef(this.strokeOpacity) &&
goog.isDef(this.strokeWidth);
goog.asserts.assert(fillDef || strokeDef,
'Either fillColor and fillOpacity or ' +
'strokeColor and strokeOpacity and strokeWidth must be set');
};
goog.inherits(ol.style.PolygonLiteral, ol.style.Literal);
/**
* @inheritDoc
*/
ol.style.PolygonLiteral.prototype.equals = function(polygonLiteral) {
return this.fillColor == polygonLiteral.fillColor &&
this.fillOpacity == polygonLiteral.fillOpacity &&
this.strokeColor == polygonLiteral.strokeColor &&
this.strokeOpacity == polygonLiteral.strokeOpacity &&
this.strokeWidth == polygonLiteral.strokeWidth;
};

View File

@@ -0,0 +1,102 @@
goog.provide('ol.style.ShapeLiteral');
goog.provide('ol.style.ShapeType');
goog.require('goog.asserts');
goog.require('ol.style.PointLiteral');
/**
* @enum {string}
*/
ol.style.ShapeType = {
CIRCLE: 'circle'
};
/**
* @typedef {{type: (ol.style.ShapeType),
* size: (number),
* fillColor: (string|undefined),
* fillOpacity: (number|undefined),
* strokeColor: (string|undefined),
* strokeOpacity: (number|undefined),
* strokeWidth: (number|undefined)}}
*/
ol.style.ShapeLiteralOptions;
/**
* @constructor
* @extends {ol.style.PointLiteral}
* @param {ol.style.ShapeLiteralOptions} options Shape literal options.
*/
ol.style.ShapeLiteral = function(options) {
goog.asserts.assertString(options.type, 'type must be a string');
/** @type {ol.style.ShapeType} */
this.type = options.type;
goog.asserts.assertNumber(options.size, 'size must be a number');
/** @type {number} */
this.size = options.size;
/** @type {string|undefined} */
this.fillColor = options.fillColor;
if (goog.isDef(options.fillColor)) {
goog.asserts.assertString(options.fillColor, 'fillColor must be a string');
}
/** @type {number|undefined} */
this.fillOpacity = options.fillOpacity;
if (goog.isDef(options.fillOpacity)) {
goog.asserts.assertNumber(
options.fillOpacity, 'fillOpacity must be a number');
}
/** @type {string|undefined} */
this.strokeColor = options.strokeColor;
if (goog.isDef(this.strokeColor)) {
goog.asserts.assertString(
this.strokeColor, 'strokeColor must be a string');
}
/** @type {number|undefined} */
this.strokeOpacity = options.strokeOpacity;
if (goog.isDef(this.strokeOpacity)) {
goog.asserts.assertNumber(
this.strokeOpacity, 'strokeOpacity must be a number');
}
/** @type {number|undefined} */
this.strokeWidth = options.strokeWidth;
if (goog.isDef(this.strokeWidth)) {
goog.asserts.assertNumber(
this.strokeWidth, 'strokeWidth must be a number');
}
// fill and/or stroke properties must be defined
var fillDef = goog.isDef(this.fillColor) && goog.isDef(this.fillOpacity);
var strokeDef = goog.isDef(this.strokeColor) &&
goog.isDef(this.strokeOpacity) &&
goog.isDef(this.strokeWidth);
goog.asserts.assert(fillDef || strokeDef,
'Either fillColor and fillOpacity or ' +
'strokeColor and strokeOpacity and strokeWidth must be set');
};
goog.inherits(ol.style.ShapeLiteral, ol.style.PointLiteral);
/**
* @inheritDoc
*/
ol.style.ShapeLiteral.prototype.equals = function(shapeLiteral) {
return this.type == shapeLiteral.type &&
this.size == shapeLiteral.size &&
this.fillColor == shapeLiteral.fillColor &&
this.fillOpacity == shapeLiteral.fillOpacity &&
this.strokeColor == shapeLiteral.strokeColor &&
this.strokeOpacity == shapeLiteral.strokeOpacity &&
this.strokeWidth == shapeLiteral.strokeWidth;
};

View File

@@ -1,6 +1,4 @@
goog.provide('ol.style.Shape');
goog.provide('ol.style.ShapeLiteral');
goog.provide('ol.style.ShapeType');
goog.require('goog.asserts');
goog.require('ol.expr');
@@ -8,103 +6,8 @@ goog.require('ol.expr.Expression');
goog.require('ol.expr.Literal');
goog.require('ol.style.Point');
goog.require('ol.style.PointLiteral');
/**
* @enum {string}
*/
ol.style.ShapeType = {
CIRCLE: 'circle'
};
/**
* @typedef {{type: (ol.style.ShapeType),
* size: (number),
* fillColor: (string|undefined),
* fillOpacity: (number|undefined),
* strokeColor: (string|undefined),
* strokeOpacity: (number|undefined),
* strokeWidth: (number|undefined)}}
*/
ol.style.ShapeLiteralOptions;
/**
* @constructor
* @extends {ol.style.PointLiteral}
* @param {ol.style.ShapeLiteralOptions} options Shape literal options.
*/
ol.style.ShapeLiteral = function(options) {
goog.asserts.assertString(options.type, 'type must be a string');
/** @type {ol.style.ShapeType} */
this.type = options.type;
goog.asserts.assertNumber(options.size, 'size must be a number');
/** @type {number} */
this.size = options.size;
/** @type {string|undefined} */
this.fillColor = options.fillColor;
if (goog.isDef(options.fillColor)) {
goog.asserts.assertString(options.fillColor, 'fillColor must be a string');
}
/** @type {number|undefined} */
this.fillOpacity = options.fillOpacity;
if (goog.isDef(options.fillOpacity)) {
goog.asserts.assertNumber(
options.fillOpacity, 'fillOpacity must be a number');
}
/** @type {string|undefined} */
this.strokeColor = options.strokeColor;
if (goog.isDef(this.strokeColor)) {
goog.asserts.assertString(
this.strokeColor, 'strokeColor must be a string');
}
/** @type {number|undefined} */
this.strokeOpacity = options.strokeOpacity;
if (goog.isDef(this.strokeOpacity)) {
goog.asserts.assertNumber(
this.strokeOpacity, 'strokeOpacity must be a number');
}
/** @type {number|undefined} */
this.strokeWidth = options.strokeWidth;
if (goog.isDef(this.strokeWidth)) {
goog.asserts.assertNumber(
this.strokeWidth, 'strokeWidth must be a number');
}
// fill and/or stroke properties must be defined
var fillDef = goog.isDef(this.fillColor) && goog.isDef(this.fillOpacity);
var strokeDef = goog.isDef(this.strokeColor) &&
goog.isDef(this.strokeOpacity) &&
goog.isDef(this.strokeWidth);
goog.asserts.assert(fillDef || strokeDef,
'Either fillColor and fillOpacity or ' +
'strokeColor and strokeOpacity and strokeWidth must be set');
};
goog.inherits(ol.style.ShapeLiteral, ol.style.PointLiteral);
/**
* @inheritDoc
*/
ol.style.ShapeLiteral.prototype.equals = function(shapeLiteral) {
return this.type == shapeLiteral.type &&
this.size == shapeLiteral.size &&
this.fillColor == shapeLiteral.fillColor &&
this.fillOpacity == shapeLiteral.fillOpacity &&
this.strokeColor == shapeLiteral.strokeColor &&
this.strokeOpacity == shapeLiteral.strokeOpacity &&
this.strokeWidth == shapeLiteral.strokeWidth;
};
goog.require('ol.style.ShapeLiteral');
goog.require('ol.style.ShapeType');

View File

@@ -1,22 +1,7 @@
goog.provide('ol.style.Symbolizer');
goog.provide('ol.style.Literal');
goog.require('ol.Feature');
/**
* @constructor
*/
ol.style.Literal = function() {};
/**
* @param {ol.style.Literal} symbolizerLiteral Symbolizer literal to
* compare to.
* @return {boolean} Is the passed symbolizer literal equal to this instance?
*/
ol.style.Literal.prototype.equals = goog.abstractMethod;
goog.require('ol.style.Literal');

View File

@@ -0,0 +1,57 @@
goog.provide('ol.style.TextLiteral');
goog.require('goog.asserts');
goog.require('ol.style.Literal');
/**
* @typedef {{color: string,
* fontFamily: string,
* fontSize: number,
* text: string,
* opacity: number}}
*/
ol.style.TextLiteralOptions;
/**
* @constructor
* @extends {ol.style.Literal}
* @param {ol.style.TextLiteralOptions} options Text literal options.
*/
ol.style.TextLiteral = function(options) {
goog.asserts.assertString(options.color, 'color must be a string');
/** @type {string} */
this.color = options.color;
goog.asserts.assertString(options.fontFamily, 'fontFamily must be a string');
/** @type {string} */
this.fontFamily = options.fontFamily;
goog.asserts.assertNumber(options.fontSize, 'fontSize must be a number');
/** @type {number} */
this.fontSize = options.fontSize;
goog.asserts.assertString(options.text, 'text must be a string');
/** @type {string} */
this.text = options.text;
goog.asserts.assertNumber(options.opacity, 'opacity must be a number');
/** @type {number} */
this.opacity = options.opacity;
};
goog.inherits(ol.style.TextLiteral, ol.style.Literal);
/**
* @inheritDoc
*/
ol.style.TextLiteral.prototype.equals = function(textLiteral) {
return this.color == textLiteral.color &&
this.fontFamily == textLiteral.fontFamily &&
this.fontSize == textLiteral.fontSize &&
this.opacity == textLiteral.opacity;
};

View File

@@ -1,65 +1,11 @@
goog.provide('ol.style.Text');
goog.provide('ol.style.TextLiteral');
goog.require('goog.asserts');
goog.require('ol.expr');
goog.require('ol.expr.Expression');
goog.require('ol.expr.Literal');
goog.require('ol.style.Symbolizer');
goog.require('ol.style.Literal');
/**
* @typedef {{color: string,
* fontFamily: string,
* fontSize: number,
* text: string,
* opacity: number}}
*/
ol.style.TextLiteralOptions;
/**
* @constructor
* @extends {ol.style.Literal}
* @param {ol.style.TextLiteralOptions} options Text literal options.
*/
ol.style.TextLiteral = function(options) {
goog.asserts.assertString(options.color, 'color must be a string');
/** @type {string} */
this.color = options.color;
goog.asserts.assertString(options.fontFamily, 'fontFamily must be a string');
/** @type {string} */
this.fontFamily = options.fontFamily;
goog.asserts.assertNumber(options.fontSize, 'fontSize must be a number');
/** @type {number} */
this.fontSize = options.fontSize;
goog.asserts.assertString(options.text, 'text must be a string');
/** @type {string} */
this.text = options.text;
goog.asserts.assertNumber(options.opacity, 'opacity must be a number');
/** @type {number} */
this.opacity = options.opacity;
};
goog.inherits(ol.style.TextLiteral, ol.style.Literal);
/**
* @inheritDoc
*/
ol.style.TextLiteral.prototype.equals = function(textLiteral) {
return this.color == textLiteral.color &&
this.fontFamily == textLiteral.fontFamily &&
this.fontSize == textLiteral.fontSize &&
this.opacity == textLiteral.opacity;
};
goog.require('ol.style.TextLiteral');

View File

@@ -0,0 +1,71 @@
goog.provide('ol.test.style.IconLiteral');
describe('ol.style.IconLiteral', function() {
describe('#equals()', function() {
it('identifies equal literals', function() {
var literal = new ol.style.IconLiteral({
height: 10,
width: 20,
opacity: 1,
rotation: 0.1,
url: 'http://example.com/1.png'
});
var equalLiteral = new ol.style.IconLiteral({
height: 10,
width: 20,
opacity: 1,
rotation: 0.1,
url: 'http://example.com/1.png'
});
var differentLiteral1 = new ol.style.IconLiteral({
height: 11,
width: 20,
opacity: 1,
rotation: 0.1,
url: 'http://example.com/1.png'
});
var differentLiteral2 = new ol.style.IconLiteral({
height: 10,
width: 2,
opacity: 1,
rotation: 0.1,
url: 'http://example.com/1.png'
});
var differentLiteral3 = new ol.style.IconLiteral({
height: 10,
width: 20,
opacity: 0.5,
rotation: 0.1,
url: 'http://example.com/1.png'
});
var differentLiteral4 = new ol.style.IconLiteral({
height: 10,
width: 20,
opacity: 1,
rotation: 0.2,
url: 'http://example.com/1.png'
});
var differentLiteral5 = new ol.style.IconLiteral({
height: 10,
width: 20,
opacity: 1,
rotation: 0.1,
url: 'http://example.com/2.png'
});
expect(literal.equals(equalLiteral)).to.be(true);
expect(literal.equals(differentLiteral1)).to.be(false);
expect(literal.equals(differentLiteral2)).to.be(false);
expect(literal.equals(differentLiteral3)).to.be(false);
expect(literal.equals(differentLiteral4)).to.be(false);
expect(literal.equals(differentLiteral5)).to.be(false);
});
});
});
goog.require('ol.style.IconLiteral');

View File

@@ -1,71 +1,5 @@
goog.provide('ol.test.style.Icon');
describe('ol.style.IconLiteral', function() {
describe('#equals()', function() {
it('identifies equal literals', function() {
var literal = new ol.style.IconLiteral({
height: 10,
width: 20,
opacity: 1,
rotation: 0.1,
url: 'http://example.com/1.png'
});
var equalLiteral = new ol.style.IconLiteral({
height: 10,
width: 20,
opacity: 1,
rotation: 0.1,
url: 'http://example.com/1.png'
});
var differentLiteral1 = new ol.style.IconLiteral({
height: 11,
width: 20,
opacity: 1,
rotation: 0.1,
url: 'http://example.com/1.png'
});
var differentLiteral2 = new ol.style.IconLiteral({
height: 10,
width: 2,
opacity: 1,
rotation: 0.1,
url: 'http://example.com/1.png'
});
var differentLiteral3 = new ol.style.IconLiteral({
height: 10,
width: 20,
opacity: 0.5,
rotation: 0.1,
url: 'http://example.com/1.png'
});
var differentLiteral4 = new ol.style.IconLiteral({
height: 10,
width: 20,
opacity: 1,
rotation: 0.2,
url: 'http://example.com/1.png'
});
var differentLiteral5 = new ol.style.IconLiteral({
height: 10,
width: 20,
opacity: 1,
rotation: 0.1,
url: 'http://example.com/2.png'
});
expect(literal.equals(equalLiteral)).to.be(true);
expect(literal.equals(differentLiteral1)).to.be(false);
expect(literal.equals(differentLiteral2)).to.be(false);
expect(literal.equals(differentLiteral3)).to.be(false);
expect(literal.equals(differentLiteral4)).to.be(false);
expect(literal.equals(differentLiteral5)).to.be(false);
});
});
});
describe('ol.style.Icon', function() {
describe('constructor', function() {

View File

@@ -0,0 +1,31 @@
goog.provide('ol.test.style.LineLiteral');
describe('ol.style.LineLiteral', function() {
describe('#equals()', function() {
it('identifies equal literals', function() {
var literal = new ol.style.LineLiteral({
strokeWidth: 3,
strokeColor: '#BADA55',
strokeOpacity: 1
});
var equalLiteral = new ol.style.LineLiteral({
strokeColor: '#BADA55',
strokeWidth: 3,
strokeOpacity: 1
});
var differentLiteral = new ol.style.LineLiteral({
strokeColor: '#013',
strokeWidth: 3,
strokeOpacity: 1
});
expect(literal.equals(equalLiteral)).to.be(true);
expect(literal.equals(differentLiteral)).to.be(false);
});
});
});
goog.require('ol.style.LineLiteral');

View File

@@ -1,33 +1,5 @@
goog.provide('ol.test.style.Line');
describe('ol.style.LineLiteral', function() {
describe('#equals()', function() {
it('identifies equal literals', function() {
var literal = new ol.style.LineLiteral({
strokeWidth: 3,
strokeColor: '#BADA55',
strokeOpacity: 1
});
var equalLiteral = new ol.style.LineLiteral({
strokeColor: '#BADA55',
strokeWidth: 3,
strokeOpacity: 1
});
var differentLiteral = new ol.style.LineLiteral({
strokeColor: '#013',
strokeWidth: 3,
strokeOpacity: 1
});
expect(literal.equals(equalLiteral)).to.be(true);
expect(literal.equals(differentLiteral)).to.be(false);
});
});
});
describe('ol.style.Line', function() {
describe('constructor', function() {

View File

@@ -0,0 +1,70 @@
goog.provide('ol.test.style.PolygonLiteral');
describe('ol.style.PolygonLiteral', function() {
describe('#equals()', function() {
it('identifies equal literals', function() {
var literal = new ol.style.PolygonLiteral({
strokeWidth: 3,
strokeColor: '#013',
strokeOpacity: 0.4,
fillColor: '#BADA55',
fillOpacity: 0.3
});
var equalLiteral = new ol.style.PolygonLiteral({
strokeWidth: 3,
strokeColor: '#013',
strokeOpacity: 0.4,
fillColor: '#BADA55',
fillOpacity: 0.3
});
var differentStrokeWidth = new ol.style.PolygonLiteral({
strokeWidth: 5,
strokeColor: '#013',
strokeOpacity: 0.4,
fillColor: '#BADA55',
fillOpacity: 0.3
});
var differentStrokeColor = new ol.style.PolygonLiteral({
strokeWidth: 3,
strokeColor: '#ffff00',
strokeOpacity: 0.4,
fillColor: '#BADA55',
fillOpacity: 0.3
});
var differentStrokeOpacity = new ol.style.PolygonLiteral({
strokeWidth: 3,
strokeColor: '#013',
strokeOpacity: 0.41,
fillColor: '#BADA55',
fillOpacity: 0.3
});
var differentFillColor = new ol.style.PolygonLiteral({
strokeWidth: 3,
strokeColor: '#013',
strokeOpacity: 0.4,
fillColor: '#00ffff',
fillOpacity: 0.3
});
var differentFillOpacity = new ol.style.PolygonLiteral({
strokeWidth: 3,
strokeColor: '#013',
strokeOpacity: 0.4,
fillColor: '#BADA55',
fillOpacity: 0.31
});
expect(literal.equals(equalLiteral)).to.be(true);
expect(literal.equals(differentStrokeWidth)).to.be(false);
expect(literal.equals(differentStrokeColor)).to.be(false);
expect(literal.equals(differentStrokeOpacity)).to.be(false);
expect(literal.equals(differentFillColor)).to.be(false);
expect(literal.equals(differentFillOpacity)).to.be(false);
});
});
});
goog.require('ol.style.PolygonLiteral');

View File

@@ -1,71 +1,5 @@
goog.provide('ol.test.style.Polygon');
describe('ol.style.PolygonLiteral', function() {
describe('#equals()', function() {
it('identifies equal literals', function() {
var literal = new ol.style.PolygonLiteral({
strokeWidth: 3,
strokeColor: '#013',
strokeOpacity: 0.4,
fillColor: '#BADA55',
fillOpacity: 0.3
});
var equalLiteral = new ol.style.PolygonLiteral({
strokeWidth: 3,
strokeColor: '#013',
strokeOpacity: 0.4,
fillColor: '#BADA55',
fillOpacity: 0.3
});
var differentStrokeWidth = new ol.style.PolygonLiteral({
strokeWidth: 5,
strokeColor: '#013',
strokeOpacity: 0.4,
fillColor: '#BADA55',
fillOpacity: 0.3
});
var differentStrokeColor = new ol.style.PolygonLiteral({
strokeWidth: 3,
strokeColor: '#ffff00',
strokeOpacity: 0.4,
fillColor: '#BADA55',
fillOpacity: 0.3
});
var differentStrokeOpacity = new ol.style.PolygonLiteral({
strokeWidth: 3,
strokeColor: '#013',
strokeOpacity: 0.41,
fillColor: '#BADA55',
fillOpacity: 0.3
});
var differentFillColor = new ol.style.PolygonLiteral({
strokeWidth: 3,
strokeColor: '#013',
strokeOpacity: 0.4,
fillColor: '#00ffff',
fillOpacity: 0.3
});
var differentFillOpacity = new ol.style.PolygonLiteral({
strokeWidth: 3,
strokeColor: '#013',
strokeOpacity: 0.4,
fillColor: '#BADA55',
fillOpacity: 0.31
});
expect(literal.equals(equalLiteral)).to.be(true);
expect(literal.equals(differentStrokeWidth)).to.be(false);
expect(literal.equals(differentStrokeColor)).to.be(false);
expect(literal.equals(differentStrokeOpacity)).to.be(false);
expect(literal.equals(differentFillColor)).to.be(false);
expect(literal.equals(differentFillOpacity)).to.be(false);
});
});
});
describe('ol.style.Polygon', function() {
describe('constructor', function() {

View File

@@ -0,0 +1,93 @@
goog.provide('ol.test.style.ShapeLiteral');
describe('ol.style.ShapeLiteral', function() {
describe('#equals()', function() {
it('identifies equal literals', function() {
var literal = new ol.style.ShapeLiteral({
type: ol.style.ShapeType.CIRCLE,
size: 4,
fillColor: '#BADA55',
fillOpacity: 0.9,
strokeColor: '#013',
strokeOpacity: 0.8,
strokeWidth: 3
});
var equalLiteral = new ol.style.ShapeLiteral({
type: ol.style.ShapeType.CIRCLE,
size: 4,
fillColor: '#BADA55',
fillOpacity: 0.9,
strokeColor: '#013',
strokeOpacity: 0.8,
strokeWidth: 3
});
var differentSize = new ol.style.ShapeLiteral({
type: ol.style.ShapeType.CIRCLE,
size: 5,
fillColor: '#BADA55',
fillOpacity: 0.9,
strokeColor: '#013',
strokeOpacity: 0.8,
strokeWidth: 3
});
var differentFillColor = new ol.style.ShapeLiteral({
type: ol.style.ShapeType.CIRCLE,
size: 4,
fillColor: '#ffffff',
fillOpacity: 0.9,
strokeColor: '#013',
strokeOpacity: 0.8,
strokeWidth: 3
});
var differentFillOpacity = new ol.style.ShapeLiteral({
type: ol.style.ShapeType.CIRCLE,
size: 4,
fillColor: '#BADA55',
fillOpacity: 0.8,
strokeColor: '#013',
strokeOpacity: 0.8,
strokeWidth: 3
});
var differentStrokeColor = new ol.style.ShapeLiteral({
type: ol.style.ShapeType.CIRCLE,
size: 4,
fillColor: '#BADA55',
fillOpacity: 0.9,
strokeColor: '#ffffff',
strokeOpacity: 0.8,
strokeWidth: 3
});
var differentStrokeOpacity = new ol.style.ShapeLiteral({
type: ol.style.ShapeType.CIRCLE,
size: 4,
fillColor: '#BADA55',
fillOpacity: 0.9,
strokeColor: '#013',
strokeOpacity: 0.7,
strokeWidth: 3
});
var differentStrokeWidth = new ol.style.ShapeLiteral({
type: ol.style.ShapeType.CIRCLE,
size: 4,
fillColor: '#BADA55',
fillOpacity: 0.9,
strokeColor: '#013',
strokeOpacity: 0.8,
strokeWidth: 4
});
expect(literal.equals(equalLiteral)).to.be(true);
expect(literal.equals(differentSize)).to.be(false);
expect(literal.equals(differentFillColor)).to.be(false);
expect(literal.equals(differentFillOpacity)).to.be(false);
expect(literal.equals(differentStrokeColor)).to.be(false);
expect(literal.equals(differentStrokeOpacity)).to.be(false);
expect(literal.equals(differentStrokeWidth)).to.be(false);
});
});
});
goog.require('ol.style.ShapeLiteral');

View File

@@ -1,95 +1,5 @@
goog.provide('ol.test.style.Shape');
describe('ol.style.ShapeLiteral', function() {
describe('#equals()', function() {
it('identifies equal literals', function() {
var literal = new ol.style.ShapeLiteral({
type: ol.style.ShapeType.CIRCLE,
size: 4,
fillColor: '#BADA55',
fillOpacity: 0.9,
strokeColor: '#013',
strokeOpacity: 0.8,
strokeWidth: 3
});
var equalLiteral = new ol.style.ShapeLiteral({
type: ol.style.ShapeType.CIRCLE,
size: 4,
fillColor: '#BADA55',
fillOpacity: 0.9,
strokeColor: '#013',
strokeOpacity: 0.8,
strokeWidth: 3
});
var differentSize = new ol.style.ShapeLiteral({
type: ol.style.ShapeType.CIRCLE,
size: 5,
fillColor: '#BADA55',
fillOpacity: 0.9,
strokeColor: '#013',
strokeOpacity: 0.8,
strokeWidth: 3
});
var differentFillColor = new ol.style.ShapeLiteral({
type: ol.style.ShapeType.CIRCLE,
size: 4,
fillColor: '#ffffff',
fillOpacity: 0.9,
strokeColor: '#013',
strokeOpacity: 0.8,
strokeWidth: 3
});
var differentFillOpacity = new ol.style.ShapeLiteral({
type: ol.style.ShapeType.CIRCLE,
size: 4,
fillColor: '#BADA55',
fillOpacity: 0.8,
strokeColor: '#013',
strokeOpacity: 0.8,
strokeWidth: 3
});
var differentStrokeColor = new ol.style.ShapeLiteral({
type: ol.style.ShapeType.CIRCLE,
size: 4,
fillColor: '#BADA55',
fillOpacity: 0.9,
strokeColor: '#ffffff',
strokeOpacity: 0.8,
strokeWidth: 3
});
var differentStrokeOpacity = new ol.style.ShapeLiteral({
type: ol.style.ShapeType.CIRCLE,
size: 4,
fillColor: '#BADA55',
fillOpacity: 0.9,
strokeColor: '#013',
strokeOpacity: 0.7,
strokeWidth: 3
});
var differentStrokeWidth = new ol.style.ShapeLiteral({
type: ol.style.ShapeType.CIRCLE,
size: 4,
fillColor: '#BADA55',
fillOpacity: 0.9,
strokeColor: '#013',
strokeOpacity: 0.8,
strokeWidth: 4
});
expect(literal.equals(equalLiteral)).to.be(true);
expect(literal.equals(differentSize)).to.be(false);
expect(literal.equals(differentFillColor)).to.be(false);
expect(literal.equals(differentFillOpacity)).to.be(false);
expect(literal.equals(differentStrokeColor)).to.be(false);
expect(literal.equals(differentStrokeOpacity)).to.be(false);
expect(literal.equals(differentStrokeWidth)).to.be(false);
});
});
});
describe('ol.style.Shape', function() {
describe('constructor', function() {

View File

@@ -0,0 +1,69 @@
goog.provide('ol.test.style.TextLiteral');
describe('ol.style.TextLiteral', function() {
describe('#equals()', function() {
it('identifies equal literals', function() {
var literal = new ol.style.TextLiteral({
color: '#ff0000',
fontFamily: 'Arial',
fontSize: 11,
text: 'Test',
opacity: 0.5
});
var equalLiteral = new ol.style.TextLiteral({
color: '#ff0000',
fontFamily: 'Arial',
fontSize: 11,
text: 'Test',
opacity: 0.5
});
var differentLiteral1 = new ol.style.TextLiteral({
color: '#0000ff',
fontFamily: 'Arial',
fontSize: 11,
text: 'Test',
opacity: 0.5
});
var differentLiteral2 = new ol.style.TextLiteral({
color: '#ff0000',
fontFamily: 'Dingbats',
fontSize: 11,
text: 'Test',
opacity: 0.5
});
var differentLiteral3 = new ol.style.TextLiteral({
color: '#ff0000',
fontFamily: 'Arial',
fontSize: 12,
text: 'Test',
opacity: 0.5
});
var differentLiteral4 = new ol.style.TextLiteral({
color: '#ff0000',
fontFamily: 'Arial',
fontSize: 11,
text: 'Test',
opacity: 0.6
});
var equalLiteral2 = new ol.style.TextLiteral({
color: '#ff0000',
fontFamily: 'Arial',
fontSize: 11,
text: 'Text is not compared for equality',
opacity: 0.5
});
expect(literal.equals(equalLiteral)).to.be(true);
expect(literal.equals(differentLiteral1)).to.be(false);
expect(literal.equals(differentLiteral2)).to.be(false);
expect(literal.equals(differentLiteral3)).to.be(false);
expect(literal.equals(differentLiteral4)).to.be(false);
expect(literal.equals(equalLiteral2)).to.be(true);
});
});
});
goog.require('ol.style.TextLiteral');

View File

@@ -1,71 +1,5 @@
goog.provide('ol.test.style.Text');
describe('ol.style.TextLiteral', function() {
describe('#equals()', function() {
it('identifies equal literals', function() {
var literal = new ol.style.TextLiteral({
color: '#ff0000',
fontFamily: 'Arial',
fontSize: 11,
text: 'Test',
opacity: 0.5
});
var equalLiteral = new ol.style.TextLiteral({
color: '#ff0000',
fontFamily: 'Arial',
fontSize: 11,
text: 'Test',
opacity: 0.5
});
var differentLiteral1 = new ol.style.TextLiteral({
color: '#0000ff',
fontFamily: 'Arial',
fontSize: 11,
text: 'Test',
opacity: 0.5
});
var differentLiteral2 = new ol.style.TextLiteral({
color: '#ff0000',
fontFamily: 'Dingbats',
fontSize: 11,
text: 'Test',
opacity: 0.5
});
var differentLiteral3 = new ol.style.TextLiteral({
color: '#ff0000',
fontFamily: 'Arial',
fontSize: 12,
text: 'Test',
opacity: 0.5
});
var differentLiteral4 = new ol.style.TextLiteral({
color: '#ff0000',
fontFamily: 'Arial',
fontSize: 11,
text: 'Test',
opacity: 0.6
});
var equalLiteral2 = new ol.style.TextLiteral({
color: '#ff0000',
fontFamily: 'Arial',
fontSize: 11,
text: 'Text is not compared for equality',
opacity: 0.5
});
expect(literal.equals(equalLiteral)).to.be(true);
expect(literal.equals(differentLiteral1)).to.be(false);
expect(literal.equals(differentLiteral2)).to.be(false);
expect(literal.equals(differentLiteral3)).to.be(false);
expect(literal.equals(differentLiteral4)).to.be(false);
expect(literal.equals(equalLiteral2)).to.be(true);
});
});
});
describe('ol.style.Text', function() {
describe('constructor', function() {