diff options
author | Chris Schlaeger <chris@linux.com> | 2014-08-12 21:56:44 +0200 |
---|---|---|
committer | Chris Schlaeger <chris@linux.com> | 2014-08-12 21:56:44 +0200 |
commit | ea346a785dc1b3f7c156f6fc33da634e1f1a627b (patch) | |
tree | af67530553d20b6e82ad60fd79593e9c4abf5565 /misc/openlayers/tests/Format/WMC/v1.html | |
parent | 59741cd535c47f25971bf8c32b25da25ceadc6d5 (diff) | |
download | postrunner-ea346a785dc1b3f7c156f6fc33da634e1f1a627b.zip |
Adding jquery, flot and openlayers to be included with the GEM.v0.0.4
Diffstat (limited to 'misc/openlayers/tests/Format/WMC/v1.html')
-rw-r--r-- | misc/openlayers/tests/Format/WMC/v1.html | 266 |
1 files changed, 266 insertions, 0 deletions
diff --git a/misc/openlayers/tests/Format/WMC/v1.html b/misc/openlayers/tests/Format/WMC/v1.html new file mode 100644 index 0000000..05e6078 --- /dev/null +++ b/misc/openlayers/tests/Format/WMC/v1.html @@ -0,0 +1,266 @@ +<html> +<head> + <script src="../../OLLoader.js"></script> + <script type="text/javascript"> + + function test_write_wmc_StyleList(t) { + t.plan(4); + + var layer, layerContext, got, expected; + + var format = new OpenLayers.Format.WMC(); + var parser = format.getParser("1"); + var name = "test"; + var url = "http://foo"; + + // test named style + layer = new OpenLayers.Layer.WMS(name, url, { + styles: "mystyle" + }); + layerContext = format.layerToContext(layer); + got = parser.write_wmc_StyleList(layerContext); + expected = + "<StyleList xmlns='http://www.opengis.net/context'>" + + "<Style current='1'>" + + "<Name>mystyle</Name><Title>Default</Title>" + + "</Style>" + + "</StyleList>"; + + t.xml_eq(got, expected, "named style correctly written"); + layer.destroy(); + + // test linked style + layer = new OpenLayers.Layer.WMS(name, url, { + sld: "http://linked.sld" + }); + layerContext = format.layerToContext(layer); + got = parser.write_wmc_StyleList(layerContext); + expected = + "<StyleList xmlns='http://www.opengis.net/context'>" + + "<Style current='1'>" + + "<SLD>" + + "<Title>Default</Title>" + + "<OnlineResource xmlns:xlink='http://www.w3.org/1999/xlink' "+ + "xlink:type='simple' " + + "xlink:href='http://linked.sld' />" + + "</SLD>" + + "</Style>" + + "</StyleList>"; + + t.xml_eq(got, expected, "linked style correctly written"); + layer.destroy(); + + // test inline style + layer = new OpenLayers.Layer.WMS(name, url, { + sld_body: + "<sld:StyledLayerDescriptor version='1.0.0' " + + "xmlns:ogc='http://www.opengis.net/ogc' " + + "xmlns:sld='http://www.opengis.net/sld' " + + "xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' " + + "xsi:schemaLocation='http://www.opengis.net/sld http://schemas.opengeospatial.net/sld/1.0.0/StyledLayerDescriptor.xsd'>" + + "<sld:NamedLayer>" + + "<sld:Name>AAA212</sld:Name>" + + "<sld:UserStyle>" + + "<sld:FeatureTypeStyle>" + + "<sld:Rule>" + + "<sld:TextSymbolizer>" + + "<sld:Label>" + + "<ogc:PropertyName>ZONENR</ogc:PropertyName>" + + "</sld:Label>" + + "<sld:Font>" + + "<sld:CssParameter name='font-family'>Arial</sld:CssParameter>" + + "<sld:CssParameter name='font-size'>10</sld:CssParameter>" + + "</sld:Font>" + + "<sld:Fill>" + + "<sld:CssParameter name='fill'>#FF9900</sld:CssParameter>" + + "</sld:Fill>" + + "</sld:TextSymbolizer>" + + "</sld:Rule>" + + "</sld:FeatureTypeStyle>" + + "</sld:UserStyle>" + + "</sld:NamedLayer>" + + "</sld:StyledLayerDescriptor>" + }); + + layerContext = format.layerToContext(layer); + got = parser.write_wmc_StyleList(layerContext); + expected = + "<StyleList xmlns='http://www.opengis.net/context'>" + + "<Style current='1'>" + + "<SLD>" + + "<Title>Default</Title>" + + "<sld:StyledLayerDescriptor version='1.0.0' " + + "xmlns:sld='http://www.opengis.net/sld' " + + "xmlns:ogc='http://www.opengis.net/ogc' " + + "xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' " + + "xsi:schemaLocation='http://www.opengis.net/sld http://schemas.opengeospatial.net/sld/1.0.0/StyledLayerDescriptor.xsd'>" + + "<sld:NamedLayer>" + + "<sld:Name>AAA212</sld:Name>" + + "<sld:UserStyle>" + + "<sld:FeatureTypeStyle>" + + "<sld:Rule>" + + "<sld:TextSymbolizer>" + + "<sld:Label>" + + "<ogc:PropertyName>ZONENR</ogc:PropertyName>" + + "</sld:Label>" + + "<sld:Font>" + + "<sld:CssParameter name='font-family'>Arial</sld:CssParameter>" + + "<sld:CssParameter name='font-size'>10</sld:CssParameter>" + + "</sld:Font>" + + "<sld:Fill>" + + "<sld:CssParameter name='fill'>#FF9900</sld:CssParameter>" + + "</sld:Fill>" + + "</sld:TextSymbolizer>" + + "</sld:Rule>" + + "</sld:FeatureTypeStyle>" + + "</sld:UserStyle>" + + "</sld:NamedLayer>" + + "</sld:StyledLayerDescriptor>" + + "</SLD>" + + "</Style>" + + "</StyleList>"; + + t.xml_eq(got, expected, "inline style correctly written"); + layer.destroy(); + + // test inline FeatureTypeStyle + layer = new OpenLayers.Layer.WMS(name, url, { + sld_body: + "<sld:FeatureTypeStyle version='1.0.0' " + + "xmlns:sld='http://www.opengis.net/sld' " + + "xmlns:ogc='http://www.opengis.net/ogc' " + + "xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' " + + "xsi:schemaLocation='http://www.opengis.net/sld http://schemas.opengeospatial.net/sld/1.0.0/StyledLayerDescriptor.xsd'>" + + "<sld:Rule>" + + "<sld:TextSymbolizer>" + + "<sld:Label>" + + "<ogc:PropertyName>ZONENR</ogc:PropertyName>" + + "</sld:Label>" + + "<sld:Font>" + + "<sld:CssParameter name='font-family'>Arial</sld:CssParameter>" + + "<sld:CssParameter name='font-size'>10</sld:CssParameter>" + + "</sld:Font>" + + "<sld:Fill>" + + "<sld:CssParameter name='fill'>#FF9900</sld:CssParameter>" + + "</sld:Fill>" + + "</sld:TextSymbolizer>" + + "</sld:Rule>" + + "</sld:FeatureTypeStyle>" + }); + + layerContext = format.layerToContext(layer); + got = parser.write_wmc_StyleList(layerContext); + expected = + "<StyleList xmlns='http://www.opengis.net/context'>" + + "<Style current='1'>" + + "<SLD>" + + "<Title>Default</Title>" + + "<sld:FeatureTypeStyle version='1.0.0' " + + "xmlns:sld='http://www.opengis.net/sld' " + + "xmlns:ogc='http://www.opengis.net/ogc' " + + "xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' " + + "xsi:schemaLocation='http://www.opengis.net/sld http://schemas.opengeospatial.net/sld/1.0.0/StyledLayerDescriptor.xsd'>" + + "<sld:Rule>" + + "<sld:TextSymbolizer>" + + "<sld:Label>" + + "<ogc:PropertyName>ZONENR</ogc:PropertyName>" + + "</sld:Label>" + + "<sld:Font>" + + "<sld:CssParameter name='font-family'>Arial</sld:CssParameter>" + + "<sld:CssParameter name='font-size'>10</sld:CssParameter>" + + "</sld:Font>" + + "<sld:Fill>" + + "<sld:CssParameter name='fill'>#FF9900</sld:CssParameter>" + + "</sld:Fill>" + + "</sld:TextSymbolizer>" + + "</sld:Rule>" + + "</sld:FeatureTypeStyle>" + + "</SLD>" + + "</Style>" + + "</StyleList>"; + + t.xml_eq(got, expected, "inline FeatureTypeStyle correctly written"); + layer.destroy(); + } + + function test_read_wmc_StyleList(t) { + t.plan(3); + + var xml = new OpenLayers.Format.XML(); + var format = new OpenLayers.Format.WMC(); + var parser = format.getParser("1"); + var node, text, layerContext, layer; + + // test named style + text = + "<StyleList xmlns='http://www.opengis.net/context'>" + + "<Style current='1'>" + + "<Name>mystyle</Name><Title>Default</Title>" + + "</Style>" + + "</StyleList>"; + node = xml.read(text).documentElement; + layerContext = { + styles: [] + }; + parser.read_wmc_StyleList(layerContext, node); + layer = format.getLayerFromContext(layerContext); + t.eq(layer.params.STYLES, "mystyle", "named style correctly read"); + + // test linked style + text = + "<StyleList xmlns='http://www.opengis.net/context'>" + + "<Style current='1'>" + + "<SLD>" + + "<OnlineResource xmlns:xlink='http://www.w3.org/1999/xlink' "+ + "xlink:type='simple' " + + "xlink:href='http://linked.sld' />" + + "</SLD>" + + "</Style>" + + "</StyleList>"; + node = xml.read(text).documentElement; + layerContext = { + styles: [] + }; + parser.read_wmc_StyleList(layerContext, node); + layer = format.getLayerFromContext(layerContext); + t.eq(layer.params.SLD, "http://linked.sld", "linked style correctly read"); + + // test inline style + // any valid xml under the StyledLayerDescriptor node should make the + // round trip from string to node and back + text = + "<StyleList xmlns='http://www.opengis.net/context'>" + + "<Style current='1'>" + + "<SLD>" + + "<sld:StyledLayerDescriptor version='1.0.0' " + + "xmlns:sld='http://www.opengis.net/sld' " + + "xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' " + + "xsi:schemaLocation='http://www.opengis.net/sld http://schemas.opengeospatial.net/sld/1.0.0/StyledLayerDescriptor.xsd'>" + + "<foo>bar<more/></foo>" + + "</sld:StyledLayerDescriptor>" + + "</SLD>" + + "</Style>" + + "</StyleList>"; + node = xml.read(text).documentElement; + layerContext = { + styles: [] + }; + parser.read_wmc_StyleList(layerContext, node); + layer = format.getLayerFromContext(layerContext); + var expected = + "<sld:StyledLayerDescriptor version='1.0.0' " + + "xmlns:sld='http://www.opengis.net/sld' " + + "xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' " + + "xsi:schemaLocation='http://www.opengis.net/sld http://schemas.opengeospatial.net/sld/1.0.0/StyledLayerDescriptor.xsd'>" + + "<foo xmlns='http://www.opengis.net/context'>bar<more/></foo>" + + "</sld:StyledLayerDescriptor>"; + t.xml_eq(layer.params.SLD_BODY, expected, "inline style correctly read"); + + } + + + </script> +</head> +<body> +</body> +</html> |