Changeset 6425 for cowsclient


Ignore:
Timestamp:
28/01/10 12:34:31 (9 years ago)
Author:
pnorton
Message:

fixed the initial layer selection when the CSML folder structure is used. Also re-built the compressed_client.js

Location:
cowsclient/trunk/cowsclient/public
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • cowsclient/trunk/cowsclient/public/js/compressed_client.js

    r6119 r6425  
    1 "use strict";var WMSC={};WMSC.DEBUG=true;WMSC.log=function(b){if(!WMSC.DEBUG){return}try{console.log(b)}catch(a){}};"use strict";var Utils={};Utils.addHTMLEventListener=function(d,a,c,e){var b=function(f){c.apply(e,[f,this])};if(d.addEventListener){d.addEventListener(a,b,false)}else{if(d.attachEvent){d.attachEvent("on"+a,b)}}return b};Utils.removeHTMLEventListener=function(b,a,c){if(b.removeEventListener){b.removeEventListener(a,c,false)}else{if(b.detachEvent){b.detachEvent("on"+a,c)}}};Utils.buildScopedFunction=function(b,a){return function(c){b.apply(a,[c])}};Utils.buildSelectBox=function(d,c,a,b){return Utils.buildSelect("select_"+d,"select_"+d,c,a,b)};Utils.buildSelect=function(h,c,g,b,f){var d;var a=document.createElement("select");if(c!==null){a.name=c}if(h!==null){a.id=h}for(d=0;d<b.length;d++){var e=document.createElement("option");e.innerHTML=g[d];e.value=b[d];a.appendChild(e)}if(f!==null&&f!==undefined){for(d=0;d<b.length;d++){if(b[d]===f){a.selectedIndex=d;break}}}return a};Utils.buildLabel=function(c,d){var b=document.createElement("label");b.innerHTML=c;for(var a in d){b[a]=d[a]}return b};Utils.buildLabelInputDiv=function(d,e,c,a){var f=document.createElement("div");if(c!==undefined){f.className=c}var b=document.createElement("label");if(a!==undefined){b.className=a}b.innerHTML=d;f.appendChild(b);f.appendChild(e);return f};Utils.addHandlerToFormElements=function(f,a,h,e){var b={};var g=Utils.getActiveFormElements(f);for(var d=0;d<g.length;d++){var c=g[d];b[c.id]=Utils.addHTMLEventListener(c,a,h,e)}return b};Utils.getActiveFormElements=function(e){var c=[];var d=["INPUT","SELECT","TEXTAREA","BUTTON"];for(var b=0;b<e.elements.length;b++){var a=e.elements[b];if(Utils.isValueInList(a.tagName.toUpperCase(),d)){c.push(a)}}return c};Utils.removeEventHandlersFromLookup=function(d,b){if(b===undefined){b="change"}for(var e in d){if(e===""){continue}var a=document.getElementById(e);if(a===null||a===""){WMSC.log("Element not found for id="+e)}var c=d[e];if(c!==null){Utils.removeHTMLEventListener(a,b,c)}}};Utils.removeItems=function(c,b){var a=0;while(a<c.length){if(c[a]===b){c.splice(a,1)}else{a++}}return c};Utils.buildHiddenInputElement=function(b,c,d){var a=document.createElement("input");a.type="hidden";a.name=b;a.value=c;if(d!==undefined){a.id=d}return a};Utils.makeCombobox=function(k,a,c,i,g){var d={prehighlightClassName:"yui-ac-prehighlight",useShadow:true,queryDelay:0,minQueryLength:0,animVert:0.01,maxResultsDisplayed:25};var j=new YAHOO.util.LocalDataSource(i);var f=new YAHOO.widget.AutoComplete(k,c,j,d);if(g!==null&&g!==undefined){f.textboxChangeEvent.subscribe(g)}var h=document.getElementById(a);var e=new YAHOO.widget.Button({container:h});var b=function(l){YAHOO.util.Event.stopEvent(l);if(!YAHOO.util.Dom.hasClass(h,"open")){YAHOO.util.Dom.addClass(h,"open")}if(f.isContainerOpen()){f.collapseContainer()}else{f.getInputEl().focus();setTimeout(function(){f.sendQuery("")},0)}};e.on("mousedown",b);f.containerCollapseEvent.subscribe(function(){YAHOO.util.Dom.removeClass(h,"open")})};Utils.addParamsToUrl=function(c,h){var b=Utils.getParamsFromURL(c);var d=[];for(var a in b){d.push(a.toUpperCase())}var g=true;if(d.length>0){g=false}var f="";for(var e in h){if(Utils.isValueInList(e.toUpperCase(),d)){continue}if(g===true){f+="?";g=false}else{f+="&"}f+=e+"="+h[e]}return c+f};Utils.replaceParamsInUrl=function(c,g){var a=false;var b=c;if(c.indexOf("?")>0){b=c.substring(0,c.indexOf("?"))}var e="";var h=[];for(var f in g){h.push(f.toUpperCase());if(a===false){e+="?";a=true}else{e+="&"}e+=f+"="+g[f]}var d=Utils.getParamsFromURL(c);for(f in d){if(Utils.isValueInList(f.toUpperCase(),h)){continue}else{if(d[f]===""){continue}}if(a===false){e+="?";a=true}else{e+="&"}e+=f+"="+d[f]}return b+e};Utils.removeParamsInUrl=function(b,d){var h=b;if(b.indexOf("?")>0){h=b.substring(0,b.indexOf("?"))}var a="";var e=[];for(var g=0;g<d.length;g++){e.push(d[g].toUpperCase())}var f=Utils.getParamsFromURL(b);var j=false;for(var c in f){if(Utils.isValueInList(c.toUpperCase(),e)){continue}if(j===false){a+="?";j=true}else{a+="&"}a+=c+"="+f[c]}return h+a};Utils.isValueInList=function(c,b){var d=false;for(var a=0;a<b.length;a++){if(c===b[a]){d=true;break}}return d};Utils.getParamsFromURL=function(d){var g={};if(d.indexOf("?")>0){var f=d.substr(d.indexOf("?")+1);for(var e=0;e<2000;e++){var b=f.indexOf("&");if(b===-1){b=f.length}var a=f.substring(0,f.indexOf("="));var c=f.substring(f.indexOf("=")+1,b);g[a]=c;if(f.indexOf("&")<0){break}f=f.substr(f.indexOf("&")+1)}}return g};Utils.findPos=function(b){var c=0;var a=0;if(b.offsetParent){do{c+=b.offsetLeft;a+=b.offsetTop;WMSC.log(" obj, height, width , left, top= "+b+","+b.offsetHeight+","+b.offsetWidth+","+b.offsetLeft+","+b.offsetTop);b=b.offsetParent}while(b);return[c,a]}};Utils.reMatch=function(d,b){var c=new RegExp(d);var a=c.test(b);WMSC.log("expression ="+d+" text ="+b+" match = "+a);return a};Utils.alertErrorMessage=function(d,c,b){var a="Error: "+d+"\n";a+="URL: "+c+"\n";a+="Line: "+b+"\n\n";alert(a)};Utils.disableEnterKey=function(c){var a;if(window.event){a=window.event.keyCode}else{a=c.which}var b;if(a===13){WMSC.log("Enter detected");b=false;c.preventDefault()}else{b=true}return b};Utils.logAtts=function(b){for(var a in b){if(typeof(b[a])==="function"){WMSC.log(" "+a+" method")}else{WMSC.log(" "+a+" = "+b[a])}}};Utils.getContainedElementsByName=function(e,b){var d=e.getElementsByTagName("*");var a=[];for(var c=0;c<d.length;c++){if(d[c].name===b){a.push(d[c])}}return a};Utils.getDateString=function(){var b=new Date();function a(c){return c<10?"0"+c:c}return b.getUTCFullYear()+"-"+a(b.getUTCMonth()+1)+"-"+a(b.getUTCDate())+"T"+a(b.getUTCHours())+":"+a(b.getUTCMinutes())+":"+a(b.getUTCSeconds())+"Z"};Utils.getTimeString=function(){var b=new Date();function a(c){return c<10?"0"+c:c}return a(b.getUTCHours())+":"+a(b.getUTCMinutes())+":"+a(b.getUTCSeconds())+"."+b.getMilliseconds()};Utils.getObjString=function(b){var c="{";for(var a in b){c+="'"+a+"':"+b[a]+","}return c};Utils.buildObjectList=function(c,a){var d=[];if(a!==null){for(var b=0;b<a.length;b++){d.push(new c(a[b]))}}return d};Utils.hasAttr=function(c,a){for(var b in c){if(b===a){return true}}return false};"use strict";var Endpoint=function(a){for(var b=0;b<this.REQUIRED_PROPERTIES.length;b++){var d=this.REQUIRED_PROPERTIES[b];if(a[d]===undefined){var c="Requierd property '"+d+"' not found in conf"+Utils.getObjString(a);WMSC.log(c);throw (c)}else{this[d]=a[d]}}};Endpoint.prototype={REQUIRED_PROPERTIES:["url","name","service"]};"use strict";var FurtherInfoLink=function(a){var b,d;for(b=0;b<this.REQUIRED_PROPERTIES.length;b++){d=this.REQUIRED_PROPERTIES[b];if(a[d]===undefined){var c="Requierd property '"+d+"' not found in conf"+Utils.getObjString(a);WMSC.log(c);throw (c)}else{this[d]=a[d]}}for(b=0;b<this.OPTIONAL_PROPERTIES.length;b++){d=this.OPTIONAL_PROPERTIES[b];if(a[d]!==undefined){this[d]=a[d]}}};FurtherInfoLink.prototype={REQUIRED_PROPERTIES:["endpoint","link"],OPTIONAL_PROPERTIES:["name","image"],match:function(a){return Utils.reMatch(this.endpoint,a)},getHTML:function(){var a="info";if(Utils.hasAttr(this,"name")){a=this.name}a=a.escapeHTML();if(Utils.hasAttr(this,"image")){a=a+'<image src="'+escape(this.image)+'" />'}return'<a target="_blank" href="'+this.link+'">'+a+"</a>"}};"use strict";var DisplayOptionsRetriever=function(){this._lookup={}};DisplayOptionsRetriever.prototype={getDisplayOptions:function(c,a){if(this.isCached(c)){a(this._lookup[c])}else{var b=function(i){var g=null;try{g=JSON.parse(i.responseText)}catch(f){var h="Error occurred parsing JSON.\n Description:"+f.stack+"\n";WMSC.log(h)}this.addToLookup(c,g);a(g)};var e={REQUEST:"GetDisplayOptions",URL:c};var d=new Ajax.Request("",{parameters:e,method:"get",onSuccess:b.bindAsEventListener(this),onException:function(g,f){WMSC.log("Exception:"+f)}})}},addToLookup:function(a,b){this._lookup[a]=b},isCached:function(b){for(var a in this._lookup){if(a===b){return true}}return false}};"use strict";WMSC.VisApp=OpenLayers.Class.create();WMSC.VisApp.prototype={EVENT_TYPES:["MAP_SELECTION_CHANGED"],initialize:function(a,b,g,c,k,e,h){this.figureCounter=1;this.showCoast=c;this.eventsManager=e;this.bgImagePath=h;var j=360/g;var d=[];for(var f=0;f<b;f++){d.push(j/Math.pow(1.4,f))}this.map=new DDCVisMap(a,{resolutions:d,controls:[],tileSize:new OpenLayers.Size(320,320)});this.boxesLayer=new OpenLayers.Layer.Boxes("Sub-selection");this.subselControl=new SubSelectionMouseToolbar(new OpenLayers.Pixel(g-40,10),"vertical",this.boxesLayer);this.map.addControl(new OpenLayers.Control.LoadingPanel());this.map.addControl(this.subselControl);this.map.addControl(new OpenLayers.Control.PanZoomBar());this.map.addControl(new OpenLayers.Control.MousePosition());this.baseLayer=new OpenLayers.Layer.Image("None",this.bgImagePath,new OpenLayers.Bounds(-180,-90,180,90),new OpenLayers.Size(8,8),{isBaseLayer:true,resolutions:d});this.map.addLayer(this.baseLayer);this.map.setLayerIndex(this.baseLayer,0);this.map.addLayer(this.boxesLayer);this.map.setLayerIndex(this.boxesLayer,1);this.maxExtent=k;this.map.zoomToExtent(this.maxExtent);this.map.zoom=0;this.map.resolution=this.map.getResolutionForZoom(this.map.zoom);WMSC.log("this.map resolution= "+this.map.getResolution()+" zoom="+this.map.zoom+" maxExtent(b,l,t,r)="+this.map.maxExtent.bottom+","+this.map.maxExtent.left+","+this.map.maxExtent.top+","+this.map.maxExtent.right+" center(lat,lon)="+this.map.getCenter().lat+","+this.map.getCenter().lon+" size="+this.map.getSize().w+","+this.map.getSize().h+" bounds(b,l,t,r)="+this.map.calculateBounds().bottom+","+this.map.calculateBounds().left+","+this.map.calculateBounds().top+","+this.map.calculateBounds().right);this.subselControl.switchModeTo("zoombox");this._divId=a;this.eventsManager.register("TEXT_SELECTION_CHANGED",this,this.updateSelectionBox);this.eventsManager.register("clearSelection",this,this.resetMapCoords);this.eventsManager.register("LAYER_ORDER_CHANGED",this,this.onLayerOrderChanged);this.map.events.register("moveend",this,this.updateBoundsControl);this.map.events.register("zoomend",this,this.updateBoundsBoundsControl)},_logLocation:function(){WMSC.log("map div location = "+Utils.findPos(document.getElementById(this._divId)));WMSC.log("dims location= "+Utils.findPos(document.getElementById("dims")))},updateBoundsBoundsControl:function(a){WMSC.log("map zoomed -- this.map resolution = "+this.map.resolution+" zoom="+this.map.zoom+" maxExtent: b="+this.map.maxExtent.bottom+" l="+this.map.maxExtent.left+" t="+this.map.maxExtent.top+" r="+this.map.maxExtent.right)},onLayerOrderChanged:function(a){this.drawLayers(a.layers)},destroy:function(){if(this.dimControl){this.dimControl.destroy()}if(this.layerControl){this.layerControl.destroy()}this.subselControl.destroy()},_initCoast:function(a){if(!this.coastLayer||this.coastLayer.params.LAYERS!==a){this.coastLayer=new OpenLayers.Layer.WMS("Coastline","http://labs.metacarta.com/wms/vmap0",{layers:a,format:"image/gif",transparent:"true"})}this.map.addLayer(this.coastLayer)},updateVisLayer:function(){var c=this.map.getNumLayers();var d=0;for(d=0;d<c;d++){this.map.removeLayer(this.map.layers[0])}if(!this.visLayer){this.visLayer=new OpenLayers.Layer.WMS("OpenLayers WMS","http://labs.metacarta.com/wms/vmap0",{layers:"basic",format:"image/png"});this._mergeDimParams(this.visLayer)}this.map.addLayer(this.visLayer);var e=document.getElementById("layerlist");if(e!==null){for(d=e.childNodes.length-1;e&&d>=0;d--){var h=e.childNodes[d];if(h.className==="hiddenList"){continue}if(h.nodeName==="LI"){var g=h.getAttribute("wmcURL");var f=h.getAttribute("title");var b=h.getAttribute("layerName");var a=new OpenLayers.Layer.WMS(f,g,{format:"image/gif",version:"1.3.0",CRS:"CRS:84",layers:b,styles:"",transparent:"true"});this._mergeDimParams(a);this.map.addLayer(a)}}}if(this.showCoast){this._initCoast("coastline_01")}this.map.addLayer(this.boxesLayer);this.loadLegend()},_mergeDimParams:function(a){if(this.dimControl&&this.dimControl.wmsParams){a.mergeNewParams(this.dimControl.wmsParams)}a.setZIndex(300)},resetMapCoords:function(){WMSC.log("resetMapCoords");this.subselControl.deactivateSubsel();this.map.zoomToExtent(this.maxExtent);this.updateBoundsControl()},loadLegend:function(){var e=$("legend");if(!e){return}var g=function(j){$("legend").innerHTML="";var i=j.responseText;if(i){$("legend").innerHTML=i}};var c=function(i){};var a=this.map.layers.length;if(a<4){e.innerHTML="";return}var d=this.map.layers[a-3];if(d.url===null){e.innerHTML=""}else{var b=d.getFullRequestString({REQUEST:"GetLegend"});var h={REQUEST:"GetLegend",ENDPOINT:b};var f=new Ajax.Request("",{parameters:h,method:"get",onSuccess:g.bindAsEventListener(this),onFailure:c.bindAsEventListener(this)})}},updateBoundsControl:function(){var a=this.subselControl.getActiveBounds();WMSC.log("triggering MAP_SELECTION_CHANGED, selection = "+a);this.eventsManager.triggerEvent("MAP_SELECTION_CHANGED",{selection:a})},updateSelectionBox:function(d){WMSC.log("started update selection box");var a=this.subselControl.getActiveBounds();var c=d.selection;if(!(c.left>-180&&c.left<180)){c.left=a.left}if(!(c.right>-180&&c.right<180)){c.right=a.right}if(!(c.top>-90&&c.top<90)){c.top=a.top}if(!(c.bottom>-90&&c.bottom<90)){c.bottom=a.bottom}var b;if(c.left>c.right){b=c.left;c.left=c.right;c.right=b}if(c.bottom>c.top){b=c.bottom;c.bottom=c.top;c.top=b}this.subselControl.setSubSel(c);WMSC.log("finished update selection box")},drawLayers:function(e){var d;if(this.map.layers.length>0){var f=[];for(d=0;d<this.map.layers.length;d++){if(this.map.layers[d]!==this.baseLayer&&this.map.layers[d]!==this.boxesLayer){f.push(this.map.layers[d])}}for(d=0;d<f.length;d++){var c=f[d];this.map.removeLayer(c)}}var a=1;if(e.length>0){for(d=e.length-1;d>=0;d--){var b=e[d];this.map.addLayer(b);this.map.setLayerIndex(b,a);a++}}this.map.setLayerIndex(this.boxesLayer,a)}};"use strict";WMSC.VisAppLayers=OpenLayers.Class.create();function prependChild(a,b){a.insertBefore(b,a.firstChild)}function isPopupBlocker(){var a=window.open("./","testpopupblocker");if(a===null||typeof(a)==="undefined"){return true}else{a.close();return false}}WMSC.VisAppLayers.prototype={EVENT_TYPES:["NEW_LAYER"],treeDiv:null,layerDiv:null,events:null,initialize:function(g,h,f,c,i,a,b,e){WMSC.log("Initialising Control");this.treeDiv=g;this.layerDiv=h;this.wmcRetriever=f;this.endpointInputBox=$(c);this.addNewEndpointBtn=$(i);if(this.addNewEndpointBtn!==null){this.addNewEndpointBtn.onclick=this.onNewEndpointClick.bindAsEventListener(this)}this.eventsManager=b;this.furtherInfoLinks=e;this._selectedTreeNode=null;this._selectedLayer=null;this.tree=new YAHOO.widget.TreeView(this.treeDiv);this.tree.subscribe("clickEvent",this._onTreeClick.bindAsEventListener(this));this.tree.subscribe("expand",function(j){this._selectTreeNode(j);return true}.bindAsEventListener(this));this.idIndex=0;var d={format:"image/png",version:"1.3.0",CRS:"CRS:84",transparent:"true"};this.defaultSetter=new LayerDefaultSetter(d,a);this.layersToSelect={};this._delIconHandlers={};this.eventsManager.register("NEW_ENDPOINT",this,this.onNewEndpoint)},destroy:function(){this.tree.unsubscribe()},addListeners:function(){var b;for(b=0;b<this.tree.getRoot().children.length;b++){var a=this.tree.getRoot().children[b].index;var d=document.getElementById("delIcon_"+a);if(d!==null){this._delIconHandlers[d.id]=Utils.addHTMLEventListener(d,"click",this._removeNode,this)}}var c=document.getElementsByClassName("nodeInfo");for(b=0;b<c.length;b++){Utils.addHTMLEventListener(c[b],"click",this._onInfoNodeClick,this)}},removeListeners:function(){Utils.removeEventHandlersFromLookup(this._delIconHandlers);this._delIconHandlers={}},redrawTree:function(){this.removeListeners();this.tree.draw();this.addListeners();if(this._selectedTreeNode!==null){if(this._selectedTreeNode.labelElId){var a=$(this._selectedTreeNode.labelElId);if(a===null){this._selectedTreeNode=null}else{a.className="WMSC_selectedField"}}}},addWebMapContext:function(a){var h=this.tree.getRoot();var d='<table><tr><td class="nodeTitle">...loading</td></tr></table>';var f=new YAHOO.widget.TextNode({label:d},h,false);var e=function(k){this.tree.removeNode(f);var j=this._addWMCTree(k,a);this.redrawTree();if(this.layersToSelect[a]!==undefined){this._selectEndpointLayers(a,this.layersToSelect[a]);this.layersToSelect[a]=undefined}};var c=function(j){this.tree.removeNode(f);this.redrawTree();alert("Login was unsucessful");return false};var b=function(l){if(l.status===302){if(!isPopupBlocker()){window.showModalDialog("./securityredirect","please log in","dialogHeight=350px","dialogWidth=500px");var j=e.bindAsEventListener(this);var k=c.bindAsEventListener(this);this.wmcRetriever.getWMC(a,j,k)}else{alert("Please enable popups for this site to login to the secure WMS")}}else{alert("Attempt to retrive endpoint "+a+" failed, response.status = "+l.status+" ("+l.statusText+").");this.tree.removeNode(f);this.redrawTree();WMSC.log("Attempt to retrive endpoint "+a+" failed, response.status = "+l.status+" ("+l.statusText+").")}};this.redrawTree();var i=e.bindAsEventListener(this);var g=b.bindAsEventListener(this);this.wmcRetriever.getWMC(a,i,g)},_addWMCTree:function(g,a,f){var e;var b={};var c=g.getTitle();var k=[];if(this.furtherInfoLinks!==null){for(e=0;e<this.furtherInfoLinks.length;e++){var h=this.furtherInfoLinks[e];if(h.match(a)){k.push(h)}}}b.label=c;b.layer=g.getTitle();b["abstract"]=g.getTitle();b.wmcEndpoint=a;var j=new YAHOO.widget.MenuNode(b,this.tree.getRoot(),false);j.label=this._createNodeLabel(c,j.index,k);var d=g.getSubLayers();for(e=0;e<d.length;e++){this._addLayerTree(d[e],a,j)}return j},_addLayerTree:function(d,h,a){var f=d.getAbstract();if(f===null||f===""){f=d.getTitle()}var b={};b.wmcEndpoint=h;b.label=f;b.layer=d.getName();b["abstract"]=d.getAbstract();b.layerData=d;b.title=d.getAbstract();var g=new YAHOO.widget.MenuNode(b,a,false);var e=d.getSubLayers();for(var c=0;c<e.length;c++){this._addLayerTree(e[c],h,g)}return g},_createNodeLabel:function(f,e,d){if(d===undefined||d.length===0){return'<table><tr><td class="nodeTitle">'+f+'</td><td class="delIcon"><img id="delIcon_'+e+'" src="js/img/close.gif" /></td></tr></table>'}else{var b="";for(var a=0;a<d.length;a++){var c=d[a];b+='<td class="nodeInfo">'+c.getHTML()+"</td>"}return'<table><tr><td class="nodeTitle">'+f+"</td>"+b+'<td class="delIcon"><img id="delIcon_'+e+'" src="js/img/close.gif" /></td></tr></table>'}},_removeNode:function(a){var c=Event.element(a);var d=c.id.substring(c.id.indexOf("_")+1,c.id.length);var b=this.tree.getNodeByIndex(d);this.tree.removeNode(b);this.redrawTree()},_onTreeClick:function(a){var b=a.node;this._selectTreeNode(b)},_selectTreeNode:function(b){var a;a=this._selectedTreeNode;while(a!==null){if(a.labelElId){$(a.labelElId).className=this._selectedTreeNode.labelStyle;a=a.parent}else{a=null}}this._selectedTreeNode=b;a=this._selectedTreeNode;while(a!==null){if(a.labelElId){$(a.labelElId).className="WMSC_selectedField";a=a.parent}else{a=null}}if(b.children.length===0){if(b.label.indexOf("...loading")>-1){return}this._addLayer(b);this._selectedLayer=b}},_addLayer:function(b){var a=this.makeNewLayer(b.data.wmcEndpoint,b.data.layer);this.eventsManager.triggerEvent("NEW_LAYER",{layer:a});return},makeNewLayer:function(c,b){var e=this.defaultSetter.getDefaults(c,b);var a=["request","service"];c=Utils.removeParamsInUrl(c,a);var d=new OpenLayers.Layer.WMS("#"+this.idIndex+" "+b,c,e,{isBaseLayer:false,buffer:0});d.params.LAYERS=b;d.id=c+"_"+d.name+"_"+this.idIndex;this.idIndex+=1;return d},onNewEndpointClick:function(a){this.addWebMapContext(this.endpointInputBox.value)},onNewEndpoint:function(a){this.addWebMapContext(a.url)},addLayersToSelect:function(b,a){this.layersToSelect[b]=a},_selectEndpointLayers:function(a,f){var d=this._getNodeForEndpoint(a);if(d===null){WMSC.log("No node found for endpoint "+a);return}if(d.expanded===false){d.expand()}for(var c=0;c<f.length;c++){var b=f[c];var e=this._getChildNodeForLayer(d,b);if(e===null){WMSC.log("No node found for layer "+b+" in endpoint "+a);continue}e.expand()}},_getNodeForEndpoint:function(a){var d=this.tree.root.children;for(var b=0;b<d.length;b++){var c=d[b];if(c.data.wmcEndpoint===a){return c}}return null},_getChildNodeForLayer:function(c,a){for(var b=0;b<c.children.length;b++){var d=c.children[b];if(d.data.layer===a){return d}}return null},_onInfoNodeClick:function(a){if(!a){a=window.event}a.cancelBubble=true;if(a.stopPropagation){a.stopPropagation()}return false}};"use strict";WMSC.nsMap={wms:"http://www.opengis.net/wms",xlink:"http://www.w3.org/1999/xlink"};WMSC._searchElement=function(e,d){var c,a,b;b=e.childNodes;for(c=0;c<b.length;c++){a=b[c];if(a.nodeName==d){return a}}return null};WMSC.traverseWMSDom=function(b,c){var a;for(a=0;a<c.length;a++){b=WMSC._searchElement(b,c[a]);if(b===null){return null}}return b};WMSC.getTextContent=function(a){if(a.textContent){return a.textContent}else{return a.text}};WMSC.Capabilities=function(a){this.dom=a};WMSC.Capabilities.prototype={evaluate:function(b,a){if(a===null){a=this.dom}return WMSC.evalXPath(b,a)},getTitle:function(){var a=WMSC.traverseWMSDom(this.dom,["Service","Title"]);return WMSC.getTextContent(a)},getAbstract:function(){var a=WMSC.traverseWMSDom(this.dom,["Service","Abstract"]);return WMSC.getTextContent(a)},getRootLayer:function(){var a=WMSC.traverseWMSDom(this.dom,["Capability","Layer"]);if(a===null){return null}return new WMSC.Layer(a)},getEndpoint:function(){var b=WMSC.traverseWMSDom(this.dom,["Service","OnlineResource"]);if(b===null){return null}var a=b.getAttribute("href");if(!a){a=b.getAttribute("xlink:href")}return a},getSubLayers:function(){return this.getRootLayer().getSubLayers()},getAllRequests:function(){var a;var b=WMSC.traverseWMSDom(this.dom,["Capability","Request"]);a=this._getRequestsFromNode(b);var c=WMSC.traverseWMSDom(this.dom,["Capability","_ExtendedCapabilities","Request"]);if(c!==null){a=a.concat(this._getRequestsFromNode(c))}return a},_getRequestsFromNode:function(f){var b=[];for(var d=0;d<f.childNodes.length;d++){var g=f.childNodes[d];if(g.nodeType!=1){continue}var c=g.nodeName;var a=this._getRequestFormats(g);var e=new WMSC.Request(c,a);b.push(e)}return b},_getRequestFormats:function(c){var b;var a=[];for(b=0;b<c.childNodes.length;b++){var d=c.childNodes[b];if(d.nodeName.toUpperCase()=="FORMAT"){a.push(WMSC.getTextContent(d))}}return a},getRequest:function(b){var a=this.getAllRequests();for(var c=0;c<a.length;c++){if(a[c].name==b){return a[c]}}return null},supportsRequest:function(a){return this.getRequest(a)!==null}};WMSC.Layer=function(a){this.node=a};WMSC.Layer.prototype={getName:function(){var a=WMSC.traverseWMSDom(this.node,["Name"]);if(a===null){return null}return WMSC.getTextContent(a)},getTitle:function(){var a=WMSC.traverseWMSDom(this.node,["Title"]);return WMSC.getTextContent(a)},getAbstract:function(){var a=WMSC.traverseWMSDom(this.node,["Abstract"]);if(!a){return""}return WMSC.getTextContent(a)},getDimensions:function(){var b;var a;var d={};var c=this.node.getElementsByTagName("Dimension");for(b=0;b<c.length;b++){a=new WMSC.Dimension(c[b]);d[a.getName()]=a}return d},getSubLayers:function(){var b,a,d;var c=[];a=this.node.childNodes;for(b=0;b<a.length;b++){d=a[b];if(d.nodeName=="Layer"){c[c.length]=new WMSC.Layer(d)}}return c},getEndpoint:function(){var b=WMSC.traverseWMSDom(this.node,["Server","OnlineResource"]);if(b===null){return null}var a=b.getAttribute("href");if(!a){a=b.getAttribute("xlink:href")}return a},getStyles:function(){var f=[];for(var c=0;c<this.node.getElementsByTagName("Style").length;c++){var b=this.node.getElementsByTagName("Style")[c];var d=WMSC.traverseWMSDom(b,["Name"]);var a=WMSC.traverseWMSDom(b,["Title"]);var g=WMSC.getTextContent(d);var e=WMSC.getTextContent(a);f.push(new WMSC.Style(g,e))}return f},getLegendURL:function(a){if(a===null||a===""){a=undefined}var b=this.getStyles();if(b.length===0){return null}WMSC.log("style = "+a);if(a===undefined){return this._getLegendURLForStyle(b[0].name)}else{return this._getLegendURLForStyle(a)}},_getLegendURLForStyle:function(f){var d=null;for(var c=0;c<this.node.getElementsByTagName("Style").length;c++){var b=this.node.getElementsByTagName("Style")[c];var a=WMSC.traverseWMSDom(b,["Name"]);var e=WMSC.getTextContent(a);if(e===f){var g=WMSC.traverseWMSDom(b,["LegendURL","OnlineResource"]);d=this._getLinkFromORElement(g);break}}return d},getDisplayOptionsURL:function(){var b=null;for(var a=0;a<this.node.getElementsByTagName("MetadataURL").length;a++){var d=this.node.getElementsByTagName("MetadataURL")[a];if(d!==undefined&&d.getAttribute("type")=="display_options"){var c=WMSC.traverseWMSDom(d,["OnlineResource"]);b=this._getLinkFromORElement(c)}}return b},getAxisConfigURL:function(){var a=null;for(var b=0;b<this.node.getElementsByTagName("MetadataURL").length;b++){var d=this.node.getElementsByTagName("MetadataURL")[b];if(d!==undefined&&d.getAttribute("type")=="axis_config"){var c=WMSC.traverseWMSDom(d,["OnlineResource"]);a=this._getLinkFromORElement(c)}}return a},_getLinkFromORElement:function(c){var a=null;for(var b=0;b<c.attributes.length;b++){if(c.attributes[b].name=="xlink:href"){a=c.attributes[b].value}}return a}};WMSC.Dimension=function(a){this.node=a};WMSC.Dimension.prototype={getName:function(){var a=this.node.attributes.getNamedItem("name");return a.value},getUnits:function(){var a=this.node.attributes.getNamedItem("units");return a.value},getExtent:function(){if(this.node.textContent){return this.node.textContent.split(",")}else{return this.node.text.split(",")}}};WMSC.Style=function(a,b){this.name=a;this.title=b};WMSC.Request=function(b,a){this.name=b;this.formats=a};WMSC.WebMapContext=function(a){this.dom=a};WMSC.WebMapContext.prototype={evaluate:function(b,a){if(a===null){a=this.dom}return WMSC.evalXPath(b,a)},getTitle:function(){var a=WMSC.traverseWMSDom(this.dom,["General","Title"]);return WMSC.getTextContent(a)},getSubLayers:function(){var c=WMSC._searchElement(this.dom,"LayerList");var b=c.childNodes;var d=[];for(var a=0;a<b.length;a++){if(b[a].nodeName=="Layer"){d[d.length]=new WMSC.Layer(b[a])}}return d}};"use strict";var WCSDownloadControl=function(a,b,c){this.downloadButton=this.createDownloadButton();this.eventsManager=c;this.downloadDiv=document.getElementById(a);this.currentBounds=b;this.currentLayer=null;this._retriever=new AjaxRetriever();Utils.addHTMLEventListener(this.downloadButton,"click",this.setupWCSrequest,this);this.downloadDiv.appendChild(this.downloadButton);this.eventsManager.register("MAP_SELECTION_CHANGED",this,this._onMapSelectionChanged);this.eventsManager.register("SELECTED_LAYER_CHANGED",this,this._onSelectedLayerChanged)};WCSDownloadControl.prototype={createDownloadButton:function(){var a=document.createElement("input");a.type="submit";a.id="wcsdownload";a.value="Download Data";return a},_onMapSelectionChanged:function(a){this.currentBounds=a.selection},_onSelectedLayerChanged:function(a){this.currentLayer=a.layer;if(this.currentLayer===null){this.downloadButton.disabled=true}else{this.downloadButton.disabled=false;WMSC.log("WCS endpoint is now "+this._getWCSEndpoint())}return 1},setupWCSrequest:function(){if(this.currentLayer===null){alert("No layer currently selected.");return}var a=this._getWCSEndpoint();var c=document.getElementById("coordsForm");var b=this.currentBounds.left+","+this.currentBounds.bottom+","+this.currentBounds.right+","+this.currentBounds.top;var d=layerParameters.layerDims.getSelectedDimensions();this.makeWCSrequest(a,this.currentLayer.params.LAYERS,b,d)},makeWCSrequest:function(c,b,h,g){var f={request:"GetCoverage",service:"WCS",version:"1.0.0",crs:"EPSG:4326",format:"cf-netcdf"};f.coverage=b;f.bbox=h;for(var a in g){f[a]=g[a]}var d=c;for(var e in f){d=d+e+"="+f[e]+"&"}WMSC.log("Making wcs request to "+d);window.open(d,"download");return false},_getWCSEndpoint:function(){var c=this.currentLayer.getFullRequestString();var b=c.split("?");var a=b[0].replace("wms","wcs")+"?";return a}};"use strict";var LayerFigureDownload=function(a,b){this._container=document.getElementById(a);this._container.innerHTML=this.controlMarkup;this._form=document.getElementById("layer_figure_download_form");this.eventsManager=b;this.displayOptsRetriever=new DisplayOptionsRetriever();this.currentWMCLayer=null;this.currentOLLayer=null;this._hiddenInputContainer=null;this._selectHandler=null;this._getFigureHandler=null;this._getFigureButton=null;this._styleSelect=null;this._currentSelection=new OpenLayers.Bounds(-180,-90,180,90);this.eventsManager.register("CURRENT_WMCLAYER_CHANGED",this,this._onCurrentLayerChanged)};LayerFigureDownload.prototype={EVENTS_RAISED:[],LABEL_TEXT:"Get Figure for Selected Layer",controlMarkup:'<form id="layer_figure_download_form">\n</form>\n',_onCurrentLayerChanged:function(a){this._clearForm();if(a.wmcLayer!==null&&a.olLayer!==null){this._buildInfo(a.wmcLayer,a.olLayer,a.wmc)}this.currentOLLayer=a.olLayer;this.currentWMCLayer=a.wmcLayer},_buildInfo:function(d,c,b){if(b.supportsRequest("GetFigure")){var a=Utils.buildLabel(this.LABEL_TEXT);this._form.appendChild(a);this._form.appendChild(this._buildGetFigureButton(b));this._form.appendChild(document.createTextNode("\n"))}this._hiddenInputContainer=document.createElement("div");this._form.appendChild(this._hiddenInputContainer)},_clearForm:function(){if(this._styleSelect!==null&&this._selectHandler!==null){Utils.removeHTMLEventListener(this._styleSelect,"change",this._selectHandler)}if(this._getFigureButton!==null&&this._getFigureHandler!==null){Utils.removeHTMLEventListener(this._getFigureButton,"click",this._getFigureHandler)}this._form.innerHTML="";this._styleSelect=null;this._selectHandler=null;this._getFigureButton=null;this._getFigureHandler=null;this._hiddenInputContainer=null},_getLayerProperty:function(b,c){var a=null;if(b!==null){a=b.params[c.toUpperCase()]}return a},_buildGetFigureButton:function(d){var b;var h=document.createElement("div");var e=d.getRequest("GetFigure");var c=[];var g=[];var f=e.formats;for(b=0;b<f.length;b++){g.push(f[b]);if(f[b]==="image/svg+xml"){c.push("SVG")}else{if(f[b].indexOf("image/")===0){c.push(f[b].slice(6,f[b].length).toUpperCase())}else{if(f[b]==="application/postscript"){c.push("PS")}else{if(f[b]==="application/pdf"){c.push("PDF")}else{c.push(f[b])}}}}}var a=Utils.buildSelect(null,"format",c,g);h.appendChild(a);this._getFigureButton=document.createElement("input");this._getFigureButton.type="button";this._getFigureButton.value="Get Figure";this._getFigureHandler=Utils.addHTMLEventListener(this._getFigureButton,"click",this._onGetFigureClick,this);h.appendChild(this._getFigureButton);return h},_onGetFigureClick:function(a){WMSC.log("_onGetFigureClick running");this._addHiddenInputItems();this._form.action=this.currentOLLayer.url;this._form.method="get";this._form.target="_blank";this._form.submit()},_addHiddenInputItems:function(){this._hiddenInputContainer.innerHTML="";for(var b in this.currentOLLayer.params){if(b.toUpperCase()==="REQUEST"){this._hiddenInputContainer.appendChild(Utils.buildHiddenInputElement("REQUEST","GetFigure"))}else{if(b.toUpperCase()==="FORMAT"){}else{this._hiddenInputContainer.appendChild(Utils.buildHiddenInputElement(b,this.currentOLLayer.params[b]))}}}var a=this._currentSelection.left+","+this._currentSelection.bottom+","+this._currentSelection.right+","+this._currentSelection.top;this._hiddenInputContainer.appendChild(Utils.buildHiddenInputElement("BBOX",a));this._hiddenInputContainer.appendChild(Utils.buildHiddenInputElement("WIDTH","1200"));this._hiddenInputContainer.appendChild(Utils.buildHiddenInputElement("HEIGHT","900"))},addMapSelectionChangedHandlers:function(a){a.register("MAP_SELECTION_CHANGED",this,this.onChangeSelection)},onChangeSelection:function(a){this._currentSelection=a.selection}};"use strict";var LayerInfo=function(a,b,c){if(c===undefined){this.furtherInfoLinks=[]}else{this.furtherInfoLinks=c}this._container=document.getElementById(a);this.eventsManager=b;this.eventsManager.register("CURRENT_WMCLAYER_CHANGED",this,this._onCurrentLayerChanged)};LayerInfo.prototype={EVENTS_RAISED:[],_onCurrentLayerChanged:function(a){if(a.wmcLayer!==null&&a.olLayer!==null){this._buildInfo(a.wmcLayer,a.olLayer)}else{this._clearInfo()}},_buildInfo:function(f,d){var e=document.createElement("div");e.appendChild(this._buildInfoItem("URL",d.url));e.appendChild(this._buildInfoItem("Layer Name",this._getLayerProperty(d,"layers")));e.appendChild(this._buildInfoItem("Layer Abstract",f.getAbstract()));var a="";for(var b=0;b<this.furtherInfoLinks.length;b++){var c=this.furtherInfoLinks[b];if(c.match(d.url)){a=a+c.getHTML()+", "}}if(a.length>0){a=a.slice(0,a.length-2);e.appendChild(this._buildInfoItem("Further Info",a))}this._clearInfo();this._container.appendChild(e)},_clearInfo:function(){this._container.innerHTML=""},_getLayerProperty:function(b,c){var a=null;if(b!==null){a=b.params[c.toUpperCase()]}return a},_buildInfoItem:function(a,c){var b=document.createElement("span");b.innerHTML=c;return Utils.buildLabelInputDiv(a,b,"layerInfoItem")}};"use strict";var DDM=YAHOO.util.DragDropMgr;var LayerList=OpenLayers.Class.create();LayerList.prototype={EVENTS_RAISED:["SELECTED_LAYER_CHANGED","LAYER_ORDER_CHANGED","LAYER_REMOVED"],MAX_LAYERS:10,events:null,SELECTED_CLASS:"selected",initialize:function(a,c,b){this._dragList=document.getElementById(a);this._outlineOnTopChk=document.getElementById(c);this.eventsManager=b;while(this._dragList.childNodes[0]){this._dragList.removeChild(this._dragList.childNodes[0])}this._layers=[];this.target=new YAHOO.util.DDTarget(a);this.removeLayerBtn=document.getElementById("btn_remove_selected_layer");Utils.addHTMLEventListener(this.removeLayerBtn,"click",this._onRemoveClick,this);Utils.addHTMLEventListener(this._outlineOnTopChk,"click",this._onOutlineOnTopClick,this);this.eventsManager.register("NEW_OUTLINE",this,this.onNewLayer);this.eventsManager.register("NEW_LAYER",this,this.onNewLayer)},_addOnClickListeners:function(){var a=this._getCurrentListItems();for(var b=0;b<a.length;b++){Utils.addHTMLEventListener(a[b],"click",this._onItemClick,this)}},_onItemClick:function(b){var a=b.target||b.srcElement;this._selectItem(a)},_onDragEnd:function(a){this._selectItem(a);if(this._outlineOnTopChk.checked&&this._isOutlineInList()){if(!this._isOutlineOnTop()){this._moveOutlineToTop()}}this._triggerLayerOrderChange()},_onRemoveClick:function(c,d){var a=this.getSelectedLayer();if(a!==null){var e=a.id;this._removeSelectedItem();var b=this._getCurrentListItems();if(b.length>1){if(b[0].id==="outline_layer"){this._selectItem(b[1])}else{this._selectItem(b[0])}}else{if(b.length===1){this._selectItem(b[0])}}this._triggerLayerRemoved(e);this._triggerLayerOrderChange();this._triggerSelectedLayerChange()}},_onOutlineOnTopClick:function(a){if(this._outlineOnTopChk.checked&&this._isOutlineInList()){if(!this._isOutlineOnTop()){this._moveOutlineToTop();this._triggerLayerOrderChange()}}},_selectItem:function(a){if(!this._isSelected(a)){this._unselectAll();a.className=this.SELECTED_CLASS+" "+a.className;this._triggerSelectedLayerChange()}},_unselectAll:function(){var a=this._getCurrentListItems();for(var b in a){this._unselectItem(a[b])}},_unselectItem:function(a){if(this._isSelected(a)){a.className=a.className.slice(this.SELECTED_CLASS.length)}},_isSelected:function(a){if(a.className!==undefined){return a.className.slice(0,this.SELECTED_CLASS.length)===this.SELECTED_CLASS}return false},_getSelectedItem:function(){var a=this._getCurrentListItems();for(var b in a){if(this._isSelected(a[b])){return a[b]}}return null},_removeSelectedItem:function(){var a=this._getSelectedItem();this._removeItem(a)},_removeItem:function(b){if(b!==null){var a=DDM.getDDById(b.id);if(a!==null){a.unreg()}this._removeLayer(b.id);this._dragList.removeChild(b)}},_removeLayer:function(a){var d=this._layers;var e=[];for(var c=0;c<d.length;c++){var b=d[c];if(b.id!==a){e.push(b)}}this._layers=e},_addListItem:function(e){var b=this._getCurrentListItems();var d=Utils.buildScopedFunction(this._onDragEnd,this);var c=new YAHOO.example.DDList(e.id,d);var a=document.createElement("li");var f=this._dragList.firstChild;if(f===null){this._dragList.appendChild(a)}else{if(e.id==="outline_layer"){this._dragList.insertBefore(a,f)}else{if(this._outlineOnTopChk.checked&&this._isOutlineInList()){if(f.id!=="outline_layer"){this._moveOutlineToTop()}this._dragList.insertBefore(a,f.nextSibling)}else{this._dragList.insertBefore(a,f)}}}a.className="list";a.id=e.id;a.appendChild(document.createTextNode(e.name));this._addOnClickListeners();return a},_getCurrentListItems:function(){var a=[];for(var b=0;b<this._dragList.childNodes.length;b++){var c=this._dragList.childNodes[b];if(c.nodeType===1&&c.nodeName==="LI"){a.push(c)}}return a},onNewLayer:function(c){if(this._layers.length>=this.MAX_LAYERS){alert("Can't have more than "+this.MAX_LAYERS+" layers in the list.")}else{var a=false;for(var b=0;b<this._layers.length;b++){if(this._layers[b].id===c.layer.id){a=true}}if(a){alert("Layer with id = "+c.layer.id+" already in the list")}else{this._addLayer(c.layer)}}},_addLayer:function(a){this._layers.push(a);var b=this._addListItem(a);this._triggerLayerOrderChange();this._selectItem(b)},_triggerLayerOrderChange:function(){this.eventsManager.triggerEvent("LAYER_ORDER_CHANGED",{layers:this._getOrderedLayers()})},_triggerSelectedLayerChange:function(){this.eventsManager.triggerEvent("SELECTED_LAYER_CHANGED",{layer:this.getSelectedLayer()})},_triggerLayerRemoved:function(a){this.eventsManager.triggerEvent("LAYER_REMOVED",{layer_id:a})},_getOrderedLayers:function(){var a=this._getCurrentListItems();var d=[];for(var c=0;c<a.length;c++){var b=a[c].id;d.push(this._getLayerById(b))}return d},_getLayerById:function(b){for(var a=0;a<this._layers.length;a++){if(this._layers[a].id===b){return this._layers[a]}}return null},getSelectedLayer:function(){var b=this._getSelectedItem();var a;if(b===null){a=null}else{a=this._getLayerById(b.id)}return a},destroy:function(){this.target.unreg();this._removeAllItems()},_isOutlineInList:function(){return this._getLayerById("outline_layer")!==null},_isOutlineOnTop:function(){return this._dragList.firstChild.id==="outline_layer"},_moveOutlineToTop:function(){var b=this._dragList.firstChild;if(b.id==="outline_layer"){return}var d=null;for(var a=1;a<this._dragList.childNodes.length;a++){var c=this._dragList.childNodes[a];if(c.id==="outline_layer"){d=c;break}}if(d!==null){this._dragList.insertBefore(d,b)}},_removeAllItems:function(){var a=this._getCurrentListItems();for(var b=0;b<a.length;b++){this._removeItem(a[b])}}};"use strict";var LayerDisplayOpts=function(a,b,c){this._form=document.getElementById(a);this.eventsManager=c;this.displayOptsRetriever=new DisplayOptionsRetriever();this.hideDisplayOptions=b;this.currentWMCLayer=null;this.currentOLLayer=null;this._handlerLookup=null;this.eventsManager.register("LAYER_STYLE_CHANGED",this,this._onLayerStyleChanged);this.eventsManager.register("CURRENT_WMCLAYER_CHANGED",this,this._onCurrentLayerChanged)};LayerDisplayOpts.prototype={EVENTS_RAISED:["LAYER_DISPLAY_CHANGED"],_onSelectionChange:function(c){var b=c.target||c.srcElement;var d=b.id.substr(7);var a=b.value;if(b.type==="checkbox"){a=(b.checked)?"True":"False"}WMSC.log("value = "+a);a=escape(a);WMSC.log("escaped value = "+a);this.eventsManager.triggerEvent("LAYER_DISPLAY_CHANGED",{param:d,value:a})},_onLayerStyleChanged:function(a){this._buildDisplayControls()},_onCurrentLayerChanged:function(a){this._clearForm();this.currentWMCLayer=a.wmcLayer;this.currentOLLayer=a.olLayer;if(a.wmcLayer!==null&&a.olLayer!==null){this._buildDisplayControls()}},_buildDisplayControls:function(){var b=this.currentWMCLayer.getDisplayOptionsURL();if(b!==null){var a=this._buildDisplayOptions.bindAsEventListener(this);this.displayOptsRetriever.getDisplayOptions(b,a)}else{this._buildDisplayOptions(null)}},_clearForm:function(){if(this._handlerLookup!==null){Utils.removeEventHandlersFromLookup(this._handlerLookup,"change");this._handlerLookup=null}this._form.innerHTML=""},_buildDisplayOptions:function(g){this._clearForm();var f=this.currentOLLayer.url;var e=[];if(this.hideDisplayOptions!==null){for(var c=0;c<this.hideDisplayOptions.length;c++){if(Utils.reMatch(this.hideDisplayOptions[c].endpoint,f)){for(var b=0;b<this.hideDisplayOptions[c].options.length;b++){e.push(this.hideDisplayOptions[c].options[b])}}}}var h=document.createElement("div");var d=this.currentWMCLayer.getStyles();var a=this._getCurrentLayerProperty("styles");h.appendChild(this._buildGenericDisplayOptions(d,a,e));if(g!==null){if(g.common!==undefined){h.appendChild(this._buildDisplayOptionsList(g.common,e))}if(a!==null){if(g[a]!==undefined){h.appendChild(this._buildDisplayOptionsList(g[a],e))}}}this._form.innerHTML="";this._form.appendChild(h);this._handlerLookup=Utils.addHandlerToFormElements(this._form,"change",this._onSelectionChange,this)},_buildGenericDisplayOptions:function(c,a,b){var d=document.createElement("div");if(c.length>0){d.appendChild(this._buildStyleSelect(c,a))}if(!Utils.isValueInList("transparent",b)){d.appendChild(this._buildDisplayOptionBool({name:"transparent",title:"Transparent Background",defaultValue:"true"}))}if(!Utils.isValueInList("bgcolor",b)){d.appendChild(this._buildDisplayOptionValue({name:"bgcolor",title:"Background Colour",defaultValue:null}))}return d},_buildDisplayOptionsList:function(d,c){var e=document.createElement("div");for(var b=0;b<d.length;b++){var a=d[b];if(Utils.isValueInList(a.name,c)){continue}if(a.type==="select"){e.appendChild(this._buildDisplayOptionSelect(a))}else{if(a.type==="value"){e.appendChild(this._buildDisplayOptionValue(a))}else{if(a.type==="bool"){e.appendChild(this._buildDisplayOptionBool(a))}}}}return e},_buildDisplayOptionSelect:function(b){var c=this._getDisplayOptionTitle(b);var e=this._getDefaultValue(b);var a=Utils.buildSelectBox(b.name,b.options,b.options,e);var d=Utils.buildLabelInputDiv(c,a,"displayOptionItem");return d},_buildDisplayOptionValue:function(b){var c=this._getDisplayOptionTitle(b);var a=document.createElement("input");a.id="select_"+b.name;a.name="select_"+b.name;a.type="text";a.value=this._getDefaultValue(b);Utils.addHTMLEventListener(a,"keypress",Utils.disableEnterKey,this);var d=Utils.buildLabelInputDiv(c,a,"displayOptionItem");return d},_buildDisplayOptionBool:function(b){var c=this._getDisplayOptionTitle(b);var a=document.createElement("input");a.id="select_"+b.name;a.name="select_"+b.name;a.type="checkbox";a.onClick="";var e=this._getDefaultValue(b);if(String(e).toUpperCase()==="TRUE"){a.checked=true}var d=Utils.buildLabelInputDiv(c,a,"displayOptionItem");return d},_getDefaultValue:function(a){var b=this._getCurrentLayerProperty(a.name);if(b===null||b===undefined){if(a.defaultVal===undefined||a.defaultVal===null){b=""}else{b=a.defaultVal}}return b},_getCurrentLayerProperty:function(c){var b=null;if(this.currentOLLayer!==null){b=this.currentOLLayer.params[c.toUpperCase()];if(b===""&&c.toUpperCase()==="STYLES"){var a=this.currentWMCLayer.getStyles();if(a.length>0){b=a[0].name}}}return b},_getDisplayOptionTitle:function(a){var b=a.title;if(b===undefined){b=a.name}return b},_buildStyleSelect:function(e,c){var a=[];var b=[];for(var d=0;d<e.length;d++){a.push(e[d].name);b.push(e[d].title)}this._styleSelect=Utils.buildSelectBox("styles",b,a,c);return Utils.buildLabelInputDiv("Style",this._styleSelect,"layerInfoItem")}};"use strict";var LayerDownload=function(a,b,c,d,e){this._containingDiv=document.getElementById(a);if(e){this.controlMarkup=e}this._containingDiv.innerHTML=this.controlMarkup;this.figBuilder=new FigureBuilder("composite_figure_container",c,b,d);this.wcsdown=new WCSDownloadControl("wcs_download_div",b,d);this.figDownload=new LayerFigureDownload("get_figure_container",d)};LayerDownload.prototype={EVENTS_RAISED:[],controlMarkup:'    <label>Generate Composite Figure</label>        <div id="composite_figure_container"></div>    <label>Download Data from Selected Layer</label>        <div id="wcs_download_div"></div>    <div id="get_figure_container"></div>'};var LayoutManager=function(){};LayoutManager.prototype={EVENTS_RAISED:[],setupLayout:function(){var b=YAHOO.util.Dom;var a=YAHOO.util.Event;this.layout=new YAHOO.widget.Layout({units:[{position:"bottom",header:"",height:200,resize:true,body:"bottom1",gutter:"5px",collapse:true},{position:"center",body:"center1"}]});a.onDOMReady(this._onDomReady.bindAsEventListener(this));this.layout.on("resize",function(h){var e=b.get("center_content");b.setStyle(e,"height",h.sizes.center.h+"px");var k;var d;var c=h.sizes.center.h-2;var f=h.sizes.center.w-4;var g=h.sizes.center.w/h.sizes.center.h;var j=c*2;var i=f*2;if(g>2){k=c;d=j}else{if(g==2){k=c;d=Math.floor(c/2)}else{d=f;k=Math.floor(f/2)}}b.setStyle("map","width",d+"px");b.setStyle("map","height",k+"px");b.setStyle(("tab_content"),"height",h.sizes.bottom.h-86+"px");b.setStyle(("bottom_left"),"height",h.sizes.bottom.h-40+"px");b.setStyle(("bottom_middle"),"height",h.sizes.bottom.h-40+"px");b.setStyle(("bottom_right"),"height",h.sizes.bottom.h-40+"px")})},refreshTabWidths:function(){var d=this._getWidth("bottom1")-6;var g=this._getWidth("bottom_right");var c=this._getWidth("bottom_middle");var f=this._getWidth("bottom_left");var e=g+c+f;var b=Math.floor(g/e*d);var h=Math.floor(c/e*d);var a=Math.floor(f/e*d);if(b<100){b=100}if(h<100){h=100}if(a<100){a=100}this._setWidth("bottom_left",a);this._setWidth("bottom_middle",h);this._setWidth("bottom_right",b)},_onDomReady:function(){this.layout.render();var a=this._getWidth("bottom1")-6;var c=new YAHOO.util.Resize("bottom_left",{handles:["r"],minWidth:100,maxWidth:a-200});c.on("resize",this._onLeftResize.bindAsEventListener(this));var b=new YAHOO.util.Resize("bottom_middle",{handles:["r"],minWidth:100,maxWidth:a-200});b.on("resize",this._onMiddleResize.bindAsEventListener(this))},_onLeftResize:function(f){var b=f.width;var d=this._getWidth("bottom1")-6;var g=this._getWidth("bottom_right");var c=this._getWidth("bottom_middle");var e=true;var h=null;var a=null;if(c>100){h=d-b-g;if(h>100){e=false}else{h=100}}else{h=100}if(e){a=d-b-h;if(a<100){a=100;b=d-h-a}}this._setWidth("bottom_left",b);this._setWidth("bottom_middle",h);this._setWidth("bottom_right",a)},_onMiddleResize:function(c){var a=c.width;var b=this._getWidth("bottom1")-6;var e=this._getWidth("bottom_right");var d=this._getWidth("bottom_left");targetRightWidth=b-a-d;if(targetRightWidth<100){targetRightWidth=100;a=b-targetRightWidth-d}this._setWidth("bottom_middle",a);this._setWidth("bottom_right",targetRightWidth)},_getWidth:function(b){var c=YAHOO.util.Dom.getRegion(b);var a=c.right-c.left;return a},_setWidth:function(b,a){YAHOO.util.Dom.setStyle(b,"width",(a)+"px")}};"use strict";var SplitAxisSelectList=function(c,b,a){this.indexFactor=c;this.label=b;this.values=a};var SplitAxisMapping=function(c,b){this.axisValues=c;this.selectLists=b;for(var a=0;a<b.length;a++){if(this.selectLists[a].constructor!==SplitAxisSelectList){throw ("Unknown value in select list ("+this.selectLists[a].constructor+") expected SplitAxisSelectList.")}}};var SplitAxisConfig=function(a){for(var c in a){var b=a[c];if(b.constructor!==SplitAxisMapping){throw ("Unknown value in mapping list ("+b.constructor+") expected SplitAxisMapping.")}}this.mappingObj=a};SplitAxisConfig.prototype={getAxisNames:function(){var a=[];for(var b in this.mappingObj){a.push(b)}return a},getAxisMapping:function(a){var c=false;var d=this.getAxisNames();for(var b=0;b<d.length;b++){if(a===d[b]){c=true;break}}if(!c){WMSC.log("Axis name "+a+" not found in the mapping list.");return null}return this.mappingObj[a]}};var SplitAxisConfigBuilder=function(a){this.node=a};SplitAxisConfigBuilder.prototype={buildConfig:function(){var b=this._getAllAxisElements();var a={};for(var c=0;c<b.length;c++){var g=b[c];var f=this._buildAxisValues(g);var e=this._buildSelectLists(g);var d=g.getAttribute("name").toLowerCase();a[d]=new SplitAxisMapping(f,e)}return new SplitAxisConfig(a)},_buildAxisValues:function(c){var a=WMSC.traverseWMSDom(c,["AxisValues"]);var d=[];for(var b=0;b<a.childNodes.length;b++){var e=a.childNodes[b];if(e.nodeName==="AxisValue"){d.push(WMSC.getTextContent(e))}}return d},_getAllAxisElements:function(){var a;var b=[];for(a=0;a<this.node.childNodes.length;a++){var c=this.node.childNodes[a];if(c.nodeName.toUpperCase()==="AXIS"){b.push(c)}}return b},_buildSelectLists:function(c){var b=WMSC.traverseWMSDom(c,["SelectLists"]);var d=[];for(var a=0;a<b.childNodes.length;a++){var e=b.childNodes[a];if(e.nodeName==="SelectList"){d.push(this._buildSplitAxisSelect(e))}}return d},_buildSplitAxisSelect:function(e){var c=e.getAttribute("indexFactor");var b=e.getAttribute("label");var a=[];for(var d=0;d<e.childNodes.length;d++){var f=e.childNodes[d];if(f.nodeName==="Option"){a.push(WMSC.getTextContent(f))}}return new SplitAxisSelectList(c,b,a)}};"use strict";var SplitAxisSelect=function(a,c,b,d){this.containerId=this.name+"_split_select";this.name=a;this.data=c;this.containerClass=d;if(b===undefined){this.labelText=a}else{this.labelText=b}};SplitAxisSelect.prototype={build:function(){var a=document.createElement("div");if(this.containerClass!==undefined){a.className=this.containerClass}if(this.data.constructor===Array){a.appendChild(Utils.buildLabel(this.labelText,{id:this.name+"_label",htmlFor:this.name}));a.appendChild(document.createTextNode("\n"));a.appendChild(Utils.buildSelect("select_"+this.name,this.name,this.data,this.data))}else{this._buildSplitSelect(a)}return a},_buildSplitSelect:function(a){a.appendChild(Utils.buildLabel(this.labelText,{id:this.name+"_label"}));a.appendChild(document.createTextNode("\n"));for(var c=0;c<this.data.selectLists.length;c++){var b=this.data.selectLists[c];var h="select_"+this.name+"_subselect_"+c;var g=document.createElement("div");g.className="subselect_input";g.appendChild(Utils.buildLabel(b.label,{id:this.name+"_subselect_"+c+"_label"}));var f=Utils.buildSelect(h,null,b.values,b.values);var d=Utils.addHTMLEventListener(f,"change",this._buildTime,this);g.appendChild(f);g.appendChild(document.createTextNode("\n"));a.appendChild(g)}var e=this.data.axisValues[0];a.appendChild(Utils.buildHiddenInputElement("select_"+this.name,e,"select_"+this.name));a.appendChild(document.createTextNode("\n"))},_buildTime:function(){var a=document.getElementById("select_"+this.name);a.value=this._buildTimeString()},_buildTimeString:function(){var a=0;for(var c=0;c<this.data.selectLists.length;c++){var d="select_"+this.name+"_subselect_"+c;var b=document.getElementById(d);a+=b.selectedIndex*this.data.selectLists[c].indexFactor}return this.data.axisValues[a]}};"use strict";var EndpointSelection=function(a,b,c){this._container=document.getElementById(a);this.endpointList=b;this.eventsManager=c;this._container.innerHTML=this.controlMarkup;this._select=this._buildSelect(b);this._input=document.getElementById("new_endpoint_1");this._addButton=document.getElementById("new_endpoint_button");this._selectMethodRadio=document.getElementById("endpoint_select_method_select");this._inputMethodRadio=document.getElementById("endpoint_select_method_input");Utils.addHTMLEventListener(this._selectMethodRadio,"click",this._onMethodRadioClick,this);Utils.addHTMLEventListener(this._inputMethodRadio,"click",this._onMethodRadioClick,this);Utils.addHTMLEventListener(this._addButton,"click",this._onAddButtonClick,this);this._selectContainer=document.getElementById("new_endpoint_select_container");this._selectContainer.appendChild(this._select);this._inputContainer=document.getElementById("new_endpoint_input_container");this._inputContainer.style.display="none";this._selectMethodRadio.checked=true};EndpointSelection.prototype={EVENT_TYPES:["NEW_ENDPOINT"],controlMarkup:'\n<div>\n    <label for="endpoint_select_method_select"> Select Preset </label>\n   <input type="radio" name="endpoint_select_method" value="select" \n                  id="endpoint_select_method_select" ></input>\n   <label for="endpoint_select_method_input"> Enter URL </label>\n   <input type="radio" name="endpoint_select_method" value="input" \n                   id="endpoint_select_method_input" ></input>\n</div>\n<div>\n    <span id="new_endpoint_select_container"></span> \n    <span id="new_endpoint_input_container"> \n      <input id="new_endpoint_1" size="40" type="text" ></input> \n    </span> \n  <input type="button" id="new_endpoint_button" value="Add" /> \n</div>\n',_buildSelect:function(d){var b=[];var a=[];for(var c=0;c<d.length;c++){b.push(d[c].name);a.push(d[c].url)}return Utils.buildSelect("new_endpoint_2","new_endpoint_2",b,a)},_onAddButtonClick:function(b){WMSC.log("Add endpoint clicked.");var a=null;if(this._selectMethodRadio.checked){a=this._select.value}else{a=this._input.value}this.eventsManager.triggerEvent("NEW_ENDPOINT",{url:a})},_onMethodRadioClick:function(a){if(this._selectMethodRadio.checked){if(this._selectContainer.style.display==="none"){this._selectContainer.style.display="";this._inputContainer.style.display="none"}}else{if(this._inputContainer.style.display==="none"){this._inputContainer.style.display="";this._selectContainer.style.display="none"}}}};"use strict";var AjaxRetriever=function(){this._contextLookup={}};AjaxRetriever.prototype={lookup:{},getResponse:function(d,b,a,c){this._getResponse(d,b,a,c)},_getResponse:function(f,b,a,d){var g,c,e;if(this._isCached(f)){g=this._getParamsString(f);b(this._contextLookup[g])}else{c=function(i){var h=this._processResponse(i);this._addToLookup(f,h);b(h)};if(a===undefined){a=function(h){WMSC.log("Failure:"+h)}}if(d===undefined){d=function(i,h){WMSC.log("Exception:"+h)}}e=new Ajax.Request("",{parameters:f,method:"get",onSuccess:c.bindAsEventListener(this),onException:d,onFailure:a})}},_processResponse:function(a){return a},_addToLookup:function(b,a){var c=this._getParamsString(b);this._contextLookup[c]=a},_isCached:function(b){var c,a;c=this._getParamsString(b);for(a in this._contextLookup){if(a===c){return true}}return false},_getParamsString:function(c){var b="",a;for(a in c){b=b+a+":"+c[a]+","}return b}};"use strict";var AxisConfigRetriever=function(){this._contextLookup={}};AxisConfigRetriever.prototype=new AjaxRetriever();AxisConfigRetriever.prototype.constructor=AxisConfigRetriever;AxisConfigRetriever.prototype.getResponse=function(c,b,a,d){var e={REQUEST:"GetAxisConfig",URL:c};this._getResponse(e,b,a,d)};AxisConfigRetriever.prototype._processResponse=function(b){var a=new SplitAxisConfigBuilder(b.responseXML.firstChild);return a.buildConfig()};"use strict";var LayerDimensions=function(a,b){this._form=document.getElementById(a);this.eventsManager=b;this._handlerLookup=null;this._retriever=new AxisConfigRetriever();this.eventsManager.register("CURRENT_WMCLAYER_CHANGED",this,this._onCurrentLayerChanged)};LayerDimensions.prototype={EVENTS_RAISED:["LAYER_DIMENSION_CHANGED"],_onCurrentLayerChanged:function(c){this._clearForm();if(c.wmcLayer!==null&&c.olLayer!==null){var a=c.wmcLayer.getAxisConfigURL();if(a===null){this._buildForm(c.wmcLayer,c.olLayer)}else{var b=function(d){this._buildForm(c.wmcLayer,c.olLayer,d)};this._retriever.getResponse(a,b.bindAsEventListener(this))}}},_clearForm:function(){if(this._handlerLookup!==null){Utils.removeEventHandlersFromLookup(this._handlerLookup,"change");this._handlerLookup=null}this._form.innerHTML=""},_buildForm:function(h,e,c){var d=h.getDimensions();var g=document.createElement("div");for(var f in d){var b=d[f].getExtent();var a=null;if(c===undefined){a=new SplitAxisSelect(f,b,d[f].getName(),"layerDimItem")}else{a=new SplitAxisSelect(f,c.getAxisMapping(f),d[f].getName(),"layerDimItem")}g.appendChild(a.build())}this._form.appendChild(g);this._handlerLookup=Utils.addHandlerToFormElements(this._form,"change",this._onSelectionChange,this)},_onSelectionChange:function(d){var c=d.target||d.srcElement;var f=null;var b=null;var a=c.id.indexOf("_subselect_");if(a>-1){f=c.id.substring(7,a);b=document.getElementById("select_"+f).value}else{f=c.id.substr(7);b=c.value}this.eventsManager.triggerEvent("LAYER_DIMENSION_CHANGED",{param:f,value:b})},getDimensionText:function(b,a){return a},_getLayerProperty:function(b,c){var a=null;if(b!==null){a=b.params[c.toUpperCase()]}return a},getSelectedDimensions:function(){var e={};var d=Utils.getActiveFormElements(this._form);for(var c=0;c<d.length;c++){var b=d[c];if(b.name!==null){var a=b.name;if(a.substr(0,7)==="selected_"){a=a.substr(7)}e[a]=b.value}}return e}};"use strict";var LayerParameters=function(f,b,e,c,d,a){this.eventsManager=d;this.propertiesDiv=document.getElementById(f);this.currentOLLayer=null;this.currentWMCLayer=null;this.wmcRetriever=e;this.layerInfo=new LayerInfo("layer_info",this.eventsManager,a);this.layerDims=new LayerDimensions("WMSC_dimForm",this.eventsManager);this.layerDisplay=new LayerDisplayOpts(b,c,this.eventsManager);this.eventsManager.register("LAYER_DISPLAY_CHANGED",this,this.onParamChange);this.eventsManager.register("LAYER_DIMENSION_CHANGED",this,this.onParamChange);this.eventsManager.register("SELECTED_LAYER_CHANGED",this,this.onSelectedLayerChanged);WMSC.log("layer parameters created")};LayerParameters.prototype={EVENTS_RAISED:["LAYER_PROPERTY_CHANGED","CURRENT_WMCLAYER_CHANGED","LAYER_STYLE_CHANGED"].concat(LayerInfo.prototype.EVENTS_RAISED,LayerDimensions.prototype.EVENTS_RAISED,LayerDisplayOpts.prototype.EVENTS_RAISED),onParamChange:function(a){if(this.currentOLLayer!==null){this.currentOLLayer.params[a.param.toUpperCase()]=a.value;this.currentOLLayer.redraw()}this.eventsManager.triggerEvent("LAYER_PROPERTY_CHANGED",{layer:this.currentOLLayer,wmcLayer:this.currentWMCLayer});if(a.param.toUpperCase()==="STYLES"){this.eventsManager.triggerEvent("LAYER_STYLE_CHANGED",{style:a.value})}},onSelectedLayerChanged:function(b){this.currentOLLayer=b.layer;this.currentWMCLayer=null;if(b.layer===null){var a={wmc:null,olLayer:null,wmcLayer:null};this.globalEventsManager.triggerEvent("CURRENT_WMCLAYER_CHANGED",a);this.internalEvents.triggerEvent("CURRENT_WMCLAYER_CHANGED",a)}else{this.updateControls()}},hideControls:function(){this.propertiesDiv.style.display="none"},showControls:function(){this.propertiesDiv.style.display="block"},updateControls:function(){var a=this.buildControls.bindAsEventListener(this);this.wmcRetriever.getWMC(this.currentOLLayer.url,a)},buildControls:function(b){var c=this.searchSubLayers(b.getSubLayers());if(c===null){WMSC.log("WARNING: layer "+this.currentOLLayer.params.LAYERS+" not found in capabilities document.")}this.currentWMCLayer=c;var a={wmc:b,olLayer:this.currentOLLayer,wmcLayer:this.currentWMCLayer};this.eventsManager.triggerEvent("CURRENT_WMCLAYER_CHANGED",a)},searchSubLayers:function(c){var d=null;for(var b=0;b<c.length;b++){var a=c[b];if(a.getName()===this.currentOLLayer.params.LAYERS){d=a;break}if(a.getSubLayers().length>0){d=this.searchSubLayers(a.getSubLayers());if(d!==null){break}}}return d},destroy:function(){this.internalEvents.destroy();this._removeAllItems()}};"use strict";var FigureBuilder=function(c,b,a,d){this._container=document.getElementById(c);this._container.innerHTML=this.controlMarkup;this._form=document.getElementById("figureForm");this._form.action=b;this._button=document.getElementById("make_figure_btn");this._currentLayers=null;this._hiddenControlsDiv=this.buildHiddenControlsDiv();this._handler=Utils.addHTMLEventListener(this._button,"click",this.createFigure,this);this._currentSelection=a;this.eventsManager=d;d.register("LAYER_ORDER_CHANGED",this,this.onLayerOrderChanged);d.register("MAP_SELECTION_CHANGED",this,this.onChangeSelection)};FigureBuilder.prototype={controlMarkup:'\n<form id="figureForm" method="get">\n    <div>\n        <select name="figFormat">\n          <option value="image/png" selected="1"> PNG </option>\n          <option value="image/jpeg"> JPEG </option>\n          <option value="image/gif"> GIF </option>\n          <option value="application/postscript"> EPS </option>\n          <option value="image/svg+xml"> SVG </option>\n        </select>\n        <input type="button" value="Make Figure" id="make_figure_btn"/>\n    </div>\n</form>',onLayerOrderChanged:function(a){this._currentLayers=a.layers},onChangeSelection:function(a){this._currentSelection=a.selection;WMSC.log("this._currentSelection = "+this._currentSelection)},buildHiddenControlsDiv:function(){var a=document.createElement("div");a.style.display="none";this._form.appendChild(a);return a},createFigure:function(){this._hiddenControlsDiv.innerHTML="";if(this._currentLayers===null||this._currentLayers.length===0){alert("No layer found.")}else{for(var c=0;c<this._currentLayers.length;c++){var b=this._currentLayers[c];this._hiddenControlsDiv.appendChild(this._buildLayerInputs(c+1,b))}var a=this._currentSelection.left+","+this._currentSelection.bottom+","+this._currentSelection.right+","+this._currentSelection.top;this._hiddenControlsDiv.appendChild(this._buildInputElement("BBOX",a));this._hiddenControlsDiv.appendChild(this._buildInputElement("WIDTH","1200"));this._hiddenControlsDiv.appendChild(this._buildInputElement("HEIGHT","900"));this._form.setAttribute("target","_blank");this._form.submit()}},_buildLayerInputs:function(b,a){var d=document.createElement("div");d.appendChild(this._buildInputElement(b+"_ENDPOINT",a.url));for(var c in a.params){d.appendChild(this._buildInputElement(b+"_"+c,a.params[c]))}return d},_buildInputElement:function(b,c){var a=document.createElement("input");a.type="hidden";a.name=b;a.value=c;return a},destroy:function(){if(this._handler!==null){Utils.removeHTMLEventListener(this._button,"click",this._handler)}}};"use strict";var LegendContainer=OpenLayers.Class.create();LegendContainer.prototype={initialize:function(a,b){this.legendDiv=document.getElementById(a);this._retriever=new AjaxRetriever();this.eventsManager=b;this.eventsManager.register("LAYER_PROPERTY_CHANGED",this,this.onLayerPropertyChanged);this.eventsManager.register("CURRENT_WMCLAYER_CHANGED",this,this.onLayerChanged)},onLayerChanged:function(a){this.setLegendForLayer(a.olLayer,a.wmcLayer)},onLayerPropertyChanged:function(a){this.setLegendForLayer(a.layer,a.wmcLayer)},setLegendForLayer:function(d,e){var c=false;if(e!==null&&d!==null){var b=d.params.STYLES;var a=e.getLegendURL(b);WMSC.log("Legend url = "+a);if(a!==null){a=Utils.addParamsToUrl(a,d.params);this.loadNewLegend(a);c=true}}if(c===false){this.clearLegend()}},loadNewLegend:function(a){WMSC.log("getting legend url = "+a);var b=this.setLegend.bindAsEventListener(this);var c={REQUEST:"GetLegend",ENDPOINT:a};this._retriever.getResponse(c,b)},setLegend:function(b){WMSC.log("setting legend at"+new Date());this.legendDiv.innerHTML="";var a=b.responseText;if(a){this.legendDiv.innerHTML=a}},clearLegend:function(a){this.legendDiv.innerHTML=""}};"use strict";WMSC.BoundsControl=OpenLayers.Class.create();WMSC.BoundsControl.prototype={EVENT_TYPES:["clearSelection","TEXT_SELECTION_CHANGED"],GLOBAL_BOUNDS:new OpenLayers.Bounds(-180,-90,180,90),wmsParams:null,clearButtonID:"WMSC_clear",formID:"coordsForm",controlMarkup:'<div id="WMSC_sel" class="WMSC_domain"><table>  <tr><td colspan="2"          align="center">    <input type="text" name="bboxN" size="4" value="90"/><br/>N  </td></tr>  <tr>   <td><input type="text" name="bboxW" size="4" value="-180"/> W</td>   <td>E <input type="text" name="bboxE" size="4" value="180"/></td>  </tr>  <tr><td colspan="2" align="center">S<br/>    <input type="text" name="bboxS" size="4" value="-90"/>  </td></tr></table><input id="WMSC_clear" type="button" value="Reset selection"/></div>',initialize:function(b,a,c,d){this._input_names=["bboxN","bboxW","bboxE","bboxS"];this._supressTextChangeEvent=false;this.domainDivID=b;if(d){this.controlMarkup=d}this.eventsManager=c;this.wmsParams={};this._selectedDims={};this._lastSelection=null;this._initDomainDiv();if(a!==null){this.setSelection(a)}else{this.setSelection(this.GLOBAL_BOUNDS)}this.eventsManager.register("MAP_SELECTION_CHANGED",this,this._onMapSelectionChanged)},destroy:function(){},_selectionListener:function(){var a=this.getSelection();WMSC.log("triggering TEXT_SELECTION_CHANGED, selection = "+a);if(this._supressTextChangeEvent===false){this.eventsManager.triggerEvent("TEXT_SELECTION_CHANGED",{selection:a})}},_initDomainDiv:function(){var a=document.getElementById(this.domainDivID);a.innerHTML=this.controlMarkup;var e=$(this.clearButtonID);if(e){e.onclick=this._clearSelection.bindAsEventListener(this)}var d=this._selectionListener.bindAsEventListener(this);this.selectionForm=$(this.formID);var c=this._getInputElements();for(var b=0;b<c.length;b++){c[b].onchange=d}},_getInputElements:function(){var b=document.getElementById(this.domainDivID);var d=[];for(var c=0;c<this._input_names.length;c++){var a=Utils.getContainedElementsByName(b,this._input_names[c]);if(a.length===0||a[0]===null||a[0].tagName!=="INPUT"){throw"Required input element "+this._input_names[c]+" not found in BoundsControl."}d.push(a[0])}return d},_clearSelection:function(){this.eventsManager.triggerEvent("clearSelection")},getSelection:function(){var e=this._getInputElements();var g,f,d,a;for(var c=0;c<e.length;c++){var b=e[c];if(b.name==="bboxW"){g=b.value}else{if(b.name==="bboxS"){a=b.value}else{if(b.name==="bboxE"){d=b.value}else{if(b.name==="bboxN"){f=b.value}}}}}return new OpenLayers.Bounds(g,a,d,f)},setSelection:function(f){var a=this.getSelection();if(!(f.left>=-180&&f.left<180)){f.left=a.left}if(!(f.right>-180&&f.right<=180)){f.right=a.right}if(!(f.top>-90&&f.top<=90)){f.top=a.top}if(!(f.bottom>=-90&&f.bottom<90)){f.bottom=a.bottom}var d;if(f.left>f.right){d=f.left;f.left=f.right;f.right=d}if(f.bottom>f.top){d=f.bottom;f.bottom=f.top;f.top=d}var e=this._getInputElements();for(var c=0;c<e.length;c++){var b=e[c];if(b.name==="bboxW"){b.value=f.left.toFixed(1)}else{if(b.name==="bboxS"){b.value=f.bottom.toFixed(1)}else{if(b.name==="bboxE"){b.value=f.right.toFixed(1)}else{if(b.name==="bboxN"){b.value=f.top.toFixed(1)}}}}}},_onMapSelectionChanged:function(a){this._supressTextChangeEvent=true;this.setSelection(a.selection);this._supressTextChangeEvent=false}};"use strict";var WMCRetriever=OpenLayers.Class.create();WMCRetriever.prototype={contextLookup:{},initialize:function(a){if(a!==undefined){this.getWMC(a)}},getWMC:function(f,b,a){if(this.isWMCCached(f)){b(this.contextLookup[f])}else{var c=function(h){var g=new WMSC.Capabilities(h.responseXML.documentElement);this.addWMCToLookup(f,g);b(g)};var e={REQUEST:"GetWebMapCapabilities",ENDPOINT:f};if(a===undefined){a=function(g){WMSC.log("Failure:"+g)}}var d=new Ajax.Request("",{parameters:e,method:"get",onSuccess:c.bindAsEventListener(this),onException:function(h,g){WMSC.log("Exception:"+g)},onFailure:a})}},addWMCToLookup:function(b,a){this.contextLookup[b]=a},isWMCCached:function(b){var a;for(a in this.contextLookup){if(a===b){return true}}return false}};"use strict";var LayerDefaultSetter=function(b,a){this.globalDefaults=b;this.defaultOptionsList=a};LayerDefaultSetter.prototype={getDefaults:function(c,a){var b={};this._setValues(b,this.globalDefaults);if(this.defaultOptionsList!==null&&this.defaultOptionsList!==""){this._addDefaultsFromOptionsList(b,c,a)}return b},_addDefaultsFromOptionsList:function(g,d,e){for(var c=0;c<this.defaultOptionsList.length;c++){var a=this.defaultOptionsList[c].endpoint;if(Utils.reMatch(a,d)){for(var b=0;b<this.defaultOptionsList[c].layers.length;b++){var f=this.defaultOptionsList[c].layers[b];if(Utils.reMatch(f,e)){this._setValues(g,this.defaultOptionsList[c].values)}}}}},_setValues:function(c,b){for(var a in b){c[a]=b[a]}}};"use strict";var OutlineControl=function(b,e,a){this.outlineButton=document.getElementById(b);this.eventsManager=e;for(var d=0;d<this.OPTIONAL_ARGS.length;d++){var c=this.OPTIONAL_ARGS[d];if(a[c]!==undefined){this[c]=a[c]}}Utils.addHTMLEventListener(this.outlineButton,"click",this.addNewOutline,this);this.eventsManager.register("LAYER_REMOVED",this,this.onLayerRemoved)};OutlineControl.prototype={EVENT_TYPES:["NEW_OUTLINE"],OPTIONAL_ARGS:["url","params"],url:"http://labs.metacarta.com/wms/vmap0",params:{layers:"coastline_01",format:"image/png"},addNewOutline:function(){var a=new OpenLayers.Layer.WMS("Outline",this.url,this.params,{isBaseLayer:false,buffer:1});a.params.CRS="CRS:84";a.params.FORMAT="image/png";a.params.VERSION="1.3.0";a.params.TRANSPARENT="true";a.id="outline_layer";this.eventsManager.triggerEvent("NEW_OUTLINE",{layer:a});this.outlineButton.disabled=true},onLayerRemoved:function(a){if(a.layer_id==="outline_layer"){this.outlineButton.disabled=false}}}; 
     1"use strict";var WMSC={};WMSC.DEBUG=true;WMSC.log=function(b){if(!WMSC.DEBUG){return}try{console.log(b)}catch(a){}};"use strict";var Utils={};Utils.addHTMLEventListener=function(d,a,c,e){var b=function(f){c.apply(e,[f,this])};if(d.addEventListener){d.addEventListener(a,b,false)}else{if(d.attachEvent){d.attachEvent("on"+a,b)}}return b};Utils.removeHTMLEventListener=function(b,a,c){if(b.removeEventListener){b.removeEventListener(a,c,false)}else{if(b.detachEvent){b.detachEvent("on"+a,c)}}};Utils.buildScopedFunction=function(b,a){return function(c){b.apply(a,[c])}};Utils.buildSelectBox=function(d,c,a,b){return Utils.buildSelect("select_"+d,"select_"+d,c,a,b)};Utils.buildSelect=function(h,c,g,b,f){var d;var a=document.createElement("select");if(c!==null){a.name=c}if(h!==null){a.id=h}for(d=0;d<b.length;d++){var e=document.createElement("option");e.innerHTML=g[d];e.value=b[d];a.appendChild(e)}if(f!==null&&f!==undefined){for(d=0;d<b.length;d++){if(b[d]===f){a.selectedIndex=d;break}}}return a};Utils.buildLabel=function(c,d){var b=document.createElement("label");b.innerHTML=c;for(var a in d){b[a]=d[a]}return b};Utils.buildLabelInputDiv=function(d,e,c,a){var f=document.createElement("div");if(c!==undefined){f.className=c}var b=document.createElement("label");if(a!==undefined){b.className=a}b.innerHTML=d;f.appendChild(b);f.appendChild(e);return f};Utils.addHandlerToFormElements=function(f,a,h,e){var b={};var g=Utils.getActiveFormElements(f);for(var d=0;d<g.length;d++){var c=g[d];b[c.id]=Utils.addHTMLEventListener(c,a,h,e)}return b};Utils.getActiveFormElements=function(e){var c=[];var d=["INPUT","SELECT","TEXTAREA","BUTTON"];for(var b=0;b<e.elements.length;b++){var a=e.elements[b];if(Utils.isValueInList(a.tagName.toUpperCase(),d)){c.push(a)}}return c};Utils.removeEventHandlersFromLookup=function(d,b){if(b===undefined){b="change"}for(var e in d){if(e===""){continue}var a=document.getElementById(e);if(a===null||a===""){WMSC.log("Element not found for id="+e)}var c=d[e];if(c!==null){Utils.removeHTMLEventListener(a,b,c)}}};Utils.removeItems=function(c,b){var a=0;while(a<c.length){if(c[a]===b){c.splice(a,1)}else{a++}}return c};Utils.buildHiddenInputElement=function(b,c,d){var a=document.createElement("input");a.type="hidden";a.name=b;a.value=c;if(d!==undefined){a.id=d}return a};Utils.makeCombobox=function(k,a,c,i,g){var d={prehighlightClassName:"yui-ac-prehighlight",useShadow:true,queryDelay:0,minQueryLength:0,animVert:0.01,maxResultsDisplayed:25};var j=new YAHOO.util.LocalDataSource(i);var f=new YAHOO.widget.AutoComplete(k,c,j,d);if(g!==null&&g!==undefined){f.textboxChangeEvent.subscribe(g)}var h=document.getElementById(a);var e=new YAHOO.widget.Button({container:h});var b=function(l){YAHOO.util.Event.stopEvent(l);if(!YAHOO.util.Dom.hasClass(h,"open")){YAHOO.util.Dom.addClass(h,"open")}if(f.isContainerOpen()){f.collapseContainer()}else{f.getInputEl().focus();setTimeout(function(){f.sendQuery("")},0)}};e.on("mousedown",b);f.containerCollapseEvent.subscribe(function(){YAHOO.util.Dom.removeClass(h,"open")})};Utils.addParamsToUrl=function(c,h){var b=Utils.getParamsFromURL(c);var d=[];for(var a in b){d.push(a.toUpperCase())}var g=true;if(d.length>0){g=false}var f="";for(var e in h){if(Utils.isValueInList(e.toUpperCase(),d)){continue}if(g===true){f+="?";g=false}else{f+="&"}f+=e+"="+h[e]}return c+f};Utils.replaceParamsInUrl=function(c,g){var a=false;var b=c;if(c.indexOf("?")>0){b=c.substring(0,c.indexOf("?"))}var e="";var h=[];for(var f in g){h.push(f.toUpperCase());if(a===false){e+="?";a=true}else{e+="&"}e+=f+"="+g[f]}var d=Utils.getParamsFromURL(c);for(f in d){if(Utils.isValueInList(f.toUpperCase(),h)){continue}else{if(d[f]===""){continue}}if(a===false){e+="?";a=true}else{e+="&"}e+=f+"="+d[f]}return b+e};Utils.removeParamsInUrl=function(b,d){var h=b;if(b.indexOf("?")>0){h=b.substring(0,b.indexOf("?"))}var a="";var e=[];for(var g=0;g<d.length;g++){e.push(d[g].toUpperCase())}var f=Utils.getParamsFromURL(b);var j=false;for(var c in f){if(Utils.isValueInList(c.toUpperCase(),e)){continue}if(j===false){a+="?";j=true}else{a+="&"}a+=c+"="+f[c]}return h+a};Utils.isValueInList=function(c,b){var d=false;for(var a=0;a<b.length;a++){if(c===b[a]){d=true;break}}return d};Utils.getParamsFromURL=function(d){var g={};if(d.indexOf("?")>0){var f=d.substr(d.indexOf("?")+1);for(var e=0;e<2000;e++){var b=f.indexOf("&");if(b===-1){b=f.length}var a=f.substring(0,f.indexOf("="));var c=f.substring(f.indexOf("=")+1,b);g[a]=c;if(f.indexOf("&")<0){break}f=f.substr(f.indexOf("&")+1)}}return g};Utils.findPos=function(b){var c=0;var a=0;if(b.offsetParent){do{c+=b.offsetLeft;a+=b.offsetTop;WMSC.log(" obj, height, width , left, top= "+b+","+b.offsetHeight+","+b.offsetWidth+","+b.offsetLeft+","+b.offsetTop);b=b.offsetParent}while(b);return[c,a]}};Utils.reMatch=function(d,b){var c=new RegExp(d);var a=c.test(b);return a};Utils.alertErrorMessage=function(d,c,b){var a="Error: "+d+"\n";a+="URL: "+c+"\n";a+="Line: "+b+"\n\n";alert(a)};Utils.disableEnterKey=function(c){var a;if(window.event){a=window.event.keyCode}else{a=c.which}var b;if(a===13){WMSC.log("Enter detected");b=false;c.preventDefault()}else{b=true}return b};Utils.logAtts=function(b){for(var a in b){if(typeof(b[a])==="function"){WMSC.log(" "+a+" method")}else{WMSC.log(" "+a+" = "+b[a])}}};Utils.getContainedElementsByName=function(e,b){var d=e.getElementsByTagName("*");var a=[];for(var c=0;c<d.length;c++){if(d[c].name===b){a.push(d[c])}}return a};Utils.getDateString=function(){var b=new Date();function a(c){return c<10?"0"+c:c}return b.getUTCFullYear()+"-"+a(b.getUTCMonth()+1)+"-"+a(b.getUTCDate())+"T"+a(b.getUTCHours())+":"+a(b.getUTCMinutes())+":"+a(b.getUTCSeconds())+"Z"};Utils.getTimeString=function(){var b=new Date();function a(c){return c<10?"0"+c:c}return a(b.getUTCHours())+":"+a(b.getUTCMinutes())+":"+a(b.getUTCSeconds())+"."+b.getMilliseconds()};Utils.getObjString=function(b){var c="{";for(var a in b){c+="'"+a+"':"+b[a]+","}return c};Utils.buildObjectList=function(c,a){var d=[];if(a!==null){for(var b=0;b<a.length;b++){d.push(new c(a[b]))}}return d};Utils.hasAttr=function(c,a){for(var b in c){if(b===a){return true}}return false};"use strict";var Endpoint=function(a){for(var b=0;b<this.REQUIRED_PROPERTIES.length;b++){var d=this.REQUIRED_PROPERTIES[b];if(a[d]===undefined){var c="Requierd property '"+d+"' not found in conf"+Utils.getObjString(a);WMSC.log(c);throw (c)}else{this[d]=a[d]}}};Endpoint.prototype={REQUIRED_PROPERTIES:["url","name","service"]};"use strict";var FurtherInfoLink=function(a){var b,d;for(b=0;b<this.REQUIRED_PROPERTIES.length;b++){d=this.REQUIRED_PROPERTIES[b];if(a[d]===undefined){var c="Requierd property '"+d+"' not found in conf"+Utils.getObjString(a);WMSC.log(c);throw (c)}else{this[d]=a[d]}}for(b=0;b<this.OPTIONAL_PROPERTIES.length;b++){d=this.OPTIONAL_PROPERTIES[b];if(a[d]!==undefined){this[d]=a[d]}}};FurtherInfoLink.prototype={REQUIRED_PROPERTIES:["endpoint","link"],OPTIONAL_PROPERTIES:["name","image"],match:function(a){return Utils.reMatch(this.endpoint,a)},getHTML:function(){var a="info";if(Utils.hasAttr(this,"name")){a=this.name}a=a.escapeHTML();if(Utils.hasAttr(this,"image")){a=a+'<image src="'+escape(this.image)+'" />'}return'<a target="_blank" href="'+this.link+'">'+a+"</a>"}};"use strict";var DisplayOptionsRetriever=function(){this._lookup={}};DisplayOptionsRetriever.prototype={getDisplayOptions:function(c,a){if(this.isCached(c)){a(this._lookup[c])}else{var b=function(i){var g=null;try{g=JSON.parse(i.responseText)}catch(f){var h="Error occurred parsing JSON.\n Description:"+f.stack+"\n";WMSC.log(h)}this.addToLookup(c,g);a(g)};var e={REQUEST:"GetDisplayOptions",URL:c};var d=new Ajax.Request("",{parameters:e,method:"get",onSuccess:b.bindAsEventListener(this),onException:function(g,f){WMSC.log("Exception:"+f)}})}},addToLookup:function(a,b){this._lookup[a]=b},isCached:function(b){for(var a in this._lookup){if(a===b){return true}}return false}};"use strict";WMSC.VisApp=OpenLayers.Class.create();WMSC.VisApp.prototype={EVENT_TYPES:["MAP_SELECTION_CHANGED"],initialize:function(a,b,g,c,k,e,h){this.figureCounter=1;this.showCoast=c;this.eventsManager=e;this.bgImagePath=h;var j=360/g;var d=[];for(var f=0;f<b;f++){d.push(j/Math.pow(1.4,f))}this.map=new DDCVisMap(a,{resolutions:d,controls:[],tileSize:new OpenLayers.Size(320,320)});this.boxesLayer=new OpenLayers.Layer.Boxes("Sub-selection");this.subselControl=new SubSelectionMouseToolbar(new OpenLayers.Pixel(g-40,10),"vertical",this.boxesLayer);this.map.addControl(new OpenLayers.Control.LoadingPanel());this.map.addControl(this.subselControl);this.map.addControl(new OpenLayers.Control.PanZoomBar());this.map.addControl(new OpenLayers.Control.MousePosition());this.baseLayer=new OpenLayers.Layer.Image("None",this.bgImagePath,new OpenLayers.Bounds(-180,-90,180,90),new OpenLayers.Size(8,8),{isBaseLayer:true,resolutions:d});this.map.addLayer(this.baseLayer);this.map.setLayerIndex(this.baseLayer,0);this.map.addLayer(this.boxesLayer);this.map.setLayerIndex(this.boxesLayer,1);this.maxExtent=k;this.map.zoomToExtent(this.maxExtent);this.map.zoom=0;this.map.resolution=this.map.getResolutionForZoom(this.map.zoom);WMSC.log("this.map resolution= "+this.map.getResolution()+" zoom="+this.map.zoom+" maxExtent(b,l,t,r)="+this.map.maxExtent.bottom+","+this.map.maxExtent.left+","+this.map.maxExtent.top+","+this.map.maxExtent.right+" center(lat,lon)="+this.map.getCenter().lat+","+this.map.getCenter().lon+" size="+this.map.getSize().w+","+this.map.getSize().h+" bounds(b,l,t,r)="+this.map.calculateBounds().bottom+","+this.map.calculateBounds().left+","+this.map.calculateBounds().top+","+this.map.calculateBounds().right);this.subselControl.switchModeTo("zoombox");this._divId=a;this.eventsManager.register("TEXT_SELECTION_CHANGED",this,this.updateSelectionBox);this.eventsManager.register("clearSelection",this,this.resetMapCoords);this.eventsManager.register("LAYER_ORDER_CHANGED",this,this.onLayerOrderChanged);this.map.events.register("moveend",this,this.updateBoundsControl);this.map.events.register("zoomend",this,this.updateBoundsBoundsControl)},_logLocation:function(){WMSC.log("map div location = "+Utils.findPos(document.getElementById(this._divId)));WMSC.log("dims location= "+Utils.findPos(document.getElementById("dims")))},updateBoundsBoundsControl:function(a){WMSC.log("map zoomed -- this.map resolution = "+this.map.resolution+" zoom="+this.map.zoom+" maxExtent: b="+this.map.maxExtent.bottom+" l="+this.map.maxExtent.left+" t="+this.map.maxExtent.top+" r="+this.map.maxExtent.right)},onLayerOrderChanged:function(a){this.drawLayers(a.layers)},destroy:function(){if(this.dimControl){this.dimControl.destroy()}if(this.layerControl){this.layerControl.destroy()}this.subselControl.destroy()},_initCoast:function(a){if(!this.coastLayer||this.coastLayer.params.LAYERS!==a){this.coastLayer=new OpenLayers.Layer.WMS("Coastline","http://labs.metacarta.com/wms/vmap0",{layers:a,format:"image/gif",transparent:"true"})}this.map.addLayer(this.coastLayer)},updateVisLayer:function(){var c=this.map.getNumLayers();var d=0;for(d=0;d<c;d++){this.map.removeLayer(this.map.layers[0])}if(!this.visLayer){this.visLayer=new OpenLayers.Layer.WMS("OpenLayers WMS","http://labs.metacarta.com/wms/vmap0",{layers:"basic",format:"image/png"});this._mergeDimParams(this.visLayer)}this.map.addLayer(this.visLayer);var e=document.getElementById("layerlist");if(e!==null){for(d=e.childNodes.length-1;e&&d>=0;d--){var h=e.childNodes[d];if(h.className==="hiddenList"){continue}if(h.nodeName==="LI"){var g=h.getAttribute("wmcURL");var f=h.getAttribute("title");var b=h.getAttribute("layerName");var a=new OpenLayers.Layer.WMS(f,g,{format:"image/gif",version:"1.3.0",CRS:"CRS:84",layers:b,styles:"",transparent:"true"});this._mergeDimParams(a);this.map.addLayer(a)}}}if(this.showCoast){this._initCoast("coastline_01")}this.map.addLayer(this.boxesLayer);this.loadLegend()},_mergeDimParams:function(a){if(this.dimControl&&this.dimControl.wmsParams){a.mergeNewParams(this.dimControl.wmsParams)}a.setZIndex(300)},resetMapCoords:function(){WMSC.log("resetMapCoords");this.subselControl.deactivateSubsel();this.map.zoomToExtent(this.maxExtent);this.updateBoundsControl()},loadLegend:function(){var e=$("legend");if(!e){return}var g=function(j){$("legend").innerHTML="";var i=j.responseText;if(i){$("legend").innerHTML=i}};var c=function(i){};var a=this.map.layers.length;if(a<4){e.innerHTML="";return}var d=this.map.layers[a-3];if(d.url===null){e.innerHTML=""}else{var b=d.getFullRequestString({REQUEST:"GetLegend"});var h={REQUEST:"GetLegend",ENDPOINT:b};var f=new Ajax.Request("",{parameters:h,method:"get",onSuccess:g.bindAsEventListener(this),onFailure:c.bindAsEventListener(this)})}},updateBoundsControl:function(){var a=this.subselControl.getActiveBounds();WMSC.log("triggering MAP_SELECTION_CHANGED, selection = "+a);this.eventsManager.triggerEvent("MAP_SELECTION_CHANGED",{selection:a})},updateSelectionBox:function(d){WMSC.log("started update selection box");var a=this.subselControl.getActiveBounds();var c=d.selection;if(!(c.left>-180&&c.left<180)){c.left=a.left}if(!(c.right>-180&&c.right<180)){c.right=a.right}if(!(c.top>-90&&c.top<90)){c.top=a.top}if(!(c.bottom>-90&&c.bottom<90)){c.bottom=a.bottom}var b;if(c.left>c.right){b=c.left;c.left=c.right;c.right=b}if(c.bottom>c.top){b=c.bottom;c.bottom=c.top;c.top=b}this.subselControl.setSubSel(c);WMSC.log("finished update selection box")},drawLayers:function(e){var d;if(this.map.layers.length>0){var f=[];for(d=0;d<this.map.layers.length;d++){if(this.map.layers[d]!==this.baseLayer&&this.map.layers[d]!==this.boxesLayer){f.push(this.map.layers[d])}}for(d=0;d<f.length;d++){var c=f[d];this.map.removeLayer(c)}}var a=1;if(e.length>0){for(d=e.length-1;d>=0;d--){var b=e[d];this.map.addLayer(b);this.map.setLayerIndex(b,a);a++}}this.map.setLayerIndex(this.boxesLayer,a)}};"use strict";WMSC.VisAppLayers=OpenLayers.Class.create();function prependChild(a,b){a.insertBefore(b,a.firstChild)}function isPopupBlocker(){var a=window.open("./","testpopupblocker");if(a===null||typeof(a)==="undefined"){return true}else{a.close();return false}}WMSC.VisAppLayers.prototype={EVENT_TYPES:["NEW_LAYER"],treeDiv:null,layerDiv:null,events:null,initialize:function(g,h,f,c,i,a,b,e){WMSC.log("Initialising Control");this.treeDiv=g;this.layerDiv=h;this.wmcRetriever=f;this.endpointInputBox=$(c);this.addNewEndpointBtn=$(i);if(this.addNewEndpointBtn!==null){this.addNewEndpointBtn.onclick=this.onNewEndpointClick.bindAsEventListener(this)}this.eventsManager=b;this.furtherInfoLinks=e;this._selectedTreeNode=null;this._selectedLayer=null;this.tree=new YAHOO.widget.TreeView(this.treeDiv);this.tree.subscribe("clickEvent",this._onTreeClick.bindAsEventListener(this));this.tree.subscribe("expand",function(j){this._selectTreeNode(j);return true}.bindAsEventListener(this));this.idIndex=0;var d={format:"image/png",version:"1.3.0",CRS:"CRS:84",transparent:"true"};this.defaultSetter=new LayerDefaultSetter(d,a);this.layersToSelect={};this._delIconHandlers={};this.eventsManager.register("NEW_ENDPOINT",this,this.onNewEndpoint)},destroy:function(){this.tree.unsubscribe()},addListeners:function(){var b;for(b=0;b<this.tree.getRoot().children.length;b++){var a=this.tree.getRoot().children[b].index;var d=document.getElementById("delIcon_"+a);if(d!==null){this._delIconHandlers[d.id]=Utils.addHTMLEventListener(d,"click",this._removeNode,this)}}var c=document.getElementsByClassName("nodeInfo");for(b=0;b<c.length;b++){Utils.addHTMLEventListener(c[b],"click",this._onInfoNodeClick,this)}},removeListeners:function(){Utils.removeEventHandlersFromLookup(this._delIconHandlers);this._delIconHandlers={}},redrawTree:function(){WMSC.log("Redrawing tree");this.removeListeners();this.tree.draw();this.addListeners();if(this._selectedLayer!==null){if(this._selectedLayer.labelElId){var a=$(this._selectedLayer.labelElId);if(a===null){this._selectedLayer=null}else{a.className="WMSC_selectedField"}}}},addWebMapContext:function(a){var h=this.tree.getRoot();var d='<table><tr><td class="nodeTitle">...loading</td></tr></table>';var f=new YAHOO.widget.TextNode({label:d},h,false);var e=function(k){this.tree.removeNode(f);var j=this._addWMCTree(k,a);this.redrawTree();if(this.layersToSelect[a]!==undefined){this._selectEndpointLayers(a,this.layersToSelect[a]);this.layersToSelect[a]=undefined}};var c=function(j){this.tree.removeNode(f);this.redrawTree();if(j.status==403){alert("Login to secure service was unsucessful: you are logged in but do not have the correct permissions to access this data.")}else{alert("Login to secure service was unsucessful: the server responded with - "+j.text)}return false};var b=function(m){WMSC.log("response status = "+m.status);if(m.status===401){var l="./securitylogin?endpoint="+a;if(!isPopupBlocker()){window.showModalDialog(l,"please log in","dialogHeight=500px","dialogWidth=800px");var j=e.bindAsEventListener(this);var k=c.bindAsEventListener(this);this.wmcRetriever.getWMC(a,j,k)}else{alert("Please enable popups for this site to login to the secure WMS")}}else{if(m.status==403){alert("Login to secure service was unsucessful: you are logged in but do not have the correct permissions to access this data.");this.tree.removeNode(f);this.redrawTree();WMSC.log("Attempt to retrive endpoint "+a+" failed, response.status = "+m.status+" ("+m.statusText+").")}else{alert("Attempt to retrive endpoint "+a+" failed, response.status = "+m.status+" ("+m.statusText+").");this.tree.removeNode(f);this.redrawTree();WMSC.log("Attempt to retrive endpoint "+a+" failed, response.status = "+m.status+" ("+m.statusText+").")}}};this.redrawTree();var i=e.bindAsEventListener(this);var g=b.bindAsEventListener(this);this.wmcRetriever.getWMC(a,i,g)},_addWMCTree:function(g,a,f){var e;var b={};var c=g.getTitle();var k=[];if(this.furtherInfoLinks!==null){for(e=0;e<this.furtherInfoLinks.length;e++){var h=this.furtherInfoLinks[e];if(h.match(a)){k.push(h)}}}b.label=c;b.layer=g.getTitle();b["abstract"]=g.getTitle();b.wmcEndpoint=a;var j=new YAHOO.widget.MenuNode(b,this.tree.getRoot(),false);j.label=this._createNodeLabel(c,j.index,k);var d=g.getSubLayers();for(e=0;e<d.length;e++){this._addLayerTree(d[e],a,j)}return j},_addLayerTree:function(d,h,a){var f=d.getAbstract();if(f===null||f===""){f=d.getTitle()}var b={};b.wmcEndpoint=h;b.label=f;b.layer=d.getName();b["abstract"]=d.getAbstract();b.layerData=d;b.title=d.getAbstract();var g=new YAHOO.widget.MenuNode(b,a,false);var e=d.getSubLayers();for(var c=0;c<e.length;c++){this._addLayerTree(e[c],h,g)}return g},_createNodeLabel:function(f,e,d){if(d===undefined||d.length===0){return'<table><tr><td class="nodeTitle">'+f+'</td><td class="delIcon"><img id="delIcon_'+e+'" src="js/img/close.gif" /></td></tr></table>'}else{var b="";for(var a=0;a<d.length;a++){var c=d[a];b+='<td class="nodeInfo">'+c.getHTML()+"</td>"}return'<table><tr><td class="nodeTitle">'+f+"</td>"+b+'<td class="delIcon"><img id="delIcon_'+e+'" src="js/img/close.gif" /></td></tr></table>'}},_removeNode:function(a){var c=Event.element(a);var d=c.id.substring(c.id.indexOf("_")+1,c.id.length);var b=this.tree.getNodeByIndex(d);this.tree.removeNode(b);this.redrawTree()},_onTreeClick:function(a){var b=a.node;this._selectTreeNode(b)},_selectTreeNode:function(a){if(this._selectedLayer){$(this._selectedLayer.labelElId).className=a.labelStyle}$(a.labelElId).className="WMSC_selectedField";this._selectedLayer=a;if(a.children.length===0){if(a.label.indexOf("...loading")>-1){return}this._addLayer(a)}},_addLayer:function(b){var a=this.makeNewLayer(b.data.wmcEndpoint,b.data.layer);this.eventsManager.triggerEvent("NEW_LAYER",{layer:a});return},makeNewLayer:function(c,b){var e=this.defaultSetter.getDefaults(c,b);var a=["request","service"];c=Utils.removeParamsInUrl(c,a);var d=new OpenLayers.Layer.WMS("#"+this.idIndex+" "+b,c,e,{isBaseLayer:false,buffer:0});d.params.LAYERS=b;d.id=c+"_"+d.name+"_"+this.idIndex;this.idIndex+=1;return d},onNewEndpointClick:function(a){this.addWebMapContext(this.endpointInputBox.value)},onNewEndpoint:function(a){this.addWebMapContext(a.url)},addLayersToSelect:function(b,a){this.layersToSelect[b]=a},_selectEndpointLayers:function(a,f){var d=this._getNodeForEndpoint(a);if(d===null){WMSC.log("No node found for endpoint "+a);return}if(d.expanded===false){d.expand()}for(var c=0;c<f.length;c++){var b=f[c];var e=this._getChildNodeForLayer(d,b);if(e===null){WMSC.log("No node found for layer "+b+" in endpoint "+a);continue}this._expandNodeParentsFirst(e)}},_expandNodeParentsFirst:function(a){if(a.parent){this._expandNodeParentsFirst(a.parent)}if(a.expanded===false){a.expand()}},_getNodeForEndpoint:function(a){var d=this.tree.root.children;for(var b=0;b<d.length;b++){var c=d[b];if(c.data.wmcEndpoint===a){return c}}return null},_getChildNodeForLayer:function(c,a){for(var b=0;b<c.children.length;b++){var e=c.children[b];if(e.data.layer===a){return e}if(e.children.length>=0){var d=this._getChildNodeForLayer(e,a);if(d!==null){return d}}}return null},_onInfoNodeClick:function(a){if(!a){a=window.event}a.cancelBubble=true;if(a.stopPropagation){a.stopPropagation()}return false}};"use strict";WMSC.nsMap={wms:"http://www.opengis.net/wms",xlink:"http://www.w3.org/1999/xlink"};WMSC._searchElement=function(e,d){var c,a,b;b=e.childNodes;for(c=0;c<b.length;c++){a=b[c];if(a.nodeName==d){return a}}return null};WMSC.traverseWMSDom=function(b,c){var a;for(a=0;a<c.length;a++){b=WMSC._searchElement(b,c[a]);if(b===null){return null}}return b};WMSC.getTextContent=function(a){if(a.textContent){return a.textContent}else{return a.text}};WMSC.Capabilities=function(a){this.dom=a};WMSC.Capabilities.prototype={evaluate:function(b,a){if(a===null){a=this.dom}return WMSC.evalXPath(b,a)},getTitle:function(){var a=WMSC.traverseWMSDom(this.dom,["Service","Title"]);return WMSC.getTextContent(a)},getAbstract:function(){var a=WMSC.traverseWMSDom(this.dom,["Service","Abstract"]);return WMSC.getTextContent(a)},getRootLayer:function(){var a=WMSC.traverseWMSDom(this.dom,["Capability","Layer"]);if(a===null){return null}return new WMSC.Layer(a)},getEndpoint:function(){var b=WMSC.traverseWMSDom(this.dom,["Service","OnlineResource"]);if(b===null){return null}var a=b.getAttribute("href");if(!a){a=b.getAttribute("xlink:href")}return a},getSubLayers:function(){return this.getRootLayer().getSubLayers()},getAllRequests:function(){var a;var b=WMSC.traverseWMSDom(this.dom,["Capability","Request"]);a=this._getRequestsFromNode(b);var c=WMSC.traverseWMSDom(this.dom,["Capability","_ExtendedCapabilities","Request"]);if(c!==null){a=a.concat(this._getRequestsFromNode(c))}return a},_getRequestsFromNode:function(f){var b=[];for(var d=0;d<f.childNodes.length;d++){var g=f.childNodes[d];if(g.nodeType!=1){continue}var c=g.nodeName;var a=this._getRequestFormats(g);var e=new WMSC.Request(c,a);b.push(e)}return b},_getRequestFormats:function(c){var b;var a=[];for(b=0;b<c.childNodes.length;b++){var d=c.childNodes[b];if(d.nodeName.toUpperCase()=="FORMAT"){a.push(WMSC.getTextContent(d))}}return a},getRequest:function(b){var a=this.getAllRequests();for(var c=0;c<a.length;c++){if(a[c].name==b){return a[c]}}return null},supportsRequest:function(a){return this.getRequest(a)!==null}};WMSC.Layer=function(a){this.node=a};WMSC.Layer.prototype={getName:function(){var a=WMSC.traverseWMSDom(this.node,["Name"]);if(a===null){return null}return WMSC.getTextContent(a)},getTitle:function(){var a=WMSC.traverseWMSDom(this.node,["Title"]);return WMSC.getTextContent(a)},getAbstract:function(){var a=WMSC.traverseWMSDom(this.node,["Abstract"]);if(!a){return""}return WMSC.getTextContent(a)},getDimensions:function(){var b;var a;var d={};var c=this.node.getElementsByTagName("Dimension");for(b=0;b<c.length;b++){a=new WMSC.Dimension(c[b]);d[a.getName()]=a}return d},getSubLayers:function(){var b,a,d;var c=[];a=this.node.childNodes;for(b=0;b<a.length;b++){d=a[b];if(d.nodeName=="Layer"){c[c.length]=new WMSC.Layer(d)}}return c},getEndpoint:function(){var b=WMSC.traverseWMSDom(this.node,["Server","OnlineResource"]);if(b===null){return null}var a=b.getAttribute("href");if(!a){a=b.getAttribute("xlink:href")}return a},getStyles:function(){var f=[];for(var c=0;c<this.node.getElementsByTagName("Style").length;c++){var b=this.node.getElementsByTagName("Style")[c];var d=WMSC.traverseWMSDom(b,["Name"]);var a=WMSC.traverseWMSDom(b,["Title"]);var g=WMSC.getTextContent(d);var e=WMSC.getTextContent(a);f.push(new WMSC.Style(g,e))}return f},getLegendURL:function(a){if(a===null||a===""){a=undefined}var b=this.getStyles();if(b.length===0){return null}WMSC.log("style = "+a);if(a===undefined){return this._getLegendURLForStyle(b[0].name)}else{return this._getLegendURLForStyle(a)}},_getLegendURLForStyle:function(f){var d=null;for(var c=0;c<this.node.getElementsByTagName("Style").length;c++){var b=this.node.getElementsByTagName("Style")[c];var a=WMSC.traverseWMSDom(b,["Name"]);var e=WMSC.getTextContent(a);if(e===f){var g=WMSC.traverseWMSDom(b,["LegendURL","OnlineResource"]);d=this._getLinkFromORElement(g);break}}return d},getDisplayOptionsURL:function(){var b=null;for(var a=0;a<this.node.getElementsByTagName("MetadataURL").length;a++){var d=this.node.getElementsByTagName("MetadataURL")[a];if(d!==undefined&&d.getAttribute("type")=="display_options"){var c=WMSC.traverseWMSDom(d,["OnlineResource"]);b=this._getLinkFromORElement(c)}}return b},getAxisConfigURL:function(){var a=null;for(var b=0;b<this.node.getElementsByTagName("MetadataURL").length;b++){var d=this.node.getElementsByTagName("MetadataURL")[b];if(d!==undefined&&d.getAttribute("type")=="axis_config"){var c=WMSC.traverseWMSDom(d,["OnlineResource"]);a=this._getLinkFromORElement(c)}}return a},_getLinkFromORElement:function(c){var a=null;for(var b=0;b<c.attributes.length;b++){if(c.attributes[b].name=="xlink:href"){a=c.attributes[b].value}}return a}};WMSC.Dimension=function(a){this.node=a};WMSC.Dimension.prototype={getName:function(){var a=this.node.attributes.getNamedItem("name");return a.value},getUnits:function(){var a=this.node.attributes.getNamedItem("units");return a.value},getExtent:function(){if(this.node.textContent){return this.node.textContent.split(",")}else{return this.node.text.split(",")}}};WMSC.Style=function(a,b){this.name=a;this.title=b};WMSC.Request=function(b,a){this.name=b;this.formats=a};WMSC.WebMapContext=function(a){this.dom=a};WMSC.WebMapContext.prototype={evaluate:function(b,a){if(a===null){a=this.dom}return WMSC.evalXPath(b,a)},getTitle:function(){var a=WMSC.traverseWMSDom(this.dom,["General","Title"]);return WMSC.getTextContent(a)},getSubLayers:function(){var c=WMSC._searchElement(this.dom,"LayerList");var b=c.childNodes;var d=[];for(var a=0;a<b.length;a++){if(b[a].nodeName=="Layer"){d[d.length]=new WMSC.Layer(b[a])}}return d}};"use strict";var WCSDownloadControl=function(a,b,c){this.downloadButton=this.createDownloadButton();this.eventsManager=c;this.downloadDiv=document.getElementById(a);this.currentBounds=b;this.currentLayer=null;this._retriever=new AjaxRetriever();Utils.addHTMLEventListener(this.downloadButton,"click",this.setupWCSrequest,this);this.downloadDiv.appendChild(this.downloadButton);this.eventsManager.register("MAP_SELECTION_CHANGED",this,this._onMapSelectionChanged);this.eventsManager.register("SELECTED_LAYER_CHANGED",this,this._onSelectedLayerChanged)};WCSDownloadControl.prototype={createDownloadButton:function(){var a=document.createElement("input");a.type="submit";a.id="wcsdownload";a.value="Download Data";return a},_onMapSelectionChanged:function(a){this.currentBounds=a.selection},_onSelectedLayerChanged:function(a){this.currentLayer=a.layer;if(this.currentLayer===null){this.downloadButton.disabled=true}else{this.downloadButton.disabled=false;WMSC.log("WCS endpoint is now "+this._getWCSEndpoint())}return 1},setupWCSrequest:function(){if(this.currentLayer===null){alert("No layer currently selected.");return}var a=this._getWCSEndpoint();var c=document.getElementById("coordsForm");var b=this.currentBounds.left+","+this.currentBounds.bottom+","+this.currentBounds.right+","+this.currentBounds.top;var d=layerParameters.layerDims.getSelectedDimensions();this.makeWCSrequest(a,this.currentLayer.params.LAYERS,b,d)},makeWCSrequest:function(c,b,h,g){var f={request:"GetCoverage",service:"WCS",version:"1.0.0",crs:"EPSG:4326",format:"cf-netcdf"};f.coverage=b;f.bbox=h;for(var a in g){f[a]=g[a]}var d=c;for(var e in f){d=d+e+"="+f[e]+"&"}WMSC.log("Making wcs request to "+d);window.open(d,"download");return false},_getWCSEndpoint:function(){var c=this.currentLayer.getFullRequestString();var b=c.split("?");var a=b[0].replace("wms","wcs")+"?";return a}};"use strict";var LayerFigureDownload=function(a,b){this._container=document.getElementById(a);this._container.innerHTML=this.controlMarkup;this._form=document.getElementById("layer_figure_download_form");this.eventsManager=b;this.displayOptsRetriever=new DisplayOptionsRetriever();this.currentWMCLayer=null;this.currentOLLayer=null;this._hiddenInputContainer=null;this._selectHandler=null;this._getFigureHandler=null;this._getFigureButton=null;this._styleSelect=null;this._currentSelection=new OpenLayers.Bounds(-180,-90,180,90);this.eventsManager.register("CURRENT_WMCLAYER_CHANGED",this,this._onCurrentLayerChanged)};LayerFigureDownload.prototype={EVENTS_RAISED:[],LABEL_TEXT:"Get Figure for Selected Layer",controlMarkup:'<form id="layer_figure_download_form">\n</form>\n',_onCurrentLayerChanged:function(a){this._clearForm();if(a.wmcLayer!==null&&a.olLayer!==null){this._buildInfo(a.wmcLayer,a.olLayer,a.wmc)}this.currentOLLayer=a.olLayer;this.currentWMCLayer=a.wmcLayer},_buildInfo:function(d,c,b){if(b.supportsRequest("GetFigure")){var a=Utils.buildLabel(this.LABEL_TEXT);this._form.appendChild(a);this._form.appendChild(this._buildGetFigureButton(b));this._form.appendChild(document.createTextNode("\n"))}this._hiddenInputContainer=document.createElement("div");this._form.appendChild(this._hiddenInputContainer)},_clearForm:function(){if(this._styleSelect!==null&&this._selectHandler!==null){Utils.removeHTMLEventListener(this._styleSelect,"change",this._selectHandler)}if(this._getFigureButton!==null&&this._getFigureHandler!==null){Utils.removeHTMLEventListener(this._getFigureButton,"click",this._getFigureHandler)}this._form.innerHTML="";this._styleSelect=null;this._selectHandler=null;this._getFigureButton=null;this._getFigureHandler=null;this._hiddenInputContainer=null},_getLayerProperty:function(b,c){var a=null;if(b!==null){a=b.params[c.toUpperCase()]}return a},_buildGetFigureButton:function(d){var b;var h=document.createElement("div");var e=d.getRequest("GetFigure");var c=[];var g=[];var f=e.formats;for(b=0;b<f.length;b++){g.push(f[b]);if(f[b]==="image/svg+xml"){c.push("SVG")}else{if(f[b].indexOf("image/")===0){c.push(f[b].slice(6,f[b].length).toUpperCase())}else{if(f[b]==="application/postscript"){c.push("PS")}else{if(f[b]==="application/pdf"){c.push("PDF")}else{c.push(f[b])}}}}}var a=Utils.buildSelect(null,"format",c,g);h.appendChild(a);this._getFigureButton=document.createElement("input");this._getFigureButton.type="button";this._getFigureButton.value="Get Figure";this._getFigureHandler=Utils.addHTMLEventListener(this._getFigureButton,"click",this._onGetFigureClick,this);h.appendChild(this._getFigureButton);return h},_onGetFigureClick:function(a){WMSC.log("_onGetFigureClick running");this._addHiddenInputItems();this._form.action=this.currentOLLayer.url;this._form.method="get";this._form.target="_blank";this._form.submit()},_addHiddenInputItems:function(){this._hiddenInputContainer.innerHTML="";for(var b in this.currentOLLayer.params){if(b.toUpperCase()==="REQUEST"){this._hiddenInputContainer.appendChild(Utils.buildHiddenInputElement("REQUEST","GetFigure"))}else{if(b.toUpperCase()==="FORMAT"){}else{this._hiddenInputContainer.appendChild(Utils.buildHiddenInputElement(b,this.currentOLLayer.params[b]))}}}var a=this._currentSelection.left+","+this._currentSelection.bottom+","+this._currentSelection.right+","+this._currentSelection.top;this._hiddenInputContainer.appendChild(Utils.buildHiddenInputElement("BBOX",a));this._hiddenInputContainer.appendChild(Utils.buildHiddenInputElement("WIDTH","1200"));this._hiddenInputContainer.appendChild(Utils.buildHiddenInputElement("HEIGHT","900"))},addMapSelectionChangedHandlers:function(a){a.register("MAP_SELECTION_CHANGED",this,this.onChangeSelection)},onChangeSelection:function(a){this._currentSelection=a.selection}};"use strict";var LayerInfo=function(a,b,c){if(c===undefined){this.furtherInfoLinks=[]}else{this.furtherInfoLinks=c}this._container=document.getElementById(a);this.eventsManager=b;this.eventsManager.register("CURRENT_WMCLAYER_CHANGED",this,this._onCurrentLayerChanged)};LayerInfo.prototype={EVENTS_RAISED:[],_onCurrentLayerChanged:function(a){if(a.wmcLayer!==null&&a.olLayer!==null){this._buildInfo(a.wmcLayer,a.olLayer)}else{this._clearInfo()}},_buildInfo:function(f,d){var e=document.createElement("div");e.appendChild(this._buildInfoItem("URL",d.url));e.appendChild(this._buildInfoItem("Layer Name",this._getLayerProperty(d,"layers")));e.appendChild(this._buildInfoItem("Layer Abstract",f.getAbstract()));var a="";for(var b=0;b<this.furtherInfoLinks.length;b++){var c=this.furtherInfoLinks[b];if(c.match(d.url)){a=a+c.getHTML()+", "}}if(a.length>0){a=a.slice(0,a.length-2);e.appendChild(this._buildInfoItem("Further Info",a))}this._clearInfo();this._container.appendChild(e)},_clearInfo:function(){this._container.innerHTML=""},_getLayerProperty:function(b,c){var a=null;if(b!==null){a=b.params[c.toUpperCase()]}return a},_buildInfoItem:function(a,c){var b=document.createElement("span");b.innerHTML=c;return Utils.buildLabelInputDiv(a,b,"layerInfoItem")}};"use strict";var DDM=YAHOO.util.DragDropMgr;var LayerList=OpenLayers.Class.create();LayerList.prototype={EVENTS_RAISED:["SELECTED_LAYER_CHANGED","LAYER_ORDER_CHANGED","LAYER_REMOVED"],MAX_LAYERS:10,events:null,SELECTED_CLASS:"selected",initialize:function(a,c,b){this._dragList=document.getElementById(a);this._outlineOnTopChk=document.getElementById(c);this.eventsManager=b;while(this._dragList.childNodes[0]){this._dragList.removeChild(this._dragList.childNodes[0])}this._layers=[];this.target=new YAHOO.util.DDTarget(a);this.removeLayerBtn=document.getElementById("btn_remove_selected_layer");Utils.addHTMLEventListener(this.removeLayerBtn,"click",this._onRemoveClick,this);Utils.addHTMLEventListener(this._outlineOnTopChk,"click",this._onOutlineOnTopClick,this);this.eventsManager.register("NEW_OUTLINE",this,this.onNewLayer);this.eventsManager.register("NEW_LAYER",this,this.onNewLayer)},_addOnClickListeners:function(){var a=this._getCurrentListItems();for(var b=0;b<a.length;b++){Utils.addHTMLEventListener(a[b],"click",this._onItemClick,this)}},_onItemClick:function(b){var a=b.target||b.srcElement;this._selectItem(a)},_onDragEnd:function(a){this._selectItem(a);if(this._outlineOnTopChk.checked&&this._isOutlineInList()){if(!this._isOutlineOnTop()){this._moveOutlineToTop()}}this._triggerLayerOrderChange()},_onRemoveClick:function(c,d){var a=this.getSelectedLayer();if(a!==null){var e=a.id;this._removeSelectedItem();var b=this._getCurrentListItems();if(b.length>1){if(b[0].id==="outline_layer"){this._selectItem(b[1])}else{this._selectItem(b[0])}}else{if(b.length===1){this._selectItem(b[0])}}this._triggerLayerRemoved(e);this._triggerLayerOrderChange();this._triggerSelectedLayerChange()}},_onOutlineOnTopClick:function(a){if(this._outlineOnTopChk.checked&&this._isOutlineInList()){if(!this._isOutlineOnTop()){this._moveOutlineToTop();this._triggerLayerOrderChange()}}},_selectItem:function(a){if(!this._isSelected(a)){this._unselectAll();a.className=this.SELECTED_CLASS+" "+a.className;this._triggerSelectedLayerChange()}},_unselectAll:function(){var a=this._getCurrentListItems();for(var b in a){this._unselectItem(a[b])}},_unselectItem:function(a){if(this._isSelected(a)){a.className=a.className.slice(this.SELECTED_CLASS.length)}},_isSelected:function(a){if(a.className!==undefined){return a.className.slice(0,this.SELECTED_CLASS.length)===this.SELECTED_CLASS}return false},_getSelectedItem:function(){var a=this._getCurrentListItems();for(var b in a){if(this._isSelected(a[b])){return a[b]}}return null},_removeSelectedItem:function(){var a=this._getSelectedItem();this._removeItem(a)},_removeItem:function(b){if(b!==null){var a=DDM.getDDById(b.id);if(a!==null){a.unreg()}this._removeLayer(b.id);this._dragList.removeChild(b)}},_removeLayer:function(a){var d=this._layers;var e=[];for(var c=0;c<d.length;c++){var b=d[c];if(b.id!==a){e.push(b)}}this._layers=e},_addListItem:function(e){var b=this._getCurrentListItems();var d=Utils.buildScopedFunction(this._onDragEnd,this);var c=new YAHOO.example.DDList(e.id,d);var a=document.createElement("li");var f=this._dragList.firstChild;if(f===null){this._dragList.appendChild(a)}else{if(e.id==="outline_layer"){this._dragList.insertBefore(a,f)}else{if(this._outlineOnTopChk.checked&&this._isOutlineInList()){if(f.id!=="outline_layer"){this._moveOutlineToTop()}this._dragList.insertBefore(a,f.nextSibling)}else{this._dragList.insertBefore(a,f)}}}a.className="list";a.id=e.id;a.appendChild(document.createTextNode(e.name));this._addOnClickListeners();return a},_getCurrentListItems:function(){var a=[];for(var b=0;b<this._dragList.childNodes.length;b++){var c=this._dragList.childNodes[b];if(c.nodeType===1&&c.nodeName==="LI"){a.push(c)}}return a},onNewLayer:function(c){if(this._layers.length>=this.MAX_LAYERS){alert("Can't have more than "+this.MAX_LAYERS+" layers in the list.")}else{var a=false;for(var b=0;b<this._layers.length;b++){if(this._layers[b].id===c.layer.id){a=true}}if(a){alert("Layer with id = "+c.layer.id+" already in the list")}else{this._addLayer(c.layer)}}},_addLayer:function(a){this._layers.push(a);var b=this._addListItem(a);this._triggerLayerOrderChange();this._selectItem(b)},_triggerLayerOrderChange:function(){this.eventsManager.triggerEvent("LAYER_ORDER_CHANGED",{layers:this._getOrderedLayers()})},_triggerSelectedLayerChange:function(){this.eventsManager.triggerEvent("SELECTED_LAYER_CHANGED",{layer:this.getSelectedLayer()})},_triggerLayerRemoved:function(a){this.eventsManager.triggerEvent("LAYER_REMOVED",{layer_id:a})},_getOrderedLayers:function(){var a=this._getCurrentListItems();var d=[];for(var c=0;c<a.length;c++){var b=a[c].id;d.push(this._getLayerById(b))}return d},_getLayerById:function(b){for(var a=0;a<this._layers.length;a++){if(this._layers[a].id===b){return this._layers[a]}}return null},getSelectedLayer:function(){var b=this._getSelectedItem();var a;if(b===null){a=null}else{a=this._getLayerById(b.id)}return a},destroy:function(){this.target.unreg();this._removeAllItems()},_isOutlineInList:function(){return this._getLayerById("outline_layer")!==null},_isOutlineOnTop:function(){return this._dragList.firstChild.id==="outline_layer"},_moveOutlineToTop:function(){var b=this._dragList.firstChild;if(b.id==="outline_layer"){return}var d=null;for(var a=1;a<this._dragList.childNodes.length;a++){var c=this._dragList.childNodes[a];if(c.id==="outline_layer"){d=c;break}}if(d!==null){this._dragList.insertBefore(d,b)}},_removeAllItems:function(){var a=this._getCurrentListItems();for(var b=0;b<a.length;b++){this._removeItem(a[b])}}};"use strict";var LayerDisplayOpts=function(a,b,c){this._form=document.getElementById(a);this.eventsManager=c;this.displayOptsRetriever=new DisplayOptionsRetriever();this.hideDisplayOptions=b;this.currentWMCLayer=null;this.currentOLLayer=null;this._handlerLookup=null;this.eventsManager.register("LAYER_STYLE_CHANGED",this,this._onLayerStyleChanged);this.eventsManager.register("CURRENT_WMCLAYER_CHANGED",this,this._onCurrentLayerChanged)};LayerDisplayOpts.prototype={EVENTS_RAISED:["LAYER_DISPLAY_CHANGED"],_onSelectionChange:function(c){var b=c.target||c.srcElement;var d=b.id.substr(7);var a=b.value;if(b.type==="checkbox"){a=(b.checked)?"True":"False"}WMSC.log("value = "+a);a=escape(a);WMSC.log("escaped value = "+a);this.eventsManager.triggerEvent("LAYER_DISPLAY_CHANGED",{param:d,value:a})},_onLayerStyleChanged:function(a){this._buildDisplayControls()},_onCurrentLayerChanged:function(a){this._clearForm();this.currentWMCLayer=a.wmcLayer;this.currentOLLayer=a.olLayer;if(a.wmcLayer!==null&&a.olLayer!==null){this._buildDisplayControls()}},_buildDisplayControls:function(){var b=this.currentWMCLayer.getDisplayOptionsURL();if(b!==null){var a=this._buildDisplayOptions.bindAsEventListener(this);this.displayOptsRetriever.getDisplayOptions(b,a)}else{this._buildDisplayOptions(null)}},_clearForm:function(){if(this._handlerLookup!==null){Utils.removeEventHandlersFromLookup(this._handlerLookup,"change");this._handlerLookup=null}this._form.innerHTML=""},_buildDisplayOptions:function(g){this._clearForm();var f=this.currentOLLayer.url;var e=[];if(this.hideDisplayOptions!==null){for(var c=0;c<this.hideDisplayOptions.length;c++){if(Utils.reMatch(this.hideDisplayOptions[c].endpoint,f)){for(var b=0;b<this.hideDisplayOptions[c].options.length;b++){e.push(this.hideDisplayOptions[c].options[b])}}}}var h=document.createElement("div");var d=this.currentWMCLayer.getStyles();var a=this._getCurrentLayerProperty("styles");h.appendChild(this._buildGenericDisplayOptions(d,a,e));if(g!==null){if(g.common!==undefined){h.appendChild(this._buildDisplayOptionsList(g.common,e))}if(a!==null){if(g[a]!==undefined){h.appendChild(this._buildDisplayOptionsList(g[a],e))}}}this._form.innerHTML="";this._form.appendChild(h);this._handlerLookup=Utils.addHandlerToFormElements(this._form,"change",this._onSelectionChange,this)},_buildGenericDisplayOptions:function(c,a,b){var d=document.createElement("div");if(c.length>0){d.appendChild(this._buildStyleSelect(c,a))}if(!Utils.isValueInList("transparent",b)){d.appendChild(this._buildDisplayOptionBool({name:"transparent",title:"Transparent Background",defaultValue:"true"}))}if(!Utils.isValueInList("bgcolor",b)){d.appendChild(this._buildDisplayOptionValue({name:"bgcolor",title:"Background Colour",defaultValue:null}))}return d},_buildDisplayOptionsList:function(d,c){var e=document.createElement("div");for(var b=0;b<d.length;b++){var a=d[b];if(Utils.isValueInList(a.name,c)){continue}if(a.type==="select"){e.appendChild(this._buildDisplayOptionSelect(a))}else{if(a.type==="value"){e.appendChild(this._buildDisplayOptionValue(a))}else{if(a.type==="bool"){e.appendChild(this._buildDisplayOptionBool(a))}}}}return e},_buildDisplayOptionSelect:function(b){var c=this._getDisplayOptionTitle(b);var e=this._getDefaultValue(b);var a=Utils.buildSelectBox(b.name,b.options,b.options,e);var d=Utils.buildLabelInputDiv(c,a,"displayOptionItem");return d},_buildDisplayOptionValue:function(b){var c=this._getDisplayOptionTitle(b);var a=document.createElement("input");a.id="select_"+b.name;a.name="select_"+b.name;a.type="text";a.value=this._getDefaultValue(b);Utils.addHTMLEventListener(a,"keypress",Utils.disableEnterKey,this);var d=Utils.buildLabelInputDiv(c,a,"displayOptionItem");return d},_buildDisplayOptionBool:function(b){var c=this._getDisplayOptionTitle(b);var a=document.createElement("input");a.id="select_"+b.name;a.name="select_"+b.name;a.type="checkbox";a.onClick="";var e=this._getDefaultValue(b);if(String(e).toUpperCase()==="TRUE"){a.checked=true}var d=Utils.buildLabelInputDiv(c,a,"displayOptionItem");return d},_getDefaultValue:function(a){var b=this._getCurrentLayerProperty(a.name);if(b===null||b===undefined){if(a.defaultVal===undefined||a.defaultVal===null){b=""}else{b=a.defaultVal}}return b},_getCurrentLayerProperty:function(c){var b=null;if(this.currentOLLayer!==null){b=this.currentOLLayer.params[c.toUpperCase()];if(b===""&&c.toUpperCase()==="STYLES"){var a=this.currentWMCLayer.getStyles();if(a.length>0){b=a[0].name}}}return b},_getDisplayOptionTitle:function(a){var b=a.title;if(b===undefined){b=a.name}return b},_buildStyleSelect:function(e,c){var a=[];var b=[];for(var d=0;d<e.length;d++){a.push(e[d].name);b.push(e[d].title)}this._styleSelect=Utils.buildSelectBox("styles",b,a,c);return Utils.buildLabelInputDiv("Style",this._styleSelect,"layerInfoItem")}};"use strict";var LayerDownload=function(a,b,c,d,e){this._containingDiv=document.getElementById(a);if(e){this.controlMarkup=e}this._containingDiv.innerHTML=this.controlMarkup;this.figBuilder=new FigureBuilder("composite_figure_container",c,b,d);this.wcsdown=new WCSDownloadControl("wcs_download_div",b,d);this.figDownload=new LayerFigureDownload("get_figure_container",d)};LayerDownload.prototype={EVENTS_RAISED:[],controlMarkup:'    <label>Generate Composite Figure</label>        <div id="composite_figure_container"></div>    <label>Download Data from Selected Layer</label>        <div id="wcs_download_div"></div>    <div id="get_figure_container"></div>'};var LayoutManager=function(){};LayoutManager.prototype={EVENTS_RAISED:[],setupLayout:function(){var b=YAHOO.util.Dom;var a=YAHOO.util.Event;this.layout=new YAHOO.widget.Layout({units:[{position:"bottom",header:"",height:200,resize:true,body:"bottom1",gutter:"5px",collapse:true},{position:"center",body:"center1"}]});a.onDOMReady(this._onDomReady.bindAsEventListener(this));this.layout.on("resize",function(h){var e=b.get("center_content");b.setStyle(e,"height",h.sizes.center.h+"px");var k;var d;var c=h.sizes.center.h-2;var f=h.sizes.center.w-4;var g=h.sizes.center.w/h.sizes.center.h;var j=c*2;var i=f*2;if(g>2){k=c;d=j}else{if(g==2){k=c;d=Math.floor(c/2)}else{d=f;k=Math.floor(f/2)}}b.setStyle("map","width",d+"px");b.setStyle("map","height",k+"px");b.setStyle(("tab_content"),"height",h.sizes.bottom.h-86+"px");b.setStyle(("bottom_left"),"height",h.sizes.bottom.h-40+"px");b.setStyle(("bottom_middle"),"height",h.sizes.bottom.h-40+"px");b.setStyle(("bottom_right"),"height",h.sizes.bottom.h-40+"px")})},refreshTabWidths:function(){var d=this._getWidth("bottom1")-6;var g=this._getWidth("bottom_right");var c=this._getWidth("bottom_middle");var f=this._getWidth("bottom_left");var e=g+c+f;var b=Math.floor(g/e*d);var h=Math.floor(c/e*d);var a=Math.floor(f/e*d);if(b<100){b=100}if(h<100){h=100}if(a<100){a=100}this._setWidth("bottom_left",a);this._setWidth("bottom_middle",h);this._setWidth("bottom_right",b)},_onDomReady:function(){this.layout.render();var a=this._getWidth("bottom1")-6;var c=new YAHOO.util.Resize("bottom_left",{handles:["r"],minWidth:100,maxWidth:a-200});c.on("resize",this._onLeftResize.bindAsEventListener(this));var b=new YAHOO.util.Resize("bottom_middle",{handles:["r"],minWidth:100,maxWidth:a-200});b.on("resize",this._onMiddleResize.bindAsEventListener(this))},_onLeftResize:function(f){var b=f.width;var d=this._getWidth("bottom1")-6;var g=this._getWidth("bottom_right");var c=this._getWidth("bottom_middle");var e=true;var h=null;var a=null;if(c>100){h=d-b-g;if(h>100){e=false}else{h=100}}else{h=100}if(e){a=d-b-h;if(a<100){a=100;b=d-h-a}}this._setWidth("bottom_left",b);this._setWidth("bottom_middle",h);this._setWidth("bottom_right",a)},_onMiddleResize:function(c){var a=c.width;var b=this._getWidth("bottom1")-6;var e=this._getWidth("bottom_right");var d=this._getWidth("bottom_left");targetRightWidth=b-a-d;if(targetRightWidth<100){targetRightWidth=100;a=b-targetRightWidth-d}this._setWidth("bottom_middle",a);this._setWidth("bottom_right",targetRightWidth)},_getWidth:function(b){var c=YAHOO.util.Dom.getRegion(b);var a=c.right-c.left;return a},_setWidth:function(b,a){YAHOO.util.Dom.setStyle(b,"width",(a)+"px")}};"use strict";var SplitAxisSelectList=function(c,b,a){this.indexFactor=c;this.label=b;this.values=a};var SplitAxisMapping=function(c,b){this.axisValues=c;this.selectLists=b;for(var a=0;a<b.length;a++){if(this.selectLists[a].constructor!==SplitAxisSelectList){throw ("Unknown value in select list ("+this.selectLists[a].constructor+") expected SplitAxisSelectList.")}}};var SplitAxisConfig=function(a){for(var c in a){var b=a[c];if(b.constructor!==SplitAxisMapping){throw ("Unknown value in mapping list ("+b.constructor+") expected SplitAxisMapping.")}}this.mappingObj=a};SplitAxisConfig.prototype={getAxisNames:function(){var a=[];for(var b in this.mappingObj){a.push(b)}return a},getAxisMapping:function(a){var c=false;var d=this.getAxisNames();for(var b=0;b<d.length;b++){if(a===d[b]){c=true;break}}if(!c){WMSC.log("Axis name "+a+" not found in the mapping list.");return null}return this.mappingObj[a]}};var SplitAxisConfigBuilder=function(a){this.node=a};SplitAxisConfigBuilder.prototype={buildConfig:function(){var b=this._getAllAxisElements();var a={};for(var c=0;c<b.length;c++){var g=b[c];var f=this._buildAxisValues(g);var e=this._buildSelectLists(g);var d=g.getAttribute("name").toLowerCase();a[d]=new SplitAxisMapping(f,e)}return new SplitAxisConfig(a)},_buildAxisValues:function(c){var a=WMSC.traverseWMSDom(c,["AxisValues"]);var d=[];for(var b=0;b<a.childNodes.length;b++){var e=a.childNodes[b];if(e.nodeName==="AxisValue"){d.push(WMSC.getTextContent(e))}}return d},_getAllAxisElements:function(){var a;var b=[];for(a=0;a<this.node.childNodes.length;a++){var c=this.node.childNodes[a];if(c.nodeName.toUpperCase()==="AXIS"){b.push(c)}}return b},_buildSelectLists:function(c){var b=WMSC.traverseWMSDom(c,["SelectLists"]);var d=[];for(var a=0;a<b.childNodes.length;a++){var e=b.childNodes[a];if(e.nodeName==="SelectList"){d.push(this._buildSplitAxisSelect(e))}}return d},_buildSplitAxisSelect:function(e){var c=e.getAttribute("indexFactor");var b=e.getAttribute("label");var a=[];for(var d=0;d<e.childNodes.length;d++){var f=e.childNodes[d];if(f.nodeName==="Option"){a.push(WMSC.getTextContent(f))}}return new SplitAxisSelectList(c,b,a)}};"use strict";var SplitAxisSelect=function(a,c,b,d){this.containerId=this.name+"_split_select";this.name=a;this.data=c;this.containerClass=d;if(b===undefined){this.labelText=a}else{this.labelText=b}};SplitAxisSelect.prototype={build:function(){var a=document.createElement("div");if(this.containerClass!==undefined){a.className=this.containerClass}if(this.data.constructor===Array){a.appendChild(Utils.buildLabel(this.labelText,{id:this.name+"_label",htmlFor:this.name}));a.appendChild(document.createTextNode("\n"));a.appendChild(Utils.buildSelect("select_"+this.name,this.name,this.data,this.data))}else{this._buildSplitSelect(a)}return a},_buildSplitSelect:function(a){a.appendChild(Utils.buildLabel(this.labelText,{id:this.name+"_label"}));a.appendChild(document.createTextNode("\n"));for(var c=0;c<this.data.selectLists.length;c++){var b=this.data.selectLists[c];var h="select_"+this.name+"_subselect_"+c;var g=document.createElement("div");g.className="subselect_input";g.appendChild(Utils.buildLabel(b.label,{id:this.name+"_subselect_"+c+"_label"}));var f=Utils.buildSelect(h,null,b.values,b.values);var d=Utils.addHTMLEventListener(f,"change",this._buildTime,this);g.appendChild(f);g.appendChild(document.createTextNode("\n"));a.appendChild(g)}var e=this.data.axisValues[0];a.appendChild(Utils.buildHiddenInputElement("select_"+this.name,e,"select_"+this.name));a.appendChild(document.createTextNode("\n"))},_buildTime:function(){var a=document.getElementById("select_"+this.name);a.value=this._buildTimeString()},_buildTimeString:function(){var a=0;for(var c=0;c<this.data.selectLists.length;c++){var d="select_"+this.name+"_subselect_"+c;var b=document.getElementById(d);a+=b.selectedIndex*this.data.selectLists[c].indexFactor}return this.data.axisValues[a]}};"use strict";var EndpointSelection=function(a,b,c){this._container=document.getElementById(a);this.endpointList=b;this.eventsManager=c;this._container.innerHTML=this.controlMarkup;this._select=this._buildSelect(b);this._input=document.getElementById("new_endpoint_1");this._addButton=document.getElementById("new_endpoint_button");this._selectMethodRadio=document.getElementById("endpoint_select_method_select");this._inputMethodRadio=document.getElementById("endpoint_select_method_input");Utils.addHTMLEventListener(this._selectMethodRadio,"click",this._onMethodRadioClick,this);Utils.addHTMLEventListener(this._inputMethodRadio,"click",this._onMethodRadioClick,this);Utils.addHTMLEventListener(this._addButton,"click",this._onAddButtonClick,this);this._selectContainer=document.getElementById("new_endpoint_select_container");this._selectContainer.appendChild(this._select);this._inputContainer=document.getElementById("new_endpoint_input_container");this._inputContainer.style.display="none";this._selectMethodRadio.checked=true};EndpointSelection.prototype={EVENT_TYPES:["NEW_ENDPOINT"],controlMarkup:'\n<div>\n    <label for="endpoint_select_method_select"> Select Preset </label>\n   <input type="radio" name="endpoint_select_method" value="select" \n                  id="endpoint_select_method_select" ></input>\n   <label for="endpoint_select_method_input"> Enter URL </label>\n   <input type="radio" name="endpoint_select_method" value="input" \n                   id="endpoint_select_method_input" ></input>\n</div>\n<div>\n    <span id="new_endpoint_select_container"></span> \n    <span id="new_endpoint_input_container"> \n      <input id="new_endpoint_1" size="40" type="text" ></input> \n    </span> \n  <input type="button" id="new_endpoint_button" value="Add" /> \n</div>\n',_buildSelect:function(d){var b=[];var a=[];for(var c=0;c<d.length;c++){b.push(d[c].name);a.push(d[c].url)}return Utils.buildSelect("new_endpoint_2","new_endpoint_2",b,a)},_onAddButtonClick:function(b){WMSC.log("Add endpoint clicked.");var a=null;if(this._selectMethodRadio.checked){a=this._select.value}else{a=this._input.value}this.eventsManager.triggerEvent("NEW_ENDPOINT",{url:a})},_onMethodRadioClick:function(a){if(this._selectMethodRadio.checked){if(this._selectContainer.style.display==="none"){this._selectContainer.style.display="";this._inputContainer.style.display="none"}}else{if(this._inputContainer.style.display==="none"){this._inputContainer.style.display="";this._selectContainer.style.display="none"}}}};"use strict";var AjaxRetriever=function(){this._contextLookup={}};AjaxRetriever.prototype={lookup:{},getResponse:function(d,b,a,c){this._getResponse(d,b,a,c)},_getResponse:function(f,b,a,d){var g,c,e;if(this._isCached(f)){g=this._getParamsString(f);b(this._contextLookup[g])}else{c=function(i){var h=this._processResponse(i);this._addToLookup(f,h);b(h)};if(a===undefined){a=function(h){WMSC.log("Failure:"+h)}}if(d===undefined){d=function(i,h){WMSC.log("Exception:"+h)}}e=new Ajax.Request("",{parameters:f,method:"get",onSuccess:c.bindAsEventListener(this),onException:d,onFailure:a})}},_processResponse:function(a){return a},_addToLookup:function(b,a){var c=this._getParamsString(b);this._contextLookup[c]=a},_isCached:function(b){var c,a;c=this._getParamsString(b);for(a in this._contextLookup){if(a===c){return true}}return false},_getParamsString:function(c){var b="",a;for(a in c){b=b+a+":"+c[a]+","}return b}};"use strict";var AxisConfigRetriever=function(){this._contextLookup={}};AxisConfigRetriever.prototype=new AjaxRetriever();AxisConfigRetriever.prototype.constructor=AxisConfigRetriever;AxisConfigRetriever.prototype.getResponse=function(c,b,a,d){var e={REQUEST:"GetAxisConfig",URL:c};this._getResponse(e,b,a,d)};AxisConfigRetriever.prototype._processResponse=function(b){respXML=b.responseXML;var a=new SplitAxisConfigBuilder(respXML.documentElement);return a.buildConfig()};"use strict";var LayerDimensions=function(a,b){this._form=document.getElementById(a);this.eventsManager=b;this._handlerLookup=null;this._retriever=new AxisConfigRetriever();this.eventsManager.register("CURRENT_WMCLAYER_CHANGED",this,this._onCurrentLayerChanged)};LayerDimensions.prototype={EVENTS_RAISED:["LAYER_DIMENSION_CHANGED"],_onCurrentLayerChanged:function(c){this._clearForm();if(c.wmcLayer!==null&&c.olLayer!==null){var a=c.wmcLayer.getAxisConfigURL();if(a===null){this._buildForm(c.wmcLayer,c.olLayer)}else{var b=function(d){this._buildForm(c.wmcLayer,c.olLayer,d)};this._retriever.getResponse(a,b.bindAsEventListener(this))}}},_clearForm:function(){if(this._handlerLookup!==null){Utils.removeEventHandlersFromLookup(this._handlerLookup,"change");this._handlerLookup=null}this._form.innerHTML=""},_buildForm:function(h,e,c){var d=h.getDimensions();var g=document.createElement("div");for(var f in d){var b=d[f].getExtent();var a=null;if(c===undefined){a=new SplitAxisSelect(f,b,d[f].getName(),"layerDimItem")}else{a=new SplitAxisSelect(f,c.getAxisMapping(f),d[f].getName(),"layerDimItem")}g.appendChild(a.build())}this._form.appendChild(g);this._handlerLookup=Utils.addHandlerToFormElements(this._form,"change",this._onSelectionChange,this)},_onSelectionChange:function(d){var c=d.target||d.srcElement;var f=null;var b=null;var a=c.id.indexOf("_subselect_");if(a>-1){f=c.id.substring(7,a);b=document.getElementById("select_"+f).value}else{f=c.id.substr(7);b=c.value}this.eventsManager.triggerEvent("LAYER_DIMENSION_CHANGED",{param:f,value:b})},getDimensionText:function(b,a){return a},_getLayerProperty:function(b,c){var a=null;if(b!==null){a=b.params[c.toUpperCase()]}return a},getSelectedDimensions:function(){var e={};var d=Utils.getActiveFormElements(this._form);for(var c=0;c<d.length;c++){var b=d[c];if(b.name!==null){var a=b.name;if(a.substr(0,7)==="selected_"){a=a.substr(7)}e[a]=b.value}}return e}};"use strict";var LayerParameters=function(f,b,e,c,d,a){this.eventsManager=d;this.propertiesDiv=document.getElementById(f);this.currentOLLayer=null;this.currentWMCLayer=null;this.wmcRetriever=e;this.layerInfo=new LayerInfo("layer_info",this.eventsManager,a);this.layerDims=new LayerDimensions("WMSC_dimForm",this.eventsManager);this.layerDisplay=new LayerDisplayOpts(b,c,this.eventsManager);this.eventsManager.register("LAYER_DISPLAY_CHANGED",this,this.onParamChange);this.eventsManager.register("LAYER_DIMENSION_CHANGED",this,this.onParamChange);this.eventsManager.register("SELECTED_LAYER_CHANGED",this,this.onSelectedLayerChanged);WMSC.log("layer parameters created")};LayerParameters.prototype={EVENTS_RAISED:["LAYER_PROPERTY_CHANGED","CURRENT_WMCLAYER_CHANGED","LAYER_STYLE_CHANGED"].concat(LayerInfo.prototype.EVENTS_RAISED,LayerDimensions.prototype.EVENTS_RAISED,LayerDisplayOpts.prototype.EVENTS_RAISED),onParamChange:function(a){if(this.currentOLLayer!==null){this.currentOLLayer.params[a.param.toUpperCase()]=a.value;this.currentOLLayer.redraw()}this.eventsManager.triggerEvent("LAYER_PROPERTY_CHANGED",{layer:this.currentOLLayer,wmcLayer:this.currentWMCLayer});if(a.param.toUpperCase()==="STYLES"){this.eventsManager.triggerEvent("LAYER_STYLE_CHANGED",{style:a.value})}},onSelectedLayerChanged:function(b){this.currentOLLayer=b.layer;this.currentWMCLayer=null;if(b.layer===null){var a={wmc:null,olLayer:null,wmcLayer:null};this.globalEventsManager.triggerEvent("CURRENT_WMCLAYER_CHANGED",a);this.internalEvents.triggerEvent("CURRENT_WMCLAYER_CHANGED",a)}else{this.updateControls()}},hideControls:function(){this.propertiesDiv.style.display="none"},showControls:function(){this.propertiesDiv.style.display="block"},updateControls:function(){var a=this.buildControls.bindAsEventListener(this);this.wmcRetriever.getWMC(this.currentOLLayer.url,a)},buildControls:function(b){var c=this.searchSubLayers(b.getSubLayers());if(c===null){WMSC.log("WARNING: layer "+this.currentOLLayer.params.LAYERS+" not found in capabilities document.")}this.currentWMCLayer=c;var a={wmc:b,olLayer:this.currentOLLayer,wmcLayer:this.currentWMCLayer};this.eventsManager.triggerEvent("CURRENT_WMCLAYER_CHANGED",a)},searchSubLayers:function(c){var d=null;for(var b=0;b<c.length;b++){var a=c[b];if(a.getName()===this.currentOLLayer.params.LAYERS){d=a;break}if(a.getSubLayers().length>0){d=this.searchSubLayers(a.getSubLayers());if(d!==null){break}}}return d},destroy:function(){this.internalEvents.destroy();this._removeAllItems()}};"use strict";var FigureBuilder=function(c,b,a,d){this._container=document.getElementById(c);this._container.innerHTML=this.controlMarkup;this._form=document.getElementById("figureForm");this._form.action=b;this._button=document.getElementById("make_figure_btn");this._currentLayers=null;this._hiddenControlsDiv=this.buildHiddenControlsDiv();this._handler=Utils.addHTMLEventListener(this._button,"click",this.createFigure,this);this._currentSelection=a;this.eventsManager=d;d.register("LAYER_ORDER_CHANGED",this,this.onLayerOrderChanged);d.register("MAP_SELECTION_CHANGED",this,this.onChangeSelection)};FigureBuilder.prototype={controlMarkup:'\n<form id="figureForm" method="get">\n    <div>\n        <select name="figFormat">\n          <option value="image/png" selected="1"> PNG </option>\n          <option value="image/jpeg"> JPEG </option>\n          <option value="image/gif"> GIF </option>\n          <option value="application/postscript"> EPS </option>\n          <option value="image/svg+xml"> SVG </option>\n        </select>\n        <input type="button" value="Make Figure" id="make_figure_btn"/>\n    </div>\n</form>',onLayerOrderChanged:function(a){this._currentLayers=a.layers},onChangeSelection:function(a){this._currentSelection=a.selection;WMSC.log("this._currentSelection = "+this._currentSelection)},buildHiddenControlsDiv:function(){var a=document.createElement("div");a.style.display="none";this._form.appendChild(a);return a},createFigure:function(){this._hiddenControlsDiv.innerHTML="";if(this._currentLayers===null||this._currentLayers.length===0){alert("No layer found.")}else{for(var c=0;c<this._currentLayers.length;c++){var b=this._currentLayers[c];this._hiddenControlsDiv.appendChild(this._buildLayerInputs(c+1,b))}var a=this._currentSelection.left+","+this._currentSelection.bottom+","+this._currentSelection.right+","+this._currentSelection.top;this._hiddenControlsDiv.appendChild(this._buildInputElement("BBOX",a));this._hiddenControlsDiv.appendChild(this._buildInputElement("WIDTH","1200"));this._hiddenControlsDiv.appendChild(this._buildInputElement("HEIGHT","900"));this._form.setAttribute("target","_blank");this._form.submit()}},_buildLayerInputs:function(b,a){var d=document.createElement("div");d.appendChild(this._buildInputElement(b+"_ENDPOINT",a.url));for(var c in a.params){d.appendChild(this._buildInputElement(b+"_"+c,a.params[c]))}return d},_buildInputElement:function(b,c){var a=document.createElement("input");a.type="hidden";a.name=b;a.value=c;return a},destroy:function(){if(this._handler!==null){Utils.removeHTMLEventListener(this._button,"click",this._handler)}}};"use strict";var LegendContainer=OpenLayers.Class.create();LegendContainer.prototype={initialize:function(a,b){this.legendDiv=document.getElementById(a);this._retriever=new AjaxRetriever();this.eventsManager=b;this.eventsManager.register("LAYER_PROPERTY_CHANGED",this,this.onLayerPropertyChanged);this.eventsManager.register("CURRENT_WMCLAYER_CHANGED",this,this.onLayerChanged)},onLayerChanged:function(a){this.setLegendForLayer(a.olLayer,a.wmcLayer)},onLayerPropertyChanged:function(a){this.setLegendForLayer(a.layer,a.wmcLayer)},setLegendForLayer:function(d,e){var c=false;if(e!==null&&d!==null){var b=d.params.STYLES;var a=e.getLegendURL(b);WMSC.log("Legend url = "+a);if(a!==null){a=Utils.addParamsToUrl(a,d.params);this.loadNewLegend(a);c=true}}if(c===false){this.clearLegend()}},loadNewLegend:function(a){WMSC.log("getting legend url = "+a);var b=this.setLegend.bindAsEventListener(this);var c={REQUEST:"GetLegend",ENDPOINT:a};this._retriever.getResponse(c,b)},setLegend:function(b){WMSC.log("setting legend at"+new Date());this.legendDiv.innerHTML="";var a=b.responseText;if(a){this.legendDiv.innerHTML=a}},clearLegend:function(a){this.legendDiv.innerHTML=""}};"use strict";WMSC.BoundsControl=OpenLayers.Class.create();WMSC.BoundsControl.prototype={EVENT_TYPES:["clearSelection","TEXT_SELECTION_CHANGED"],GLOBAL_BOUNDS:new OpenLayers.Bounds(-180,-90,180,90),wmsParams:null,clearButtonID:"WMSC_clear",formID:"coordsForm",controlMarkup:'<div id="WMSC_sel" class="WMSC_domain"><table>  <tr><td colspan="2"          align="center">    <input type="text" name="bboxN" size="4" value="90"/><br/>N  </td></tr>  <tr>   <td><input type="text" name="bboxW" size="4" value="-180"/> W</td>   <td>E <input type="text" name="bboxE" size="4" value="180"/></td>  </tr>  <tr><td colspan="2" align="center">S<br/>    <input type="text" name="bboxS" size="4" value="-90"/>  </td></tr></table><input id="WMSC_clear" type="button" value="Reset selection"/></div>',initialize:function(b,a,c,d){this._input_names=["bboxN","bboxW","bboxE","bboxS"];this._supressTextChangeEvent=false;this.domainDivID=b;if(d){this.controlMarkup=d}this.eventsManager=c;this.wmsParams={};this._selectedDims={};this._lastSelection=null;this._initDomainDiv();if(a!==null){this.setSelection(a)}else{this.setSelection(this.GLOBAL_BOUNDS)}this.eventsManager.register("MAP_SELECTION_CHANGED",this,this._onMapSelectionChanged)},destroy:function(){},_selectionListener:function(){var a=this.getSelection();WMSC.log("triggering TEXT_SELECTION_CHANGED, selection = "+a);if(this._supressTextChangeEvent===false){this.eventsManager.triggerEvent("TEXT_SELECTION_CHANGED",{selection:a})}},_initDomainDiv:function(){var a=document.getElementById(this.domainDivID);a.innerHTML=this.controlMarkup;var e=$(this.clearButtonID);if(e){e.onclick=this._clearSelection.bindAsEventListener(this)}var d=this._selectionListener.bindAsEventListener(this);this.selectionForm=$(this.formID);var c=this._getInputElements();for(var b=0;b<c.length;b++){c[b].onchange=d}},_getInputElements:function(){var b=document.getElementById(this.domainDivID);var d=[];for(var c=0;c<this._input_names.length;c++){var a=Utils.getContainedElementsByName(b,this._input_names[c]);if(a.length===0||a[0]===null||a[0].tagName!=="INPUT"){throw"Required input element "+this._input_names[c]+" not found in BoundsControl."}d.push(a[0])}return d},_clearSelection:function(){this.eventsManager.triggerEvent("clearSelection")},getSelection:function(){var e=this._getInputElements();var g,f,d,a;for(var c=0;c<e.length;c++){var b=e[c];if(b.name==="bboxW"){g=b.value}else{if(b.name==="bboxS"){a=b.value}else{if(b.name==="bboxE"){d=b.value}else{if(b.name==="bboxN"){f=b.value}}}}}return new OpenLayers.Bounds(g,a,d,f)},setSelection:function(f){var a=this.getSelection();if(!(f.left>=-180&&f.left<180)){f.left=a.left}if(!(f.right>-180&&f.right<=180)){f.right=a.right}if(!(f.top>-90&&f.top<=90)){f.top=a.top}if(!(f.bottom>=-90&&f.bottom<90)){f.bottom=a.bottom}var d;if(f.left>f.right){d=f.left;f.left=f.right;f.right=d}if(f.bottom>f.top){d=f.bottom;f.bottom=f.top;f.top=d}var e=this._getInputElements();for(var c=0;c<e.length;c++){var b=e[c];if(b.name==="bboxW"){b.value=f.left.toFixed(1)}else{if(b.name==="bboxS"){b.value=f.bottom.toFixed(1)}else{if(b.name==="bboxE"){b.value=f.right.toFixed(1)}else{if(b.name==="bboxN"){b.value=f.top.toFixed(1)}}}}}},_onMapSelectionChanged:function(a){this._supressTextChangeEvent=true;this.setSelection(a.selection);this._supressTextChangeEvent=false}};"use strict";var WMCRetriever=OpenLayers.Class.create();WMCRetriever.prototype={contextLookup:{},initialize:function(a){if(a!==undefined){this.getWMC(a)}},getWMC:function(f,b,a){if(this.isWMCCached(f)){b(this.contextLookup[f])}else{var c=function(h){var g=new WMSC.Capabilities(h.responseXML.documentElement);this.addWMCToLookup(f,g);b(g)};var e={REQUEST:"GetWebMapCapabilities",ENDPOINT:f};if(a===undefined){a=function(g){WMSC.log("Failure:"+g)}}var d=new Ajax.Request("",{parameters:e,method:"get",onSuccess:c.bindAsEventListener(this),onException:function(h,g){WMSC.log("Exception:"+g)},onFailure:a})}},addWMCToLookup:function(b,a){this.contextLookup[b]=a},isWMCCached:function(b){var a;for(a in this.contextLookup){if(a===b){return true}}return false}};"use strict";var LayerDefaultSetter=function(b,a){this.globalDefaults=b;this.defaultOptionsList=a};LayerDefaultSetter.prototype={getDefaults:function(c,a){var b={};this._setValues(b,this.globalDefaults);if(this.defaultOptionsList!==null&&this.defaultOptionsList!==""){this._addDefaultsFromOptionsList(b,c,a)}return b},_addDefaultsFromOptionsList:function(g,d,e){for(var c=0;c<this.defaultOptionsList.length;c++){var a=this.defaultOptionsList[c].endpoint;if(Utils.reMatch(a,d)){for(var b=0;b<this.defaultOptionsList[c].layers.length;b++){var f=this.defaultOptionsList[c].layers[b];if(Utils.reMatch(f,e)){this._setValues(g,this.defaultOptionsList[c].values)}}}}},_setValues:function(c,b){for(var a in b){c[a]=b[a]}}};"use strict";var OutlineControl=function(b,e,a){this.outlineButton=document.getElementById(b);this.eventsManager=e;for(var d=0;d<this.OPTIONAL_ARGS.length;d++){var c=this.OPTIONAL_ARGS[d];if(a[c]!==undefined){this[c]=a[c]}}Utils.addHTMLEventListener(this.outlineButton,"click",this.addNewOutline,this);this.eventsManager.register("LAYER_REMOVED",this,this.onLayerRemoved)};OutlineControl.prototype={EVENT_TYPES:["NEW_OUTLINE"],OPTIONAL_ARGS:["url","params"],url:"http://labs.metacarta.com/wms/vmap0",params:{layers:"coastline_01",format:"image/png"},addNewOutline:function(){var a=new OpenLayers.Layer.WMS("Outline",this.url,this.params,{isBaseLayer:false,buffer:1});a.params.CRS="CRS:84";a.params.FORMAT="image/png";a.params.VERSION="1.3.0";a.params.TRANSPARENT="true";a.id="outline_layer";this.eventsManager.triggerEvent("NEW_OUTLINE",{layer:a});this.outlineButton.disabled=true},onLayerRemoved:function(a){if(a.layer_id==="outline_layer"){this.outlineButton.disabled=false}}}; 
  • cowsclient/trunk/cowsclient/public/js/layerControl.js

    r6335 r6425  
    162162     */ 
    163163    redrawTree: function () { 
     164         
     165        WMSC.log("Redrawing tree"); 
     166         
    164167        this.removeListeners(); 
    165168        this.tree.draw(); 
     
    169172         
    170173        //re apply the selected node (as the html will have been re-built 
    171         if (this._selectedTreeNode !== null) { 
    172             if (this._selectedTreeNode.labelElId) { 
    173                 var selectedElt = $(this._selectedTreeNode.labelElId); 
     174        if (this._selectedLayer !== null) { 
     175            if (this._selectedLayer.labelElId) { 
     176                var selectedElt = $(this._selectedLayer.labelElId); 
    174177                if (selectedElt === null) { 
    175                     this._selectedTreeNode = null; 
     178                    this._selectedLayer = null; 
    176179                } 
    177180                else { 
     
    409412    _selectTreeNode: function (node) { 
    410413         
    411         var node1; 
    412          
    413         // clear the already selected node 
    414         node1 = this._selectedTreeNode; 
    415         while (node1 !== null)  
    416         { 
    417             if (node1.labelElId)  
     414        if (this._selectedLayer) { 
    418415            { 
    419                 $(node1.labelElId).className = this._selectedTreeNode.labelStyle; 
    420                 node1 = node1.parent; 
    421             } 
    422             else  
    423             { 
    424                 node1 = null; 
    425             } 
    426         } 
    427  
    428         this._selectedTreeNode = node; 
    429         node1 = this._selectedTreeNode; 
    430          
    431         // select the new nodes 
    432         while (node1 !== null)  
    433         { 
    434             if (node1.labelElId)  
    435             {    
    436                 $(node1.labelElId).className = 'WMSC_selectedField'; 
    437                 node1 = node1.parent; 
    438             } 
    439             else  
    440             { 
    441                 node1 = null; 
    442             } 
    443         } 
    444  
     416                $(this._selectedLayer.labelElId).className = node.labelStyle; 
     417            }    
     418        } 
     419         
     420        $(node.labelElId).className = 'WMSC_selectedField'; 
     421         
     422        // set the selected layer 
     423        this._selectedLayer = node;         
     424         
    445425        // If this node is a leaf, display the different layers available 
    446426        // NB, need to treat differently depending on whether we're dealing 
     
    448428        if (node.children.length === 0)  
    449429        { 
    450              
     430         
    451431            // check this isn't the 'loading...' leaf; escape if it is 
    452432            if (node.label.indexOf("...loading") > -1) { 
     
    456436            //add the selected layer to the layers panel 
    457437            this._addLayer(node); 
    458              
    459             // set the selected layer 
    460             this._selectedLayer = node; 
     438 
    461439        } 
    462440    }, 
     
    550528            } 
    551529             
    552             layerNode.expand(); 
    553         } 
    554          
     530            this._expandNodeParentsFirst(layerNode); 
     531            //layerNode.expand(); 
     532        } 
     533         
     534    }, 
     535     
     536    /** 
     537     * To avoid trying to set the selected class no nodes that haven't been  
     538     * created in the DOM yet, expand the given nodes from the bottom up. This 
     539     * means that all the pairent nodes will be added to the DOM.  
     540     */ 
     541    _expandNodeParentsFirst: function (node) { 
     542        if (node.parent) { 
     543            this._expandNodeParentsFirst(node.parent); 
     544        } 
     545         
     546        if (node.expanded === false) { 
     547            node.expand(); 
     548        }         
    555549    }, 
    556550     
     
    581575                return child; 
    582576            } 
    583         } 
     577             
     578            if (child.children.length >= 0) { 
     579                var found = this._getChildNodeForLayer(child, layerName); 
     580                 
     581                if (found !== null) { 
     582                    return found; 
     583                } 
     584            } 
     585        } 
     586         
     587         
    584588        return null; 
    585589    }, 
  • cowsclient/trunk/cowsclient/public/layout/control.css

    r5776 r6425  
    5757} 
    5858 
    59 A.WMSC_selectedField { 
     59.WMSC_selectedField { 
    6060  color: blue; 
    6161  //background-color: lightgray; 
     
    8686.ygtvrow table { 
    8787    width:100%; 
     88} 
     89 
     90 
     91.ygtvfocus { 
     92        background-color:transparent; 
    8893} 
    8994 
Note: See TracChangeset for help on using the changeset viewer.