Skip to content

Commit

Permalink
move logic into GeoServer profile as suggested by @ahocevar
Browse files Browse the repository at this point in the history
  • Loading branch information
Bart van den Eijnden committed Mar 30, 2012
1 parent 75c187d commit 4b22a1e
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 14 deletions.
4 changes: 1 addition & 3 deletions lib/OpenLayers/Format/SLD/v1.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,7 @@ OpenLayers.Format.SLD.v1 = OpenLayers.Class(OpenLayers.Format.Filter.v1_0_0, {
rule.maxScaleDenominator = parseFloat(this.getChildValue(node));
},
"TextSymbolizer": function(node, rule) {
var config = {
graphic: false
};
var config = {};
this.readChildNodes(node, config);
if (this.multipleSymbolizers) {
config.zIndex = this.featureTypeCounter;
Expand Down
7 changes: 7 additions & 0 deletions lib/OpenLayers/Format/SLD/v1_0_0_GeoServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ OpenLayers.Format.SLD.v1_0_0_GeoServer = OpenLayers.Class(
obj.vendorOptions = {};
}
obj.vendorOptions[node.getAttribute("name")] = this.getChildValue(node);
},
"TextSymbolizer": function(node, rule) {
OpenLayers.Format.SLD.v1_0_0.prototype.readers.sld.TextSymbolizer.apply(this, arguments);
var symbolizer = this.multipleSymbolizers ? rule.symbolizers[rule.symbolizers.length-1] : rule.symbolizer["Text"];
if (symbolizer.graphic === undefined) {
symbolizer.graphic = false;
}
}
}, OpenLayers.Format.SLD.v1_0_0.prototype.readers["sld"])
}, OpenLayers.Format.SLD.v1_0_0.prototype.readers),
Expand Down
11 changes: 0 additions & 11 deletions tests/Format/SLD/v1_0_0.html
Original file line number Diff line number Diff line change
Expand Up @@ -622,17 +622,6 @@

}

function test_readTextSymbolizer(t) {
t.plan(1);
var format = new OpenLayers.Format.SLD.v1_0_0({
multipleSymbolizers: true,
namedLayersAsArray: true
});
doc = readXML("point_pointwithdefaultlabel.sld");
var sld = format.read(doc);
t.eq(sld.namedLayers[0].userStyles[0].rules[0].symbolizers[1].graphic, false, "graphic set to false on TextSymbolizer");
}

function test_roundtrip(t) {

t.plan(5);
Expand Down
50 changes: 50 additions & 0 deletions tests/Format/SLD/v1_0_0_GeoServer.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@
out = format.write(data);
t.xml_eq(out, readXML("poly_label_nographic.sld").documentElement, "If graphic is false no Graphic is outputted");
}

function test_readTextSymbolizer(t) {
t.plan(1);
var format = new OpenLayers.Format.SLD({
profile: "GeoServer",
multipleSymbolizers: true,
namedLayersAsArray: true
});
doc = readXML("point_pointwithdefaultlabel.sld");
var sld = format.read(doc);
t.eq(sld.namedLayers[0].userStyles[0].rules[0].symbolizers[1].graphic, false, "graphic set to false on TextSymbolizer");
}

</script>
</head>
Expand Down Expand Up @@ -174,5 +186,43 @@
</NamedLayer>
</StyledLayerDescriptor>
--></div>
<div id="point_pointwithdefaultlabel.sld"><!--
<StyledLayerDescriptor version="1.0.0"
xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd"
xmlns="http://www.opengis.net/sld"
xmlns:ogc="http://www.opengis.net/ogc"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<NamedLayer>
<Name>Point with default label</Name>
<UserStyle>
<Title>GeoServer SLD Cook Book: Point with default label</Title>
<FeatureTypeStyle>
<Rule>
<PointSymbolizer>
<Graphic>
<Mark>
<WellKnownName>circle</WellKnownName>
<Fill>
<CssParameter name="fill">#FF0000</CssParameter>
</Fill>
</Mark>
<Size>6</Size>
</Graphic>
</PointSymbolizer>
<TextSymbolizer>
<Label>
<ogc:PropertyName>name</ogc:PropertyName>
</Label>
<Fill>
<CssParameter name="fill">#000000</CssParameter>
</Fill>
</TextSymbolizer>
</Rule>
</FeatureTypeStyle>
</UserStyle>
</NamedLayer>
</StyledLayerDescriptor>
--></div>
</body>
</html>

0 comments on commit 4b22a1e

Please sign in to comment.