Skip to content

Commit

Permalink
Merge pull request openlayers#372 from bartvde/graphictext
Browse files Browse the repository at this point in the history
setting graphic to false by default when reading a TextSymbolizer (r=@ahocevar)
  • Loading branch information
Bart van den Eijnden committed Mar 31, 2012
2 parents 9a5364f + 4b22a1e commit a00b565
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
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
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 a00b565

Please sign in to comment.