Big thanks to Andreas Hocevar for this SLD format class - this continues to extend his Rule and Style work by giving us the ability to read SLD docs - onward with style r=tschaub (closes #533).
git-svn-id: http://svn.openlayers.org/trunk/openlayers@5520 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
var test_content = '<sld:StyledLayerDescriptor xmlns:sld="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml"><sld:NamedLayer><sld:Name>TestLayer</sld:Name><sld:UserStyle><sld:Name>foo</sld:Name><sld:FeatureTypeStyle><sld:Rule><sld:Name>bar</sld:Name><ogc:Filter></ogc:Filter><sld:PolygonSymbolizer><sld:Fill><sld:CssParameter name="fill"><ogc:Literal>blue</ogc:Literal></sld:CssParameter></sld:Fill></sld:PolygonSymbolizer></sld:Rule></sld:FeatureTypeStyle></sld:UserStyle></sld:NamedLayer></sld:StyledLayerDescriptor>';
|
||||
|
||||
function test_Format_SLD_constructor(t) {
|
||||
t.plan(3);
|
||||
|
||||
var options = {'foo': 'bar'};
|
||||
var format = new OpenLayers.Format.SLD(options);
|
||||
t.ok(format instanceof OpenLayers.Format.SLD,
|
||||
"new OpenLayers.Format.SLD returns object" );
|
||||
t.eq(format.foo, "bar", "constructor sets options correctly");
|
||||
t.eq(typeof format.read, "function", "format has a read function");
|
||||
}
|
||||
|
||||
function test_Format_SLD_read(t) {
|
||||
t.plan(5);
|
||||
var styles = new OpenLayers.Format.SLD().read(this.test_content,
|
||||
{withNamedLayer: true});
|
||||
|
||||
var testLayer = styles[1].TestLayer;
|
||||
|
||||
t.ok(testLayer.foo != undefined, "SLD correctly reads a UserStyle named \"foo\"");
|
||||
t.eq(testLayer.foo.rules.length, 1, "The number of rules for the UserStyle is correct");
|
||||
t.eq(testLayer.foo.rules[0].name, "bar", "The first rule's name is \"bar\"");
|
||||
t.eq(testLayer.foo.rules[0].symbolizer.Polygon.fillColor, "blue", "The fillColor for the Polygon symbolizer is correct");
|
||||
t.eq(testLayer.foo.name, styles[0][0].name, "The content hash of the Format contains the correct rules.");
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
@@ -22,6 +22,7 @@
|
||||
<li>test_Format.html</li>
|
||||
<li>Format/test_XML.html</li>
|
||||
<li>Format/test_KML.html</li>
|
||||
<li>Format/test_SLD.html</li>
|
||||
<li>Format/test_GeoRSS.html</li>
|
||||
<li>Format/test_JSON.html</li>
|
||||
<li>Format/test_GeoJSON.html</li>
|
||||
|
||||
Reference in New Issue
Block a user