[Commits] r2142 - in sandbox/bartvde/playground/geoext: examples lib/GeoExt/widgets/tree tests tests/lib/GeoExt/widgets/tree
commits at geoext.org
commits at geoext.org
Thu Apr 29 13:02:40 CEST 2010
Author: bartvde
Date: 2010-04-29 13:02:40 +0200 (Thu, 29 Apr 2010)
New Revision: 2142
Added:
sandbox/bartvde/playground/geoext/tests/lib/GeoExt/widgets/tree/WMSLoader.html
Modified:
sandbox/bartvde/playground/geoext/examples/wms-tree.js
sandbox/bartvde/playground/geoext/lib/GeoExt/widgets/tree/WMSLoader.js
sandbox/bartvde/playground/geoext/tests/list-tests.html
Log:
more work including tests on WMS Loader
Modified: sandbox/bartvde/playground/geoext/examples/wms-tree.js
===================================================================
--- sandbox/bartvde/playground/geoext/examples/wms-tree.js 2010-04-29 08:26:58 UTC (rev 2141)
+++ sandbox/bartvde/playground/geoext/examples/wms-tree.js 2010-04-29 11:02:40 UTC (rev 2142)
@@ -13,7 +13,9 @@
}),
listeners: {
'click': function(node) {
- mapPanel.map.addLayer(node.attributes.layer);
+ if (node.attributes.layer !== undefined) {
+ mapPanel.map.addLayer(node.attributes.layer);
+ }
}
}
}
Modified: sandbox/bartvde/playground/geoext/lib/GeoExt/widgets/tree/WMSLoader.js
===================================================================
--- sandbox/bartvde/playground/geoext/lib/GeoExt/widgets/tree/WMSLoader.js 2010-04-29 08:26:58 UTC (rev 2141)
+++ sandbox/bartvde/playground/geoext/lib/GeoExt/widgets/tree/WMSLoader.js 2010-04-29 11:02:40 UTC (rev 2142)
@@ -26,6 +26,26 @@
Ext.extend(GeoExt.tree.WMSLoader, Ext.tree.TreeLoader, {
+ /** api: config[url]
+ * ``String``
+ * The online resource of the Web Map Service.
+ */
+ url: null,
+
+ /** api: config[layerOptions]
+ * ``Object``
+ * Optional options to set on the WMS layers which will be created by
+ * this loader.
+ */
+ layerOptions: null,
+
+ /** api: config[layerParams]
+ * ``Object``
+ * Optional parameters to set on the WMS layers which will be created by
+ * this loader.
+ */
+ layerParams: null,
+
/** private: property[requestMethod]
* ``String`` WMS GetCapabilities request needs to be done using HTTP GET
*/
@@ -65,12 +85,15 @@
* node.
*/
createWMSLayer: function(layer, url) {
- return new OpenLayers.Layer.WMS( layer.title, url,
- OpenLayers.Util.extend({formats: layer.formats[0], layers: layer.name}, this.layerParams),
- OpenLayers.Util.extend({minScale: layer.minScale,
- queryable: layer.queryable, maxScale: layer.maxScale,
- metadata: layer
- }, this.layerOptions));
+ if (layer.name) {
+ return new OpenLayers.Layer.WMS( layer.title, url,
+ OpenLayers.Util.extend({formats: layer.formats[0],
+ layers: layer.name}, this.layerParams),
+ OpenLayers.Util.extend({minScale: layer.minScale,
+ queryable: layer.queryable, maxScale: layer.maxScale,
+ metadata: layer
+ }, this.layerOptions));
+ }
},
/** private: method[processLayer]
Added: sandbox/bartvde/playground/geoext/tests/lib/GeoExt/widgets/tree/WMSLoader.html
===================================================================
--- sandbox/bartvde/playground/geoext/tests/lib/GeoExt/widgets/tree/WMSLoader.html (rev 0)
+++ sandbox/bartvde/playground/geoext/tests/lib/GeoExt/widgets/tree/WMSLoader.html 2010-04-29 11:02:40 UTC (rev 2142)
@@ -0,0 +1,54 @@
+<html>
+ <head>
+ <script src="../../../../../../openlayers/lib/OpenLayers.js"></script>
+ <script src="../../../../../../ext/adapter/ext/ext-base.js"></script>
+ <script src="../../../../../../ext/ext-all-debug.js"></script>
+ <script src="../../../../../lib/GeoExt.js"></script>
+ <script src="../../data/WMSCapabilitiesReader.js"></script>
+
+ <script>
+
+ function test_constructor(t) {
+
+ t.plan(3);
+
+ var loader = new GeoExt.tree.WMSLoader({
+ url: "http://foo/wms?",
+ layerOptions: {singleTile: true},
+ layerParams: {transparent: 'TRUE'}
+ });
+
+ t.eq(loader.url, "http://foo/wms?", "url set correctly");
+ t.eq(loader.layerOptions.singleTile, true, "layerOptions set correctly");
+ t.eq(loader.layerParams.transparent, 'TRUE', "layerParams set correctly");
+ }
+
+ function test_load(t) {
+
+ t.plan(5);
+
+ var loader = new GeoExt.tree.WMSLoader({
+ layerOptions: {singleTile: true},
+ layerParams: {transparent: 'TRUE'}
+ });
+
+ var root = new Ext.tree.AsyncTreeNode({
+ text: 'GeoServer Demo WMS'
+ });
+
+ loader.processResponse({responseXML: doc}, root, function() {
+ t.eq(root.childNodes[0].text, "GeoServer Web Map Service", "Title of root layer set as text");
+ t.eq(root.childNodes[0].attributes.layer, undefined, "A layer without a <Name> does not get a layer attribute");
+ t.ok(root.childNodes[0].childNodes[0].attributes.layer instanceof OpenLayers.Layer.WMS, "WMS layer created");
+ t.eq(root.childNodes[0].childNodes[0].attributes.layer.options.singleTile, true, "singleTile correctly set");
+ t.eq(root.childNodes[0].childNodes[0].attributes.layer.params.TRANSPARENT, "TRUE", "transparent parameter correctly set");
+ });
+
+ }
+
+ </script>
+ </head>
+ <body>
+ <div id="tree" style="width: 100px; height: 100px;"></div>
+ </body>
+</html>
Modified: sandbox/bartvde/playground/geoext/tests/list-tests.html
===================================================================
--- sandbox/bartvde/playground/geoext/tests/list-tests.html 2010-04-29 08:26:58 UTC (rev 2141)
+++ sandbox/bartvde/playground/geoext/tests/list-tests.html 2010-04-29 11:02:40 UTC (rev 2142)
@@ -37,6 +37,7 @@
<li>lib/GeoExt/widgets/tree/RadioButtonMixin.html</li>
<li>lib/GeoExt/widgets/tree/LayerParamLoader.html</li>
<li>lib/GeoExt/widgets/tree/LayerParamNode.html</li>
+ <li>lib/GeoExt/widgets/tree/WMSLoader.html</li>
<li>lib/GeoExt/widgets/LegendImage.html</li>
<li>lib/GeoExt/widgets/LegendPanel.html</li>
<li>lib/GeoExt/widgets/LayerLegend.html</li>
More information about the Commits
mailing list