Adding point, line, polygon, text, and raster symbolizer constructors. This paves the way for rendering multiple symbolizers per rule. The SLD parser now successfully round-trips documents with multiple symbolizers and multiple FeatureTypeStyle elements (through the symbolizer zIndex property). The Style2 (yes, ack) constructor is used to represent a collection of rules with multiple symbolizers. Style2 objects are currently only used by the SLD parser if the multipleSymbolizer property is set to true. Future enhancements to the renderers can be made to account for multiple symbolizers. r=ahocevar (closes #2760).
git-svn-id: http://svn.openlayers.org/trunk/openlayers@10560 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -6,6 +6,11 @@
|
||||
/**
|
||||
* @requires OpenLayers/Util.js
|
||||
* @requires OpenLayers/Style.js
|
||||
* @requires OpenLayers/Symbolizer/Point.js
|
||||
* @requires OpenLayers/Symbolizer/Line.js
|
||||
* @requires OpenLayers/Symbolizer/Polygon.js
|
||||
* @requires OpenLayers/Symbolizer/Text.js
|
||||
* @requires OpenLayers/Symbolizer/Raster.js
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -24,7 +29,7 @@ OpenLayers.Rule = OpenLayers.Class({
|
||||
* APIProperty: name
|
||||
* {String} name of this rule
|
||||
*/
|
||||
name: 'default',
|
||||
name: null,
|
||||
|
||||
/**
|
||||
* Property: title
|
||||
@@ -73,6 +78,17 @@ OpenLayers.Rule = OpenLayers.Class({
|
||||
*/
|
||||
symbolizer: null,
|
||||
|
||||
/**
|
||||
* Property: symbolizers
|
||||
* {Array} Collection of symbolizers associated with this rule. If
|
||||
* provided at construction, the symbolizers array has precedence
|
||||
* over the deprecated symbolizer property. Note that multiple
|
||||
* symbolizers are not currently supported by the vector renderers.
|
||||
* Rules with multiple symbolizers are currently only useful for
|
||||
* maintaining elements in an SLD document.
|
||||
*/
|
||||
symbolizers: null,
|
||||
|
||||
/**
|
||||
* APIProperty: minScaleDenominator
|
||||
* {Number} or {String} minimum scale at which to draw the feature.
|
||||
@@ -103,6 +119,9 @@ OpenLayers.Rule = OpenLayers.Class({
|
||||
initialize: function(options) {
|
||||
this.symbolizer = {};
|
||||
OpenLayers.Util.extend(this, options);
|
||||
if (this.symbolizers) {
|
||||
delete this.symbolizer;
|
||||
}
|
||||
this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_");
|
||||
},
|
||||
|
||||
@@ -115,6 +134,7 @@ OpenLayers.Rule = OpenLayers.Class({
|
||||
this.symbolizer[i] = null;
|
||||
}
|
||||
this.symbolizer = null;
|
||||
delete this.symbolizers;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -187,16 +207,25 @@ OpenLayers.Rule = OpenLayers.Class({
|
||||
*/
|
||||
clone: function() {
|
||||
var options = OpenLayers.Util.extend({}, this);
|
||||
// clone symbolizer
|
||||
options.symbolizer = {};
|
||||
var value, type;
|
||||
for(var key in this.symbolizer) {
|
||||
value = this.symbolizer[key];
|
||||
type = typeof value;
|
||||
if(type === "object") {
|
||||
options.symbolizer[key] = OpenLayers.Util.extend({}, value);
|
||||
} else if(type === "string") {
|
||||
options.symbolizer[key] = value;
|
||||
if (this.symbolizers) {
|
||||
// clone symbolizers
|
||||
var len = this.symbolizers.length;
|
||||
options.symbolizers = new Array(len);
|
||||
for (var i=0; i<len; ++i) {
|
||||
options.symbolizers[i] = this.symbolizers[i].clone();
|
||||
}
|
||||
} else {
|
||||
// clone symbolizer
|
||||
options.symbolizer = {};
|
||||
var value, type;
|
||||
for(var key in this.symbolizer) {
|
||||
value = this.symbolizer[key];
|
||||
type = typeof value;
|
||||
if(type === "object") {
|
||||
options.symbolizer[key] = OpenLayers.Util.extend({}, value);
|
||||
} else if(type === "string") {
|
||||
options.symbolizer[key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
// clone filter
|
||||
|
||||
Reference in New Issue
Block a user