Ext.namespace("GeoExt");GeoExt.singleFile=!0;
(function(){if("object"!=typeof GeoExt||!GeoExt.singleFile)for(var a="GeoExt/data/AttributeReader.js GeoExt/data/AttributeStore.js GeoExt/data/FeatureRecord.js GeoExt/data/FeatureReader.js GeoExt/data/FeatureStore.js GeoExt/data/LayerRecord.js GeoExt/data/LayerReader.js GeoExt/data/LayerStore.js GeoExt/data/ScaleStore.js GeoExt/data/StyleReader.js GeoExt/data/WMSCapabilitiesReader.js GeoExt/data/WMSCapabilitiesStore.js GeoExt/data/WFSCapabilitiesReader.js GeoExt/data/WFSCapabilitiesStore.js GeoExt/data/WMSDescribeLayerReader.js GeoExt/data/WMSDescribeLayerStore.js GeoExt/data/WMCReader.js GeoExt/widgets/Action.js GeoExt/data/ProtocolProxy.js GeoExt/widgets/FeatureRenderer.js GeoExt/widgets/MapPanel.js GeoExt/widgets/Popup.js GeoExt/widgets/form.js GeoExt/widgets/form/SearchAction.js GeoExt/widgets/form/BasicForm.js GeoExt/widgets/form/FormPanel.js GeoExt/widgets/grid/SymbolizerColumn.js GeoExt/widgets/tips/SliderTip.js GeoExt/widgets/tips/LayerOpacitySliderTip.js GeoExt/widgets/tips/ZoomSliderTip.js GeoExt/widgets/tree/LayerNode.js GeoExt/widgets/tree/TreeNodeUIEventMixin.js GeoExt/plugins/TreeNodeComponent.js GeoExt/plugins/TreeNodeRadioButton.js GeoExt/plugins/TreeNodeActions.js GeoExt/widgets/tree/LayerLoader.js GeoExt/widgets/tree/LayerContainer.js GeoExt/widgets/tree/BaseLayerContainer.js GeoExt/widgets/tree/OverlayLayerContainer.js GeoExt/widgets/tree/LayerParamNode.js GeoExt/widgets/tree/LayerParamLoader.js GeoExt/widgets/tree/WMSCapabilitiesLoader.js GeoExt/widgets/LayerOpacitySlider.js GeoExt/widgets/LayerLegend.js GeoExt/widgets/LegendImage.js GeoExt/widgets/UrlLegend.js GeoExt/widgets/WMSLegend.js GeoExt/widgets/VectorLegend.js GeoExt/widgets/LegendPanel.js GeoExt/widgets/ZoomSlider.js GeoExt/widgets/grid/FeatureSelectionModel.js GeoExt/data/PrintPage.js GeoExt/data/PrintProvider.js GeoExt/plugins/PrintPageField.js GeoExt/plugins/PrintProviderField.js GeoExt/plugins/PrintExtent.js GeoExt/plugins/AttributeForm.js GeoExt/widgets/PrintMapPanel.js GeoExt/state/PermalinkProvider.js GeoExt/Lang.js".split(" "),b=
a.length,c=S3.Ap.concat("/static/scripts/gis/GeoExt/lib/"),d,e,g=0;g<b;g++)d=c+a[g],e=document.createElement("script"),e.src=d,e.async=!1,document.getElementsByTagName("head")[0].appendChild(e)})();Ext.namespace("GeoExt");
GeoExt.LayerLegend=Ext.extend(Ext.Container,{layerRecord:null,showTitle:!0,legendTitle:null,labelCls:null,layerStore:null,initComponent:function(){GeoExt.LayerLegend.superclass.initComponent.call(this);this.autoEl={};this.add({xtype:"label",html:this.getLayerTitle(this.layerRecord),cls:"x-form-item x-form-item-label"+(this.labelCls?" "+this.labelCls:"")});this.layerRecord&&this.layerRecord.store&&(this.layerStore=this.layerRecord.store,this.layerStore.on("update",this.onStoreUpdate,this),this.layerStore.on("add",
this.onStoreAdd,this),this.layerStore.on("remove",this.onStoreRemove,this))},getLabel:function(){var a=this.items.get(0);return a.rendered?a.el.dom.innerHTML:a.html},onStoreRemove:function(a,b,c){},onStoreAdd:function(a,b,c){},onStoreUpdate:function(a,b,c){b===this.layerRecord&&0<this.items.getCount()&&(a=b.getLayer(),this.setVisible(a.getVisibility()&&a.calculateInRange()&&a.displayInLayerSwitcher&&!b.get("hideInLegend")),this.update())},update:function(){var a=this.getLayerTitle(this.layerRecord),
b=this.items.itemAt(0);b instanceof Ext.form.Label&&this.getLabel()!==a&&b.setText(a,!1)},getLayerTitle:function(a){var b=this.legendTitle||"";this.showTitle&&!b&&a&&!a.get("hideTitle")&&(b=a.get("title")||a.get("name")||a.getLayer().name||"");return b},beforeDestroy:function(){this.layerStore&&(this.layerStore.un("update",this.onStoreUpdate,this),this.layerStore.un("remove",this.onStoreRemove,this),this.layerStore.un("add",this.onStoreAdd,this));GeoExt.LayerLegend.superclass.beforeDestroy.apply(this,
arguments)},onDestroy:function(){this.layerStore=this.layerRecord=null;GeoExt.LayerLegend.superclass.onDestroy.apply(this,arguments)}});GeoExt.LayerLegend.getTypes=function(a,b){var c=(b||[]).concat(),d=[],e,g;for(g in GeoExt.LayerLegend.types)e=GeoExt.LayerLegend.types[g].supports(a),0<e?-1==c.indexOf(g)&&d.push({type:g,score:e}):c.remove(g);d.sort(function(a,b){return a.score<b.score?1:a.score==b.score?0:-1});e=d.length;g=Array(e);for(var f=0;f<e;++f)g[f]=d[f].type;return c.concat(g)};
GeoExt.LayerLegend.supports=function(a){};GeoExt.LayerLegend.types={};Ext.namespace("GeoExt");
GeoExt.VectorLegend=Ext.extend(GeoExt.LayerLegend,{layerRecord:null,layer:null,rules:null,symbolType:null,untitledPrefix:"",clickableSymbol:!1,clickableTitle:!1,selectOnClick:!1,enableDD:!1,bodyBorder:!1,feature:null,selectedRule:null,currentScaleDenominator:null,initComponent:function(){GeoExt.VectorLegend.superclass.initComponent.call(this);this.layerRecord&&(this.layer=this.layerRecord.getLayer(),this.layer.map&&(this.map=this.layer.map,this.currentScaleDenominator=this.layer.map.getScale(),this.layer.map.events.on({zoomend:this.onMapZoom,
scope:this})));if(!this.symbolType)if(this.feature)this.symbolType=this.symbolTypeFromFeature(this.feature);else if(this.layer)if(0<this.layer.features.length){for(var a,b=0,c=this.layer.features.length;b<c;b++)if(null!==this.layer.features[b].geometry){a=this.layer.features[b].clone();break}a.attributes={};this.feature=a;this.symbolType=this.symbolTypeFromFeature(this.feature)}else this.layer.events.on({featuresadded:this.onFeaturesAdded,scope:this});this.layer&&this.feature&&!this.rules&&this.setRules();
this.rulesContainer=new Ext.Container({autoEl:{}});this.add(this.rulesContainer);this.addEvents("titleclick","symbolclick","ruleclick","ruleselected","ruleunselected","rulemoved");this.update()},onMapZoom:function(){this.setCurrentScaleDenominator(this.layer.map.getScale())},symbolTypeFromFeature:function(a){return(a=a.geometry.CLASS_NAME.match(/Point|Line|Polygon/))&&a[0]||"Point"},onFeaturesAdded:function(a){for(var b=0,c=a.features.length;b<c;++b)if(null!==a.features[b].geometry){this.layer.events.un({featuresadded:this.onFeaturesAdded,
scope:this});a=a.features[b].clone();a.attributes={};this.feature=a;this.symbolType=this.symbolTypeFromFeature(this.feature);this.rules||this.setRules();this.update();break}},setRules:function(){var a=this.layer.styleMap&&this.layer.styleMap.styles["default"];a||(a=new OpenLayers.Style);this.rules=0===a.rules.length?[new OpenLayers.Rule({title:a.title,symbolizer:a.createSymbolizer(this.feature)})]:a.rules},setCurrentScaleDenominator:function(a){a!==this.currentScaleDenominator&&(this.currentScaleDenominator=
a,this.update())},getRuleEntry:function(a){return this.rulesContainer.items.get(this.rules.indexOf(a))},addRuleEntry:function(a,b){this.rulesContainer.add(this.createRuleEntry(a));b||this.doLayout()},removeRuleEntry:function(a,b){var c=this.getRuleEntry(a);c&&(this.rulesContainer.remove(c),b||this.doLayout())},selectRuleEntry:function(a){var b=a!=this.selectedRule;this.selectedRule&&this.unselect();b&&(this.getRuleEntry(a).body.addClass("x-grid3-row-selected"),this.selectedRule=a,this.fireEvent("ruleselected",
this,a))},unselect:function(){this.rulesContainer.items.each(function(a,b){this.rules[b]==this.selectedRule&&(a.body.removeClass("x-grid3-row-selected"),this.selectedRule=null,this.fireEvent("ruleunselected",this,this.rules[b]))},this)},createRuleEntry:function(a){var b=!0;null!=this.currentScaleDenominator&&(a.minScaleDenominator&&(b=b&&this.currentScaleDenominator>=a.minScaleDenominator),a.maxScaleDenominator&&(b=b&&this.currentScaleDenominator<a.maxScaleDenominator));return{xtype:"panel",layout:"column",
border:!1,hidden:!b,bodyStyle:this.selectOnClick?{cursor:"pointer"}:void 0,defaults:{border:!1},items:[this.createRuleRenderer(a),this.createRuleTitle(a)],listeners:{render:function(b){this.selectOnClick&&b.getEl().on({click:function(b){this.selectRuleEntry(a)},scope:this});!0==this.enableDD&&this.addDD(b)},scope:this}}},createRuleRenderer:function(a){var b=[this.symbolType,"Point","Line","Polygon"],c,d,e,g,f=a.symbolizers;if(f){var h;e=0;g=b.length;a:for(;e<g;++e)if(c=b[e],h=OpenLayers.Symbolizer[c])for(var k=
0,l=f.length;k<l;++k)if(f[k]instanceof h){d=!0;break a}}else{f=a.symbolizer;e=0;for(g=b.length;e<g;++e)if(c=b[e],f[c]){f=f[c];d=!0;break}b=OpenLayers.Util.extend({},f);delete b.label;delete b.graphicHeight;delete b.graphicWidth;delete b.graphicXOffset;delete b.graphicYOffset;f=[b]}return{xtype:"gx_renderer",labelText:"Ab",symbolType:d?c:this.symbolType,symbolizers:f,style:this.clickableSymbol?{cursor:"pointer"}:void 0,listeners:{click:function(){this.clickableSymbol&&(this.fireEvent("symbolclick",
this,a),this.fireEvent("ruleclick",this,a))},scope:this}}},createRuleTitle:function(a){return{cls:"x-form-item",style:"padding: 0.2em 0.5em 0;",bodyStyle:Ext.applyIf({background:"transparent"},this.clickableTitle?{cursor:"pointer"}:void 0),html:this.getRuleTitle(a),listeners:{render:function(b){this.clickableTitle&&b.getEl().on({click:function(){this.fireEvent("titleclick",this,a);this.fireEvent("ruleclick",this,a)},scope:this})},scope:this}}},addDD:function(a){var b=a.ownerCt,c=this;new Ext.dd.DragSource(a.getEl(),
{ddGroup:b.id,onDragOut:function(a,b){var c=Ext.getCmp(b);c.removeClass("gx-ruledrag-insert-above");c.removeClass("gx-ruledrag-insert-below");return Ext.dd.DragZone.prototype.onDragOut.apply(this,arguments)},onDragEnter:function(c,e){var g=Ext.getCmp(e),f,h=b.items.indexOf(a),k=b.items.indexOf(g);h>k?f="gx-ruledrag-insert-above":h<k&&(f="gx-ruledrag-insert-below");f&&g.addClass(f);return Ext.dd.DragZone.prototype.onDragEnter.apply(this,arguments)},onDragDrop:function(d,e){c.moveRule(b.items.indexOf(a),
b.items.indexOf(Ext.getCmp(e)));return Ext.dd.DragZone.prototype.onDragDrop.apply(this,arguments)},getDragData:function(a){if(a=a.getTarget(".x-column-inner")){var b=a.cloneNode(!0);b.id=Ext.id();return{sourceEl:a,repairXY:Ext.fly(a).getXY(),ddel:b}}}});new Ext.dd.DropTarget(a.getEl(),{ddGroup:b.id,notifyDrop:function(){return!0}})},update:function(){GeoExt.VectorLegend.superclass.update.apply(this,arguments);var a,b;if(this.symbolType&&this.rules){if(this.rulesContainer.items)for(a=this.rulesContainer.items.length-
1;0<=a;--a)b=this.rulesContainer.getComponent(a),this.rulesContainer.remove(b,!0);a=0;for(b=this.rules.length;a<b;++a)this.addRuleEntry(this.rules[a],!0);this.doLayout();this.selectedRule&&this.getRuleEntry(this.selectedRule).body.addClass("x-grid3-row-selected")}},updateRuleEntry:function(a){var b=this.getRuleEntry(a);b&&(b.removeAll(),b.add(this.createRuleRenderer(a)),b.add(this.createRuleTitle(a)),b.doLayout())},moveRule:function(a,b){var c=this.rules[a];this.rules.splice(a,1);this.rules.splice(b,
0,c);this.update();this.fireEvent("rulemoved",this,c)},getRuleTitle:function(a){var b=a.title||a.name||"";!b&&this.untitledPrefix&&(b=this.untitledPrefix+(this.rules.indexOf(a)+1));return b},beforeDestroy:function(){this.layer&&(this.layer.events&&this.layer.events.un({featuresadded:this.onFeaturesAdded,scope:this}),this.layer.map&&this.layer.map.events&&this.layer.map.events.un({zoomend:this.onMapZoom,scope:this}));delete this.layer;delete this.map;delete this.rules;GeoExt.VectorLegend.superclass.beforeDestroy.apply(this,
arguments)},onStoreRemove:function(a,b,c){b.getLayer()===this.layer&&this.map&&this.map.events&&this.map.events.un({zoomend:this.onMapZoom,scope:this})},onStoreAdd:function(a,b,c){a=0;for(c=b.length;a<c;a++)if(b[a].getLayer()===this.layer&&this.layer.map&&this.layer.map.events)this.layer.map.events.on({zoomend:this.onMapZoom,scope:this})}});GeoExt.VectorLegend.supports=function(a){return a.getLayer()instanceof OpenLayers.Layer.Vector?1:0};GeoExt.LayerLegend.types.gx_vectorlegend=GeoExt.VectorLegend;
Ext.reg("gx_vectorlegend",GeoExt.VectorLegend);Ext.namespace("GeoExt.tree");
GeoExt.tree.LayerContainer=Ext.extend(Ext.tree.AsyncTreeNode,{text:"Layers",constructor:function(a){a=Ext.applyIf(a||{},{text:this.text});this.loader=a.loader instanceof GeoExt.tree.LayerLoader?a.loader:new GeoExt.tree.LayerLoader(Ext.applyIf(a.loader||{},{store:a.layerStore}));GeoExt.tree.LayerContainer.superclass.constructor.call(this,a)},recordIndexToNodeIndex:function(a){for(var b=this.loader.store,c=b.getCount(),d=this.childNodes.length,e=-1,c=c-1;0<=c&&!(!0===this.loader.filter(b.getAt(c))&&
(++e,a===c||e>d-1));--c);return e},destroy:function(){delete this.layerStore;GeoExt.tree.LayerContainer.superclass.destroy.apply(this,arguments)}});Ext.tree.TreePanel.nodeTypes.gx_layercontainer=GeoExt.tree.LayerContainer;Ext.namespace("GeoExt.tree");
GeoExt.tree.BaseLayerContainer=Ext.extend(GeoExt.tree.LayerContainer,{text:"Base Layer",constructor:function(a){a=Ext.applyIf(a||{},{text:this.text,loader:{}});a.loader=Ext.applyIf(a.loader,{baseAttrs:Ext.applyIf(a.loader.baseAttrs||{},{iconCls:"gx-tree-baselayer-icon",checkedGroup:"baselayer"}),filter:function(a){a=a.getLayer();return!0===a.displayInLayerSwitcher&&!0===a.isBaseLayer}});GeoExt.tree.BaseLayerContainer.superclass.constructor.call(this,a)}});
Ext.tree.TreePanel.nodeTypes.gx_baselayercontainer=GeoExt.tree.BaseLayerContainer;Ext.namespace("GeoExt.tree");GeoExt.tree.LayerParamLoader=function(a){Ext.apply(this,a);this.addEvents("beforeload","load");GeoExt.tree.LayerParamLoader.superclass.constructor.call(this)};
Ext.extend(GeoExt.tree.LayerParamLoader,Ext.util.Observable,{param:null,delimiter:",",load:function(a,b){if(this.fireEvent("beforeload",this,a)){for(;a.firstChild;)a.removeChild(a.firstChild);var c=a.layer instanceof OpenLayers.Layer.HTTPRequest&&a.layer.params[this.param];c&&(c=c instanceof Array?c.slice():c.split(this.delimiter),Ext.each(c,function(b,c,g){this.addParamNode(b,g,a)},this));"function"==typeof b&&b();this.fireEvent("load",this,a)}},addParamNode:function(a,b,c){a=this.createNode({layer:c.layer,
param:this.param,item:a,allItems:b,delimiter:this.delimiter});(b=c.item(0))?c.insertBefore(a,b):c.appendChild(a)},createNode:function(a){this.baseAttrs&&Ext.apply(a,this.baseAttrs);"string"==typeof a.uiProvider&&(a.uiProvider=this.uiProviders[a.uiProvider]||eval(a.uiProvider));a.nodeType=a.nodeType||"gx_layerparam";return new Ext.tree.TreePanel.nodeTypes[a.nodeType](a)}});Ext.namespace("GeoExt");
GeoExt.SliderTip=Ext.extend(Ext.slider.Tip,{hover:!0,minWidth:10,offsets:[0,-10],dragging:!1,init:function(a){GeoExt.SliderTip.superclass.init.apply(this,arguments);if(this.hover)a.on("render",this.registerThumbListeners,this);this.slider=a},registerThumbListeners:function(){for(var a,b,c=0,d=this.slider.thumbs.length;c<d;++c)a=this.slider.thumbs[c],b=a.tracker.el,function(a,b){b.on({mouseover:function(b){this.onSlide(this.slider,b,a);this.dragging=!1},mouseout:function(){this.dragging||this.hide.apply(this,
arguments)},scope:this})}.apply(this,[a,b])},onSlide:function(a,b,c){this.dragging=!0;return GeoExt.SliderTip.superclass.onSlide.apply(this,arguments)}});Ext.namespace("GeoExt");
GeoExt.ZoomSlider=Ext.extend(Ext.slider.SingleSlider,{map:null,baseCls:"gx-zoomslider",aggressive:!1,updating:!1,initComponent:function(){GeoExt.ZoomSlider.superclass.initComponent.call(this);this.map&&(this.map instanceof GeoExt.MapPanel&&(this.map=this.map.map),this.bind(this.map));if(!0===this.aggressive)this.on("change",this.changeHandler,this);else this.on("changecomplete",this.changeHandler,this);this.on("beforedestroy",this.unbind,this)},onRender:function(){GeoExt.ZoomSlider.superclass.onRender.apply(this,
arguments);this.el.addClass(this.baseCls)},afterRender:function(){Ext.slider.SingleSlider.superclass.afterRender.apply(this,arguments);this.update()},addToMapPanel:function(a){this.on({render:function(){var b=this.getEl();b.setStyle({position:"absolute",zIndex:a.map.Z_INDEX_BASE.Control});b.on({mousedown:this.stopMouseEvents,click:this.stopMouseEvents})},afterrender:function(){this.bind(a.map)},scope:this})},stopMouseEvents:function(a){a.stopEvent()},removeFromMapPanel:function(a){a=this.getEl();
a.un("mousedown",this.stopMouseEvents,this);a.un("click",this.stopMouseEvents,this);this.unbind()},bind:function(a){this.map=a;this.map.events.on({zoomend:this.onZoomEnd,updatesize:this.initZoomValues,changebaselayer:this.initZoomValues,scope:this});this.initZoomValues()},onZoomEnd:function(){this.update()},unbind:function(){this.map&&this.map.events&&this.map.events.un({zoomend:this.onZoomEnd,updatesize:this.initZoomValues,changebaselayer:this.initZoomValues,scope:this})},initZoomValues:function(){var a=
this.map.baseLayer;if(a){if(void 0===this.initialConfig.minValue){var b=this.map.getMinZoom?this.map.getMinZoom():0;this.minValue=Math.max(b,a.minZoomLevel||0)}void 0===this.initialConfig.maxValue&&(this.maxValue=null==a.minZoomLevel?a.numZoomLevels-1:a.maxZoomLevel);this.update(!0)}},getZoom:function(){return this.getValue()},getScale:function(){return OpenLayers.Util.getScaleFromResolution(this.map.getResolutionForZoom(this.getValue()),this.map.getUnits())},getResolution:function(){return this.map.getResolutionForZoom(this.getValue())},
changeHandler:function(){this.map&&!this.updating&&this.map.zoomTo(this.getValue())},update:function(a){this.rendered&&this.map&&(this.updating=!0,a&&(this.thumbs[0].value=null),this.setValue(this.map.getZoom()),this.updating=!1)}});Ext.reg("gx_zoomslider",GeoExt.ZoomSlider);Ext.namespace("GeoExt");
GeoExt.LayerOpacitySlider=Ext.extend(Ext.slider.SingleSlider,{layer:null,complementaryLayer:null,delay:5,changeVisibilityDelay:5,aggressive:!1,changeVisibility:!1,value:null,inverse:!1,constructor:function(a){a.layer&&(this.layer=this.getLayer(a.layer),this.bind(),this.complementaryLayer=this.getLayer(a.complementaryLayer),void 0!==a.inverse&&(this.inverse=a.inverse),a.value=void 0!==a.value?a.value:this.getOpacityValue(this.layer),delete a.layer,delete a.complementaryLayer);GeoExt.LayerOpacitySlider.superclass.constructor.call(this,
a)},bind:function(){if(this.layer&&this.layer.map)this.layer.map.events.on({changelayer:this.update,scope:this})},unbind:function(){this.layer&&this.layer.map&&this.layer.map.events&&this.layer.map.events.un({changelayer:this.update,scope:this})},update:function(a){"opacity"!==a.property||a.layer!=this.layer||this._settingOpacity||this.setValue(this.getOpacityValue(this.layer))},setLayer:function(a){this.unbind();this.layer=this.getLayer(a);this.setValue(this.getOpacityValue(a));this.bind()},getOpacityValue:function(a){a=
a&&null!==a.opacity?parseInt(a.opacity*(this.maxValue-this.minValue)):this.maxValue;!0===this.inverse&&(a=this.maxValue-this.minValue-a);return a},getLayer:function(a){if(a instanceof OpenLayers.Layer)return a;if(a instanceof GeoExt.data.LayerRecord)return a.getLayer()},initComponent:function(){GeoExt.LayerOpacitySlider.superclass.initComponent.call(this);this.changeVisibility&&this.layer&&(0==this.layer.opacity||!1===this.inverse&&this.value==this.minValue||!0===this.inverse&&this.value==this.maxValue)&&
this.layer.setVisibility(!1);this.complementaryLayer&&(this.layer&&1==this.layer.opacity||!1===this.inverse&&this.value==this.maxValue||!0===this.inverse&&this.value==this.minValue)&&this.complementaryLayer.setVisibility(!1);if(!0===this.aggressive)this.on("change",this.changeLayerOpacity,this,{buffer:this.delay});else this.on("changecomplete",this.changeLayerOpacity,this);if(!0===this.changeVisibility)this.on("change",this.changeLayerVisibility,this,{buffer:this.changeVisibilityDelay});if(this.complementaryLayer)this.on("change",
this.changeComplementaryLayerVisibility,this,{buffer:this.changeVisibilityDelay});this.on("beforedestroy",this.unbind,this)},changeLayerOpacity:function(a,b){this.layer&&(b/=this.maxValue-this.minValue,!0===this.inverse&&(b=1-b),this._settingOpacity=!0,this.layer.setOpacity(b),delete this._settingOpacity)},changeLayerVisibility:function(a,b){var c=this.layer.getVisibility();!1===this.inverse&&b==this.minValue||!0===this.inverse&&b==this.maxValue&&!0===c?this.layer.setVisibility(!1):(!1===this.inverse&&
b>this.minValue||!0===this.inverse&&b<this.maxValue&&!1==c)&&this.layer.setVisibility(!0)},changeComplementaryLayerVisibility:function(a,b){var c=this.complementaryLayer.getVisibility();!1===this.inverse&&b==this.maxValue||!0===this.inverse&&b==this.minValue&&!0===c?this.complementaryLayer.setVisibility(!1):(!1===this.inverse&&b<this.maxValue||!0===this.inverse&&b>this.minValue&&!1==c)&&this.complementaryLayer.setVisibility(!0)},addToMapPanel:function(a){this.on({render:function(){var b=this.getEl();
b.setStyle({position:"absolute",zIndex:a.map.Z_INDEX_BASE.Control});b.on({mousedown:this.stopMouseEvents,click:this.stopMouseEvents})},scope:this})},removeFromMapPanel:function(a){this.getEl().un({mousedown:this.stopMouseEvents,click:this.stopMouseEvents,scope:this});this.unbind()},stopMouseEvents:function(a){a.stopEvent()}});Ext.reg("gx_opacityslider",GeoExt.LayerOpacitySlider);Ext.namespace("GeoExt.data");
GeoExt.data.WMSCapabilitiesReader=function(a,b){a=a||{};a.format||(a.format=new OpenLayers.Format.WMSCapabilities);"function"!==typeof b&&(b=GeoExt.data.LayerRecord.create(b||a.fields||[{name:"name",type:"string"},{name:"title",type:"string"},{name:"abstract",type:"string"},{name:"queryable",type:"boolean"},{name:"opaque",type:"boolean"},{name:"noSubsets",type:"boolean"},{name:"cascaded",type:"int"},{name:"fixedWidth",type:"int"},{name:"fixedHeight",type:"int"},{name:"minScale",type:"float"},{name:"maxScale",
type:"float"},{name:"prefix",type:"string"},{name:"formats"},{name:"styles"},{name:"srs"},{name:"dimensions"},{name:"bbox"},{name:"llbbox"},{name:"attribution"},{name:"keywords"},{name:"identifiers"},{name:"authorityURLs"},{name:"metadataURLs"},{name:"infoFormats"}]));GeoExt.data.WMSCapabilitiesReader.superclass.constructor.call(this,a,b)};
Ext.extend(GeoExt.data.WMSCapabilitiesReader,Ext.data.DataReader,{attributionCls:"gx-attribution",read:function(a){var b=a.responseXML;b&&b.documentElement||(b=a.responseText);return this.readRecords(b)},serviceExceptionFormat:function(a){return-1<OpenLayers.Util.indexOf(a,"application/vnd.ogc.se_inimage")?"application/vnd.ogc.se_inimage":-1<OpenLayers.Util.indexOf(a,"application/vnd.ogc.se_xml")?"application/vnd.ogc.se_xml":a[0]},imageFormat:function(a){var b=a.formats;return a.opaque&&-1<OpenLayers.Util.indexOf(b,
"image/jpeg")?"image/jpeg":-1<OpenLayers.Util.indexOf(b,"image/png")?"image/png":-1<OpenLayers.Util.indexOf(b,"image/png; mode=24bit")?"image/png; mode=24bit":-1<OpenLayers.Util.indexOf(b,"image/gif")?"image/gif":b[0]},imageTransparent:function(a){return void 0==a.opaque||!a.opaque},readRecords:function(a){if("string"===typeof a||a.nodeType)a=this.meta.format.read(a);if(a.error)throw new Ext.data.DataReader.Error("invalid-response",a.error);var b=a.version,c=a.capability||{};a=c.request&&c.request.getmap&&
c.request.getmap.href;var d=c.layers,c=this.serviceExceptionFormat(c.exception?c.exception.formats:[]),e=[];if(a&&d)for(var g=this.recordType.prototype.fields,f,h,k,l,m=0,n=d.length;m<n;m++)if(f=d[m],f.name){h={};for(var r=0,p=g.length;r<p;r++)k=g.items[r],l=f[k.mapping||k.name]||k.defaultValue,l=k.convert(l),h[k.name]=l;k={attribution:f.attribution?this.attributionMarkup(f.attribution):void 0,minScale:f.minScale,maxScale:f.maxScale};this.meta.layerOptions&&Ext.apply(k,this.meta.layerOptions);l={layers:f.name,
exceptions:c,format:this.imageFormat(f),transparent:this.imageTransparent(f),version:b};this.meta.layerParams&&Ext.apply(l,this.meta.layerParams);h.layer=new OpenLayers.Layer.WMS(f.title||f.name,a,l,k);e.push(new this.recordType(h,h.layer.id))}return{totalRecords:e.length,success:!0,records:e}},attributionMarkup:function(a){var b=[];a.logo&&b.push("<img class='"+this.attributionCls+"-image' src='"+a.logo.href+"' />");a.title&&b.push("<span class='"+this.attributionCls+"-title'>"+a.title+"</span>");
if(a.href)for(var c=0;c<b.length;c++)b[c]="<a class='"+this.attributionCls+"-link' href="+a.href+">"+b[c]+"</a>";return b.join(" ")}});Ext.namespace("GeoExt.data");
GeoExt.data.LayerStoreMixin=function(){return{map:null,reader:null,constructor:function(a){a=a||{};a.reader=a.reader||new GeoExt.data.LayerReader({},a.fields);delete a.fields;var b=a.map instanceof GeoExt.MapPanel?a.map.map:a.map;delete a.map;a.layers&&(a.data=a.layers);delete a.layers;var c={initDir:a.initDir};delete a.initDir;arguments.callee.superclass.constructor.call(this,a);this.addEvents("bind");b&&this.bind(b,c)},bind:function(a,b){if(!this.map){this.map=a;b=b||{};var c=b.initDir;void 0==
b.initDir&&(c=GeoExt.data.LayerStore.MAP_TO_STORE|GeoExt.data.LayerStore.STORE_TO_MAP);var d=a.layers.slice(0);c&GeoExt.data.LayerStore.STORE_TO_MAP&&this.each(function(a){this.map.addLayer(a.getLayer())},this);c&GeoExt.data.LayerStore.MAP_TO_STORE&&this.loadData(d,!0);a.events.on({changelayer:this.onChangeLayer,addlayer:this.onAddLayer,removelayer:this.onRemoveLayer,scope:this});this.on({load:this.onLoad,clear:this.onClear,add:this.onAdd,remove:this.onRemove,update:this.onUpdate,scope:this});this.data.on({replace:this.onReplace,
scope:this});this.fireEvent("bind",this,a)}},unbind:function(){this.map&&(this.map.events.un({changelayer:this.onChangeLayer,addlayer:this.onAddLayer,removelayer:this.onRemoveLayer,scope:this}),this.un("load",this.onLoad,this),this.un("clear",this.onClear,this),this.un("add",this.onAdd,this),this.un("remove",this.onRemove,this),this.data.un("replace",this.onReplace,this),this.map=null)},onChangeLayer:function(a){var b=a.layer,c=this.findBy(function(a,c){return a.getLayer()===b});if(-1<c){var d=this.getAt(c);
"order"===a.property?this._adding||this._removing||(a=this.map.getLayerIndex(b),a!==c&&(this._removing=!0,this.remove(d),delete this._removing,this._adding=!0,this.insert(a,[d]),delete this._adding)):"name"===a.property?d.set("title",b.name):this.fireEvent("update",this,d,Ext.data.Record.EDIT)}},onAddLayer:function(a){this._adding||(a=a.layer,this._adding=!0,this.loadData([a],!0),delete this._adding)},onRemoveLayer:function(a){this.map.unloadDestroy?this._removing||(a=a.layer,this._removing=!0,this.remove(this.getById(a.id)),
delete this._removing):this.unbind()},onLoad:function(a,b,c){Ext.isArray(b)||(b=[b]);if(c&&!c.add){this._removing=!0;for(a=this.map.layers.length-1;0<=a;a--)this.map.removeLayer(this.map.layers[a]);delete this._removing;a=b.length;if(0<a){c=Array(a);for(var d=0;d<a;d++)c[d]=b[d].getLayer();this._adding=!0;this.map.addLayers(c);delete this._adding}}},onClear:function(a){this._removing=!0;for(a=this.map.layers.length-1;0<=a;a--)this.map.removeLayer(this.map.layers[a]);delete this._removing},onAdd:function(a,
b,c){if(!this._adding){this._adding=!0;for(var d=b.length-1;0<=d;--d)a=b[d].getLayer(),this.map.addLayer(a),c!==this.map.layers.length-1&&this.map.setLayerIndex(a,c);delete this._adding}},onRemove:function(a,b,c){this._removing||(a=b.getLayer(),null!=this.map.getLayer(a.id)&&(this._removing=!0,this.removeMapLayer(b),delete this._removing))},onUpdate:function(a,b,c){c===Ext.data.Record.EDIT&&b.modified&&b.modified.title&&(a=b.getLayer(),b=b.get("title"),b!==a.name&&a.setName(b))},removeMapLayer:function(a){this.map.removeLayer(a.getLayer())},
onReplace:function(a,b,c){this.removeMapLayer(b)},getByLayer:function(a){var b=this.findBy(function(b){return b.getLayer()===a});if(-1<b)return this.getAt(b)},destroy:function(){this.unbind();GeoExt.data.LayerStore.superclass.destroy.call(this)}}};GeoExt.data.LayerStore=Ext.extend(Ext.data.Store,new GeoExt.data.LayerStoreMixin);GeoExt.data.LayerStore.MAP_TO_STORE=1;GeoExt.data.LayerStore.STORE_TO_MAP=2;Ext.namespace("GeoExt.tree");
GeoExt.tree.LayerLoader=function(a){Ext.apply(this,a);this.addEvents("beforeload","load");this.iconCls={};GeoExt.tree.LayerLoader.superclass.constructor.call(this)};
Ext.extend(GeoExt.tree.LayerLoader,Ext.util.Observable,{store:null,filter:function(a){return!0==a.getLayer().displayInLayerSwitcher},baseAttrs:null,uiProviders:null,load:function(a,b){if(this.fireEvent("beforeload",this,a)){for(this.removeStoreHandlers();a.firstChild;)a.removeChild(a.firstChild);this.uiProviders||(this.uiProviders=a.getOwnerTree().getLoader().uiProviders);this.store||(this.store=GeoExt.MapPanel.guess().layers);this.store.each(function(b){this.addLayerNode(a,b)},this);this.addStoreHandlers(a);
"function"==typeof b&&b();this.fireEvent("load",this,a)}},onStoreAdd:function(a,b,c,d){if(!this._reordering)for(a=d.recordIndexToNodeIndex(c+b.length-1),c=0;c<b.length;++c)this.addLayerNode(d,b[c],a)},onStoreRemove:function(a,b,c,d){this._reordering||this.removeLayerNode(d,b)},addLayerNode:function(a,b,c){c=c||0;!0===this.filter(b)&&(b=this.createNode({nodeType:"gx_layer",layer:b.getLayer(),layerStore:this.store,iconCls:this.iconCls[b.id]}),(c=a.item(c))?a.insertBefore(b,c):a.appendChild(b),b.on("move",
this.onChildMove,this))},removeLayerNode:function(a,b){if(!0===this.filter(b)){var c=a.findChildBy(function(a){return a.layer==b.getLayer()});c&&(c.un("move",this.onChildMove,this),c.remove(),a.reload())}},onChildMove:function(a,b,c,d,e){this._reordering=!0;a=this.store.getByLayer(b.layer);delete c.loader.iconCls[a.id];if(d instanceof GeoExt.tree.LayerContainer&&this.store===d.loader.store){d.loader._reordering=!0;d.loader.iconCls[a.id]=b.attributes.iconCls;this.store.remove(a);var g;if(1<d.childNodes.length){var f=
0===e?e+1:e-1;g=this.store.findBy(function(a){return d.childNodes[f].layer===a.getLayer()});0===e&&g++}else if(c.parentNode===d.parentNode){var h=d;do h=h.previousSibling;while(h&&!(h instanceof GeoExt.tree.LayerContainer&&h.lastChild));if(h)g=this.store.findBy(function(a){return h.lastChild.layer===a.getLayer()});else{var k=d;do k=k.nextSibling;while(k&&!(k instanceof GeoExt.tree.LayerContainer&&k.firstChild));k&&(g=this.store.findBy(function(a){return k.firstChild.layer===a.getLayer()}));g++}}void 0!==
g?(this.store.insert(g,[a]),window.setTimeout(function(){d.reload();c.reload()})):this.store.insert(oldRecordIndex,[a]);delete d.loader._reordering}delete this._reordering},addStoreHandlers:function(a){if(!this._storeHandlers){this._storeHandlers={add:this.onStoreAdd.createDelegate(this,[a],!0),remove:this.onStoreRemove.createDelegate(this,[a],!0)};for(var b in this._storeHandlers)this.store.on(b,this._storeHandlers[b],this)}},removeStoreHandlers:function(){if(this._storeHandlers){for(var a in this._storeHandlers)this.store.un(a,
this._storeHandlers[a],this);delete this._storeHandlers}},createNode:function(a){this.baseAttrs&&Ext.apply(a,this.baseAttrs);"string"==typeof a.uiProvider&&(a.uiProvider=this.uiProviders[a.uiProvider]||eval(a.uiProvider));a.nodeType=a.nodeType||"gx_layer";return new Ext.tree.TreePanel.nodeTypes[a.nodeType](a)},destroy:function(){this.removeStoreHandlers();this.iconCls=null}});Ext.namespace("GeoExt");
GeoExt.MapPanel=Ext.extend(Ext.Panel,{map:null,layers:null,center:null,zoom:null,extent:null,prettyStateKeys:!1,stateEvents:"aftermapmove afterlayervisibilitychange afterlayeropacitychange afterlayerorderchange afterlayernamechange afterlayeradd afterlayerremove".split(" "),initComponent:function(){this.map instanceof OpenLayers.Map||(this.map=new OpenLayers.Map(Ext.applyIf(this.map||{},{allOverlays:!0,fallThrough:!0})));var a=this.layers;if(!a||a instanceof Array)this.layers=new GeoExt.data.LayerStore({layers:a,
map:0<this.map.layers.length?this.map:null});"string"==typeof this.center?this.center=OpenLayers.LonLat.fromString(this.center):this.center instanceof Array&&(this.center=new OpenLayers.LonLat(this.center[0],this.center[1]));"string"==typeof this.extent?this.extent=OpenLayers.Bounds.fromString(this.extent):this.extent instanceof Array&&(this.extent=OpenLayers.Bounds.fromArray(this.extent));GeoExt.MapPanel.superclass.initComponent.call(this);this.addEvents("aftermapmove","afterlayervisibilitychange",
"afterlayeropacitychange","afterlayerorderchange","afterlayernamechange","afterlayeradd","afterlayerremove");this.map.events.on({moveend:this.onMoveend,changelayer:this.onChangelayer,addlayer:this.onAddlayer,removelayer:this.onRemovelayer,scope:this});this.on("afterlayout",function(){"function"===typeof this.map.getViewport&&this.items.each(function(a){"function"===typeof a.addToMapPanel&&a.getEl().appendTo(this.map.getViewport())},this)},this)},onMoveend:function(){this.fireEvent("aftermapmove")},
onChangelayer:function(a){a.property&&("visibility"===a.property?this.fireEvent("afterlayervisibilitychange"):"order"===a.property?this.fireEvent("afterlayerorderchange"):"name"===a.property?this.fireEvent("afterlayernamechange"):"opacity"===a.property&&this.fireEvent("afterlayeropacitychange"))},onAddlayer:function(){this.fireEvent("afterlayeradd")},onRemovelayer:function(){this.fireEvent("afterlayerremove")},applyState:function(a){this.center=new OpenLayers.LonLat(a.x,a.y);this.zoom=a.zoom;var b,
c,d,e,g,f=this.map.layers;b=0;for(c=f.length;b<c;b++)d=f[b],e=this.prettyStateKeys?d.name:d.id,g=a["visibility_"+e],void 0!==g&&(g=/^true$/i.test(g),d.isBaseLayer?g&&this.map.setBaseLayer(d):d.setVisibility(g)),e=a["opacity_"+e],void 0!==e&&d.setOpacity(e)},getState:function(){var a;if(this.map){a=(a=this.map.getCenter())?{x:a.lon,y:a.lat,zoom:this.map.getZoom()}:{};var b,c,d,e,g=this.map.layers;b=0;for(c=g.length;b<c;b++)d=g[b],e=this.prettyStateKeys?d.name:d.id,a["visibility_"+e]=d.getVisibility(),
a["opacity_"+e]=null==d.opacity?1:d.opacity;return a}},updateMapSize:function(){this.map&&this.map.updateSize()},renderMap:function(){var a=this.map;a.render(this.body.dom);this.layers.bind(a);if(0<a.layers.length)this.setInitialExtent();else this.layers.on("add",this.setInitialExtent,this,{single:!0})},setInitialExtent:function(){var a=this.map;this.center||null!=this.zoom?a.setCenter(this.center,this.zoom):this.extent?a.zoomToExtent(this.extent):a.zoomToMaxExtent()},afterRender:function(){GeoExt.MapPanel.superclass.afterRender.apply(this,
arguments);this.ownerCt?(this.ownerCt.on("move",this.updateMapSize,this),this.ownerCt.on({afterlayout:this.afterLayout,scope:this})):this.renderMap()},afterLayout:function(){var a=this.getInnerWidth()-this.body.getBorderWidth("lr"),b=this.getInnerHeight()-this.body.getBorderWidth("tb");0<a&&0<b&&(this.ownerCt.un("afterlayout",this.afterLayout,this),this.renderMap())},onResize:function(){GeoExt.MapPanel.superclass.onResize.apply(this,arguments);this.updateMapSize()},onBeforeAdd:function(a){"function"===
typeof a.addToMapPanel&&a.addToMapPanel(this);GeoExt.MapPanel.superclass.onBeforeAdd.apply(this,arguments)},remove:function(a,b){"function"===typeof a.removeFromMapPanel&&a.removeFromMapPanel(this);GeoExt.MapPanel.superclass.remove.apply(this,arguments)},beforeDestroy:function(){this.ownerCt&&this.ownerCt.un("move",this.updateMapSize,this);this.map&&this.map.events&&this.map.events.un({moveend:this.onMoveend,changelayer:this.onChangelayer,addlayer:this.onAddlayer,removelayer:this.onRemovelayer,scope:this});
this.initialConfig.map&&this.initialConfig.map instanceof OpenLayers.Map||this.map&&this.map.destroy&&this.map.destroy();delete this.map;GeoExt.MapPanel.superclass.beforeDestroy.apply(this,arguments)}});GeoExt.MapPanel.guess=function(){return Ext.ComponentMgr.all.find(function(a){return a instanceof GeoExt.MapPanel})};Ext.reg("gx_mappanel",GeoExt.MapPanel);Ext.namespace("GeoExt","GeoExt.data");
GeoExt.data.LayerReader=function(a,b){a=a||{};b instanceof Function||(b=GeoExt.data.LayerRecord.create(b||a.fields||{}));GeoExt.data.LayerReader.superclass.constructor.call(this,a,b)};
Ext.extend(GeoExt.data.LayerReader,Ext.data.DataReader,{totalRecords:null,readRecords:function(a){var b=[];if(a){var c=this.recordType,d=c.prototype.fields,e,g,f,h,k,l,m,n;e=0;for(g=a.length;e<g;e++){k=a[e];l={};f=0;for(h=d.length;f<h;f++)m=d.items[f],n=k[m.mapping||m.name]||m.defaultValue,n=m.convert(n),l[m.name]=n;l.layer=k;b[b.length]=new c(l,k.id)}}return{records:b,totalRecords:null!=this.totalRecords?this.totalRecords:b.length}}});Ext.namespace("GeoExt.data");
GeoExt.data.LayerRecord=Ext.data.Record.create([{name:"layer"},{name:"title",type:"string",mapping:"name"}]);GeoExt.data.LayerRecord.prototype.getLayer=function(){return this.get("layer")};GeoExt.data.LayerRecord.prototype.setLayer=function(a){a!==this.data.layer&&(this.dirty=!0,this.modified||(this.modified={}),void 0===this.modified.layer&&(this.modified.layer=this.data.layer),this.data.layer=a,this.editing||this.afterEdit())};
GeoExt.data.LayerRecord.prototype.clone=function(a){var b=this.getLayer()&&this.getLayer().clone();return new this.constructor(Ext.applyIf({layer:b},this.data),a||b.id)};
GeoExt.data.LayerRecord.create=function(a){var b=Ext.extend(GeoExt.data.LayerRecord,{}),c=b.prototype;c.fields=new Ext.util.MixedCollection(!1,function(a){return a.name});GeoExt.data.LayerRecord.prototype.fields.each(function(a){c.fields.add(a)});if(a)for(var d=0,e=a.length;d<e;d++)c.fields.add(new Ext.data.Field(a[d]));b.getField=function(a){return c.fields.get(a)};return b};Ext.namespace("GeoExt.form");
GeoExt.form.BasicForm=Ext.extend(Ext.form.BasicForm,{protocol:null,prevResponse:null,autoAbort:!0,doAction:function(a,b){"search"==a&&(b=Ext.applyIf(b||{},{protocol:this.protocol,abortPrevious:this.autoAbort}),a=new GeoExt.form.SearchAction(this,b));return GeoExt.form.BasicForm.superclass.doAction.call(this,a,b)},search:function(a){return this.doAction("search",a)}});Ext.namespace("GeoExt.data");
GeoExt.data.StyleReader=Ext.extend(Ext.data.JsonReader,{onMetaChange:function(){GeoExt.data.StyleReader.superclass.onMetaChange.apply(this,arguments);this.recordType.prototype.commit=Ext.createInterceptor(this.recordType.prototype.commit,function(){var a=this.store.reader;a.raw[a.meta.root]=a.meta.storeToData(this.store)})},readRecords:function(a){var b;b=a instanceof OpenLayers.Symbolizer.Raster?"colorMap":"rules";this.raw=a;Ext.applyIf(this.meta,GeoExt.data.StyleReader.metaData[b]);var c={metaData:this.meta};
c[b]=a[b];return GeoExt.data.StyleReader.superclass.readRecords.call(this,c)}});
GeoExt.data.StyleReader.metaData={colorMap:{root:"colorMap",idProperty:"filter",fields:[{name:"symbolizers",mapping:function(a){return{fillColor:a.color,fillOpacity:a.opacity,stroke:!1}}},{name:"filter",mapping:"quantity",type:"float"},{name:"label",mapping:function(a){return a.label||a.quantity}}],storeToData:function(a){a.sort("filter","ASC");var b=[];a.each(function(a){var d=a.get("symbolizers"),e=a.get("label"),g=a.isModified("label"),f=Number(a.get("filter"));a.data.filter=f;if(!a.json.label&&
!g&&a.isModified("filter")||g&&!e)a.data.label=f;b.push(Ext.apply(a.json,{color:d.fillColor,label:"string"==typeof e?e:void 0,opacity:d.opacity,quantity:f}))});return b}},rules:{root:"rules",fields:["symbolizers","filter",{name:"label",mapping:"title"},"name","description","elseFilter","minScaleDenominator","maxScaleDenominator"],storeToData:function(a){var b=[];a.each(function(a){var d=a.get("filter");"string"===typeof d&&(d=d?OpenLayers.Format.CQL.prototype.read(d):null);b.push(Ext.apply(a.json,
{symbolizers:a.get("symbolizers"),filter:d,title:a.get("label"),name:a.get("name"),description:a.get("description"),elseFilter:a.get("elseFilter"),minScaleDenominator:a.get("minScaleDenominator"),maxScaleDenominator:a.get("maxScaleDenominator")}))});return b}}};Ext.namespace("GeoExt","GeoExt.data");GeoExt.data.FeatureReader=function(a,b){a=a||{};b instanceof Function||(b=GeoExt.data.FeatureRecord.create(b||a.fields||{}));GeoExt.data.FeatureReader.superclass.constructor.call(this,a,b)};
Ext.extend(GeoExt.data.FeatureReader,Ext.data.DataReader,{totalRecords:null,read:function(a){return this.readRecords(a.features)},readRecords:function(a){var b=[];if(a){var c=this.recordType,d=c.prototype.fields,e,g,f,h,k,l,m,n;e=0;for(g=a.length;e<g;e++){k=a[e];l={};if(k.attributes)for(f=0,h=d.length;f<h;f++){m=d.items[f];if(/[\[\.]/.test(m.mapping))try{n=(new Function("obj","return obj."+m.mapping))(k.attributes)}catch(r){n=m.defaultValue}else n=k.attributes[m.mapping||m.name]||m.defaultValue;m.convert&&
(n=m.convert(n));l[m.name]=n}l.feature=k;l.state=k.state;l.fid=k.fid;b[b.length]=new c(l,k.state===OpenLayers.State.INSERT?void 0:k.id)}}return{records:b,totalRecords:null!=this.totalRecords?this.totalRecords:b.length}}});Ext.namespace("GeoExt");
GeoExt.WMSLegend=Ext.extend(GeoExt.LayerLegend,{defaultStyleIsFirst:!0,useScaleParameter:!0,baseParams:null,itemXType:"gx_legendimage",initComponent:function(){GeoExt.WMSLegend.superclass.initComponent.call(this);var a=this.layerRecord.getLayer();this._noMap=!a.map;a.events.register("moveend",this,this.onLayerMoveend);this.update()},onLayerMoveend:function(a){if(!0===a.zoomChanged&&!0===this.useScaleParameter||this._noMap)delete this._noMap,this.update()},getLegendUrl:function(a,b){var c=this.layerRecord,
d,e=c&&c.get("styles"),c=c.getLayer();b=b||(""+c.params.LAYERS).split(",");var g=c.params.STYLES&&(""+c.params.STYLES).split(","),f=b.indexOf(a),h=g&&g[f];e&&0<e.length&&(h?Ext.each(e,function(a){d=a.name==h&&a.legend&&a.legend.href;return!d}):g||c.params.SLD||c.params.SLD_BODY||(Ext.each(e,function(b){d=b.layerName==a&&b.legend&&b.legend.href;return!d}),d||!0!==this.defaultStyleIsFirst||(d=e[0].legend&&e[0].legend.href)));d||(d=c.getFullRequestString({REQUEST:"GetLegendGraphic",WIDTH:null,HEIGHT:null,
EXCEPTIONS:"application/vnd.ogc.se_xml",LAYER:a,LAYERS:null,STYLE:""!==h?h:null,STYLES:null,SRS:null,FORMAT:null,TIME:null}));e=Ext.apply({},this.baseParams);c.params._OLSALT&&(e._OLSALT=c.params._OLSALT);d=Ext.urlAppend(d,Ext.urlEncode(e));-1!=d.toLowerCase().indexOf("request=getlegendgraphic")&&(-1==d.toLowerCase().indexOf("format=")&&(d=Ext.urlAppend(d,"FORMAT=image%2Fgif")),!0===this.useScaleParameter&&(e=c.map.getScale(),d=Ext.urlAppend(d,"SCALE="+e)));return d},update:function(){var a=this.layerRecord.getLayer();
if(a&&a.map){GeoExt.WMSLegend.superclass.update.apply(this,arguments);var b,c,d;b=(""+a.params.LAYERS).split(",");var e=[],g=this.items.find(function(a){return a.isXType("label")});this.items.each(function(a){d=b.indexOf(a.itemId);if(0>d&&a!=g)e.push(a);else if(a!==g){c=b[d];var f=this.getLegendUrl(c,b);OpenLayers.Util.isEquivalentUrl(f,a.url)||a.setUrl(f)}},this);d=0;for(a=e.length;d<a;d++){var f=e[d];this.remove(f);f.destroy()}d=0;for(a=b.length;d<a;d++)c=b[d],this.items&&this.getComponent(c)||
this.add({xtype:this.itemXType,url:this.getLegendUrl(c,b),itemId:c});this.doLayout()}},beforeDestroy:function(){if(!0===this.useScaleParameter){var a=this.layerRecord.getLayer();a&&a.events&&a.events.unregister("moveend",this,this.onLayerMoveend)}GeoExt.WMSLegend.superclass.beforeDestroy.apply(this,arguments)}});GeoExt.WMSLegend.supports=function(a){return a.getLayer()instanceof OpenLayers.Layer.WMS?1:0};GeoExt.LayerLegend.types.gx_wmslegend=GeoExt.WMSLegend;Ext.reg("gx_wmslegend",GeoExt.WMSLegend);
Ext.namespace("GeoExt.data");GeoExt.data.WMSDescribeLayerReader=function(a,b){a=a||{};a.format||(a.format=new OpenLayers.Format.WMSDescribeLayer);"function"!==typeof b&&(b=Ext.data.Record.create(b||a.fields||[{name:"owsType",type:"string"},{name:"owsURL",type:"string"},{name:"typeName",type:"string"}]));GeoExt.data.WMSDescribeLayerReader.superclass.constructor.call(this,a,b)};
Ext.extend(GeoExt.data.WMSDescribeLayerReader,Ext.data.DataReader,{read:function(a){var b=a.responseXML;b&&b.documentElement||(b=a.responseText);return this.readRecords(b)},readRecords:function(a){if("string"===typeof a||a.nodeType)a=this.meta.format.read(a);for(var b=[],c,d=0,e=a.length;d<e;d++)(c=a[d])&&b.push(new this.recordType(c));return{totalRecords:b.length,success:!0,records:b}}});Ext.namespace("GeoExt.form");
GeoExt.form.SearchAction=Ext.extend(Ext.form.Action,{type:"search",response:null,constructor:function(a,b){GeoExt.form.SearchAction.superclass.constructor.call(this,a,b)},run:function(){var a=this.options,b=GeoExt.form.toFilter(this.form,a.logicalOp,a.wildcard);!1===a.clientValidation||this.form.isValid()?(a.abortPrevious&&this.form.prevResponse&&a.protocol.abort(this.form.prevResponse),this.form.prevResponse=a.protocol.read(Ext.applyIf({filter:b,callback:this.handleResponse,scope:this},a))):!1!==
a.clientValidation&&(this.failureType=Ext.form.Action.CLIENT_INVALID,this.form.afterAction(this,!1))},handleResponse:function(a){this.form.prevResponse=null;this.response=a;a.success()?this.form.afterAction(this,!0):this.form.afterAction(this,!1);var b=this.options;b.callback&&b.callback.call(b.scope,a)}});Ext.namespace("GeoExt.data");GeoExt.data.FeatureRecord=Ext.data.Record.create([{name:"feature"},{name:"state"},{name:"fid"}]);GeoExt.data.FeatureRecord.prototype.getFeature=function(){return this.get("feature")};
GeoExt.data.FeatureRecord.prototype.setFeature=function(a){a!==this.data.feature&&(this.dirty=!0,this.modified||(this.modified={}),void 0===this.modified.feature&&(this.modified.feature=this.data.feature),this.data.feature=a,this.editing||this.afterEdit())};
GeoExt.data.FeatureRecord.create=function(a){var b=Ext.extend(GeoExt.data.FeatureRecord,{}),c=b.prototype;c.fields=new Ext.util.MixedCollection(!1,function(a){return a.name});GeoExt.data.FeatureRecord.prototype.fields.each(function(a){c.fields.add(a)});if(a)for(var d=0,e=a.length;d<e;d++)c.fields.add(new Ext.data.Field(a[d]));b.getField=function(a){return c.fields.get(a)};return b};Ext.namespace("GeoExt.plugins");GeoExt.plugins.AttributeForm=function(a){Ext.apply(this,a)};
GeoExt.plugins.AttributeForm.prototype={attributeStore:null,formPanel:null,init:function(a){this.formPanel=a;this.attributeStore instanceof Ext.data.Store&&(this.fillForm(),this.bind(this.attributeStore));a.on("destroy",this.onFormDestroy,this)},bind:function(a){this.unbind();a.on({load:this.onLoad,scope:this});this.attributeStore=a},unbind:function(){this.attributeStore&&this.attributeStore.un("load",this.onLoad,this)},onLoad:function(){this.formPanel.items&&this.formPanel.removeAll();this.fillForm()},
fillForm:function(){this.attributeStore.each(function(a){(a=GeoExt.form.recordToField(a,Ext.apply({checkboxLabelProperty:"fieldLabel"},this.recordToFieldOptions||{})))&&this.formPanel.add(a)},this);this.formPanel.doLayout()},onFormDestroy:function(){this.unbind()}};Ext.preg("gx_attributeform",GeoExt.plugins.AttributeForm);Ext.namespace("GeoExt.data");
GeoExt.data.WMSDescribeLayerStore=function(a){a=a||{};GeoExt.data.WMSDescribeLayerStore.superclass.constructor.call(this,Ext.apply(a,{proxy:a.proxy||(a.data?void 0:new Ext.data.HttpProxy({url:a.url,disableCaching:!1,method:"GET"})),reader:new GeoExt.data.WMSDescribeLayerReader(a,a.fields)}))};Ext.extend(GeoExt.data.WMSDescribeLayerStore,Ext.data.Store);Ext.namespace("GeoExt.form");
GeoExt.form.toFilter=function(a,b,c){a instanceof Ext.form.FormPanel&&(a=a.getForm());var d=[];a=a.getValues(!1);for(var e in a){var g=e.split("__"),f=a[e],h;1<g.length&&void 0!==(h=GeoExt.form.toFilter.FILTER_MAP[g[1]])?e=g[0]:h=OpenLayers.Filter.Comparison.EQUAL_TO;if(h===OpenLayers.Filter.Comparison.LIKE)switch(c){case GeoExt.form.ENDS_WITH:f=".*"+f;break;case GeoExt.form.STARTS_WITH:f+=".*";break;case GeoExt.form.CONTAINS:f=".*"+f+".*"}d.push(new OpenLayers.Filter.Comparison({type:h,value:f,property:e}))}return 1==
d.length&&b!=OpenLayers.Filter.Logical.NOT?d[0]:new OpenLayers.Filter.Logical({type:b||OpenLayers.Filter.Logical.AND,filters:d})};GeoExt.form.toFilter.FILTER_MAP={eq:OpenLayers.Filter.Comparison.EQUAL_TO,ne:OpenLayers.Filter.Comparison.NOT_EQUAL_TO,lt:OpenLayers.Filter.Comparison.LESS_THAN,le:OpenLayers.Filter.Comparison.LESS_THAN_OR_EQUAL_TO,gt:OpenLayers.Filter.Comparison.GREATER_THAN,ge:OpenLayers.Filter.Comparison.GREATER_THAN_OR_EQUAL_TO,like:OpenLayers.Filter.Comparison.LIKE};
GeoExt.form.ENDS_WITH=1;GeoExt.form.STARTS_WITH=2;GeoExt.form.CONTAINS=3;
GeoExt.form.recordToField=function(a,b){b=b||{};var c=a.get("type");if("object"===typeof c&&c.xtype)return c;var c=c.split(":").pop(),d,e=a.get("name"),g=a.get("restriction")||{},f=a.get("nillable")||!1,h=a.get("label"),k=b.labelTpl;k?h=(k instanceof Ext.Template?k:new Ext.XTemplate(k)).apply(a.data):null==h&&(h=e);e={name:e,labelStyle:f?"":null!=b.mandatoryFieldLabelStyle?b.mandatoryFieldLabelStyle:"font-weight:bold;"};f=GeoExt.form.recordToField.REGEXES;g.enumeration?d=Ext.apply({xtype:"combo",
fieldLabel:h,mode:"local",forceSelection:!0,triggerAction:"all",editable:!1,store:g.enumeration},e):c.match(f.text)?(c=void 0!==g.maxLength?parseFloat(g.maxLength):void 0,g=void 0!==g.minLength?parseFloat(g.minLength):void 0,d=Ext.apply({xtype:"textfield",fieldLabel:h,maxLength:c,minLength:g},e)):c.match(f.number)?(c=void 0!==g.maxInclusive?parseFloat(g.maxInclusive):void 0,g=void 0!==g.minInclusive?parseFloat(g.minInclusive):void 0,d=Ext.apply({xtype:"numberfield",fieldLabel:h,maxValue:c,minValue:g},
e)):c.match(f["boolean"])?(d=Ext.apply({xtype:"checkbox"},e),d[b.checkboxLabelProperty||"boxLabel"]=h):c.match(f.date)&&(d=Ext.apply({xtype:"datefield",fieldLabel:h,format:"c"},e));return d};GeoExt.form.recordToField.REGEXES={text:/^(text|string)$/i,number:/^(number|float|decimal|double|int|long|integer|short)$/i,"boolean":/^(boolean)$/i,date:/^(date|dateTime)$/i};Ext.namespace("GeoExt");
GeoExt.FeatureRenderer=Ext.extend(Ext.BoxComponent,{feature:void 0,symbolizers:[OpenLayers.Feature.Vector.style["default"]],symbolType:"Polygon",labelText:null,resolution:1,minWidth:20,minHeight:20,renderers:["SVG","VML","Canvas"],rendererOptions:null,pointFeature:void 0,lineFeature:void 0,polygonFeature:void 0,textFeature:void 0,renderer:null,initComponent:function(){GeoExt.FeatureRenderer.superclass.initComponent.apply(this,arguments);Ext.applyIf(this,{pointFeature:new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(0,
0)),lineFeature:new OpenLayers.Feature.Vector(new OpenLayers.Geometry.LineString([new OpenLayers.Geometry.Point(-8,-3),new OpenLayers.Geometry.Point(-3,3),new OpenLayers.Geometry.Point(3,-3),new OpenLayers.Geometry.Point(8,3)])),polygonFeature:new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Polygon([new OpenLayers.Geometry.LinearRing([new OpenLayers.Geometry.Point(-8,-4),new OpenLayers.Geometry.Point(-6,-6),new OpenLayers.Geometry.Point(6,-6),new OpenLayers.Geometry.Point(8,-4),new OpenLayers.Geometry.Point(8,
4),new OpenLayers.Geometry.Point(6,6),new OpenLayers.Geometry.Point(-6,6),new OpenLayers.Geometry.Point(-8,4)])])),textFeature:new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(0,0))});this.feature||this.setFeature(null,{draw:!1});this.addEvents("click")},initCustomEvents:function(){this.clearCustomEvents();this.el.on("click",this.onClick,this)},clearCustomEvents:function(){this.el&&this.el.removeAllListeners&&this.el.removeAllListeners()},onClick:function(){this.fireEvent("click",this)},
onRender:function(a,b){this.el||(this.el=document.createElement("div"),this.el.id=this.getId());this.renderer&&this.renderer.supported()||this.assignRenderer();this.renderer.map={getResolution:function(){return this.resolution}.createDelegate(this)};GeoExt.FeatureRenderer.superclass.onRender.apply(this,arguments);this.drawFeature()},afterRender:function(){GeoExt.FeatureRenderer.superclass.afterRender.apply(this,arguments);this.initCustomEvents()},onResize:function(a,b){this.setRendererDimensions();
GeoExt.FeatureRenderer.superclass.onResize.apply(this,arguments)},setRendererDimensions:function(){var a=this.feature.geometry.getBounds(),b=a.getWidth(),c=a.getHeight(),d=this.initialConfig.resolution;d||(d=Math.max(b/this.width||0,c/this.height||0)||1);this.resolution=d;var b=Math.max(this.width||this.minWidth,b/d),c=Math.max(this.height||this.minHeight,c/d),a=a.getCenterPixel(),e=b*d/2,d=c*d/2,d=new OpenLayers.Bounds(a.x-e,a.y-d,a.x+e,a.y+d);this.renderer.setSize(new OpenLayers.Size(Math.round(b),
Math.round(c)));this.renderer.setExtent(d,!0)},assignRenderer:function(){for(var a=0,b=this.renderers.length;a<b;++a){var c=OpenLayers.Renderer[this.renderers[a]];if(c&&c.prototype.supported()){this.renderer=new c(this.el,this.rendererOptions);break}}},setSymbolizers:function(a,b){this.symbolizers=a;b&&!b.draw||this.drawFeature()},setSymbolType:function(a,b){this.symbolType=a;this.setFeature(null,b)},setFeature:function(a,b){this.feature=a||this[this.symbolType.toLowerCase()+"Feature"];b&&!b.draw||
this.drawFeature()},drawFeature:function(){this.renderer.clear();this.setRendererDimensions();for(var a,b,c=0,d=this.symbolizers.length;c<d;++c)a=this.symbolizers[c],b=this.feature,a instanceof OpenLayers.Symbolizer?(a=a.clone(),OpenLayers.Symbolizer.Text&&a instanceof OpenLayers.Symbolizer.Text&&!1===a.graphic&&(a.fill=a.stroke=!1),this.initialConfig.feature||(b=a.CLASS_NAME.split(".").pop().toLowerCase(),b=this[b+"Feature"])):a=Ext.apply({},a),void 0!==a.label&&null!==this.labelText&&(a.label=this.labelText),
this.renderer.drawFeature(b.clone(),a)},update:function(a){a=a||{};a.feature?this.setFeature(a.feature,{draw:!1}):a.symbolType&&this.setSymbolType(a.symbolType,{draw:!1});a.symbolizers&&this.setSymbolizers(a.symbolizers,{draw:!1});this.drawFeature()},beforeDestroy:function(){this.clearCustomEvents();this.renderer&&this.renderer.destroy()}});Ext.reg("gx_renderer",GeoExt.FeatureRenderer);Ext.namespace("GeoExt");
GeoExt.Popup=Ext.extend(Ext.Window,{anchored:!0,map:null,panIn:!0,unpinnable:!0,location:null,insideViewport:null,animCollapse:!1,draggable:!1,shadow:!1,popupCls:"gx-popup",ancCls:null,anchorPosition:"auto",initComponent:function(){this.map instanceof GeoExt.MapPanel&&(this.map=this.map.map);!this.map&&this.location instanceof OpenLayers.Feature.Vector&&this.location.layer&&(this.map=this.location.layer.map);this.location instanceof OpenLayers.Feature.Vector&&(this.location=this.location.geometry);
this.location instanceof OpenLayers.Geometry?("function"==typeof this.location.getCentroid&&(this.location=this.location.getCentroid()),this.location=this.location.getBounds().getCenterLonLat()):this.location instanceof OpenLayers.Pixel&&(this.location=this.map.getLonLatFromViewPortPx(this.location));this.location instanceof OpenLayers.LonLat||(this.anchored=!1);var a=this.map.getExtent();a&&this.location&&(this.insideViewport=a.containsLonLat(this.location));this.anchored?(this.addAnchorEvents(),
this.elements+=",anc"):this.unpinnable=!1;this.baseCls=this.popupCls+" "+this.baseCls;GeoExt.Popup.superclass.initComponent.call(this)},onRender:function(a,b){GeoExt.Popup.superclass.onRender.call(this,a,b);this.anchored?(this.ancCls=this.popupCls+"-anc",this.createElement("anc",this.el.dom)):this.makeDraggable()},initTools:function(){this.unpinnable&&this.addTool({id:"unpin",handler:this.unanchorPopup.createDelegate(this,[])});GeoExt.Popup.superclass.initTools.call(this)},show:function(){GeoExt.Popup.superclass.show.apply(this,
arguments);this.anchored&&(this.position(),this.panIn&&!this._mapMove&&this.panIntoView())},maximize:function(){!this.maximized&&this.anc&&this.unanchorPopup();GeoExt.Popup.superclass.maximize.apply(this,arguments)},setSize:function(a,b){if(this.anc){var c=this.anc.getSize();"object"==typeof a?(b=a.height-c.height,a=a.width):isNaN(b)||(b-=c.height)}GeoExt.Popup.superclass.setSize.call(this,a,b)},position:function(){var a=this;!0===a._mapMove&&(a.insideViewport=a.map.getExtent().containsLonLat(a.location),
a.insideViewport!==a.isVisible()&&a.setVisible(a.insideViewport));if(a.isVisible()){var b=a.map.getPixelFromLonLat(a.location),c=Ext.fly(a.map.div).getBox(!0),d=b.y+c.y,e=b.x+c.x,g=a.el.getSize(),f=a.anc.getSize(),h=a.anchorPosition;if(-1<h.indexOf("right")||b.x>c.width/2){a.anc.addClass("right");var k=a.el.getX(!0)+g.width-a.anc.getX(!0)-f.width,e=e-(g.width-k-f.width/2)}else a.anc.removeClass("right"),k=a.anc.getLeft(!0),e-=k+f.width/2;-1<h.indexOf("bottom")||b.y>c.height/2?(a.anc.removeClass("top"),
d-=g.height+f.height):(a.anc.addClass("top"),d+=f.height);a.setPagePosition(e,d);window.setTimeout(function(){a.el.dom&&a.setPagePosition(e,d)},0)}},makeDraggable:function(){this.draggable=!0;this.header.addClass("x-window-draggable");this.dd=new Ext.Window.DD(this)},unanchorPopup:function(){this.removeAnchorEvents();this.makeDraggable();this.anc.remove();this.anc=null;this.tools.unpin.hide()},panIntoView:function(){var a=Ext.fly(this.map.div).getBox(!0),b=this.getPosition(!0);b[0]-=a.x;b[1]-=a.y;
var a=[a.width,a.height],c=this.getSize(),d=[b[0],b[1]],e=this.map.paddingForPopups;b[0]<e.left?d[0]=e.left:b[0]+c.width>a[0]-e.right&&(d[0]=a[0]-e.right-c.width);b[1]<e.top?d[1]=e.top:b[1]+c.height>a[1]-e.bottom&&(d[1]=a[1]-e.bottom-c.height);this.map.pan(b[0]-d[0],b[1]-d[1])},onMapMove:function(){this.hidden&&this.insideViewport||(this._mapMove=!0,this.position(),delete this._mapMove)},addAnchorEvents:function(){this.map.events.on({move:this.onMapMove,scope:this});this.on({resize:this.position,
collapse:this.position,expand:this.position,scope:this})},removeAnchorEvents:function(){this.map.events.un({move:this.onMapMove,scope:this});this.un("resize",this.position,this);this.un("collapse",this.position,this);this.un("expand",this.position,this)},beforeDestroy:function(){this.anchored&&this.removeAnchorEvents();GeoExt.Popup.superclass.beforeDestroy.call(this)}});Ext.reg("gx_popup",GeoExt.Popup);Ext.namespace("GeoExt.data");
GeoExt.data.AttributeStoreMixin=function(){return{constructor:function(a){a=a||{};arguments.callee.superclass.constructor.call(this,Ext.apply(a,{proxy:a.proxy||(a.data?void 0:new Ext.data.HttpProxy({url:a.url,disableCaching:!1,method:"GET"})),reader:new GeoExt.data.AttributeReader(a,a.fields||["name","type","restriction",{name:"nillable",type:"boolean"},"annotation"])}));this.feature&&this.bind()},bind:function(){this.on({update:this.onUpdate,load:this.onLoad,add:this.onAdd,scope:this});var a=[];
this.each(function(b){a.push(b)});this.updateFeature(a)},onUpdate:function(a,b,c){this.updateFeature([b])},onLoad:function(a,b,c){c&&!0===c.add||this.updateFeature(b)},onAdd:function(a,b,c){this.updateFeature(b)},updateFeature:function(a){var b=this.feature,c=b.layer,d,e,g,f,h;d=0;for(e=a.length;d<e;d++)g=a[d],f=g.get("name"),g=g.get("value"),f=b.attributes[f],f!==g&&(h=!0);if(h&&c&&c.events&&!1!==c.events.triggerEvent("beforefeaturemodified",{feature:b})){d=0;for(e=a.length;d<e;d++)g=a[d],f=g.get("name"),
g=g.get("value"),b.attributes[f]=g;c.events.triggerEvent("featuremodified",{feature:b});c.drawFeature(b)}}}};GeoExt.data.AttributeStore=Ext.extend(Ext.data.Store,GeoExt.data.AttributeStoreMixin());Ext.namespace("GeoExt.form");GeoExt.form.FormPanel=Ext.extend(Ext.form.FormPanel,{protocol:null,createForm:function(){delete this.initialConfig.listeners;return new GeoExt.form.BasicForm(null,this.initialConfig)},search:function(a){this.getForm().search(a)}});Ext.reg("gx_formpanel",GeoExt.form.FormPanel);
Ext.namespace("GeoExt.tree");GeoExt.tree.OverlayLayerContainer=Ext.extend(GeoExt.tree.LayerContainer,{text:"Overlays",constructor:function(a){a=Ext.applyIf(a||{},{text:this.text});a.loader=Ext.applyIf(a.loader||{},{filter:function(a){a=a.getLayer();return!0===a.displayInLayerSwitcher&&!1===a.isBaseLayer}});GeoExt.tree.OverlayLayerContainer.superclass.constructor.call(this,a)}});Ext.tree.TreePanel.nodeTypes.gx_overlaylayercontainer=GeoExt.tree.OverlayLayerContainer;Ext.namespace("GeoExt");
GeoExt.Action=Ext.extend(Ext.Action,{control:null,activateOnEnable:!1,deactivateOnDisable:!1,map:null,uScope:null,uHandler:null,uToggleHandler:null,uCheckHandler:null,constructor:function(a){this.uScope=a.scope;this.uHandler=a.handler;this.uToggleHandler=a.toggleHandler;this.uCheckHandler=a.checkHandler;a.scope=this;a.handler=this.pHandler;a.toggleHandler=this.pToggleHandler;a.checkHandler=this.pCheckHandler;var b=this.control=a.control;delete a.control;this.activateOnEnable=!!a.activateOnEnable;
delete a.activateOnEnable;this.deactivateOnDisable=!!a.deactivateOnDisable;delete a.deactivateOnDisable;b&&(a.map&&(a.map.addControl(b),delete a.map),(a.pressed||a.checked)&&b.map&&b.activate(),b.active&&(a.pressed=!0,a.checked=!0),b.events.on({activate:this.onCtrlActivate,deactivate:this.onCtrlDeactivate,scope:this}));arguments.callee.superclass.constructor.call(this,a)},pHandler:function(a){var b=this.control;b&&b.type==OpenLayers.Control.TYPE_BUTTON&&b.trigger();this.uHandler&&this.uHandler.apply(this.uScope,
arguments)},pToggleHandler:function(a,b){this.changeControlState(b);this.uToggleHandler&&this.uToggleHandler.apply(this.uScope,arguments)},pCheckHandler:function(a,b){this.changeControlState(b);this.uCheckHandler&&this.uCheckHandler.apply(this.uScope,arguments)},changeControlState:function(a){a?this._activating||(this._activating=!0,this.control.activate(),this.initialConfig.pressed=!0,this.initialConfig.checked=!0,this._activating=!1):this._deactivating||(this._deactivating=!0,this.control.deactivate(),
this.initialConfig.pressed=!1,this._deactivating=this.initialConfig.checked=!1)},onCtrlActivate:function(){this.control.type==OpenLayers.Control.TYPE_BUTTON?this.enable():(this.safeCallEach("toggle",[!0]),this.safeCallEach("setChecked",[!0]))},onCtrlDeactivate:function(){this.control.type==OpenLayers.Control.TYPE_BUTTON?this.disable():(this.safeCallEach("toggle",[!1]),this.safeCallEach("setChecked",[!1]))},safeCallEach:function(a,b){for(var c=this.items,d=0,e=c.length;d<e;d++)c[d][a]&&(c[d].rendered?
c[d][a].apply(c[d],b):c[d].on({render:c[d][a].createDelegate(c[d],b),single:!0}))},setDisabled:function(a){!a&&this.activateOnEnable&&this.control&&!this.control.active&&this.control.activate();a&&this.deactivateOnDisable&&this.control&&this.control.active&&this.control.deactivate();return GeoExt.Action.superclass.setDisabled.apply(this,arguments)}});Ext.namespace("GeoExt");
GeoExt.ZoomSliderTip=Ext.extend(GeoExt.SliderTip,{template:"<div>Zoom Level: {zoom}</div><div>Resolution: {resolution}</div><div>Scale: 1 : {scale}</div>",compiledTemplate:null,init:function(a){this.compiledTemplate=new Ext.Template(this.template);GeoExt.ZoomSliderTip.superclass.init.call(this,a)},getText:function(a){a={zoom:a.value,resolution:this.slider.getResolution(),scale:Math.round(this.slider.getScale())};return this.compiledTemplate.apply(a)}});Ext.namespace("GeoExt.tree");
GeoExt.tree.LayerParamNode=Ext.extend(Ext.tree.TreeNode,{layer:null,param:null,item:null,delimiter:null,allItems:null,constructor:function(a){var b=a||{};b.iconCls=b.iconCls||"gx-tree-layerparam-icon";b.text=b.text||b.item;this.param=b.param;this.item=b.item;this.delimiter=b.delimiter||",";this.allItems=b.allItems;GeoExt.tree.LayerParamNode.superclass.constructor.apply(this,arguments);this.getLayer();if(this.layer){this.allItems||(this.allItems=this.getItemsFromLayer());if(null==this.attributes.checked)this.attributes.checked=
this.layer.getVisibility()&&0<=this.getItemsFromLayer().indexOf(this.item);else this.onCheckChange(this,this.attributes.checked);this.layer.events.on({visibilitychanged:this.onLayerVisibilityChanged,scope:this});this.on({checkchange:this.onCheckChange,scope:this})}},getLayer:function(){if(!this.layer){var a=this.attributes.layer;if("string"==typeof a)var b=this.attributes.layerStore||GeoExt.MapPanel.guess().layers,c=b.findBy(function(b){return b.get("title")==a}),a=-1!=c?b.getAt(c).getLayer():null;
this.layer=a}return this.layer},getItemsFromLayer:function(){var a=this.layer.params[this.param];return a instanceof Array?a:a?a.split(this.delimiter):[]},createParams:function(a){var b={};b[this.param]=this.layer.params[this.param]instanceof Array?a:a.join(this.delimiter);return b},onLayerVisibilityChanged:function(){0===this.getItemsFromLayer().length&&this.layer.mergeNewParams(this.createParams(this.allItems));var a=this.layer.getVisibility();a&&-1!==this.getItemsFromLayer().indexOf(this.item)&&
this.getUI().toggleCheck(!0);a||(this.layer.mergeNewParams(this.createParams([])),this.getUI().toggleCheck(!1))},onCheckChange:function(a,b){var c=this.layer,d=[],e=this.getItemsFromLayer();!0===b&&!1===c.getVisibility()&&e.length===this.allItems.length&&(e=[]);Ext.each(this.allItems,function(a){(a!==this.item&&-1!==e.indexOf(a)||!0===b&&a===this.item)&&d.push(a)},this);var g=0<d.length;g&&c.mergeNewParams(this.createParams(d));g!==c.getVisibility()&&c.setVisibility(g);!g&&c.mergeNewParams(this.createParams([]))},
destroy:function(){var a=this.layer;a instanceof OpenLayers.Layer&&a.events.un({visibilitychanged:this.onLayerVisibilityChanged,scope:this});delete this.layer;this.un("checkchange",this.onCheckChange,this);GeoExt.tree.LayerParamNode.superclass.destroy.apply(this,arguments)}});Ext.tree.TreePanel.nodeTypes.gx_layerparam=GeoExt.tree.LayerParamNode;Ext.namespace("GeoExt");
GeoExt.UrlLegend=Ext.extend(GeoExt.LayerLegend,{initComponent:function(){GeoExt.UrlLegend.superclass.initComponent.call(this);this.add(new GeoExt.LegendImage({url:this.layerRecord.get("legendURL")}))},update:function(){GeoExt.UrlLegend.superclass.update.apply(this,arguments);this.items.get(1).setUrl(this.layerRecord.get("legendURL"))}});GeoExt.UrlLegend.supports=function(a){return null==a.get("legendURL")?0:10};GeoExt.LayerLegend.types.gx_urllegend=GeoExt.UrlLegend;Ext.reg("gx_urllegend",GeoExt.UrlLegend);
Ext.namespace("GeoExt.state");GeoExt.state.PermalinkProvider=function(a){GeoExt.state.PermalinkProvider.superclass.constructor.apply(this,arguments);a=a||{};var b=a.url;delete a.url;Ext.apply(this,a);this.state=this.readURL(b)};
Ext.extend(GeoExt.state.PermalinkProvider,Ext.state.Provider,{encodeType:!0,readURL:function(a){var b={};a=OpenLayers.Util.getParameters(a);var c,d,e;for(c in a)a.hasOwnProperty(c)&&(d=c.split("_"),1<d.length&&(e=d[0],b[e]=b[e]||{},b[e][d.slice(1).join("_")]=this.encodeType?this.decodeValue(a[c]):a[c]));return b},getLink:function(a){a=a||document.location.href;var b={},c,d,e=this.state;for(c in e)if(e.hasOwnProperty(c))for(d in e[c])b[c+"_"+d]=this.encodeType?unescape(this.encodeValue(e[c][d])):e[c][d];
OpenLayers.Util.applyDefaults(b,OpenLayers.Util.getParameters(a));b=OpenLayers.Util.getParameterString(b);c=a.indexOf("?");0<c&&(a=a.substring(0,c));return Ext.urlAppend(a,b)}});Ext.namespace("GeoExt");
GeoExt.LegendImage=Ext.extend(Ext.BoxComponent,{url:null,defaultImgSrc:null,imgCls:null,noImgCls:"gx-legend-noimage",initComponent:function(){GeoExt.LegendImage.superclass.initComponent.call(this);null===this.defaultImgSrc&&(this.defaultImgSrc=Ext.BLANK_IMAGE_URL);this.autoEl={tag:"img","class":this.imgCls?this.imgCls+" "+this.noImgCls:this.noImgCls,src:this.defaultImgSrc}},getImgEl:function(){return this.getEl()},setUrl:function(a){this.url=a;var b=this.getImgEl();b&&(b.un("load",this.onImageLoad,
this),b.on("load",this.onImageLoad,this,{single:!0}),b.un("error",this.onImageLoadError,this),b.on("error",this.onImageLoadError,this,{single:!0}),b.dom.src=a)},onRender:function(a,b){GeoExt.LegendImage.superclass.onRender.call(this,a,b);this.url&&this.setUrl(this.url)},onDestroy:function(){var a=this.getImgEl();a&&(a.un("load",this.onImageLoad,this),a.un("error",this.onImageLoadError,this));GeoExt.LegendImage.superclass.onDestroy.apply(this,arguments)},onImageLoadError:function(){var a=this.getImgEl();
a.addClass(this.noImgCls);a.dom.src=this.defaultImgSrc},onImageLoad:function(){var a=this.getImgEl();OpenLayers.Util.isEquivalentUrl(a.dom.src,this.defaultImgSrc)||a.removeClass(this.noImgCls)}});Ext.reg("gx_legendimage",GeoExt.LegendImage);Ext.namespace("GeoExt.tree");GeoExt.tree.WMSCapabilitiesLoader=function(a){Ext.apply(this,a);GeoExt.tree.WMSCapabilitiesLoader.superclass.constructor.call(this)};
Ext.extend(GeoExt.tree.WMSCapabilitiesLoader,Ext.tree.TreeLoader,{url:null,layerOptions:null,layerParams:null,requestMethod:"GET",getParams:function(a){return{service:"WMS",request:"GetCapabilities"}},processResponse:function(a,b,c,d){a=(new OpenLayers.Format.WMSCapabilities).read(a.responseXML||a.responseText);a.capability&&this.processLayer(a.capability,a.capability.request.getmap.href,b);"function"==typeof c&&c.apply(d||b,[b])},createWMSLayer:function(a,b){return a.name?new OpenLayers.Layer.WMS(a.title,
b,OpenLayers.Util.extend({formats:a.formats[0],layers:a.name},this.layerParams),OpenLayers.Util.extend({minScale:a.minScale,queryable:a.queryable,maxScale:a.maxScale,metadata:a},this.layerOptions)):null},processLayer:function(a,b,c){Ext.each(a.nestedLayers,function(a){var e=this.createNode({text:a.title||a.name,nodeType:"node",layer:this.createWMSLayer(a,b),leaf:0===a.nestedLayers.length});e&&c.appendChild(e);a.nestedLayers&&this.processLayer(a,b,e)},this)}});Ext.namespace("GeoExt.data");
GeoExt.data.AttributeReader=function(a,b){a=a||{};a.format||(a.format=new OpenLayers.Format.WFSDescribeFeatureType);GeoExt.data.AttributeReader.superclass.constructor.call(this,a,b||a.fields);a.feature&&this.recordType.prototype.fields.add(new Ext.data.Field("value"))};
Ext.extend(GeoExt.data.AttributeReader,Ext.data.DataReader,{read:function(a){var b=a.responseXML;b&&b.documentElement||(b=a.responseText);return this.readRecords(b)},readRecords:function(a){if(!(a instanceof Array)){a=this.meta.format.read(a);if(a.error)throw new Ext.data.DataReader.Error("invalid-response",a.error);a=a.featureTypes[0].properties}for(var b=this.meta.feature,c=this.recordType,d=c.prototype.fields,e=d.length,g,f,h,k,l,m=[],n=0,r=a.length;n<r;++n){k=!1;g=a[n];f={};for(var p=0;p<e;++p){l=
d.items[p];h=l.name;l=l.convert(g[h]);if(this.ignoreAttribute(h,l)){k=!0;break}f[h]=l}b&&(l=b.attributes[f.name],void 0!==l&&(this.ignoreAttribute("value",l)?k=!0:f.value=l));k||(m[m.length]=new c(f))}return{success:!0,records:m,totalRecords:m.length}},ignoreAttribute:function(a,b){var c=!1;if(this.meta.ignore&&this.meta.ignore[a]){var d=this.meta.ignore[a];"string"==typeof d?c=d===b:d instanceof Array?c=-1<d.indexOf(b):d instanceof RegExp&&(c=d.test(b))}return c}});Ext.namespace("GeoExt.grid");
GeoExt.grid.SymbolizerColumn=Ext.extend(Ext.grid.Column,{renderer:function(a,b){if(null!=a){var c=Ext.id();window.setTimeout(function(){var b=Ext.get(c);b&&new GeoExt.FeatureRenderer({symbolizers:a instanceof Array?a:[a],renderTo:b})},0);b.css="gx-grid-symbolizercol";return'<div id="'+c+'"></div>'}}});Ext.grid.Column.types.gx_symbolizercolumn=GeoExt.grid.SymbolizerColumn;Ext.namespace("GeoExt.tree");
GeoExt.tree.LayerNodeUI=Ext.extend(Ext.tree.TreeNodeUI,{constructor:function(a){GeoExt.tree.LayerNodeUI.superclass.constructor.apply(this,arguments)},render:function(a){var b=this.node.attributes;void 0===b.checked&&(b.checked=this.node.layer.getVisibility());void 0===b.disabled&&this.node.autoDisable&&(this.node.disabled=!1===this.node.layer.inRange||!this.node.layer.calculateInRange());GeoExt.tree.LayerNodeUI.superclass.render.apply(this,arguments);var c=this.checkbox;b.checkedGroup&&(b=Ext.DomHelper.insertAfter(c,
['<input type="radio" name="',b.checkedGroup,'_checkbox" class="',c.className,c.checked?'" checked="checked"':"",'"></input>'].join("")),b.defaultChecked=c.defaultChecked,Ext.get(c).remove(),this.checkbox=b);this.enforceOneVisible()},onClick:function(a){a.getTarget(".x-tree-node-cb",1)?this.toggleCheck(this.isChecked()):GeoExt.tree.LayerNodeUI.superclass.onClick.apply(this,arguments)},toggleCheck:function(a){a=void 0===a?!this.isChecked():a;GeoExt.tree.LayerNodeUI.superclass.toggleCheck.call(this,
a);this.enforceOneVisible()},enforceOneVisible:function(){var a=this.node.attributes,b=a.checkedGroup;if(b&&"gx_baselayer"!==b){var c=this.node.layer,d=this.node.getOwnerTree().getChecked(),e=0;Ext.each(d,function(d){var f=d.layer;d.hidden||d.attributes.checkedGroup!==b||(e++,f!=c&&a.checked&&f.setVisibility(!1))});0===e&&!1==a.checked&&c.setVisibility(!0)}},appendDDGhost:function(a){var b=this.elNode.cloneNode(!0),c=Ext.DomQuery.select("input[type='radio']",b);Ext.each(c,function(a){a.name+="_clone"});
a.appendChild(b)}});
GeoExt.tree.LayerNode=Ext.extend(Ext.tree.AsyncTreeNode,{layer:null,autoDisable:null,layerStore:null,constructor:function(a){a.leaf=a.leaf||!(a.children||a.loader);a.iconCls||a.children||(a.iconCls="gx-tree-layer-icon");!a.loader||a.loader instanceof Ext.tree.TreeLoader||(a.loader=new GeoExt.tree.LayerParamLoader(a.loader));this.defaultUI=this.defaultUI||GeoExt.tree.LayerNodeUI;Ext.apply(this,{layer:a.layer,layerStore:a.layerStore,autoDisable:a.autoDisable});a.text&&(this.fixedText=!0);GeoExt.tree.LayerNode.superclass.constructor.apply(this,
arguments)},render:function(a){var b=this.layer instanceof OpenLayers.Layer&&this.layer;if(!b){this.layerStore&&"auto"!=this.layerStore||(this.layerStore=GeoExt.MapPanel.guess().layers);var c=this.layerStore.findBy(function(a){return a.get("title")==this.layer},this);-1!=c&&(b=this.layerStore.getAt(c).getLayer())}this.rendered&&b||(c=this.getUI(),b?(this.layer=b,b.isBaseLayer&&(this.draggable=!1,Ext.applyIf(this.attributes,{checkedGroup:"gx_baselayer"})),this.autoDisable=!(!1===this.autoDisable||
this.layer.isBaseLayer||this.layer.alwaysInRange),this.text||(this.text=b.name),c.show(),this.addVisibilityEventHandlers()):c.hide(),this.layerStore instanceof GeoExt.data.LayerStore&&this.addStoreEventHandlers(b));GeoExt.tree.LayerNode.superclass.render.apply(this,arguments)},addVisibilityEventHandlers:function(){this.layer.events.on({visibilitychanged:this.onLayerVisibilityChanged,scope:this});this.on({checkchange:this.onCheckChange,scope:this});this.autoDisable&&(this.layer.map?this.layer.map.events.register("moveend",
this,this.onMapMoveend):this.layer.events.register("added",this,function b(){this.layer.events.unregister("added",this,b);this.layer.map.events.register("moveend",this,this.onMapMoveend)}))},onLayerVisibilityChanged:function(){this._visibilityChanging||this.getUI().toggleCheck(this.layer.getVisibility())},onCheckChange:function(a,b){if(b!=this.layer.getVisibility()){this._visibilityChanging=!0;var c=this.layer;b&&c.isBaseLayer&&c.map?c.map.setBaseLayer(c):c.setVisibility(b);delete this._visibilityChanging}},
onMapMoveend:function(a){this.autoDisable&&(!1===this.layer.inRange?this.disable():this.enable())},addStoreEventHandlers:function(){this.layerStore.on({add:this.onStoreAdd,remove:this.onStoreRemove,update:this.onStoreUpdate,scope:this})},onStoreAdd:function(a,b,c){for(c=0;c<b.length;++c)if(a=b[c].getLayer(),this.layer==a){this.getUI().show();break}else if(this.layer==a.name){this.render();break}},onStoreRemove:function(a,b,c){this.layer==b.getLayer()&&this.getUI().hide()},onStoreUpdate:function(a,
b,c){a=b.getLayer();this.fixedText||this.layer!=a||this.text===a.name||this.setText(a.name)},destroy:function(){var a=this.layer;a instanceof OpenLayers.Layer&&(a.map&&a.map.events.unregister("moveend",this,this.onMapMoveend),a.events.un({visibilitychanged:this.onLayerVisibilityChanged,scope:this}));delete this.layer;if(a=this.layerStore)a.un("add",this.onStoreAdd,this),a.un("remove",this.onStoreRemove,this),a.un("update",this.onStoreUpdate,this);delete this.layerStore;this.un("checkchange",this.onCheckChange,
this);GeoExt.tree.LayerNode.superclass.destroy.apply(this,arguments)}});Ext.tree.TreePanel.nodeTypes.gx_layer=GeoExt.tree.LayerNode;Ext.namespace("GeoExt.data");
GeoExt.data.FeatureStoreMixin=function(){return{layer:null,reader:null,featureFilter:null,constructor:function(a){a=a||{};a.reader=a.reader||new GeoExt.data.FeatureReader({},a.fields);var b=a.layer;delete a.layer;a.features&&(a.data=a.features);delete a.features;var c={initDir:a.initDir};delete a.initDir;arguments.callee.superclass.constructor.call(this,a);b&&this.bind(b,c)},bind:function(a,b){if(!this.layer){this.layer=a;b=b||{};var c=b.initDir;void 0==b.initDir&&(c=GeoExt.data.FeatureStore.LAYER_TO_STORE|
GeoExt.data.FeatureStore.STORE_TO_LAYER);var d=a.features.slice(0);if(c&GeoExt.data.FeatureStore.STORE_TO_LAYER)for(var e=this.getRange(),g=e.length-1;0<=g;g--)this.layer.addFeatures([e[g].getFeature()]);c&GeoExt.data.FeatureStore.LAYER_TO_STORE&&this.loadData(d,!0);a.events.on({featuresadded:this.onFeaturesAdded,featuresremoved:this.onFeaturesRemoved,featuremodified:this.onFeatureModified,scope:this});this.on({load:this.onLoad,clear:this.onClear,add:this.onAdd,remove:this.onRemove,update:this.onUpdate,
scope:this})}},unbind:function(){this.layer&&(this.layer.events.un({featuresadded:this.onFeaturesAdded,featuresremoved:this.onFeaturesRemoved,featuremodified:this.onFeatureModified,scope:this}),this.un("load",this.onLoad,this),this.un("clear",this.onClear,this),this.un("add",this.onAdd,this),this.un("remove",this.onRemove,this),this.un("update",this.onUpdate,this),this.layer=null)},getRecordFromFeature:function(a){return this.getByFeature(a)||null},getByFeature:function(a){var b;if(a.state!==OpenLayers.State.INSERT)b=
this.getById(a.id);else{var c=this.findBy(function(b){return b.getFeature()===a});-1<c&&(b=this.getAt(c))}return b},onFeaturesAdded:function(a){if(!this._adding){var b=a=a.features;if(this.featureFilter){var b=[],c,d,e;c=0;for(d=a.length;c<d;c++)e=a[c],!1!==this.featureFilter.evaluate(e)&&b.push(e)}this._adding=!0;this.loadData(b,!0);delete this._adding}},onFeaturesRemoved:function(a){if(!this._removing){a=a.features;var b,c;for(c=a.length-1;0<=c;c--)b=a[c],b=this.getByFeature(b),void 0!==b&&(this._removing=
!0,this.remove(b),delete this._removing)}},onFeatureModified:function(a){if(!this._updating){a=a.feature;var b=this.getByFeature(a);if(void 0!==b){b.beginEdit();var c=a.attributes;if(c)for(var d=this.recordType.prototype.fields,e=0,g=d.length;e<g;e++){var f=d.items[e],h=f.mapping||f.name;h in c&&b.set(f.name,f.convert(c[h]))}b.set("state",a.state);b.set("fid",a.fid);b.setFeature(a);this._updating=!0;b.endEdit();delete this._updating}}},addFeaturesToLayer:function(a){var b,c,d;d=Array(c=a.length);
for(b=0;b<c;b++)d[b]=a[b].getFeature();0<d.length&&(this._adding=!0,this.layer.addFeatures(d),delete this._adding)},onLoad:function(a,b,c){c&&!0===c.add||(this._removing=!0,this.layer.removeFeatures(this.layer.features),delete this._removing,this.addFeaturesToLayer(b))},onClear:function(a){this._removing=!0;this.layer.removeFeatures(this.layer.features);delete this._removing},onAdd:function(a,b,c){this._adding||this.addFeaturesToLayer(b)},onRemove:function(a,b,c){this._removing||(a=b.getFeature(),
null!=this.layer.getFeatureById(a.id)&&(this._removing=!0,this.layer.removeFeatures([b.getFeature()]),delete this._removing))},onUpdate:function(a,b,c){if(!this._updating){var d=(new GeoExt.data.FeatureRecord).fields;a=b.getFeature();a.state!==OpenLayers.State.INSERT&&(a.state=OpenLayers.State.UPDATE);if(b.fields&&!1!==this.layer.events.triggerEvent("beforefeaturemodified",{feature:a})){var e=a.attributes;b.fields.each(function(a){var c=a.mapping||a.name;d.containsKey(c)||(e[c]=b.get(a.name))});this._updating=
!0;this.layer.events.triggerEvent("featuremodified",{feature:a});delete this._updating;null!=this.layer.getFeatureById(a.id)&&this.layer.drawFeature(a)}}},destroy:function(){this.unbind();GeoExt.data.FeatureStore.superclass.destroy.call(this)}}};GeoExt.data.FeatureStore=Ext.extend(Ext.data.Store,new GeoExt.data.FeatureStoreMixin);GeoExt.data.FeatureStore.LAYER_TO_STORE=1;GeoExt.data.FeatureStore.STORE_TO_LAYER=2;Ext.namespace("GeoExt.grid");
GeoExt.grid.FeatureSelectionModelMixin=function(){return{autoActivateControl:!0,layerFromStore:!0,selectControl:null,bound:!1,superclass:null,selectedFeatures:[],autoPanMapOnSelection:!1,constructor:function(a){a=a||{};if(a.selectControl instanceof OpenLayers.Control.SelectFeature){if(!a.singleSelect){var b=a.selectControl;a.singleSelect=!(b.multiple||b.multipleKey)}}else a.layer instanceof OpenLayers.Layer.Vector&&(this.selectControl=this.createSelectControl(a.layer,a.selectControl),delete a.layer,
delete a.selectControl);a.autoPanMapOnSelection&&(this.autoPanMapOnSelection=!0,delete a.autoPanMapOnSelection);this.superclass=arguments.callee.superclass;this.superclass.constructor.call(this,a)},initEvents:function(){this.superclass.initEvents.call(this);if(this.layerFromStore){var a=this.grid.getStore()&&this.grid.getStore().layer;!a||this.selectControl instanceof OpenLayers.Control.SelectFeature||(this.selectControl=this.createSelectControl(a,this.selectControl))}this.selectControl&&this.bind(this.selectControl)},
createSelectControl:function(a,b){b=b||{};b=OpenLayers.Util.extend({toggle:!0,multipleKey:(void 0!==b.singleSelect?b.singleSelect:this.singleSelect)?null:Ext.isMac?"metaKey":"ctrlKey"},b);var c=new OpenLayers.Control.SelectFeature(a,b);a.map.addControl(c);return c},bind:function(a,b){if(!this.bound){b=b||{};this.selectControl=a;a instanceof OpenLayers.Layer.Vector&&(this.selectControl=this.createSelectControl(a,b.controlConfig));this.autoActivateControl&&this.selectControl.activate();for(var c=this.getLayers(),
d=0,e=c.length;d<e;d++)c[d].events.on({featureselected:this.featureSelected,featureunselected:this.featureUnselected,scope:this});this.on("rowselect",this.rowSelected,this);this.on("rowdeselect",this.rowDeselected,this);this.bound=!0}return this.selectControl},unbind:function(){var a=this.selectControl;if(this.bound){for(var b=this.getLayers(),c=0,d=b.length;c<d;c++)b[c].events.un({featureselected:this.featureSelected,featureunselected:this.featureUnselected,scope:this});this.un("rowselect",this.rowSelected,
this);this.un("rowdeselect",this.rowDeselected,this);this.autoActivateControl&&a.deactivate();this.selectControl=null;this.bound=!1}return a},featureSelected:function(a){if(!this._selecting){var b=this.grid.store.findBy(function(b,d){return b.getFeature()==a.feature});-1==b||this.isSelected(b)||(this._selecting=!0,this.selectRow(b,!this.singleSelect),this._selecting=!1,this.grid.getView().focusRow(b))}},featureUnselected:function(a){if(!this._selecting){var b=this.grid.store.findBy(function(b,d){return b.getFeature()==
a.feature});-1!=b&&this.isSelected(b)&&(this._selecting=!0,this.deselectRow(b),this._selecting=!1,this.grid.getView().focusRow(b))}},rowSelected:function(a,b,c){a=c.getFeature();if(!this._selecting&&a){b=this.getLayers();c=0;for(var d=b.length;c<d;c++)if(-1==b[c].selectedFeatures.indexOf(a)){this._selecting=!0;this.selectControl.select(a);this._selecting=!1;this.selectedFeatures.push(a);break}this.autoPanMapOnSelection&&this.recenterToSelectionExtent()}},rowDeselected:function(a,b,c){a=c.getFeature();
if(!this._selecting&&a){b=this.getLayers();c=0;for(var d=b.length;c<d;c++)if(-1!=b[c].selectedFeatures.indexOf(a)){this._selecting=!0;this.selectControl.unselect(a);this._selecting=!1;OpenLayers.Util.removeItem(this.selectedFeatures,a);break}this.autoPanMapOnSelection&&0<this.selectedFeatures.length&&this.recenterToSelectionExtent()}},getLayers:function(){return this.selectControl.layers||[this.selectControl.layer]},recenterToSelectionExtent:function(){var a=this.selectControl.map,b=this.getSelectionExtent();
a.getZoomForExtent(b,!1)>a.getZoom()?a.setCenter(b.getCenterLonLat()):a.zoomToExtent(b)},getSelectionExtent:function(){var a=null,b=this.selectedFeatures;if(b&&0<b.length)for(var c=null,d=0,e=b.length;d<e;d++)if(c=b[d].geometry)null===a&&(a=new OpenLayers.Bounds),a.extend(c.getBounds());return a}}};GeoExt.grid.FeatureSelectionModel=Ext.extend(Ext.grid.RowSelectionModel,new GeoExt.grid.FeatureSelectionModelMixin);Ext.namespace("GeoExt","GeoExt.data");
GeoExt.data.ProtocolProxy=function(a){Ext.apply(this,a);GeoExt.data.ProtocolProxy.superclass.constructor.apply(this,arguments)};
Ext.extend(GeoExt.data.ProtocolProxy,Ext.data.DataProxy,{protocol:null,abortPrevious:!0,setParamsAsOptions:!1,response:null,load:function(a,b,c,d,e){!1!==this.fireEvent("beforeload",this,a)?(b=OpenLayers.Function.bind(this.loadResponse,this,{params:a||{},request:{callback:c,scope:d,arg:e},reader:b}),this.abortPrevious&&this.abortRequest(),a={params:a,callback:b,scope:this},Ext.applyIf(a,e),!0===this.setParamsAsOptions&&(Ext.applyIf(a,a.params),delete a.params),this.response=this.protocol.read(a)):
c.call(d||this,null,e,!1)},abortRequest:function(){this.response&&(this.protocol.abort(this.response),this.response=null)},loadResponse:function(a,b){if(b.success()){var c=a.reader.read(b);this.fireEvent("load",this,a,a.request.arg);a.request.callback.call(a.request.scope,c,a.request.arg,!0)}else this.fireEvent("loadexception",this,a,b),a.request.callback.call(a.request.scope,null,a.request.arg,!1)}});Ext.namespace("GeoExt");
GeoExt.LegendPanel=Ext.extend(Ext.Panel,{dynamic:!0,layerStore:null,preferredTypes:null,filter:function(a){return!0},onRender:function(){GeoExt.LegendPanel.superclass.onRender.apply(this,arguments);this.layerStore||(this.layerStore=GeoExt.MapPanel.guess().layers);this.layerStore.each(function(a){this.addLegend(a)},this);if(this.dynamic)this.layerStore.on({add:this.onStoreAdd,remove:this.onStoreRemove,clear:this.onStoreClear,scope:this})},recordIndexToPanelIndex:function(a){for(var b=this.layerStore,
c=b.getCount(),d=-1,e=this.items?this.items.length:0,g,f=c-1;0<=f&&!(g=b.getAt(f),c=g.getLayer(),g=GeoExt.LayerLegend.getTypes(g),c.displayInLayerSwitcher&&0<g.length&&!0!==b.getAt(f).get("hideInLegend")&&(++d,a===f||d>e-1));--f);return d},getIdForLayer:function(a){return this.id+"-"+a.id},onStoreAdd:function(a,b,c){a=this.recordIndexToPanelIndex(c+b.length-1);c=0;for(var d=b.length;c<d;c++)this.addLegend(b[c],a);this.doLayout()},onStoreRemove:function(a,b,c){this.removeLegend(b)},removeLegend:function(a){this.items&&
(a=this.getComponent(this.getIdForLayer(a.getLayer())))&&(this.remove(a,!0),this.doLayout())},onStoreClear:function(a){this.removeAllLegends()},removeAllLegends:function(){this.removeAll(!0);this.doLayout()},addLegend:function(a,b){if(!0===this.filter(a)){var c=a.getLayer();b=b||0;var d=GeoExt.LayerLegend.getTypes(a,this.preferredTypes);c.displayInLayerSwitcher&&!a.get("hideInLegend")&&0<d.length&&this.insert(b,{xtype:d[0],id:this.getIdForLayer(c),layerRecord:a,hidden:!(!c.map&&c.visibility||c.getVisibility()&&
c.calculateInRange())})}},onDestroy:function(){this.layerStore&&(this.layerStore.un("add",this.onStoreAdd,this),this.layerStore.un("remove",this.onStoreRemove,this),this.layerStore.un("clear",this.onStoreClear,this));GeoExt.LegendPanel.superclass.onDestroy.apply(this,arguments)}});Ext.reg("gx_legendpanel",GeoExt.LegendPanel);Ext.namespace("GeoExt.tree");
GeoExt.tree.TreeNodeUIEventMixin=function(){return{constructor:function(a){a.addEvents("rendernode","rawclicknode");this.superclass=arguments.callee.superclass;this.superclass.constructor.apply(this,arguments)},render:function(a){this.rendered||(this.superclass.render.apply(this,arguments),this.fireEvent("rendernode",this.node))},onClick:function(a){!1!==this.fireEvent("rawclicknode",this.node,a)&&this.superclass.onClick.apply(this,arguments)}}};Ext.namespace("GeoExt.data");
GeoExt.data.WMSCapabilitiesStore=function(a){a=a||{};GeoExt.data.WMSCapabilitiesStore.superclass.constructor.call(this,Ext.apply(a,{proxy:a.proxy||(a.data?void 0:new Ext.data.HttpProxy({url:a.url,disableCaching:!1,method:"GET"})),reader:new GeoExt.data.WMSCapabilitiesReader(a,a.fields)}))};Ext.extend(GeoExt.data.WMSCapabilitiesStore,Ext.data.Store);Ext.namespace("GeoExt");
GeoExt.LayerOpacitySliderTip=Ext.extend(GeoExt.SliderTip,{template:"<div>{opacity}%</div>",compiledTemplate:null,init:function(a){this.compiledTemplate=new Ext.Template(this.template);GeoExt.LayerOpacitySliderTip.superclass.init.call(this,a)},getText:function(a){return this.compiledTemplate.apply({opacity:a.value})}});Ext.namespace("gxp");
gxp.NewSourceDialog=Ext.extend(Ext.Panel,{title:"Add New Server...",cancelText:"Cancel",addServerText:"Add Server",invalidURLText:"Enter a valid URL to a WMS endpoint (e.g. http://example.com/geoserver/wms)",contactingServerText:"Contacting Server...",bodyStyle:"padding: 0px",error:null,initComponent:function(){this.addEvents("urlselected");this.urlTextField=new Ext.form.TextField({fieldLabel:"URL",allowBlank:!1,width:240,msgTarget:"under",validator:this.urlValidator.createDelegate(this)});this.form=
new Ext.form.FormPanel({items:[this.urlTextField],border:!1,labelWidth:30,bodyStyle:"padding: 5px",autoWidth:!0,autoHeight:!0});this.bbar=[new Ext.Button({text:this.cancelText,handler:this.hide,scope:this}),new Ext.Toolbar.Fill,new Ext.Button({text:this.addServerText,iconCls:"add",handler:function(){this.error=null;this.urlTextField.validate()&&this.fireEvent("urlselected",this,this.urlTextField.getValue())},scope:this})];this.items=this.form;gxp.NewSourceDialog.superclass.initComponent.call(this);
this.form.on("render",function(){this.loadMask=new Ext.LoadMask(this.form.getEl(),{msg:this.contactingServerText})},this);this.on({hide:this.reset,removed:this.reset,scope:this});this.on("urlselected",function(a,b){this.setLoading();this.addSource(b,this.hide,function(){this.setError(this.sourceLoadFailureMessage)},this)},this)},reset:function(){this.error=null;this.urlTextField.reset();this.loadMask.hide()},urlRegExp:/^(http(s)?:)?\/\/([\w%]+:[\w%]+@)?([^@\/:]+)(:\d+)?\//i,urlValidator:function(a){a=
this.urlRegExp.test(a)?!this.error||this.error:this.invalidURLText;this.error=null;return a},setLoading:function(){this.loadMask.show()},setError:function(a){this.loadMask.hide();this.error=a;this.urlTextField.validate()},addSource:function(a,b,c,d){}});Ext.reg("gxp_newsourcedialog",gxp.NewSourceDialog);Ext.namespace("gxp");
gxp.NewSourceWindow=Ext.extend(Ext.Window,{bodyStyle:"padding: 0px",hideBorders:!0,width:300,closeAction:"hide",error:null,initComponent:function(){window.setTimeout(function(){throw"gxp.NewSourceWindow is deprecated. Use gxp.NewSourceDialog instead.";},0);this.addEvents("server-added");gxp.NewSourceWindow.superclass.initComponent.apply(this,arguments);this.addEvents("server-added");var a=this.add(new gxp.NewSourceDialog(Ext.applyIf({addSource:this.addSource,header:!1,listeners:{urlselected:function(a,
c){this.fireEvent("server-added",c)}}},this.initialConfig)));this.setTitle(a.title);this.setLoading=a.setLoading.createDelegate(a);this.setError=a.setError.createDelegate(a);this.on("hide",a.onHide,a)},addSource:function(a,b,c,d){}});Ext.namespace("gxp");
gxp.util={_uniqueNames:{},getOGCExceptionText:function(a){var b;a&&a.exceptions?(b=[],Ext.each(a.exceptions,function(a){Ext.each(a.texts,function(a){b.push(a)})}),b=b.join("\n")):b="Unknown error (no exception report).";return b},dispatch:function(a,b,c){function d(){++f;f===g&&b.call(c,h)}function e(b){window.setTimeout(function(){a[b].apply(c,[d,h])})}b=b||Ext.emptyFn;c=c||this;for(var g=a.length,f=0,h={},k=0;k<g;++k)e(k)},uniqueName:function(a,b){b=b||" ";var c=new RegExp(b+"[0-9]*$"),d=a.replace(c,
""),c=c.exec(a),c=void 0!==this._uniqueNames[d]?this._uniqueNames[d]:c instanceof Array?Number(c[0]):void 0,e=d;void 0!==c&&(c++,e+=b+c);this._uniqueNames[d]=c||0;return e},getAbsoluteUrl:function(a){var b;Ext.isIE6||Ext.isIE7||Ext.isIE8?(b=document.createElement("<a href='"+a+"'/>"),b.style.display="none",document.body.appendChild(b),b.href=b.href,document.body.removeChild(b)):(b=document.createElement("a"),b.href=a);return b.href},md5:function(){function a(a){return String.fromCharCode(a&255)+String.fromCharCode(a>>>
8&255)+String.fromCharCode(a>>>16&255)+String.fromCharCode(a>>>24&255)}function b(a){for(;0>a;)a+=4294967296;for(;4294967295<a;)a-=4294967296;return a}var c=[0,3614090360,3905402710,606105819,3250441966,4118548399,1200080426,2821735955,4249261313,1770035416,2336552879,4294925233,2304563134,1804603682,4254626195,2792965006,1236535329,4129170786,3225465664,643717713,3921069994,3593408605,38016083,3634488961,3889429448,568446438,3275163606,4107603335,1163531501,2850285829,4243563512,1735328473,2368359562,
4294588738,2272392833,1839030562,4259657740,2763975236,1272893353,4139469664,3200236656,681279174,3936430074,3572445317,76029189,3654602809,3873151461,530742520,3299628645,4096336452,1126891415,2878612391,4237533241,1700485571,2399980690,4293915773,2240044497,1873313359,4264355552,2734768916,1309151649,4149444226,3174756917,718787259,3951481745],d=[[function(a,b,c){return a&b|~a&c},[[0,7,1],[1,12,2],[2,17,3],[3,22,4],[4,7,5],[5,12,6],[6,17,7],[7,22,8],[8,7,9],[9,12,10],[10,17,11],[11,22,12],[12,7,
13],[13,12,14],[14,17,15],[15,22,16]]],[function(a,b,c){return a&c|b&~c},[[1,5,17],[6,9,18],[11,14,19],[0,20,20],[5,5,21],[10,9,22],[15,14,23],[4,20,24],[9,5,25],[14,9,26],[3,14,27],[8,20,28],[13,5,29],[2,9,30],[7,14,31],[12,20,32]]],[function(a,b,c){return a^b^c},[[5,4,33],[8,11,34],[11,16,35],[14,23,36],[1,4,37],[4,11,38],[7,16,39],[10,23,40],[13,4,41],[0,11,42],[3,16,43],[6,23,44],[9,4,45],[12,11,46],[15,16,47],[2,23,48]]],[function(a,b,c){return b^(a|~c)},[[0,6,49],[7,10,50],[14,15,51],[5,21,
52],[12,6,53],[3,10,54],[10,15,55],[1,21,56],[8,6,57],[15,10,58],[6,15,59],[13,21,60],[4,6,61],[11,10,62],[2,15,63],[9,21,64]]]];return function(e){var g,f,h,k,l,m,n,r,p,t,v;g=[1732584193,4023233417,2562383102,271733878];f=e.length;h=f&63;k=56>h?56-h:120-h;if(0<k)for(e+="\u0080",h=0;h<k-1;h++)e+="\x00";e+=a(8*f);e+=a(0);f+=k+8;k=[0,1,2,3];l=[16];m=[4];for(t=0;t<f;t+=64){h=0;for(p=t;16>h;h++,p+=4)l[h]=e.charCodeAt(p)|e.charCodeAt(p+1)<<8|e.charCodeAt(p+2)<<16|e.charCodeAt(p+3)<<24;for(h=0;4>h;h++)m[h]=
g[h];for(h=0;4>h;h++)for(n=d[h][0],r=d[h][1],p=0;16>p;p++){v=l;var s=m,w=r[p],x=void 0,y=void 0,u=void 0,A=void 0,q=void 0,z=void 0,B=void 0,u=q=void 0,x=k[0],y=k[1],u=k[2],A=k[3],q=w[0],z=w[1],B=w[2],u=n(s[y],s[u],s[A]),q=s[x]+u+v[q]+c[B],q=b(q),q=q<<z|q>>>32-z,q=q+s[y];s[x]=b(q);v=k[0];k[0]=k[3];k[3]=k[2];k[2]=k[1];k[1]=v}for(h=0;4>h;h++)g[h]+=m[h],g[h]=b(g[h])}h=a(g[0])+a(g[1])+a(g[2])+a(g[3]);g="";for(e=0;16>e;e++)f=h.charCodeAt(e),g+="0123456789abcdef".charAt(f>>4&15),g+="0123456789abcdef".charAt(f&
15);return g}}()};Ext.namespace("gxp.plugins");
gxp.plugins.Tool=Ext.extend(Ext.util.Observable,{ptype:"gxp_tool",autoActivate:!0,actionTarget:"map.tbar",output:null,constructor:function(a){this.initialConfig=a||{};this.active=!1;Ext.apply(this,a);this.id||(this.id=Ext.id());this.output=[];this.addEvents("activate","deactivate");gxp.plugins.Tool.superclass.constructor.apply(this,arguments)},init:function(a){a.tools[this.id]=this;this.target=a;this.autoActivate&&this.activate();this.target.on("portalready",this.addActions,this)},activate:function(){if(!1===
this.active)return this.active=!0,this.fireEvent("activate",this),!0},deactivate:function(){if(!0===this.active)return this.active=!1,this.fireEvent("deactivate",this),!0},addActions:function(a){if((a=a||this.actions)&&null!==this.actionTarget){var b=this.actionTarget instanceof Array?this.actionTarget:[this.actionTarget];a=a instanceof Array?a:[a];var c,d,e,g,f,h=null;for(d=b.length-1;0<=d;--d){if(c=b[d]){c instanceof Object&&(h=c.index,c=c.target);c=c.split(".");if(e=c[0])if("map"==e)f=this.target.mapPanel;
else{if(f=Ext.getCmp(e)||this.target.portal[e],!f)throw Error("Can't find component with id: "+e);}else f=this.target.portal;if(c=1<c.length&&c[1])f=(e={tbar:"getTopToolbar",bbar:"getBottomToolbar",fbar:"getFooterToolbar"}[c])?f[e]():f[c]}e=0;for(g=a.length;e<g;++e)if(a[e]instanceof Ext.Action||a[e]instanceof Ext.Component||"string"==typeof a[e]||(e==this.defaultAction&&(a[e].pressed=!0),a[e]=new Ext.Action(a[e])),c=a[e],e==this.defaultAction&&c instanceof GeoExt.Action&&(c.isDisabled()?c.activateOnEnable=
!0:c.control.activate()),f){f instanceof Ext.menu.Menu?c=Ext.apply(new Ext.menu.CheckItem(c),{text:c.initialConfig.menuText,group:c.initialConfig.toggleGroup,groupClass:null}):f instanceof Ext.Toolbar||(c=new Ext.Button(c));var k=null===h?f.add(c):f.insert(h,c);c=c instanceof Ext.Button?c:k;null!==h&&(h+=1);if(null!=this.outputAction&&e==this.outputAction){var l;c.on("click",function(){l?this.outputTarget?l.show():l.ownerCt.ownerCt.show():l=this.addOutput()},this)}}f&&(f.isVisible()?f.doLayout():
f instanceof Ext.menu.Menu||f.show())}return this.actions=a}this.addOutput()},addOutput:function(a){if(a||this.outputConfig){a=a||{};var b=this.outputTarget;b?(b="map"===b?this.target.mapPanel:Ext.getCmp(b)||this.target.portal[b],a instanceof Ext.Component||Ext.apply(a,this.outputConfig)):(b=this.outputConfig||{},b=(new Ext.Window(Ext.apply({hideBorders:!0,shadow:!1,closeAction:"hide",autoHeight:!b.height,layout:b.height?"fit":void 0,items:[{defaults:Ext.applyIf({autoHeight:!b.height&&!(b.defaults&&
b.defaults.height)},b.defaults)}]},b))).show().items.get(0));if(b)return a=b.add(a),a.on("removed",function(a){this.output.remove(a)},this,{single:!0}),a instanceof Ext.Window?a.show():b.doLayout(),this.output.push(a),a;a=this.ptype;window.console&&console.error("Failed to create output for plugin with ptype: "+a)}},removeOutput:function(){for(var a,b=this.output.length-1;0<=b;--b)if(a=this.output[b],this.outputTarget)if(a.ownerCt){if(a.ownerCt.remove(a),a.ownerCt instanceof Ext.Window)a.ownerCt[a.ownerCt.closeAction]()}else a.remove();
else a.findParentBy(function(a){return a instanceof Ext.Window}).close();this.output=[]},getState:function(){return Ext.apply({},this.initialConfig)}});Ext.preg(gxp.plugins.Tool.prototype.ptype,gxp.plugins.Tool);Ext.namespace("gxp.plugins");
gxp.plugins.RemoveLayer=Ext.extend(gxp.plugins.Tool,{ptype:"gxp_removelayer",removeMenuText:"Remove layer",removeActionTip:"Remove layer",addActions:function(){var a,b=gxp.plugins.RemoveLayer.superclass.addActions.apply(this,[{menuText:this.removeMenuText,iconCls:"gxp-icon-removelayers",disabled:!0,tooltip:this.removeActionTip,handler:function(){var b=a;b&&this.target.mapPanel.layers.remove(b)},scope:this}]),c=b[0];this.target.on("layerselectionchange",function(b){a=b;c.setDisabled(1>=this.target.mapPanel.layers.getCount()||
!b)},this);var d=function(b){c.setDisabled(!a||1>=b.getCount())};this.target.mapPanel.layers.on({add:d,remove:d});return b}});Ext.preg(gxp.plugins.RemoveLayer.prototype.ptype,gxp.plugins.RemoveLayer);
Ext.grid.RowExpander=function(a){Ext.apply(this,a);this.addEvents({beforeexpand:!0,expand:!0,beforecollapse:!0,collapse:!0});Ext.grid.RowExpander.superclass.constructor.call(this);this.tpl&&("string"==typeof this.tpl&&(this.tpl=new Ext.Template(this.tpl)),this.tpl.compile());this.state={};this.bodyContent={}};
Ext.extend(Ext.grid.RowExpander,Ext.util.Observable,{header:"",width:20,sortable:!1,fixed:!0,menuDisabled:!0,dataIndex:"",id:"expander",lazyRender:!0,enableCaching:!0,getRowClass:function(a,b,c,d){c.cols-=1;(d=this.bodyContent[a.id])||this.lazyRender||(d=this.getBodyContent(a,b));d&&(c.body=d);return this.state[a.id]?"x-grid3-row-expanded":"x-grid3-row-collapsed"},init:function(a){this.grid=a;var b=a.getView();b.getRowClass=this.getRowClass.createDelegate(this);b.enableRowBody=!0;a.on("render",function(){b.mainBody.on("mousedown",
this.onMouseDown,this)},this)},getBodyContent:function(a,b){if(!this.enableCaching)return this.tpl.apply(a.data);var c=this.bodyContent[a.id];c||(c=this.tpl.apply(a.data),this.bodyContent[a.id]=c);return c},onMouseDown:function(a,b){if("x-grid3-row-expander"==b.className){a.stopEvent();var c=a.getTarget(".x-grid3-row");this.toggleRow(c)}},renderer:function(a,b,c){b.cellAttr='rowspan="2"';return'<div class="x-grid3-row-expander">&#160;</div>'},beforeExpand:function(a,b,c){return!1!==this.fireEvent("beforeexpand",
this,a,b,c)?(this.tpl&&this.lazyRender&&(b.innerHTML=this.getBodyContent(a,c)),!0):!1},toggleRow:function(a){"number"==typeof a&&(a=this.grid.view.getRow(a));this[Ext.fly(a).hasClass("x-grid3-row-collapsed")?"expandRow":"collapseRow"](a)},expandRow:function(a){"number"==typeof a&&(a=this.grid.view.getRow(a));var b=this.grid.store.getAt(a.rowIndex),c=Ext.DomQuery.selectNode("tr:nth(2) div.x-grid3-row-body",a);this.beforeExpand(b,c,a.rowIndex)&&(this.state[b.id]=!0,Ext.fly(a).replaceClass("x-grid3-row-collapsed",
"x-grid3-row-expanded"),this.fireEvent("expand",this,b,c,a.rowIndex))},collapseRow:function(a){"number"==typeof a&&(a=this.grid.view.getRow(a));var b=this.grid.store.getAt(a.rowIndex),c=Ext.fly(a).child("tr:nth(1) div.x-grid3-row-body",!0);!1!==this.fireEvent("beforecollapse",this,b,c,a.rowIndex)&&(this.state[b.id]=!1,Ext.fly(a).replaceClass("x-grid3-row-expanded","x-grid3-row-collapsed"),this.fireEvent("collapse",this,b,c,a.rowIndex))}});Ext.namespace("gxp.plugins");
gxp.plugins.LayerSource=Ext.extend(Ext.util.Observable,{store:null,lazy:!1,title:"",constructor:function(a){this.initialConfig=a;Ext.apply(this,a);this.addEvents("ready","failure");gxp.plugins.LayerSource.superclass.constructor.apply(this,arguments)},init:function(a){this.target=a;this.createStore()},getMapProjection:function(){var a=this.target.mapPanel.map.projection;return this.target.mapPanel.map.getProjectionObject()||a&&new OpenLayers.Projection(a)||new OpenLayers.Projection("EPSG:4326")},getProjection:function(a){a=
a.getLayer();var b=this.getMapProjection();return(a.projection?a.projection instanceof OpenLayers.Projection?a.projection:new OpenLayers.Projection(a.projection):b).equals(b)?b:null},createStore:function(){this.fireEvent("ready",this)},createLayerRecord:function(a){},getConfigForRecord:function(a){var b=a.getLayer();return{source:a.get("source"),name:a.get("name"),title:a.get("title"),visibility:b.getVisibility(),opacity:b.opacity||void 0,group:a.get("group"),fixed:a.get("fixed"),selected:a.get("selected")}},
getState:function(){return Ext.apply({},this.initialConfig)}});(function(){function a(a){var c=this.meta.format;if("string"===typeof a||a.nodeType){a=c.read(a);var d=c.read;c.read=function(){c.read=d;return a}}this.raw=a}Ext.intercept(GeoExt.data.WMSCapabilitiesReader.prototype,"readRecords",a);GeoExt.data.AttributeReader&&Ext.intercept(GeoExt.data.AttributeReader.prototype,"readRecords",a)})();Ext.namespace("gxp.plugins");
gxp.plugins.WMSSource=Ext.extend(gxp.plugins.LayerSource,{ptype:"gxp_wmssource",baseParams:null,format:null,describeLayerStore:null,describedLayers:null,schemaCache:null,ready:!1,requiredProperties:["title","bbox"],constructor:function(a){a&&!0===a.forceLazy&&(a.requiredProperties=[],delete a.forceLazy,window.console&&console.warn("Deprecated config option 'forceLazy: true' for layer source '"+a.id+"'. Use 'requiredProperties: []' instead."));gxp.plugins.WMSSource.superclass.constructor.apply(this,
arguments);this.format||(this.format=new OpenLayers.Format.WMSCapabilities({keepData:!0}))},init:function(a){gxp.plugins.WMSSource.superclass.init.apply(this,arguments);this.target.on("authorizationchange",this.onAuthorizationChange,this)},onAuthorizationChange:function(){this.store&&"/"===this.store.url.charAt(0)&&this.store.reload()},destroy:function(){this.target.un("authorizationchange",this.onAuthorizationChange,this);gxp.plugins.WMSSource.superclass.destroy.apply(this,arguments)},isLazy:function(){var a=
!0,b=this.target.initialConfig.map;if(b&&b.layers)for(var c,d=0,e=b.layers.length;d<e&&(c=b.layers[d],c.source!==this.id||(a=this.layerConfigComplete(c),!1!==a));++d);return a},layerConfigComplete:function(a){var b=!0;if(!Ext.isObject(a.capability))for(var c=this.requiredProperties,d=c.length-1;0<=d&&(b=!!a[c[d]],!1!==b);--d);return b},createStore:function(){var a=this.baseParams||{SERVICE:"WMS",REQUEST:"GetCapabilities"};this.version&&(a.VERSION=this.version);var b=this.isLazy();this.store=new GeoExt.data.WMSCapabilitiesStore({url:this.trimUrl(this.url,
a),baseParams:a,format:this.format,autoLoad:!b,layerParams:{exceptions:null},listeners:{load:function(){this.store.reader.raw&&this.store.reader.raw.service?(this.title||(this.title=this.store.reader.raw.service.title),this.ready?this.lazy=!1:(this.ready=!0,this.fireEvent("ready",this))):this.fireEvent("failure",this,"Invalid capabilities document.");delete this.format.data},exception:function(a,b,e,g,f,h){delete this.store;a="";"response"===b?"string"==typeof h?b=h:(b="Invalid response from server.",
(a=this.format&&this.format.data)&&a.parseError&&(b+="  "+a.parseError.reason+" - line: "+a.parseError.line),f=f.status,a=200<=f&&300>f?gxp.util.getOGCExceptionText(h&&h.arg&&h.arg.exceptionReport):"Status: "+f):(b="Trouble creating layer store from response.",a="Unable to handle response.");this.fireEvent("failure",this,b,a);delete this.format.data},scope:this}});b&&(this.lazy=!0,Ext.Ajax.request({method:"GET",url:this.url,params:{SERVICE:"WMS"},callback:function(a,b,e){a=e.status;200<=a&&403>a&&
e.responseText?(this.ready=!0,this.fireEvent("ready",this)):this.fireEvent("failure",this,"Layer source not available.","Unable to contact WMS service.")},scope:this}))},trimUrl:function(a,b,c){c=OpenLayers.Util.getParameters(a);b=OpenLayers.Util.upperCaseObject(b);var d=0,e;for(e in c)++d,e.toUpperCase()in b&&(--d,delete c[e]);return a.split("?").shift()+(d?"?"+OpenLayers.Util.getParameterString(c):"")},createLazyLayerRecord:function(a){a=Ext.apply({},a);var b=a.srs||this.target.map.projection;a.srs=
{};a.srs[b]=!0;var c=a.bbox||this.target.map.maxExtent;a.bbox={};a.bbox[b]={bbox:c};c=this.store&&this.store instanceof GeoExt.data.WMSCapabilitiesStore?new this.store.recordType(a):new GeoExt.data.LayerRecord(a);c.setLayer(new OpenLayers.Layer.WMS(a.title||a.name,a.url||this.url,{layers:a.name,transparent:"transparent"in a?a.transparent:!0,format:a.format},{projection:b}));c.json=a;return c},createLayerRecord:function(a){var b,c,d=this.store.findExact("name",a.name);-1<d?c=this.store.getAt(d):Ext.isObject(a.capability)?
c=this.store.reader.readRecords({capability:{request:{getmap:{href:this.url}},layers:[a.capability]}}).records[0]:this.layerConfigComplete(a)&&(c=this.createLazyLayerRecord(a));if(c){b=c.getLayer().clone();var d=this.getMapProjection(),e=this.getProjection(c),g=(e||d).getCode(),f=c.get("bbox"),h;if(f&&f[g])b.addOptions({projection:e}),h=OpenLayers.Bounds.fromArray(f[g].bbox,b.reverseAxisOrder());else if(e=c.get("llbbox"))d=OpenLayers.Bounds.fromArray(e).transform("EPSG:4326",d),0<1/d.getHeight()&&
0<1/d.getWidth()&&(h=d);b.mergeNewParams({STYLES:a.styles,FORMAT:a.format,TRANSPARENT:a.transparent});d=!1;"tiled"in a?d=!a.tiled:c.data.dimensions&&c.data.dimensions.time&&(d=!0);b.setName(a.title||b.name);b.addOptions({attribution:b.attribution,maxExtent:h,restrictedExtent:h,singleTile:d,ratio:a.ratio||1,visibility:"visibility"in a?a.visibility:!0,opacity:"opacity"in a?a.opacity:1,buffer:"buffer"in a?a.buffer:1,dimensions:c.data.dimensions,transitionEffect:d?"resize":null});h=Ext.applyIf({title:b.name,
group:a.group,infoFormat:a.infoFormat,source:a.source,properties:"gxp_wmslayerpanel",fixed:a.fixed,selected:"selected"in a?a.selected:!1,restUrl:this.restUrl,layer:b},c.data);var k=[{name:"source",type:"string"},{name:"group",type:"string"},{name:"properties",type:"string"},{name:"fixed",type:"boolean"},{name:"selected",type:"boolean"},{name:"restUrl",type:"string"},{name:"infoFormat",type:"string"}];c.fields.each(function(a){k.push(a)});b=new (GeoExt.data.LayerRecord.create(k))(h,b.id);b.json=a}else window.console&&
0<this.store.getCount()&&console.warn("Could not create layer record for layer '"+a.name+"'. Check if the layer is found in the WMS GetCapabilities response.");return b},getProjection:function(a){var b=this.getMapProjection(),c=b;a=a.get("srs");if(!a[b.getCode()]){var c=null,d;for(d in a)if((a=new OpenLayers.Projection(d)).equals(b)){c=a;break}}return c},initDescribeLayerStore:function(){var a=this.store.reader.raw;this.lazy&&(a={capability:{request:{describelayer:{href:this.url}}},version:this.version||
"1.1.1"});var b=a.capability.request.describelayer;b&&(a=a.version,1.1<parseFloat(a)&&(a="1.1.1"),a={SERVICE:"WMS",VERSION:a,REQUEST:"DescribeLayer"},this.describeLayerStore=new GeoExt.data.WMSDescribeLayerStore({url:this.trimUrl(b.href,a),baseParams:a}))},describeLayer:function(a,b,c){function d(a){window.setTimeout(function(){b.call(c,a)},0)}this.describeLayerStore||this.initDescribeLayerStore();if(this.describeLayerStore){this.describedLayers||(this.describedLayers={});var e=a.getLayer().params.LAYERS;
a=function(){for(var a=Ext.isArray(arguments[1])?arguments[1]:arguments[0],d,f,m=a.length-1;0<=m;m--){d=a[m];f=d.get("layerName");if(f==e){this.describeLayerStore.un("load",arguments.callee,this);this.describedLayers[f]=!0;b.call(c,d);return}"function"==typeof this.describedLayers[f]&&(d=this.describedLayers[f],this.describeLayerStore.un("load",d,this),d.apply(this,arguments))}delete g[e];b.call(c,!1)};var g=this.describedLayers,f;if(g[e])if(-1==(f=this.describeLayerStore.findExact("layerName",e)))this.describeLayerStore.on("load",
a,this);else d(this.describeLayerStore.getAt(f));else g[e]=a,this.describeLayerStore.load({params:{LAYERS:e},add:!0,callback:a,scope:this})}else d(!1)},fetchSchema:function(a,b,c,d){var e=this.schemaCache[b];if(e)if(0==e.getCount())e.on("load",function(){c.call(d,e)},this,{single:!0});else c.call(d,e);else e=new GeoExt.data.AttributeStore({url:a,baseParams:{SERVICE:"WFS",VERSION:"1.1.0",REQUEST:"DescribeFeatureType",TYPENAME:b},autoLoad:!0,listeners:{load:function(){c.call(d,e)},scope:this}}),this.schemaCache[b]=
e},getSchema:function(a,b,c){this.schemaCache||(this.schemaCache={});this.describeLayer(a,function(d){if(d&&"WFS"==d.get("owsType")){var e=d.get("typeName");d=d.get("owsURL");this.fetchSchema(d,e,b,c)}else d?b.call(c,!1):this.fetchSchema(this.url,a.get("name"),b,c)},this)},getWFSProtocol:function(a,b,c){this.getSchema(a,function(d){var e=!1;if(d){var g,f=/gml:((Multi)?(Point|Line|Polygon|Curve|Surface|Geometry)).*/;d.each(function(a){f.exec(a.get("type"))&&(g=a.get("name"))},this);e=new OpenLayers.Protocol.WFS({version:"1.1.0",
srsName:a.getLayer().projection.getCode(),url:d.url,featureType:d.reader.raw.featureTypes[0].typeName,featureNS:d.reader.raw.targetNamespace,geometryName:g})}b.call(c,e,d,a)},this)},getConfigForRecord:function(a){var b=Ext.applyIf(gxp.plugins.WMSSource.superclass.getConfigForRecord.apply(this,arguments),a.json),c=a.getLayer(),d=c.params,e=b.name,g=this.store.reader.raw;if(g)for(var g=g.capability.layers,f=g.length-1;0<=f;--f)if(g[f].name===e){b.capability=Ext.apply({},g[f]);e={};e[c.projection.getCode()]=
!0;b.capability.srs=e;break}b.capability||(c.maxExtent&&(b.bbox=c.maxExtent.toArray()),b.srs=c.projection.getCode());return Ext.apply(b,{format:d.FORMAT,styles:d.STYLES,transparent:d.TRANSPARENT})},getState:function(){var a=gxp.plugins.WMSSource.superclass.getState.apply(this,arguments);return Ext.applyIf(a,{title:this.title})}});Ext.preg(gxp.plugins.WMSSource.prototype.ptype,gxp.plugins.WMSSource);Ext.namespace("gxp.plugins");
gxp.plugins.AddLayers=Ext.extend(gxp.plugins.Tool,{ptype:"gxp_addlayers",addActionMenuText:"Add layers",findActionMenuText:"Find layers",addActionTip:"Add layers",addServerText:"Add a New Server",addButtonText:"Add layers",untitledText:"Untitled",addLayerSourceErrorText:"Error getting WMS capabilities ({msg}).\nPlease check the url and try again.",availableLayersText:"Available Layers",expanderTemplateText:"<p><b>Abstract:</b> {abstract}</p>",panelTitleText:"Title",layerSelectionText:"View available data from:",
doneText:"Done",uploadText:"Upload Data",relativeUploadOnly:!0,startSourceId:null,selectedSource:null,constructor:function(a){this.addEvents("sourceselected");gxp.plugins.AddLayers.superclass.constructor.apply(this,arguments)},addActions:function(){var a={tooltip:this.addActionTip,text:this.addActionText,menuText:this.addActionMenuText,disabled:!0,iconCls:"gxp-icon-addlayers"},a=this.initialConfig.search?Ext.apply(a,{menu:new Ext.menu.Menu({items:[new Ext.menu.Item({iconCls:"gxp-icon-addlayers",text:this.addActionMenuText,
handler:this.showCapabilitiesGrid,scope:this}),new Ext.menu.Item({iconCls:"gxp-icon-addlayers",text:this.findActionMenuText,handler:this.showCatalogueSearch,scope:this})]})}):Ext.apply(a,{handler:this.showCapabilitiesGrid,scope:this}),b=gxp.plugins.AddLayers.superclass.addActions.apply(this,[a]);this.target.on("ready",function(){b[0].enable()});return b},showCatalogueSearch:function(){var a=this.initialConfig.search.selectedSource,b={},c;for(c in this.target.layerSources){var d=this.target.layerSources[c];
if(d instanceof gxp.plugins.CatalogueSource){var e={};e[c]=d;Ext.apply(b,e)}}a=gxp.plugins.AddLayers.superclass.addOutput.apply(this,[{sources:b,selectedSource:a,xtype:"gxp_cataloguesearchpanel",map:this.target.mapPanel.map,listeners:{addlayer:function(a,b,c){a=this.target.layerSources[b].createLayerRecord(c);this.target.mapPanel.layers.add(a)},scope:this}}]);(b=a.findParentByType("window"))&&b.center();return a},showCapabilitiesGrid:function(){this.capGrid||this.initCapGrid();this.capGrid.show()},
initCapGrid:function(){function a(){for(var a=k.getValue(),b=this.target.mapPanel.layers,c=this.target.layerSources[a],d=h.getSelectionModel().getSelections(),e,f=0,g=d.length;f<g;++f)(e=c.createLayerRecord({name:d[f].get("name"),source:a}))&&("background"===e.get("group")?b.insert(0,[e]):b.add([e]))}var b,c=[],d=this.target,e;for(e in d.layerSources)b=d.layerSources[e],b.store&&"gxp_cataloguesource"!==b.ptype&&c.push([e,b.title||e,b.url]);var g=new Ext.data.ArrayStore({fields:["id","title","url"],
data:c}),d=this.createExpander(),f=0;null!==this.startSourceId&&g.each(function(a){a.get("id")===this.startSourceId&&(f=g.indexOf(a))},this);b=this.target.layerSources[c[f][0]];var h=new Ext.grid.GridPanel({store:b.store,autoScroll:!0,flex:1,autoExpandColumn:"title",plugins:[d],loadMask:!0,colModel:new Ext.grid.ColumnModel([d,{id:"title",header:this.panelTitleText,dataIndex:"title",sortable:!0},{header:"Id",dataIndex:"name",width:150,sortable:!0}]),listeners:{rowdblclick:a,scope:this}}),k=new Ext.form.ComboBox({ref:"../sourceComboBox",
store:g,valueField:"id",displayField:"title",tpl:'<tpl for="."><div ext:qtip="{url}" class="x-combo-list-item">{title}</div></tpl>',triggerAction:"all",editable:!1,allowBlank:!1,forceSelection:!0,mode:"local",value:c[f][0],listeners:{select:function(a,b,c){a=this.target.layerSources[b.get("id")];h.reconfigure(a.store,h.getColumnModel());h.getView().focusRow(0);this.setSelectedSource(a)},scope:this}});b=null;if(this.target.proxy||1<c.length)b=[new Ext.Toolbar.TextItem({text:this.layerSelectionText}),
k];this.target.proxy&&b.push("-",new Ext.Button({text:this.addServerText,iconCls:"gxp-icon-addserver",handler:function(){this.outputTarget?this.addOutput(l):(new Ext.Window({title:gxp.NewSourceDialog.prototype.title,modal:!0,hideBorders:!0,width:300,items:l})).show()},scope:this}));var l={xtype:"gxp_newsourcedialog",header:!1,listeners:{hide:function(a){this.outputTarget||a.ownerCt.hide()},urlselected:function(a,b){a.setLoading();this.target.addLayerSource({config:{url:b},callback:function(b){b=new g.recordType({id:b,
title:this.target.layerSources[b].title||this.untitledText});g.insert(0,[b]);k.onSelect(b,0);a.hide()},fallback:function(a,b){this.setError((new Ext.Template(this.addLayerSourceErrorText)).apply({msg:b}))},scope:this})},scope:this}},d={xtype:"container",region:"center",layout:"vbox",items:[h]};this.instructionsText&&d.items.push({xtype:"box",autoHeight:!0,autoEl:{tag:"p",cls:"x-form-item",style:"padding-left: 5px; padding-right: 5px"},html:this.instructionsText});e=["->",new Ext.Button({text:this.addButtonText,
iconCls:"gxp-icon-addlayers",handler:a,scope:this}),new Ext.Button({text:this.doneText,handler:function(){this.capGrid.hide()},scope:this})];var m=this.createUploadButton();m&&e.unshift(m);m=this.outputTarget?Ext.Panel:Ext.Window;this.capGrid=new m(Ext.apply({title:this.availableLayersText,closeAction:"hide",layout:"border",height:300,width:450,modal:!0,items:d,tbar:b,bbar:e,listeners:{hide:function(a){h.getSelectionModel().clearSelections()},show:function(a){null===this.selectedSource?this.setSelectedSource(this.target.layerSources[c[f][0]]):
this.setSelectedSource(this.selectedSource)},scope:this}},this.initialConfig.outputConfig));m===Ext.Panel&&this.addOutput(this.capGrid)},setSelectedSource:function(a,b){this.selectedSource=a;this.fireEvent("sourceselected",this,a);a.lazy&&a.store.load({callback:function(){var a=this.capGrid.sourceComboBox,b=a.store,e=a.valueField,g=b.findExact(e,a.getValue()),g=b.getAt(g),f=this.target.layerSources[g.get("id")];f?f.title!==g.get("title")&&(g.set("title",f.title),a.setValue(g.get(e))):b.remove(g)}.createDelegate(this)})},
createUploadButton:function(){var a,b=this.initialConfig.upload,c;if(b){"boolean"===typeof b&&(b={});a=new Ext.Button({xtype:"button",text:this.uploadText,iconCls:"gxp-icon-filebrowse",hidden:!0,handler:function(){var a=new gxp.LayerUploadPanel(Ext.apply({title:this.outputTarget?this.uploadText:void 0,url:c,width:350,border:!1,bodyStyle:"padding: 10px 10px 0 10px;",frame:!0,labelWidth:65,autoScroll:!0,defaults:{anchor:"95%",allowBlank:!1,msgTarget:"side"},listeners:{uploadcomplete:function(a,b){for(var c=
b.layers,e={},g=0,r=c.length;g<r;++g)e[c[g].name]=!0;this.selectedSource.store.load({callback:function(a,b,c){var d=this.capGrid.get(0).get(0);a=d.getSelectionModel();a.clearSelections();var f=[],g=0;this.selectedSource.store.each(function(a,b){a.get("name")in e&&(g=b,f.push(a))});a.selectRecords(f);window.setTimeout(function(){d.getView().focusRow(g)},100)},scope:this});this.outputTarget?a.hide():d.close()},scope:this}},b)),d;this.outputTarget?this.addOutput(a):(d=new Ext.Window({title:this.uploadText,
modal:!0,resizable:!1,items:[a]}),d.show())},scope:this});var d={},e=function(a,b,c){a in d?window.setTimeout(function(){b.call(c,d[a])},0):Ext.Ajax.request({url:a,disableCaching:!1,callback:function(e,l,m){e=m.status;d[a]=e;b.call(c,e)}})};this.on({sourceselected:function(b,d){a.hide();if(this.isEligibleForUpload(d)){var h=d.url.split("/");h.pop();h.push("rest");c=h.join("/");this.target.isAuthorized()&&e(c+"/upload",function(b){a.setVisible(405===b)},this)}},scope:this})}return a},isEligibleForUpload:function(a){return a.url&&
(this.relativeUploadOnly?"/"===a.url.charAt(0):!0)&&-1===(this.nonUploadSources||[]).indexOf(a.id)},createExpander:function(){return new Ext.grid.RowExpander({tpl:new Ext.Template(this.expanderTemplateText)})}});Ext.preg(gxp.plugins.AddLayers.prototype.ptype,gxp.plugins.AddLayers);
