diff --git a/src/objectliterals.exports b/src/objectliterals.exports index 3f0a1e984d..13f0d5808c 100644 --- a/src/objectliterals.exports +++ b/src/objectliterals.exports @@ -113,6 +113,11 @@ @exportObjectLiteralProperty ol.source.SingleImageWMSOptions.url string|undefined @exportObjectLiteralProperty ol.source.SingleImageWMSOptions.version string|undefined +@exportObjectLiteral ol.source.SourceOptions +@exportObjectLiteralProperty ol.source.SourceOptions.attributions Array.|undefined +@exportObjectLiteralProperty ol.source.SourceOptions.extent ol.Extent|undefined +@exportObjectLiteralProperty ol.source.SourceOptions.projection ol.Projection|undefined + @exportObjectLiteral ol.source.StamenOptions @exportObjectLiteralProperty ol.source.StamenOptions.flavor string|undefined @exportObjectLiteralProperty ol.source.StamenOptions.provider string @@ -139,6 +144,32 @@ @exportObjectLiteralProperty ol.source.TiledWMSOptions.url string|undefined @exportObjectLiteralProperty ol.source.TiledWMSOptions.urls Array.|undefined +@exportObjectLiteral ol.style.LineOptions +@exportObjectLiteralProperty ol.style.LineOptions.strokeStyle string|ol.Expression|undefined +@exportObjectLiteralProperty ol.style.LineOptions.strokeWidth number|ol.Expression|undefined +@exportObjectLiteralProperty ol.style.LineOptions.opacity number|ol.Expression|undefined + +@exportObjectLiteral ol.style.PolygonOptions +@exportObjectLiteralProperty ol.style.PolygonOptions.fillStyle string|ol.Expression|undefined +@exportObjectLiteralProperty ol.style.PolygonOptions.strokeStyle string|ol.Expression|undefined +@exportObjectLiteralProperty ol.style.PolygonOptions.strokeWidth number|ol.Expression|undefined +@exportObjectLiteralProperty ol.style.PolygonOptions.opacity number|ol.Expression|undefined + +@exportObjectLiteral ol.style.RuleOptions +@exportObjectLiteralProperty ol.style.RuleOptions.filter ol.filter.Filter|undefined +@exportObjectLiteralProperty ol.style.RuleOptions.symbolizers Array.|undefined + +@exportObjectLiteral ol.style.ShapeOptions +@exportObjectLiteralProperty ol.style.ShapeOptions.type ol.style.ShapeType|undefined +@exportObjectLiteralProperty ol.style.ShapeOptions.size number|ol.Expression|undefined +@exportObjectLiteralProperty ol.style.ShapeOptions.fillStyle string|ol.Expression|undefined +@exportObjectLiteralProperty ol.style.ShapeOptions.strokeStyle string|ol.Expression|undefined +@exportObjectLiteralProperty ol.style.ShapeOptions.strokeWidth number|ol.Expression|undefined +@exportObjectLiteralProperty ol.style.ShapeOptions.opacity number|ol.Expression|undefined + +@exportObjectLiteral ol.style.StyleOptions +@exportObjectLiteralProperty ol.style.StyleOptions.rules Array. + @exportObjectLiteral ol.tilegrid.TileGridOptions @exportObjectLiteralProperty ol.tilegrid.TileGridOptions.origin ol.Coordinate|undefined @exportObjectLiteralProperty ol.tilegrid.TileGridOptions.origins Array.|undefined diff --git a/src/ol/feature.exports b/src/ol/feature.exports new file mode 100644 index 0000000000..3192a1fd2d --- /dev/null +++ b/src/ol/feature.exports @@ -0,0 +1,6 @@ +@exportSymbol ol.Feature +@exportProperty ol.Feature.prototype.get +@exportProperty ol.Feature.prototype.getAttributes +@exportProperty ol.Feature.prototype.getGeometry +@exportProperty ol.Feature.prototype.set +@exportProperty ol.Feature.prototype.setGeometry diff --git a/src/ol/filter/filter.exports b/src/ol/filter/filter.exports new file mode 100644 index 0000000000..696edee702 --- /dev/null +++ b/src/ol/filter/filter.exports @@ -0,0 +1,7 @@ +@exportSymbol ol.filter.Filter +@exportSymbol ol.filter.Geometry +@exportSymbol ol.filter.Logical + +@exportSymbol ol.filter.LogicalOperator +@exportProperty ol.filter.LogicalOperator.AND +@exportProperty ol.filter.LogicalOperator.OR diff --git a/src/ol/geom/expression.exports b/src/ol/geom/expression.exports new file mode 100644 index 0000000000..911b8a12c6 --- /dev/null +++ b/src/ol/geom/expression.exports @@ -0,0 +1 @@ +@exportSymbol ol.Expression diff --git a/src/ol/geom/geometry.exports b/src/ol/geom/geometry.exports new file mode 100644 index 0000000000..4170284a9e --- /dev/null +++ b/src/ol/geom/geometry.exports @@ -0,0 +1,6 @@ +@exportSymbol ol.geom.Point +@exportSymbol ol.geom.LineString +@exportSymbol ol.geom.Polygon +@exportSymbol ol.geom.MultiPoint +@exportSymbol ol.geom.MultiLineString +@exportSymbol ol.geom.MultiPolygon diff --git a/src/ol/layer/vectorlayer.exports b/src/ol/layer/vectorlayer.exports new file mode 100644 index 0000000000..6abe609b01 --- /dev/null +++ b/src/ol/layer/vectorlayer.exports @@ -0,0 +1,3 @@ +@exportClass ol.layer.Vector ol.layer.LayerOptions + +@exportProperty ol.layer.Vector.prototype.addFeatures diff --git a/src/ol/source/vectorsource.exports b/src/ol/source/vectorsource.exports new file mode 100644 index 0000000000..27cbc2bea0 --- /dev/null +++ b/src/ol/source/vectorsource.exports @@ -0,0 +1 @@ +@exportClass ol.source.Vector ol.source.SourceOptions diff --git a/src/ol/source/vectorsource.js b/src/ol/source/vectorsource.js index 60ff1f1228..e45cc25548 100644 --- a/src/ol/source/vectorsource.js +++ b/src/ol/source/vectorsource.js @@ -13,27 +13,13 @@ goog.require('ol.geom.GeometryType'); goog.require('ol.source.Source'); -/** - * @typedef {{attributions: (Array.|undefined), - * extent: (ol.Extent|undefined), - * projection: (ol.Projection|undefined)}} - */ -ol.source.VectorOptions; - - /** * @constructor * @extends {ol.source.Source} - * @param {ol.source.VectorOptions} options Source options. + * @param {ol.source.SourceOptions} options Source options. */ ol.source.Vector = function(options) { - - goog.base(this, { - attributions: options.attributions, - extent: options.extent, - projection: options.projection - }); - + goog.base(this, options); }; goog.inherits(ol.source.Vector, ol.source.Source); diff --git a/src/ol/style.exports b/src/ol/style.exports new file mode 100644 index 0000000000..9b47275dfb --- /dev/null +++ b/src/ol/style.exports @@ -0,0 +1,7 @@ +@exportClass ol.style.Line ol.style.LineOptions +@exportClass ol.style.Polygon ol.style.PolygonOptions +@exportClass ol.style.Rule ol.style.RuleOptions +@exportClass ol.style.Shape ol.style.ShapeOptions +@exportClass ol.style.Style ol.style.StyleOptions +@exportSymbol ol.style.ShapeType +@exportProperty ol.style.ShapeType.CIRCLE diff --git a/src/ol/style/line.js b/src/ol/style/line.js index 1f8d4bea80..59de816f72 100644 --- a/src/ol/style/line.js +++ b/src/ol/style/line.js @@ -24,12 +24,15 @@ ol.style.LineLiteralOptions; ol.style.LineLiteral = function(config) { goog.base(this); + goog.asserts.assertString(config.strokeStyle, 'strokeStyle must be a string'); /** @type {string} */ this.strokeStyle = config.strokeStyle; + goog.asserts.assertNumber(config.strokeWidth, 'strokeWidth must be a number'); /** @type {number} */ this.strokeWidth = config.strokeWidth; + goog.asserts.assertNumber(config.opacity, 'opacity must be a number'); /** @type {number} */ this.opacity = config.opacity; @@ -47,14 +50,6 @@ ol.style.LineLiteral.prototype.equals = function(lineLiteral) { }; -/** - * @typedef {{strokeStyle: (string|ol.Expression|undefined), - * strokeWidth: (number|ol.Expression|undefined), - * opacity: (number|ol.Expression|undefined)}} - */ -ol.style.LineOptions; - - /** * @constructor diff --git a/src/ol/style/polygon.js b/src/ol/style/polygon.js index 7a126abd99..c144ada353 100644 --- a/src/ol/style/polygon.js +++ b/src/ol/style/polygon.js @@ -25,15 +25,19 @@ ol.style.PolygonLiteralOptions; ol.style.PolygonLiteral = function(config) { goog.base(this); + goog.asserts.assertString(config.fillStyle, 'fillStyle must be a string'); /** @type {string} */ this.fillStyle = config.fillStyle; + goog.asserts.assertString(config.strokeStyle, 'strokeStyle must be a string'); /** @type {string} */ this.strokeStyle = config.strokeStyle; + goog.asserts.assertNumber(config.strokeWidth, 'strokeWidth must be a number'); /** @type {number} */ this.strokeWidth = config.strokeWidth; + goog.asserts.assertNumber(config.opacity, 'opacity must be a number'); /** @type {number} */ this.opacity = config.opacity; @@ -52,15 +56,6 @@ ol.style.PolygonLiteral.prototype.equals = function(polygonLiteral) { }; -/** - * @typedef {{fillStyle: (string|ol.Expression|undefined), - * strokeStyle: (string|ol.Expression|undefined), - * strokeWidth: (number|ol.Expression|undefined), - * opacity: (number|ol.Expression|undefined)}} - */ -ol.style.PolygonOptions; - - /** * @constructor diff --git a/src/ol/style/rule.js b/src/ol/style/rule.js index 14b054a3d3..b6f1284fea 100644 --- a/src/ol/style/rule.js +++ b/src/ol/style/rule.js @@ -5,13 +5,6 @@ goog.require('ol.filter.Filter'); goog.require('ol.style.Symbolizer'); -/** - * @typedef {{filter: (ol.filter.Filter), - * symbolizers: (Array.)}} - */ -ol.style.RuleOptions; - - /** * @constructor diff --git a/src/ol/style/shape.js b/src/ol/style/shape.js index 6fe00005e0..83056a6276 100644 --- a/src/ol/style/shape.js +++ b/src/ol/style/shape.js @@ -35,21 +35,27 @@ ol.style.ShapeLiteralOptions; */ ol.style.ShapeLiteral = function(config) { - /** @type {string} */ + goog.asserts.assertString(config.type, 'type must be a string'); + /** @type {ol.style.ShapeType} */ this.type = config.type; + goog.asserts.assertNumber(config.size, 'size must be a number'); /** @type {number} */ this.size = config.size; + goog.asserts.assertString(config.fillStyle, 'fillStyle must be a string'); /** @type {string} */ this.fillStyle = config.fillStyle; + goog.asserts.assertString(config.strokeStyle, 'strokeStyle must be a string'); /** @type {string} */ this.strokeStyle = config.strokeStyle; + goog.asserts.assertNumber(config.strokeWidth, 'strokeWidth must be a number'); /** @type {number} */ this.strokeWidth = config.strokeWidth; + goog.asserts.assertNumber(config.opacity, 'opacity must be a number'); /** @type {number} */ this.opacity = config.opacity; @@ -70,17 +76,6 @@ ol.style.ShapeLiteral.prototype.equals = function(shapeLiteral) { }; -/** - * @typedef {{type: (ol.style.ShapeType|undefined), - * size: (number|ol.Expression|undefined), - * fillStyle: (string|ol.Expression|undefined), - * strokeStyle: (string|ol.Expression|undefined), - * strokeWidth: (number|ol.Expression|undefined), - * opacity: (number|ol.Expression|undefined)}} - */ -ol.style.ShapeOptions; - - /** * @constructor diff --git a/src/ol/style/style.js b/src/ol/style/style.js index e1afc68665..07edb53086 100644 --- a/src/ol/style/style.js +++ b/src/ol/style/style.js @@ -6,12 +6,6 @@ goog.require('ol.style.Rule'); goog.require('ol.style.SymbolizerLiteral'); -/** - * @typedef {{rules: (Array.)}} - */ -ol.style.StyleOptions; - - /** * @constructor diff --git a/test/spec/ol/layer/vectorlayer.test.js b/test/spec/ol/layer/vectorlayer.test.js index b6e5ff89ec..f63402c935 100644 --- a/test/spec/ol/layer/vectorlayer.test.js +++ b/test/spec/ol/layer/vectorlayer.test.js @@ -6,7 +6,7 @@ describe('ol.layer.Vector', function() { it('allows adding features', function() { var layer = new ol.layer.Vector({ - new ol.source.Vector({}) + source: new ol.source.Vector({}) }); layer.addFeatures([new ol.Feature(), new ol.Feature()]); expect(layer.getFeatures().length).toEqual(2); diff --git a/test/spec/ol/style/line.test.js b/test/spec/ol/style/line.test.js index e9957e036e..95784ab15f 100644 --- a/test/spec/ol/style/line.test.js +++ b/test/spec/ol/style/line.test.js @@ -7,15 +7,18 @@ describe('ol.style.LineLiteral', function() { it('identifies equal literals', function() { var literal = new ol.style.LineLiteral({ strokeWidth: 3, - strokeStyle: '#BADA55' + strokeStyle: '#BADA55', + opacity: 1 }); var equalLiteral = new ol.style.LineLiteral({ strokeStyle: '#BADA55', - strokeWidth: 3 + strokeWidth: 3, + opacity: 1 }); var differentLiteral = new ol.style.LineLiteral({ strokeStyle: '#013', - strokeWidth: 3 + strokeWidth: 3, + opacity: 1 }); expect(literal.equals(equalLiteral)).toBe(true); expect(literal.equals(differentLiteral)).toBe(false); diff --git a/test/spec/ol/style/polygon.test.js b/test/spec/ol/style/polygon.test.js index 3e7693bc85..4c8d443db3 100644 --- a/test/spec/ol/style/polygon.test.js +++ b/test/spec/ol/style/polygon.test.js @@ -7,15 +7,21 @@ describe('ol.style.PolygonLiteral', function() { it('identifies equal literals', function() { var literal = new ol.style.PolygonLiteral({ strokeWidth: 3, - fillStyle: '#BADA55' + strokeStyle: '#013', + fillStyle: '#BADA55', + opacity: 1 }); var equalLiteral = new ol.style.PolygonLiteral({ fillStyle: '#BADA55', - strokeWidth: 3 + strokeStyle: '#013', + strokeWidth: 3, + opacity: 1 }); var differentLiteral = new ol.style.PolygonLiteral({ fillStyle: '#013', - strokeWidth: 3 + strokeStyle: '#013', + strokeWidth: 3, + opacity: 1 }); expect(literal.equals(equalLiteral)).toBe(true); expect(literal.equals(differentLiteral)).toBe(false); diff --git a/test/spec/ol/style/shape.test.js b/test/spec/ol/style/shape.test.js index fec06b87d0..4f06a7a661 100644 --- a/test/spec/ol/style/shape.test.js +++ b/test/spec/ol/style/shape.test.js @@ -6,16 +6,28 @@ describe('ol.style.ShapeLiteral', function() { it('identifies equal literals', function() { var literal = new ol.style.ShapeLiteral({ + type: ol.style.ShapeType.CIRCLE, size: 4, - fillStyle: '#BADA55' + fillStyle: '#BADA55', + strokeStyle: '#013', + strokeWidth: 3, + opacity: 1 }); var equalLiteral = new ol.style.ShapeLiteral({ + type: ol.style.ShapeType.CIRCLE, + size: 4, fillStyle: '#BADA55', - size: 4 + strokeStyle: '#013', + strokeWidth: 3, + opacity: 1 }); var differentLiteral = new ol.style.ShapeLiteral({ + type: ol.style.ShapeType.CIRCLE, + size: 4, fillStyle: '#013', - size: 4 + strokeStyle: '#013', + strokeWidth: 3, + opacity: 1 }); expect(literal.equals(equalLiteral)).toBe(true); expect(literal.equals(differentLiteral)).toBe(false); @@ -74,3 +86,4 @@ goog.require('ol.Expression'); goog.require('ol.Feature'); goog.require('ol.style.Shape'); goog.require('ol.style.ShapeLiteral'); +goog.require('ol.style.ShapeType'); diff --git a/test/spec/ol/style/style.test.js b/test/spec/ol/style/style.test.js index f5e7530549..9b76d23b60 100644 --- a/test/spec/ol/style/style.test.js +++ b/test/spec/ol/style/style.test.js @@ -5,6 +5,7 @@ describe('ol.style.Style', function() { describe('#apply()', function() { it('applies a style to a feature', function() { + var style = new ol.style.Style({ rules: [ new ol.style.Rule({ @@ -39,8 +40,10 @@ describe('ol.style.Style', function() { it('returns an array with the Shape default for points', function() { feature.setGeometry(new ol.geom.Point([0, 0])); - expect(ol.style.Style.applyDefaultStyle(feature)[0] - .equals(ol.style.ShapeDefaults)).toBe(true); + var symbolizers = ol.style.Style.applyDefaultStyle(feature); + expect(symbolizers.length).toBe(1); + expect(symbolizers[0]).toBeA(ol.style.ShapeLiteral); + expect(symbolizers[0].equals(ol.style.ShapeDefaults)).toBe(true); }); it('returns an array with the Line default for lines', function() { @@ -66,4 +69,5 @@ goog.require('ol.geom.Polygon'); goog.require('ol.filter.Filter'); goog.require('ol.style.Rule'); goog.require('ol.style.Shape'); +goog.require('ol.style.ShapeLiteral'); goog.require('ol.style.Style');