Clearer naming of method to create symbolizer literals

This commit is contained in:
Tim Schaub
2013-08-15 08:20:35 -04:00
parent d5d0262b4c
commit a670e225cd
3 changed files with 11 additions and 8 deletions
+1 -1
View File
@@ -395,7 +395,7 @@ ol.layer.Vector.prototype.groupFeaturesBySymbolizerLiteral =
} else { } else {
if (!goog.isNull(style)) { if (!goog.isNull(style)) {
// layer style second // layer style second
literals = style.apply(feature); literals = style.createLiterals(feature);
} else { } else {
literals = ol.style.Style.applyDefaultStyle(feature); literals = ol.style.Style.applyDefaultStyle(feature);
} }
+3 -2
View File
@@ -28,11 +28,12 @@ ol.style.Style = function(options) {
/** /**
* Create an array of symbolizer literals for a feature.
* @param {ol.Feature} feature Feature. * @param {ol.Feature} feature Feature.
* @return {Array.<ol.style.Literal>} Symbolizer literals for the * @return {Array.<ol.style.Literal>} Symbolizer literals for the
* feature. * feature.
*/ */
ol.style.Style.prototype.apply = function(feature) { ol.style.Style.prototype.createLiterals = function(feature) {
var rules = this.rules_, var rules = this.rules_,
literals = [], literals = [],
rule, symbolizers; rule, symbolizers;
@@ -55,7 +56,7 @@ ol.style.Style.prototype.apply = function(feature) {
* the feature. * the feature.
*/ */
ol.style.Style.applyDefaultStyle = function(feature) { ol.style.Style.applyDefaultStyle = function(feature) {
return ol.style.Style.defaults.apply(feature); return ol.style.Style.defaults.createLiterals(feature);
}; };
+7 -5
View File
@@ -2,9 +2,9 @@ goog.provide('ol.test.style.Style');
describe('ol.style.Style', function() { 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({ var style = new ol.style.Style({
rules: [ rules: [
@@ -23,10 +23,12 @@ describe('ol.style.Style', function() {
geometry: new ol.geom.Point([1, 2]) geometry: new ol.geom.Point([1, 2])
}); });
feature.set('foo', 'bar'); feature.set('foo', 'bar');
expect(style.apply(feature).length).to.be(1); var literals = style.createLiterals(feature);
expect(style.apply(feature)[0].fillColor).to.be('#BADA55'); expect(literals).to.have.length(1);
expect(literals[0].fillColor).to.be('#BADA55');
feature.set('foo', 'baz'); feature.set('foo', 'baz');
expect(style.apply(feature).length).to.be(0); expect(style.createLiterals(feature)).to.have.length(0);
}); });
}); });