From a670e225cd9910c520521b1ce75668dc5d157b10 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Thu, 15 Aug 2013 08:20:35 -0400 Subject: [PATCH] Clearer naming of method to create symbolizer literals --- src/ol/layer/vectorlayer.js | 2 +- src/ol/style/style.js | 5 +++-- test/spec/ol/style/style.test.js | 12 +++++++----- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/ol/layer/vectorlayer.js b/src/ol/layer/vectorlayer.js index bb773113ef..77dc6698fb 100644 --- a/src/ol/layer/vectorlayer.js +++ b/src/ol/layer/vectorlayer.js @@ -395,7 +395,7 @@ ol.layer.Vector.prototype.groupFeaturesBySymbolizerLiteral = } else { if (!goog.isNull(style)) { // layer style second - literals = style.apply(feature); + literals = style.createLiterals(feature); } else { literals = ol.style.Style.applyDefaultStyle(feature); } diff --git a/src/ol/style/style.js b/src/ol/style/style.js index 8401fafc56..dbb63c8df1 100644 --- a/src/ol/style/style.js +++ b/src/ol/style/style.js @@ -28,11 +28,12 @@ ol.style.Style = function(options) { /** + * Create an array of symbolizer literals for a feature. * @param {ol.Feature} feature Feature. * @return {Array.} Symbolizer literals for the * feature. */ -ol.style.Style.prototype.apply = function(feature) { +ol.style.Style.prototype.createLiterals = function(feature) { var rules = this.rules_, literals = [], rule, symbolizers; @@ -55,7 +56,7 @@ ol.style.Style.prototype.apply = function(feature) { * the feature. */ ol.style.Style.applyDefaultStyle = function(feature) { - return ol.style.Style.defaults.apply(feature); + return ol.style.Style.defaults.createLiterals(feature); }; diff --git a/test/spec/ol/style/style.test.js b/test/spec/ol/style/style.test.js index e1bb8838e9..52535c652d 100644 --- a/test/spec/ol/style/style.test.js +++ b/test/spec/ol/style/style.test.js @@ -2,9 +2,9 @@ goog.provide('ol.test.style.Style'); describe('ol.style.Style', function() { - describe('#apply()', function() { + describe('#createLiterals()', function() { - it('applies a style to a feature', function() { + it('creates symbolizer literals for a feature', function() { var style = new ol.style.Style({ rules: [ @@ -23,10 +23,12 @@ describe('ol.style.Style', function() { geometry: new ol.geom.Point([1, 2]) }); feature.set('foo', 'bar'); - expect(style.apply(feature).length).to.be(1); - expect(style.apply(feature)[0].fillColor).to.be('#BADA55'); + var literals = style.createLiterals(feature); + expect(literals).to.have.length(1); + expect(literals[0].fillColor).to.be('#BADA55'); + feature.set('foo', 'baz'); - expect(style.apply(feature).length).to.be(0); + expect(style.createLiterals(feature)).to.have.length(0); }); });