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:
Tim Schaub
2010-08-02 19:49:52 +00:00
parent 9fd7463680
commit 6c0952934f
21 changed files with 1498 additions and 55 deletions

65
examples/sld-parser.html Normal file
View File

@@ -0,0 +1,65 @@
<!DOCTYPE html>
<html>
<head>
<title>OpenLayers SLD Parser</title>
<link rel="stylesheet" href="../theme/default/style.css" type="text/css" />
<link rel="stylesheet" href="style.css" type="text/css" />
<script src="../lib/OpenLayers.js"></script>
<style>
#input {
width: 90%;
height: 300px;
}
#output {
width: 90%;
height: 300px;
}
</style>
</head>
<body>
<h1 id="title">SLD Parser</h1>
<div id="shortdesc">Parsing Styled Layer Descriptor (SLD) documents with the SLD format.</div>
<textarea id="input">paste SLD here</textarea><br>
<input type="checkbox" id="symbolizers" checked="checked"><label for="symbolizers">Maintain multiple symbolizers and FeatureTypeStyle elements</label><br>
<input type="checkbox" id="array"><label for="array">Compile an array of named styles instead of an object.</label><br>
<input type="button" id="button" value="Parse SLD">
<div id="docs">
This example uses the SLD format to parse SLD documents pasted into the textarea above.
A rough representation of the parsed style is shown in the textarea below.
</div>
<textarea id="output"></textarea>
<script>
var button = document.getElementById("button");
var input = document.getElementById("input");
var output = document.getElementById("output");
var symbolizers = document.getElementById("symbolizers");
var array = document.getElementById("array");
var json = new OpenLayers.Format.JSON();
var format, obj;
button.onclick = function() {
var str = input.value;
format = new OpenLayers.Format.SLD({
multipleSymbolizers: !!symbolizers.checked,
namedLayersAsArray: !!array.checked
});
obj = format.read(str);
try {
output.value = json.write(obj, true);
} catch (err) {
output.value = "Trouble: " + err;
}
}
</script>
</body>
</html>