Locale.addScript("ideol/ide-extensions/ExtAdmin/lib/Locale/lang-"+Locale.getLang()+".js");Config.ExtAdmin={ADMIN_URL:'http://atlas.iver.es/IDEAdmin'};Ext.namespace("ExtAdmin");Locale.appendLocale(Locale.ExtAdmin[Locale.getLang()]);ExtAdmin=OpenLayers.Class(IDEOL.Extension,{adminPanel:null,initialize:function(){},onCreate:function(){},onUpdate:function(){},onLogin:function(){this.ideol.layout.tabPanel.add({id:'adminFrame',title:Locale.getText("txt_administracion"),defaultSrc:Config.ExtAdmin.ADMIN_URL,iconCls:'adminIcon',listeners:{domready:function(frame){},documentloaded:function(frame){}}});this.ideol.layout.tabPanel.doLayout();},onLogout:function(){var frame=Ext.getCmp('adminFrame');this.ideol.layout.tabPanel.remove(frame);},CLASS_NAME:"ExtAdmin"});Locale.addScript("ideol/ide-extensions/ExtExport/lib/Locale/lang-"+Locale.getLang()+".js");Config.ExtExport={REPORT_NAME:'atlas',REPORT_DETAIL:false};Ext.namespace("ExtExport");Locale.appendLocale(Locale.ExtExport[Locale.getLang()]);ExtExport=OpenLayers.Class(IDEOL.Extension,{exportMenuButton:null,initialize:function(){this.exportMenuButton=new ExtExport.Button.ExportMenu();},onCreate:function(){this.exportMenuButton.setIDEOL(this.ideol);this.ideol.layout.toolBar.addItem(this.exportMenuButton);this.ideol.layout.toolBar.doLayout();},onUpdate:function(){this.exportMenuButton.setIDEOL(this.ideol);},CLASS_NAME:"ExtExport"});Locale.addScript("ideol/ide-extensions/ExtMoveToLonLat/lib/Locale/lang-"+Locale.getLang()+".js");Config.ExtMoveToLonLat={};Ext.namespace("ExtMoveToLonLat");Locale.appendLocale(Locale.ExtMoveToLonLat[Locale.getLang()]);ExtMoveToLonLat=OpenLayers.Class(IDEOL.Extension,{button:null,moveToLonLatWindow:null,initialize:function(){this.createComponents();},createComponents:function(){this.button=new ExtMoveToLonLat.Button.Launcher();this.button.on("click",function(){this.moveToLonLatWindow.show();},this);this.moveToLonLatWindow=new ExtMoveToLonLat.Window.Projection();},onCreate:function(){this.ideol.layout.toolBar.addItem(this.button);this.ideol.layout.toolBar.doLayout();},onUpdate:function(){},CLASS_NAME:"ExtMoveToLonLat"});Locale.addScript("ideol/ide-extensions/ExtMunicipios/lib/Locale/lang-"+Locale.getLang()+".js");Config.ExtMunicipios={WFSLAYER_NAME:'Municipios ',MUNICIPIO_FIELD_NAME:'nombre',MUNICIPIO_FIELD_IDPROVINCIA:'codprov',MUNICIPIO_FIELD_GEOM:'the_geom',PROVINCIAS:[['03','Alicante'],['12','Castellón'],['46','Valencia']]};Config.ExtMunicipios.WFSLayers={MUNICIPIOS:new IDEOL.Layer.WFS('Municipios','http://services.iver.es/geoserver/wfs',{editable:false,projection:new OpenLayers.Projection('EPSG:23030'),geomType:'MULTIPOLYGON',featurePrefix:'atlas',featureType:'municipios',featureNS:'http://atlas.iver.es',visibility:false,displayInLayerSwitcher:false})};Ext.namespace("ExtMunicipios");Locale.appendLocale(Locale.ExtMunicipios[Locale.getLang()]);ExtMunicipios=OpenLayers.Class(IDEOL.Extension,{panel:null,initialize:function(){this.panel=new ExtMunicipios.Panel.Search();},onCreate:function(){this.ideol.layout.eastPanel.add(this.panel);this.ideol.layout.eastPanel.doLayout();},onUpdate:function(){},CLASS_NAME:"ExtMunicipios"});Locale.addScript("ideol/ide-extensions/ExtSearchAtlas/lib/Locale/lang-"+Locale.getLang()+".js");Config.ExtSearchAtlas={WFSLAYERS_ESTABLECIMIENTOS:"Establecimientos ",WFSLAYERS_AGRUPACIONES:"Concentraciones comerciales ",WFSLAYERS_MUNICIPIOS:"Municipios ",WFSLAYERS_COMERCIOS:"Comercios innovación ",WFSLAYERS_ANTENAS_LOCALES:"Antenas Locales ",WFSLAYERS_CAMARAS_COMERCIO:"Cámaras de Comercio ",TEMPLATE_DATAVIEW_PATH_ESTABLECIMIENTOS:"ideol/ide-extensions/ExtSearchAtlas/resources/tpl/establecimiento_dataview.html",TEMPLATE_DATAVIEW_PATH_AGRUPACIONES:"ideol/ide-extensions/ExtSearchAtlas/resources/tpl/agrupacion_dataview.html",TEMPLATE_DATAVIEW_PATH_CAMARAS:"ideol/ide-extensions/ExtSearchAtlas/resources/tpl/camaras_dataview.html",TEMPLATE_DATAVIEW_PATH_ANTENAS:"ideol/ide-extensions/ExtSearchAtlas/resources/tpl/antenas_dataview.html",TEMPLATE_DATAVIEW_PATH_MUNICIPIOS:"ideol/ide-extensions/ExtSearchAtlas/resources/tpl/municipio_dataview.html",TEMPLATE_DATAVIEW_PATH_COMERCIOS:"ideol/ide-extensions/ExtSearchAtlas/resources/tpl/comercios_innovacion_dataview.html",TEMPLATE_PATH_ESTABLECIMIENTOS:"ideol/ide-extensions/ExtSearchAtlas/resources/tpl/establecimiento.html",TEMPLATE_PATH_AGRUPACIONES:"ideol/ide-extensions/ExtSearchAtlas/resources/tpl/agrupacion.html",TEMPLATE_PATH_MUNICIPIOS:"ideol/ide-extensions/ExtSearchAtlas/resources/tpl/municipio.html",HTML_PATH_HELP_ES:"ideol/ide-extensions/ExtSearchAtlas/resources/help/es/help.html",HTML_PATH_HELP_VAL:"ideol/ide-extensions/ExtSearchAtlas/resources/help/val/help.html"};Config.ExtSearchAtlas.WFSLayers={COMERCIOS_INNOVACION:new IDEOL.Layer.WFS('Comercios innovación','http://services.iver.es/geoserver/wfs',{editable:false,projection:new OpenLayers.Projection('EPSG:23030'),geomType:'POINT',featurePrefix:'atlas',featureType:'comercios_innovacion',featureNS:'http://atlas.iver.es',visibility:false,displayInLayerSwitcher:false}),CAMARAS_COMERCIO:new IDEOL.Layer.WFS('Cámaras de Comercio','http://services.iver.es/geoserver/wfs',{editable:false,projection:new OpenLayers.Projection('EPSG:23030'),geomType:'POINT',featurePrefix:'atlas',featureType:'camaras',featureNS:'http://atlas.iver.es',visibility:false,displayInLayerSwitcher:false}),ANTENAS_LOCALES:new IDEOL.Layer.WFS('Antenas Locales','http://services.iver.es/geoserver/wfs',{editable:false,projection:new OpenLayers.Projection('EPSG:23030'),geomType:'POINT',featurePrefix:'atlas',featureType:'antenas',featureNS:'http://atlas.iver.es',visibility:false,displayInLayerSwitcher:false}),ESTABLECIMIENTOS:new IDEOL.Layer.WFS('Establecimientos','http://services.iver.es/geoserver/wfs',{editable:false,projection:new OpenLayers.Projection('EPSG:23030'),geomType:'POINT',featurePrefix:'atlas',featureType:'establecimientos',featureNS:'http://atlas.iver.es',visibility:false,displayInLayerSwitcher:false}),CONCENTRACIONES_COMERCIALES:new IDEOL.Layer.WFS('Concentraciones comerciales','http://services.iver.es/geoserver/wfs',{editable:false,projection:new OpenLayers.Projection('EPSG:23030'),geomType:'POINT',featurePrefix:'atlas',featureType:'agrupaciones',featureNS:'http://atlas.iver.es',visibility:false,displayInLayerSwitcher:false}),MUNICIPIOS:new IDEOL.Layer.WFS('Municipios','http://services.iver.es/geoserver/wfs',{editable:false,projection:new OpenLayers.Projection('EPSG:23030'),geomType:'MULTIPOLYGON',featurePrefix:'atlas',featureType:'municipios',featureNS:'http://atlas.iver.es',visibility:false,displayInLayerSwitcher:false})};Config.ExtSearchAtlas.Columns={ESTABLECIMIENTOS:[{header:'Rótulo',dataIndex:'rotulo',sortable:true,hidden:false,width:215},{header:'Sigla',dataIndex:'sigla',sortable:true,hidden:false,width:50},{header:'Nombre vía',dataIndex:'nomcall',sortable:true,hidden:false,width:200},{header:'Número',dataIndex:'numpol',sortable:true,hidden:false,width:60},{header:'Municipio',dataIndex:'municipio',sortable:true,hidden:false}],CONCENTRACIONES_COMERCIALES:[{header:'Nombre',dataIndex:'nombre',sortable:true,hidden:false,width:215},{header:'Sigla',dataIndex:'sigla',sortable:true,hidden:false,width:50},{header:'Nombre vía',dataIndex:'nomvia',sortable:true,hidden:false,width:200},{header:'Número',dataIndex:'numpol',sortable:true,hidden:false,width:60},{header:'Municipio',dataIndex:'municipio',sortable:true,hidden:false}]};Ext.namespace("ExtSearchAtlas");Locale.appendLocale(Locale.ExtSearchAtlas[Locale.getLang()]);ExtSearchAtlas=OpenLayers.Class(IDEOL.Extension,{infoBBoxButton:null,infoBBoxControl:null,eSearchButton:null,eSearchWindow:null,aSearchButton:null,aSearchWindow:null,gridResultWindow:null,helpButton:null,helpWindow:null,initialize:function(){this.createComponents();},createComponents:function(){this.infoBBoxButton=new ExtSearchAtlas.Button.InfoBBox();this.infoBBoxButton.on("click",function(){this.activateControl(this.infoBBoxControl);},this);this.eSearchButton=new ExtSearchAtlas.Button.ESearch();this.eSearchButton.on("click",function(){this.eSearchWindow.show();},this);this.aSearchButton=new ExtSearchAtlas.Button.ASearch();this.aSearchButton.on("click",function(){this.aSearchWindow.show();},this);this.helpButton=new ExtSearchAtlas.Button.Help();this.helpButton.on("click",function(){if(Locale.getLang()=='es')
this.helpWindow.showHTML(Locale.getText("msg_ayuda"),Config.ExtSearchAtlas.HTML_PATH_HELP_ES);else
this.helpWindow.showHTML(Locale.getText("msg_ayuda"),Config.ExtSearchAtlas.HTML_PATH_HELP_VAL);},this);},onCreate:function(){var map=this.ideol.map;this.gridResultWindow=new ExtSearchAtlas.Window.GridResult();this.eSearchWindow=new ExtSearchAtlas.Window.ESearch({gridResultWindow:this.gridResultWindow});this.aSearchWindow=new ExtSearchAtlas.Window.ASearch({gridResultWindow:this.gridResultWindow});this.helpWindow=new IDEOL.Tool.HTMLTemplateView();this.infoBBoxControl=new ExtSearchAtlas.Control.InfoBBox(this.ideol);map.addControl(this.infoBBoxControl);var layout=this.ideol.layout;layout.toolBar.addItem(this.infoBBoxButton);layout.toolBar.addItem(this.eSearchButton);layout.toolBar.addItem(this.aSearchButton);layout.toolBar.addItem(this.helpButton);layout.toolBar.doLayout();},onUpdate:function(){this.infoBBoxControl.destroy();this.infoBBoxControl=new ExtSearchAtlas.Control.InfoBBox(this.ideol);var map=this.ideol.map;map.addControl(this.infoBBoxControl);},activateControl:function(control){this.ideol.controlsManager.deactivateControls();control.activate();},CLASS_NAME:"ExtSearchAtlas"});Locale.addScript("ideol/ide-extensions/ExtStreetView/lib/Locale/lang-"+Locale.getLang()+".js");Config.ExtStreetView={};Ext.namespace("ExtStreetView");Locale.appendLocale(Locale.ExtStreetView[Locale.getLang()]);ExtStreetView=OpenLayers.Class(IDEOL.Extension,{button:null,control:null,initialize:function(){this.createComponents();},createComponents:function(){this.button=new ExtStreetView.Button.Launcher();this.button.on("click",function(){this.activateControl(this.control);},this);},onCreate:function(){this.control=new ExtStreetView.Control.Control();var map=this.ideol.map;map.addControl(this.control);var layout=this.ideol.layout;layout.toolBar.addItem(this.button);layout.toolBar.doLayout();},onUpdate:function(){this.control.destroy();this.control=new ExtStreetView.Control.Control();var map=this.ideol.map;map.addControl(this.control);},activateControl:function(control){this.deactivateControls();control.activate();},deactivateControls:function(){var controls=this.ideol.map.controls;for(var i=0;i<controls.length;i++){if(controls[i]instanceof OpenLayers.Control.NavigationHistory==false){controls[i].deactivate();}}},CLASS_NAME:"ExtStreetView"});Locale.addScript("ideol/ide-extensions/ExtWMS/lib/Locale/lang-"+Locale.getLang()+".js");Config.ExtWMS={INFO_BUTTON_ENABLE:true};Ext.namespace("ExtWMS");Locale.appendLocale(Locale.ExtWMS[Locale.getLang()]);ExtWMS=OpenLayers.Class(IDEOL.Extension,{infoButton:null,servicePanel:null,infoControl:null,initialize:function(){this.createComponents();},createComponents:function(){this.infoButton=new ExtWMS.Button.Info();this.infoButton.on("click",function(){this.activateControl(this.infoControl);},this);},onCreate:function(){this.servicePanel=new ExtWMS.Panel.Service({map:this.ideol.map});this.ideol.layout.layerWizard.addPanel(this.servicePanel);this.infoControl=new ExtWMS.Control.Info(this.ideol);var map=this.ideol.map;map.addControl(this.infoControl);if(Config.ExtWMS.INFO_BUTTON_ENABLE){var layout=this.ideol.layout;layout.toolBar.addItem(this.infoButton);layout.toolBar.doLayout();}},onUpdate:function(){this.servicePanel.setMap(this.ideol.map);this.infoControl.destroy();this.infoControl=new ExtWMS.Control.Info(this.ideol);var map=this.ideol.map;map.addControl(this.infoControl);},activateControl:function(control){this.deactivateControls();control.activate();},deactivateControls:function(){var controls=this.ideol.map.controls;for(var i=0;i<controls.length;i++){if(controls[i]instanceof OpenLayers.Control.NavigationHistory==false){controls[i].deactivate();}};}});Ext.namespace("ExtAdmin.Panel");ExtAdmin.Panel.Admin=Ext.extend(Ext.Panel,{id:'adminFrame',title:Locale.getText("txt_administracion"),defaultSrc:Config.ExtAdmin.ADMIN_URL,iconCls:'loading-indicator',loadMask:{msg:Locale.getText("txt_administracion")},listeners:{domready:function(frame){},documentloaded:function(frame){this.setIconClass('');}}});Ext.namespace("ExtExport.Window");ExtExport.Window.UploadFile=function(){this.ideol=ideol;this.url=Config.ProxyHost+Config.FILEUPLOAD_URL;this.setIDEOL=function(ideol){this.ideol=ideol;};this.fileUploadField=new Ext.form.FileUploadField({id:'uploadFileField',buttonText:'',emptyText:Locale.getText("msg_seleccionar_fichero"),fieldLabel:Locale.getText("txt_fichero"),width:350,name:'path',buttonCfg:{text:'',iconCls:'upload-icon'}});this.form=new Ext.FormPanel({fileUpload:true,frame:true,width:300,autoHeight:true,bodyStyle:'padding: 10px 10px 0 10px;',labelWidth:50,defaults:{anchor:'92%',allowBlank:false,msgTarget:'side'},items:[this.fileUploadField]});this.win=new Ext.Window({layout:'fit',bodyStyle:'padding: 2px 2px 2px',modal:true,title:Locale.getText("txt_importar_contexto"),id:'uploadFileWin',constrainHeader:true,width:300,autoHeight:true,maximizable:false,resizable:false,draggable:true,closeAction:"hide",plain:true,border:false,items:[this.form],buttons:[{text:Locale.getText("txt_enviar"),scope:this,handler:function(){if(this.form.getForm().isValid()){this.form.getForm().submit({url:this.url,scope:this,success:function(form,action){var fileName=form.items.items[0].value;this.win.hide();this.ideol.load(action.result,fileName);},failure:function(fomr,transport){this.win.close();IDEOL.UtilUI.showMessageWindow(Locale.getText("txt_error"),Locale.getText("msg_error_obtener_fichero"),Ext.MessageBox.ERROR);}});}}},{text:Locale.getText("txt_cerrar"),scope:this,handler:function(){this.win.hide();}}]});this.show=function(){this.win.show();this.win.expand();};};Ext.namespace("ExtMoveToLonLat.Button");ExtMoveToLonLat.Button.Launcher=Ext.extend(Ext.Toolbar.Button,{iconCls:'moveToLonLatIcon',tooltip:{title:Locale.getText("msg_centrado_coordenadas"),text:Locale.getText("msg_centrado_coordenadas_desc")},initComponent:function(){ExtMoveToLonLat.Button.Launcher.superclass.initComponent.call(this);}});Ext.namespace("ExtSearchAtlas.Panel.Establecimientos");ExtSearchAtlas.Panel.Establecimientos.Nombre=Ext.extend(Ext.FormPanel,{frame:true,title:Locale.getText("txt_nombre"),originalTitle:Locale.getText("txt_nombre"),autoWidth:true,height:95,buttonAlign:'center',labelWidth:70,nombreTextField:new Ext.form.TextField({fieldLabel:Locale.getText("txt_nombre"),name:'nombre',enableKeyEvents:true,anchor:'95%'}),keyEventHandler:function(object,event){var rotulo=this.nombreTextField.getValue();if(rotulo!=null&&rotulo.trim()!=""){this.setTitle('<span style="color: green;">'+this.originalTitle+'</span>');}
else{this.setTitle(this.originalTitle);}},initComponent:function(){ExtSearchAtlas.Panel.Establecimientos.Nombre.superclass.initComponent.call(this);this.nombreTextField.on('keyup',function(object,event){this.keyEventHandler(object,event);},this);this.add(this.nombreTextField);}});Ext.namespace("ExtSearchAtlas.Button");ExtSearchAtlas.Button.Help=Ext.extend(Ext.Toolbar.Button,{iconCls:'ExtSearchAtlas_Button_Help_Icon',tooltip:Locale.getText("msg_ayuda"),initComponent:function(){ExtSearchAtlas.Button.Help.superclass.initComponent.call(this);}});Ext.namespace("ExtSearchAtlas.Window");ExtSearchAtlas.Window.GridResult=OpenLayers.Class(IDEOL.Tool.WFSResultsGrid,{TEMPLATE_PATH_AGRUPACIONES:Config.ExtSearchAtlas.TEMPLATE_PATH_AGRUPACIONES,TEMPLATE_PATH_ESTABLECIMIENTOS:Config.ExtSearchAtlas.TEMPLATE_PATH_ESTABLECIMIENTOS,mask:null,streetViewButton:null,streetViewWindow:null,filterManager:new IDEOL.Manager.Filter(),fichaWindow:null,fichaButton:null,establecimientosManager:null,initialize:function(options){IDEOL.Tool.WFSResultsGrid.prototype.initialize.apply(this,[options]);this.createExtendedComponents();this.prepareExtendedComponents();},createExtendedComponents:function(){this.fichaWindow=new IDEOL.Tool.HTMLTemplateView();this.establecimientosManager=new ExtSearchAtlas.Manager.Establecimientos();this.fichaButton=new Ext.Button({text:Locale.getText('txt_ficha'),handler:function(){this.requestShowFicha();},scope:this});this.streetViewWindow=ExtStreetView.Window.Window;this.streetViewButton=new Ext.Button({text:Locale.getText('txt_streetview'),handler:function(){this.showStreetView();},scope:this});},prepareExtendedComponents:function(){this.win.buttons.unshift(this.fichaButton);this.win.buttons.unshift(this.streetViewButton);this.win.on("show",function(){this.mask=new Ext.LoadMask(this.grid.body);},this);},showStreetView:function(){var countRecords=this.grid.store.getCount();var records=this.getSelectedRecords();var record=null;if(records.length==1){record=records[0];}
else if(records.length==0&&countRecords==1){record=this.grid.store.getAt(0);}
if(record!=null){this.requestGeometryForRecord(record);}
else{IDEOL.UtilUI.showMessageWindow(Locale.getText("txt_informacion"),Locale.getText("msg_seleccionar_registro_para_street_view"),Ext.MessageBox.WARNING);}},onWFSRequestGeometrySuccess:function(wfsFeatures){var geoms=this.getGeometriesForFeatures(wfsFeatures);if(geoms.length>0){var geom=geoms[0];var bounds=geom.geometry.getBounds();var lonlat=bounds.getCenterLonLat();this.streetViewWindow.show(lonlat,this.layer.projection);}
this.mask.hide();},requestGeometryForRecord:function(record){this.mask.show();var fid=record.data.fid;var attributes=["the_geom"];var filter=new OpenLayers.Filter.FeatureId({fids:[fid]});this.wfsManager.getFeaturesByFilter(this.layer,attributes,filter,this.onWFSRequestGeometrySuccess,this.onWFSQueryFailure,this);},onEstablecimientosWFSQuerySuccess:function(establecimientos){this.mask.hide();this.agrupacion.data.establecimientos=[];if(establecimientos.length>0){this.agrupacion.data.establecimientos=establecimientos;}
this.fichaWindow.show(this.layer.name,this.agrupacion,this.TEMPLATE_PATH_AGRUPACIONES);},requestEstablecimientosForAgrupacion:function(idagrupacion){this.mask.show();var attributes=['rotulo','dactividad'];var filter=this.filterManager.getComparisonFilter(OpenLayers.Filter.Comparison.EQUAL_TO,'cod_agrup',idagrupacion,true);this.establecimientosManager.getEstablecimientos(attributes,filter,this.onEstablecimientosWFSQuerySuccess,this.onWFSQueryFailure,this);},onCompleteFeatureWFSQuerySuccess:function(wfsFeatures){var completeFeature=null;this.mask.hide();if(wfsFeatures.length>0){completeFeature=wfsFeatures[0];var layerName=this.layer.name;if(layerName==Config.ExtSearchAtlas.WFSLayers.CONCENTRACIONES_COMERCIALES.name){this.agrupacion=completeFeature;this.requestEstablecimientosForAgrupacion(this.agrupacion.data.id);}
else if(layerName==Config.ExtSearchAtlas.WFSLayers.ESTABLECIMIENTOS.name){this.fichaWindow.show(this.layer.name,completeFeature,this.TEMPLATE_PATH_ESTABLECIMIENTOS);}}},requestCompleteFeature:function(id){this.mask.show();var attributes="";var filter=this.filterManager.getComparisonFilter(OpenLayers.Filter.Comparison.EQUAL_TO,'id',id,true);this.wfsManager.getFeaturesByFilter(this.layer,attributes,filter,this.onCompleteFeatureWFSQuerySuccess,this.onWFSQueryFailure,this);},requestShowFicha:function(){var cont=this.grid.store.getCount();var records=this.getSelectedRecords();var record=records[0];if(record==null&&cont>1)
{IDEOL.UtilUI.showMessageWindow(Locale.getText("txt_informacion"),Locale.getText("msg_seleccionar_registro_para_ficha"),Ext.MessageBox.WARNING);;}
else
{if(cont==1)
record=this.grid.store.getAt(0);this.requestCompleteFeature(record.get("id"));};}});Ext.namespace("ExtSearchAtlas.Panel.Establecimientos");ExtSearchAtlas.Panel.Establecimientos.Actividad=Ext.extend(Ext.FormPanel,{frame:true,title:Locale.getText("txt_actividad"),originalTitle:Locale.getText("txt_actividad"),autoWidth:true,height:95,buttonAlign:'center',labelWidth:70,layer:Config.ExtSearchAtlas.WFSLayers.ESTABLECIMIENTOS,filterManager:new IDEOL.Manager.Filter(),mask:null,wfsManager:new IDEOL.Manager.WFS(),storeActividades:new Ext.data.Store({reader:new Ext.data.JsonReader({id:'dactividad'},['dactividad']),sortInfo:{field:'dactividad',direction:'ASC'}}),comboActividades:new Ext.form.ComboBox({displayField:'dactividad',valueField:'dactividad',fieldLabel:Locale.getText("txt_actividad"),name:'dactividad',mode:'local',typeAhead:false,triggerAction:'all',selectOnFocus:true,editable:false,anchor:'95%'}),getActividades:function(wfsFeatures){var blankFeature={dactividad:'--- '+Locale.getText("txt_seleccionar")+' ---'};var actividades=[blankFeature];for(i=0;i<wfsFeatures.length;i++){var actividad=wfsFeatures[i].data;actividades.push(actividad);}
return actividades;},onWFSQuerySuccess:function(wfsFeatures){var actividades=this.getActividades(wfsFeatures);this.loadCombo(actividades);this.mask.hide();},onWFSQueryFailure:function(response){this.mask.hide();IDEOL.UtilUI.showMessageWindow(Locale.getText("txt_informacion"),Locale.getText("msg_error_realizar_consulta"),Ext.MessageBox.ERROR);},loadCombo:function(actividades){this.storeActividades.loadData(actividades);},requestFeatures:function(){this.mask.show();var attributes=this.storeActividades.fields.keys;var filter=this.filterManager.getComparisonFilter(OpenLayers.Filter.Comparison.LIKE,'dactividad','*',false);this.wfsManager.getFeaturesByFilter(this.layer,attributes,filter,this.onWFSQuerySuccess,this.onWFSQueryFailure,this);},initialize:function(){this.comboActividades.store=this.storeActividades;this.add(this.comboActividades);this.on('render',function(panel){this.mask=new Ext.LoadMask(this.body);},this);this.on('afterrender',function(panel){this.requestFeatures();},this);this.comboActividades.on('select',function(combo,record,index){if(record.data.dactividad!='--- '+Locale.getText("txt_seleccionar")+' ---'){this.setTitle('<span style="color: green;">'+this.originalTitle+'</span>');}
else{this.setTitle(this.originalTitle);}},this);},initComponent:function(){ExtSearchAtlas.Panel.Establecimientos.Actividad.superclass.initComponent.call(this);this.initialize();}});Ext.namespace("ExtSearchAtlas.Panel.Agrupaciones");ExtSearchAtlas.Panel.Agrupaciones.Nombre=Ext.extend(Ext.FormPanel,{frame:true,title:Locale.getText("txt_nombre"),originalTitle:Locale.getText("txt_nombre"),autoWidth:true,height:95,buttonAlign:'center',labelWidth:70,nombreTextField:new Ext.form.TextField({fieldLabel:Locale.getText("txt_nombre"),name:'nombre',enableKeyEvents:true,anchor:'95%'}),keyEventHandler:function(object,event){var rotulo=this.nombreTextField.getValue();if(rotulo!=null&&rotulo.trim()!=""){this.setTitle('<span style="color: green;">'+this.originalTitle+'</span>');}
else{this.setTitle(this.originalTitle);}},initComponent:function(){ExtSearchAtlas.Panel.Agrupaciones.Nombre.superclass.initComponent.call(this);this.nombreTextField.on('keyup',function(object,event){this.keyEventHandler(object,event);},this);this.add(this.nombreTextField);}});Ext.namespace("ExtWMS.Control");ExtWMS.Control.Info=OpenLayers.Class(OpenLayers.Control,{infoWindow:null,ideol:null,xslMetadataURL:'ideol/ide-extensions/ExtWMS/resources/xsl/infoWMS.xsl',xslMetadataString:null,initialize:function(ideol){this.ideol=ideol;this.infoWindow=new ExtWMS.Window.Info();OpenLayers.Control.prototype.initialize.apply(this);this.handler=new OpenLayers.Handler.Click(this,{'click':this.onClick},this.handlerOptions);},destroy:function(){if(this.infoWindow!=null){this.infoWindow.destroy();}
OpenLayers.Control.prototype.destroy.call(this);},onClick:function(evt){var selectedNode=this.ideol.toc.selectedNode;if(selectedNode!=null){var arrayLayers=this.ideol.map.getLayersByName(selectedNode.text);var layer=null;if(arrayLayers.length==1)
layer=arrayLayers[0];if(layer!=null){if(layer.queryable){if(layer.getVisibility()){var xy=evt.xy;this.infoWindow.show(layer,xy);}
else{IDEOL.UtilUI.showMessageWindow(Locale.getText("txt_informacion"),Locale.getText("msg_capa_seleccionada_no_visible_mapa"),Ext.MessageBox.WARNING);}}
else{IDEOL.UtilUI.showMessageWindow(Locale.getText("txt_informacion"),Locale.getText("msg_capa_seleccionada_no_consultable"),Ext.MessageBox.WARNING);}}}
else{IDEOL.UtilUI.showMessageWindow(Locale.getText("txt_informacion"),Locale.getText("msg_seleccionar_capa_consultable_obtener_info"),Ext.MessageBox.WARNING);}},showXSLWMSInfo:function(featuresString){if(!this.xslMetadataString){this.xslMetadataString=this.getXSLString(this.xslMetadataURL);}
this.infoXSLWindow.show(featuresString,this.xslMetadataString);},getXSLString:function(url){var request=OpenLayers.Request.GET({proxy:IDEOL.Util.getProxy(url),url:url,async:false});return request.responseText;},CLASS_NAME:"ExtWMS.Control.Info"});Ext.namespace("ExtSearchAtlas.Panel.Establecimientos");ExtSearchAtlas.Panel.Establecimientos.Tab=Ext.extend(Ext.TabPanel,{activeTab:0,border:false,autoHeight:true,initComponent:function(){ExtSearchAtlas.Panel.Establecimientos.Tab.superclass.initComponent.call(this);}});Ext.namespace("ExtExport.Window");ExtExport.Window.InfoReport=OpenLayers.Class({infoReportPanel:null,win:null,mask:null,wmcManager:new IDEOL.Manager.WMC(),printManager:new IDEOL.Manager.Print.Print(),initialize:function(){this.createComponents();this.prepareComponents();},createComponents:function(){this.infoReportPanel=new ExtExport.Panel.InfoReport();this.win=new Ext.Window({layout:'fit',bodyStyle:'padding: 2px 2px 2px',modal:false,title:Locale.getText("txt_detalle_impresion"),constrainHeader:true,width:300,collapsible:true,autoHeight:true,maximizable:false,resizable:false,draggable:true,closeAction:"hide",plain:true,border:false});},prepareComponents:function(){this.win.add(this.infoReportPanel);this.win.addButton({text:Locale.getText("txt_imprimir")},function(button,event){this.printReport();},this);this.win.addButton({text:Locale.getText("txt_cerrar")},function(button,event){this.win.hide();},this);this.win.on('afterrender',function(){this.mask=new Ext.LoadMask(this.win.body,{msg:Locale.getText("msg_preparando_documento")});},this);},show:function(){if(!this.win.isVisible()){this.win.show();this.win.center();}
this.win.expand();},setMap:function(map){this.map=map;},getPrintRequest:function(){var printRequest=new IDEOL.Manager.Print.PrintRequest();var scale=""+this.map.getScale()+"";scale="1:"+scale.split(".")[0];printRequest.project=Config.ExtExport.REPORT_NAME;printRequest.title=this.infoReportPanel.tituloTextField.getValue().trim();printRequest.description=this.infoReportPanel.descripcionTextArea.getValue();printRequest.mapWMC=this.wmcManager.getWMCStringMap(this.map);printRequest.scale=scale;printRequest.size=this.infoReportPanel.comboSize.getValue();return printRequest;},onPrintReportSuccess:function(fileURL){this.mask.hide();window.open(fileURL);},onPrintReportFailure:function(){this.mask.hide();IDEOL.UtilUI.showMessageWindow(Locale.getText("txt_informacion"),Locale.getText("msg_error_preparar_documento"),Ext.MessageBox.ERROR);},printReport:function(){if(!this.infoReportPanel.getForm().isValid())
return;this.mask.show();var printRequest=this.getPrintRequest();this.printManager.printReport(printRequest,this.onPrintReportSuccess,this.onPrintReportFailure,this);}});Ext.namespace("ExtSearchAtlas.Panel.Establecimientos");ExtSearchAtlas.Panel.Establecimientos.Direccion=Ext.extend(Ext.FormPanel,{frame:true,title:Locale.getText("txt_direccion"),originalTitle:Locale.getText("txt_direccion"),autoWidth:true,height:95,buttonAlign:'center',labelWidth:70,layerMunicipios:Config.ExtSearchAtlas.WFSLayers.MUNICIPIOS,filterManager:new IDEOL.Manager.Filter(),mask:null,wfsManager:new IDEOL.Manager.WFS(),direccionTextField:new Ext.form.TextField({fieldLabel:Locale.getText("txt_direccion"),name:'direccion',enableKeyEvents:true,anchor:'95%'}),storeMunicipios:new Ext.data.Store({reader:new Ext.data.JsonReader({},['nombre']),sortInfo:{field:'nombre',direction:'ASC'}}),storeProvincias:new Ext.data.SimpleStore({fields:['codigo','nombre'],data:[['00','--- '+Locale.getText("txt_seleccionar")+' ---'],['03','Alicante'],['12','Castellón'],['46','Valencia']]}),comboMunicipios:new Ext.form.ComboBox({displayField:'nombre',fieldLabel:Locale.getText("txt_municipio"),name:'municipio',mode:'local',triggerAction:'all',selectOnFocus:true,editable:false,anchor:'95%'}),comboProvincias:new Ext.form.ComboBox({displayField:'nombre',fieldLabel:Locale.getText("txt_provincia"),value:'--- '+Locale.getText("txt_seleccionar")+' ---',name:'nombre',mode:'local',typeAhead:true,forceSelection:true,triggerAction:'all',selectOnFocus:true,editable:false,anchor:'95%'}),keyEventHandler:function(object,event){this.updateTitleColor();},getMunicipios:function(wfsFeatures){var blankFeature={nombre:'--- '+Locale.getText("txt_seleccionar")+' ---'};var municipios=[blankFeature];for(i=0;i<wfsFeatures.length;i++){var municipio=wfsFeatures[i].data;municipios.push(municipio);}
return municipios;},onWFSQuerySuccess:function(wfsFeatures){var municipios=this.getMunicipios(wfsFeatures);this.loadComboMunicipios(municipios);this.mask.hide();},onWFSQueryFailure:function(response){this.mask.hide();IDEOL.UtilUI.showMessageWindow(Locale.getText("txt_informacion"),Locale.getText("msg_error_realizar_consulta"),Ext.MessageBox.ERROR);},loadComboMunicipios:function(municipios){this.storeMunicipios.loadData(municipios);},requestFeatures:function(codprov){this.mask.show();var attributes=this.storeMunicipios.fields.keys;var filter=this.filterManager.getComparisonFilter(OpenLayers.Filter.Comparison.EQUAL_TO,'codprov',codprov,false);this.wfsManager.getFeaturesByFilter(this.layerMunicipios,attributes,filter,this.onWFSQuerySuccess,this.onWFSQueryFailure,this);},updateTitleColor:function(){var update=false;var provincia=this.comboProvincias.getValue();var municipio=this.comboMunicipios.getValue();var direccion=this.direccionTextField.getValue();if(provincia!=null&&provincia.trim()!=""&&provincia!='--- '+Locale.getText("txt_seleccionar")+' ---'){update=true;}
else if(direccion!=null&&direccion.trim()!=""){update=true;}
if(update){this.setTitle('<span style="color: green;">'+this.originalTitle+'</span>');}
else{this.setTitle(this.originalTitle);}},initialize:function(){this.on('render',function(panel){this.mask=new Ext.LoadMask(this.body);},this);this.comboProvincias.store=this.storeProvincias;this.comboMunicipios.store=this.storeMunicipios;this.comboProvincias.on('select',function(combo,record,index){this.storeMunicipios.removeAll();this.comboMunicipios.setValue("");this.updateTitleColor();if(record.data.codigo!='00'){this.requestFeatures(record.data.codigo);}},this);this.comboMunicipios.on('select',function(combo,record,index){this.updateTitleColor();},this);this.direccionTextField.on('keyup',function(object,event){this.keyEventHandler(object,event);},this);this.add(this.comboProvincias);this.add(this.comboMunicipios);this.add(this.direccionTextField);},initComponent:function(){ExtSearchAtlas.Panel.Establecimientos.Direccion.superclass.initComponent.call(this);this.initialize();}});Ext.namespace("ExtWMS.Window");ExtWMS.Window.Info=function(){this.layer=null;this.LAYER_PROJECTION=null;this.isGridPrepared=false;this.xy;this.drawManager=IDEOL.Manager.Draw.getInstance();this.wmsManager=new IDEOL.Manager.WMS();this.mask=null;this.htmlPanel=new Ext.Panel({layout:'fit'});this.grid=new Ext.grid.GridPanel({layout:'fit',store:new Ext.ux.data.PagingStore({reader:new Ext.data.JsonReader({},[])}),columns:[],view:new Ext.grid.GridView({forceFit:false}),sm:new Ext.grid.RowSelectionModel({singleSelect:false}),stripeRows:true,autoScroll:true,frame:true,iconCls:'icon-grid',bbar:new Ext.PagingToolbar({store:new Ext.ux.data.PagingStore({reader:new Ext.data.JsonReader({},[])}),displayInfo:true,pageSize:10,prependButtons:true})});this.getLastColumnId=function(){return this.grid.getColumnModel().getColumnId(this.grid.getColumnModel().getColumnCount()-1);};this.win=new Ext.Window({layout:'fit',bodyStyle:'padding: 2px 2px 2px',modal:false,title:Locale.getText("txt_informacion_wms"),constrainHeader:true,expandOnShow:true,width:650,minWidth:450,height:300,maximizable:true,resizable:true,draggable:true,collapsible:true,closeAction:"hide",plain:true,border:false,items:[this.grid,this.htmlPanel],buttons:[{text:Locale.getText("txt_cerrar"),scope:this,handler:function(){this.win.hide();}}]});this.getFeatureByFid=function(fid){var features=this.layer.features;for(i=0;i<features.length;i++){if(features[i].fid==fid)
return features[i];}};this.locateFeature=function(){var selectionModel=this.grid.getSelectionModel();var records=selectionModel.getSelections();if(records.length==0){IDEOL.UtilUI.showMessageWindow(Locale.getText("txt_informacion"),Locale.getText("msg_seleccionar_registro_localizar"),Ext.MessageBox.WARNING);}
else if(records.length>1){IDEOL.UtilUI.showMessageWindow(Locale.getText("txt_informacion"),Locale.getText("msg_seleccionar_unico_registro_localizar"),Ext.MessageBox.WARNING);}
else if(records.length==1){var record=records[0];var geometryWKT=record.get("geometry");var WKTFormat=new OpenLayers.Format.WKT();var feature=WKTFormat.read(geometryWKT);var bounds=feature.geometry.getBounds();var lonlat=bounds.getCenterLonLat();this.drawManager.drawMarker(lonlat,this.LAYER_PROJECTION.getCode(),true,false);}};this.getFeatureFromRecord=function(record){var feature=new OpenLayers.Feature();feature.fid=record.data.fid;feature.geometry=record.data.geometry;for(key in record.data){if(key!='fid'&&key!='geometry'){validKey=key.split(".");feature.data[validKey[1]]=record.data[key];}}
return feature;};this.getDescribeFeatureData=function(feature){var data=[];data.push('fid');for(key in feature.data){if(key!="the_geom")
data.push('data.'+key);}
data.push('geometry');return data;};this.getStore=function(describeFeatureData){var jsonReader=new Ext.data.JsonReader({},describeFeatureData);var store=new Ext.ux.data.PagingStore({reader:jsonReader});return store;};this.getColumnModel=function(describeFeatureData){var columns=[];for(var i=0;i<describeFeatureData.length;i++){var dataHeaderTitle=describeFeatureData[i].split(".")[1];if(describeFeatureData[i]=='fid')
columns.push({header:'Fid',dataIndex:describeFeatureData[i],sortable:true,hidden:true});else if(describeFeatureData[i]=='geometry')
columns.push({header:'Geometry',dataIndex:describeFeatureData[i],sortable:true,hidden:true});else if(columns.length<10){columns.push({header:dataHeaderTitle,dataIndex:describeFeatureData[i],sortable:true,editor:new Ext.form.TextField()});}
else{columns.push({header:dataHeaderTitle,dataIndex:describeFeatureData[i],sortable:true,hidden:true,editor:new Ext.form.TextField()});}}
var columnModel=new Ext.grid.ColumnModel({columns:columns});return columnModel;};this.loadGrid=function(features){this.grid.store.removeAll();var limit=this.grid.getBottomToolbar().pageSize;this.grid.store.lastOptions={params:{start:0,limit:limit}};this.grid.store.loadData(features);};this.prepareGrid=function(wmsFeature){var describeFeatureData=this.getDescribeFeatureData(wmsFeature);var store=this.getStore(describeFeatureData);var columnModel=this.getColumnModel(describeFeatureData);this.grid.reconfigure(store,columnModel);this.grid.getBottomToolbar().bindStore(store);this.isGridPrepared=true;};this.resetGrid=function(){this.grid.store.removeAll();var store=new Ext.ux.data.PagingStore({reader:new Ext.data.JsonReader({},[])});var columnModel=new Ext.grid.ColumnModel({columns:[]});this.grid.reconfigure(store,columnModel);this.isGridPrepared=false;};this.showNoInfoMessage=function(){IDEOL.UtilUI.showMessageWindow(Locale.getText("txt_informacion"),Locale.getText("msg_sin_resultados_punto"),Ext.MessageBox.INFO);};this.onWMSGetFeaturesSuccess=function(features,isXHTML){if(!isXHTML){this.grid.setVisible(true);this.grid.getBottomToolbar().setVisible(true);this.htmlPanel.setVisible(false);if(features.length>0){if(!this.isGridPrepared)
this.prepareGrid(features[0]);this.loadGrid(features);}
else{if(this.isGridPrepared)
this.grid.store.removeAll();this.showNoInfoMessage();}}
else{this.htmlPanel.setVisible(true);this.grid.setVisible(false);this.grid.getBottomToolbar().setVisible(false);this.htmlPanel.html='';this.htmlPanel.body.update(features);}
this.mask.hide();};this.onWMSGetFeaturesFailure=function(response){this.mask.hide();IDEOL.UtilUI.showMessageWindow(Locale.getText("txt_informacion"),Locale.getText("msg_error_contactar_servicio"),Ext.MessageBox.ERROR);};this.getFeatures=function(){this.mask.show();this.wmsManager.getFeatures(this.layer,this.xy,this.onWMSGetFeaturesSuccess,this.onWMSGetFeaturesFailure,this);};this.show=function(layer,xy){if(layer&&xy){if(this.layer==null||this.layer.name!=layer.name){this.layer=layer;this.LAYER_PROJECTION=this.layer.projection;this.win.setTitle(Locale.getText("txt_informacion_wms")+"  -  "+this.layer.name);this.resetGrid();}
this.xy=xy;this.win.show();if(this.mask==null)
this.mask=new Ext.LoadMask(this.win.body,{msg:Locale.getText("msg_obteniendo_datos")+" ..."});this.getFeatures();}};this.destroy=function(){this.win.close();this.win.destroy();};};Ext.namespace("ExtSearchAtlas.Button");ExtSearchAtlas.Button.ESearch=Ext.extend(Ext.Toolbar.Button,{iconCls:'ExtSearchAtlas_Button_ESearch_Icon',tooltip:Locale.getText("msg_busqueda_establecimientos"),initComponent:function(){ExtSearchAtlas.Button.ESearch.superclass.initComponent.call(this);}});Ext.namespace("ExtSearchAtlas.Button");ExtSearchAtlas.Button.InfoBBox=Ext.extend(Ext.Toolbar.Button,{iconCls:'ExtSearchAtlas_Button_InfoBBox_Icon',tooltip:{title:Locale.getText("txt_informacion"),text:Locale.getText("msg_obtiene_informacion_capa_seleccionada")},toggleGroup:'map',ideol:null,initComponent:function(){ExtSearchAtlas.Button.InfoBBox.superclass.initComponent.call(this);},setIDEOL:function(ideol){this.ideol=ideol;}});Ext.namespace("ExtStreetView.Button");ExtStreetView.Button.Launcher=Ext.extend(Ext.Toolbar.Button,{iconCls:'ExtStreetView_Button_Launcher_Icon',tooltip:{title:Locale.getText("txt_streetView"),text:Locale.getText("msg_streetView_desc")},toggleGroup:'map',initComponent:function(){ExtStreetView.Button.Launcher.superclass.initComponent.call(this);}});Ext.namespace("ExtSearchAtlas.Control");ExtSearchAtlas.Control.InfoBBox=OpenLayers.Class(OpenLayers.Control,{dataViewWindow:null,ideol:null,out:false,draw:function(){this.handler=new OpenLayers.Handler.Box(this,{done:this.showInfo},{keyMask:this.keyMask});},initialize:function(ideol){this.ideol=ideol;this.dataViewWindow=new ExtSearchAtlas.Window.DataView(this.ideol.map);OpenLayers.Control.prototype.initialize.apply(this);},checkWMSLayer:function(nodeText){var layer;var arrayLayers=this.map.getLayersByName(nodeText);if(arrayLayers.length==1)
layer=arrayLayers[0];if(layer==null)
return false;if(layer.queryable){if(!layer.getVisibility()){IDEOL.UtilUI.showMessageWindow(Locale.getText("txt_informacion"),Locale.getText("msg_capa_seleccionada_no_visible_mapa"),Ext.MessageBox.WARNING);return false;}
return true;}
else{IDEOL.UtilUI.showMessageWindow(Locale.getText("txt_informacion"),Locale.getText("msg_capa_seleccionada_no_consultable"),Ext.MessageBox.WARNING);}
return false;},showInfo:function(position){var selectedNode=this.ideol.toc.selectedNode;if(selectedNode){var wmsLayerName=selectedNode.text;if(this.checkWMSLayer(wmsLayerName)){var layerWFS=this.getWFSLayerByName(wmsLayerName);if(layerWFS!=null){var bounds=this.getBounds(position);if(bounds!=null){bounds.transform(new OpenLayers.Projection(this.map.getProjection()),new OpenLayers.Projection(layerWFS.projection.projCode));this.dataViewWindow.show(layerWFS,bounds);}}}}
else{IDEOL.UtilUI.showMessageWindow(Locale.getText("txt_informacion"),Locale.getText("msg_seleccionar_capa_consultable_obtener_info"),Ext.MessageBox.WARNING);}},getWFSLayerByName:function(layerName){var layer=null;if(layerName==Config.ExtSearchAtlas.WFSLayers.ESTABLECIMIENTOS.name)
layer=Config.ExtSearchAtlas.WFSLayers.ESTABLECIMIENTOS;else if(layerName==Config.ExtSearchAtlas.WFSLayers.CONCENTRACIONES_COMERCIALES.name)
layer=Config.ExtSearchAtlas.WFSLayers.CONCENTRACIONES_COMERCIALES;else if(layerName==Config.ExtSearchAtlas.WFSLayers.MUNICIPIOS.name)
layer=Config.ExtSearchAtlas.WFSLayers.MUNICIPIOS;else if(layerName==Config.ExtSearchAtlas.WFSLayers.COMERCIOS_INNOVACION.name)
layer=Config.ExtSearchAtlas.WFSLayers.COMERCIOS_INNOVACION;else if(layerName==Config.ExtSearchAtlas.WFSLayers.ANTENAS_LOCALES.name)
layer=Config.ExtSearchAtlas.WFSLayers.ANTENAS_LOCALES;else if(layerName==Config.ExtSearchAtlas.WFSLayers.CAMARAS_COMERCIO.name)
layer=Config.ExtSearchAtlas.WFSLayers.CAMARAS_COMERCIO;return layer;},getBounds:function(position){var bounds=null;if(position instanceof OpenLayers.Bounds){if(!this.out){var minXY=this.map.getLonLatFromPixel(new OpenLayers.Pixel(position.left,position.bottom));var maxXY=this.map.getLonLatFromPixel(new OpenLayers.Pixel(position.right,position.top));bounds=new OpenLayers.Bounds(minXY.lon,minXY.lat,maxXY.lon,maxXY.lat);}else{var pixWidth=Math.abs(position.right-position.left);var pixHeight=Math.abs(position.top-position.bottom);var zoomFactor=Math.min((this.map.size.h/pixHeight),(this.map.size.w/pixWidth));var extent=this.map.getExtent();var center=this.map.getLonLatFromPixel(position.getCenterPixel());var xmin=center.lon-(extent.getWidth()/2)*zoomFactor;var xmax=center.lon+(extent.getWidth()/2)*zoomFactor;var ymin=center.lat-(extent.getHeight()/2)*zoomFactor;var ymax=center.lat+(extent.getHeight()/2)*zoomFactor;bounds=new OpenLayers.Bounds(xmin,ymin,xmax,ymax);}}
else{var offsetPoint=14;if(!this.out){var min={x:position.x-offsetPoint,y:position.y+offsetPoint};var minLonLat=this.map.getLonLatFromPixel(min);var max={x:position.x+offsetPoint,y:position.y-offsetPoint};var maxLonLat=this.map.getLonLatFromPixel(max);bounds=new OpenLayers.Bounds(minLonLat.lon,minLonLat.lat,maxLonLat.lon,maxLonLat.lat);}else{this.map.setCenter(this.map.getLonLatFromPixel(position),this.map.getZoom()-1);}}
return bounds;},CLASS_NAME:"ExtSearchAtlas.Control.InfoBBox"});Ext.form.FileUploadField=Ext.extend(Ext.form.TextField,{buttonText:'Browse...',buttonOnly:false,buttonOffset:3,readOnly:true,autoSize:Ext.emptyFn,initComponent:function(){Ext.form.FileUploadField.superclass.initComponent.call(this);this.addEvents('fileselected');},onRender:function(ct,position){Ext.form.FileUploadField.superclass.onRender.call(this,ct,position);this.wrap=this.el.wrap({cls:'x-form-field-wrap x-form-file-wrap'});this.el.addClass('x-form-file-text');this.el.dom.removeAttribute('name');this.fileInput=this.wrap.createChild({id:this.getFileInputId(),name:this.name||this.getId(),cls:'x-form-file',tag:'input',type:'file',size:1});var btnCfg=Ext.applyIf(this.buttonCfg||{},{text:this.buttonText});this.button=new Ext.Button(Ext.apply(btnCfg,{renderTo:this.wrap,cls:'x-form-file-btn'+(btnCfg.iconCls?' x-btn-icon':'')}));if(this.buttonOnly){this.el.hide();this.wrap.setWidth(this.button.getEl().getWidth());}
this.fileInput.on('change',function(){var v=this.fileInput.dom.value;this.setValue(v);this.fireEvent('fileselected',this,v);},this);},getFileInputId:function(){return this.id+'-file';},onResize:function(w,h){Ext.form.FileUploadField.superclass.onResize.call(this,w,h);this.wrap.setWidth(w);if(!this.buttonOnly){var w=this.wrap.getWidth()-this.button.getEl().getWidth()-this.buttonOffset;this.el.setWidth(w);}},preFocus:Ext.emptyFn,getResizeEl:function(){return this.wrap;},getPositionEl:function(){return this.wrap;},alignErrorIcon:function(){this.errorIcon.alignTo(this.wrap,'tl-tr',[2,0]);}});Ext.reg('fileuploadfield',Ext.form.FileUploadField);Ext.namespace("ExtWMS.Panel");ExtWMS.Panel.Service=Ext.extend(Ext.Panel,{frame:true,bodyStyle:'padding: 2px 2px 2px 2px',title:'WMS',autoHeight:true,buttonAlign:'center',labelWidth:60,mask:null,map:null,wmsManager:new IDEOL.Manager.WMS(),comboWMSServer:null,tree:null,servers:null,store:null,form:null,connectButton:null,addLayerButton:null,initComponent:function(){ExtWMS.Panel.Service.superclass.initComponent.call(this);this.createComponents();this.prepareComponents();},createComponents:function(){this.servers=[['Catastro','http://ovc.catastro.meh.es/Cartografia/WMS/ServidorWMS.aspx'],['PNOA','http://www.idee.es/wms/PNOA/PNOA']];this.store=new Ext.data.SimpleStore({fields:['abbr','url'],data:this.servers});this.comboWMSServers=new Ext.form.ComboBox({store:this.store,id:'comboWMSServers',vtype:'url',anchor:'95%',fieldLabel:Locale.getText("txt_servidor"),displayField:'url',expandOnShow:true,typeAhead:true,mode:'local',triggerAction:'all',allowBlank:false,emptyText:Locale.getText("msg_seleccionar_servicio"),selectOnFocus:true,enableKeyEvents:true});this.form=new Ext.FormPanel({labelWidth:55,bodyStyle:'padding:10px 5px 0',autoHeight:true,buttonAlign:'center'}),this.tree=new Ext.tree.TreePanel({id:'treeWMSService',animate:true,height:150,hidden:false,border:false,frame:true,collapsible:true,collapsed:false,rootVisible:true,autoScroll:true,selModel:new Ext.tree.MultiSelectionModel(),root:{text:Locale.getText("txt_servicios"),draggable:false,leaf:true}});},prepareComponents:function(){this.tree.on('afterrender',function(tree){this.mask=new Ext.LoadMask(this.tree.body,{msg:Locale.getText("msg_obteniendo_datos")+" ..."});},this);this.keyEventHandler=function(object,event){if(event.getCharCode()==event.ENTER)
this.connect();};this.comboWMSServers.on('select',function(combo,record,index){this.connect();},this);this.comboWMSServers.on('keypress',function(object,event){this.keyEventHandler(object,event);},this);this.connectButton=this.form.addButton({text:Locale.getText("txt_conectar")},function(){this.connect();},this);this.form.add(this.comboWMSServers);this.addLayerButton=this.addButton({text:Locale.getText("txt_anyadir")},function(){this.addLayers();},this);this.add(this.form);this.add(this.tree);},addLayers:function(){var selmodel=this.tree.getSelectionModel();var selectedNodes=selmodel.getSelectedNodes();if(selectedNodes.length>0){for(var i=0;i<selectedNodes.length;i++){var node=selectedNodes[i];if(node.attributes.iconCls=='layerNode'){var wmsLayer=this.getWMSLayer(node);if(wmsLayer!=null){this.map.addLayer(wmsLayer);}}}}
else{IDEOL.UtilUI.showMessageWindow(Locale.getText("txt_informacion"),Locale.getText("msg_seleccionar_capas_anyadir"),Ext.MessageBox.WARNING);}},getWMSLayer:function(node){var capabLayer=node.attributes.layer;var capabService=node.attributes.service;var wmsLayer=new OpenLayers.Layer.WMS(capabLayer.title,this.urlService,{LAYERS:capabLayer.name,TRANSPARENT:'TRUE'},{visibility:true,queryable:capabLayer.queryable,displayInLayerSwitcher:true,isBaseLayer:false,styles:capabLayer.styles});return wmsLayer;},onWMSCapabilitiesSuccess:function(capabObject){this.loadCapabilitiesWMSTree(capabObject);this.mask.hide();this.connectButton.enable();},onWMSQueryFailure:function(response){this.mask.hide();this.connectButton.enable();IDEOL.UtilUI.showMessageWindow(Locale.getText("txt_informacion"),Locale.getText("msg_error_obtener_documento_capabilities"),Ext.MessageBox.ERROR);},requestCapabilities:function(url){this.connectButton.disable();this.mask.show();this.wmsManager.getCapabilities(url,this.onWMSCapabilitiesSuccess,this.onWMSQueryFailure,this);},loadCapabilitiesWMSTree:function(capabObject){if(capabObject!=null){this.mask.hide();this.connectButton.enable();var nodes=this.createNodes(capabObject);this.loadTree(nodes);this.tree.setVisible(true);}
else{IDEOL.UtilUI.showMessageWindow(Locale.getText("txt_informacion"),Locale.getText("msg_error_obtener_documento_capabilities"),Ext.MessageBox.ERROR);}},loadTree:function(nodes){var rootNode=this.tree.getRootNode();rootNode.destroy();this.tree.setRootNode(nodes);this.tree.getRootNode().render();this.tree.render();},createNodes:function(capabObejct){var service=capabObejct.service;var capability=capabObejct.capability;var layers=capabObejct.capability.layers;var version=capabObejct.version;var root=new Ext.tree.TreeNode({text:service.title,allowDrag:false,expanded:true,expandChildNodes:true,allowDrop:false,allowChildren:true,leaf:false,qtipCfg:{text:service.abstract?service.abstract:service.title}});for(var i=0;i<layers.length;i++){var attributes={text:layers[i].title,leaf:true,layer:layers[i],service:service,iconCls:'layerNode',qtipCfg:{text:layers[i].abstract?layers[i].abstract:layers[i].title}};var node=new Ext.tree.TreeNode(attributes);root.appendChild(node);}
return root;},deleteAllTreeNodes:function(){var rootnode=this.tree.getRootNode();while(rootnode.firstChild){var c=rootnode.firstChild;rootnode.removeChild(c);c.destroy();}},connect:function(){if(this.form.getForm().isValid()){this.urlService=this.comboWMSServers.getValue().trim();if(this.urlService){this.comboWMSServers.setValue(this.urlService);this.requestCapabilities(this.urlService);}}},setMap:function(map){this.map=map;}});Ext.namespace("ExtStreetView.Control");ExtStreetView.Control.Control=OpenLayers.Class(OpenLayers.Control,{streetViewWindow:null,initialize:function(options){OpenLayers.Control.prototype.initialize.apply(this,[options]);this.handler=new OpenLayers.Handler.Click(this,{'click':this.onClick},this.handlerOptions);},onClick:function(evt){var lonlat=this.map.getLonLatFromViewPortPx(evt.xy);if(this.streetViewWindow==null)
this.streetViewWindow=ExtStreetView.Window.Window;var projection=this.map.getProjectionObject();this.streetViewWindow.show(lonlat,projection);},CLASS_NAME:"ExtStreetView.Control.Control"});Ext.namespace("ExtSearchAtlas.Panel.Agrupaciones");ExtSearchAtlas.Panel.Agrupaciones.Centro=Ext.extend(Ext.FormPanel,{frame:true,title:Locale.getText("txt_tipo_centro"),originalTitle:Locale.getText("txt_tipo_centro"),autoWidth:true,height:95,buttonAlign:'center',labelWidth:70,layer:Config.ExtSearchAtlas.WFSLayers.CONCENTRACIONES_COMERCIALES,mask:null,wfsManager:new IDEOL.Manager.WFS(),filterManager:new IDEOL.Manager.Filter(),storeCentros:new Ext.data.Store({reader:new Ext.data.JsonReader({id:'tipo_centr'},['tipo_centr']),sortInfo:{field:'tipo_centr',direction:'ASC'}}),comboCentros:new Ext.form.ComboBox({displayField:'tipo_centr',valueField:'tipo_centr',fieldLabel:Locale.getText("txt_tipo_centro"),name:'tipo_centr',mode:'local',typeAhead:false,triggerAction:'all',selectOnFocus:true,editable:false,anchor:'95%'}),getCentros:function(wfsFeatures){var blankFeature={tipo_centr:'--- '+Locale.getText("txt_seleccionar")+' ---'};var centros=[blankFeature];for(i=0;i<wfsFeatures.length;i++){var centro=wfsFeatures[i].data;centros.push(centro);}
return centros;},onWFSQuerySuccess:function(wfsFeatures){var centros=this.getCentros(wfsFeatures);this.loadCombo(centros);this.mask.hide();},onWFSQueryFailure:function(response){this.mask.hide();IDEOL.UtilUI.showMessageWindow(Locale.getText("txt_informacion"),Locale.getText("msg_error_realizar_consulta"),Ext.MessageBox.ERROR);},loadCombo:function(centros){this.storeCentros.loadData(centros);},requestFeatures:function(){this.mask.show();var attributes=this.storeCentros.fields.keys;var filter=this.filterManager.getComparisonFilter(OpenLayers.Filter.Comparison.LIKE,'tipo_centr',"*",false);this.wfsManager.getFeaturesByFilter(this.layer,attributes,filter,this.onWFSQuerySuccess,this.onWFSQueryFailure,this);},initialize:function(){this.comboCentros.store=this.storeCentros;this.add(this.comboCentros);this.on('render',function(panel){this.mask=new Ext.LoadMask(this.body);},this);this.on('afterrender',function(panel){this.requestFeatures();},this);this.comboCentros.on('select',function(combo,record,index){if(record.data.tipo_centr!='--- '+Locale.getText("txt_seleccionar")+' ---'){this.setTitle('<span style="color: green;">'+this.originalTitle+'</span>');}
else{this.setTitle(this.originalTitle);}},this);},initComponent:function(){ExtSearchAtlas.Panel.Agrupaciones.Centro.superclass.initComponent.call(this);this.initialize();}});Ext.namespace("ExtSearchAtlas.Window");ExtSearchAtlas.Window.ASearch=OpenLayers.Class({layer:Config.ExtSearchAtlas.WFSLayers.CONCENTRACIONES_COMERCIALES,wfsManager:null,filterManager:new IDEOL.Manager.Filter(),columns:Config.ExtSearchAtlas.Columns.CONCENTRACIONES_COMERCIALES,tabPanel:null,panelNombre:null,panelDireccion:null,panelCentro:null,buscarButton:new Ext.Button({text:Locale.getText("txt_buscar")}),cerrarButton:new Ext.Button({text:Locale.getText("txt_cerrar")}),win:null,gridResultWindow:null,initialize:function(options){OpenLayers.Util.extend(this,options);this.createComponents();this.prepareComponents();},createComponents:function(){this.wfsManager=new IDEOL.Manager.WFS();this.tabPanel=new ExtSearchAtlas.Panel.Agrupaciones.Tab();this.panelNombre=new ExtSearchAtlas.Panel.Agrupaciones.Nombre();this.panelDireccion=new ExtSearchAtlas.Panel.Agrupaciones.Direccion();this.panelCentro=new ExtSearchAtlas.Panel.Agrupaciones.Centro();this.win=new Ext.Window({layout:'fit',bodyStyle:'padding: 2px 2px 2px',modal:false,title:Locale.getText("msg_busqueda_concentraciones"),titleCollapse:true,constrainHeader:true,width:340,autoHeight:true,expandOnShow:true,maximizable:false,collapsible:true,resizable:false,draggable:true,closeAction:"hide",plain:true,border:false,items:[this.tabPanel],buttons:[this.buscarButton,this.cerrarButton]});},prepareComponents:function(){this.tabPanel.add(this.panelNombre);this.tabPanel.add(this.panelDireccion);this.tabPanel.add(this.panelCentro);this.panelNombre.nombreTextField.on('keypress',function(object,event){this.keyEventHandler(object,event);},this);this.panelDireccion.direccionTextField.on('keypress',function(object,event){this.keyEventHandler(object,event);},this);this.buscarButton.on('click',function(){this.doSearch();},this);this.cerrarButton.on('click',function(){this.win.hide();},this);},keyEventHandler:function(object,event){if(event.getCharCode()==event.ENTER)
this.doSearch();},getFilter:function(){var filter=null;var filters=[];var nombre=null;nombre=this.panelNombre.nombreTextField.getValue();if(nombre!=null&&nombre.trim()!=""){var filter=this.filterManager.getComparisonFilter(OpenLayers.Filter.Comparison.LIKE,'nombre',"*"+nombre+"*",false);filters.push(filter);}
var provincia=null;provincia=this.panelDireccion.comboProvincias.getValue();if(provincia!=null&&provincia.trim()!=""&&provincia!='--- '+Locale.getText("txt_seleccionar")+' ---'){var filter=this.filterManager.getComparisonFilter(OpenLayers.Filter.Comparison.LIKE,'provincia',provincia,false);filters.push(filter);var municipio=null;municipio=this.panelDireccion.comboMunicipios.getValue();var filter=this.filterManager.getComparisonFilter(OpenLayers.Filter.Comparison.LIKE,'municipio','',false);if(municipio!=null&&municipio.trim()!=""&&municipio!='--- '+Locale.getText("txt_seleccionar")+' ---'){filter.value=municipio;}
else{filter.value='*';}
filters.push(filter);}
var direccion=null;direccion=this.panelDireccion.direccionTextField.getValue();if(direccion!=null&&direccion.trim()!=""){var filter=this.filterManager.getComparisonFilter(OpenLayers.Filter.Comparison.LIKE,'nomvia',"*"+direccion+"*",false);filters.push(filter);}
var centro=null;centro=this.panelCentro.comboCentros.getValue();if(centro!=null&&centro.trim()!=""&&centro!='--- '+Locale.getText("txt_seleccionar")+' ---'){var filter=this.filterManager.getComparisonFilter(OpenLayers.Filter.Comparison.EQUAL_TO,'tipo_centr',centro,true);filters.push(filter);}
filter=this.filterManager.getLogicalFilter(OpenLayers.Filter.Logical.AND,filters);return filter;},doSearch:function(){var filter=this.getFilter();this.gridResultWindow.show(this.layer,this.columns,filter);},show:function(){this.win.show();this.win.expand();this.panelNombre.nombreTextField.focus(false,700);},CLASS_NAME:"ExtSearchAtlas.Window.ASearch"});Ext.namespace("ExtWMS.Panel");ExtWMS.Panel.CapabilitiesPanel=Ext.extend(Ext.Panel,{title:Locale.getText("txt_mapas"),border:false,collapsed:true,iconCls:'contextCollectionPanel',autoScroll:true,ideol:null,wmsManager:new IDEOL.Manager.WMS(),selectedNode:null,tree:new Ext.tree.TreePanel({id:'treeCapabilitiesPanel',autoHeight:true,border:false,collapsible:true,collapsed:false,rootVisible:false,autoScroll:true,bodyStyle:'padding:5px 0 5px 0',root:{text:'Mapas',draggable:false,leaf:false},buttonAlign:'center'}),setIDEOL:function(ideol){this.ideol=ideol;},loadTree:function(wmsServer){var layers=this.wmsManager.getLayers(wmsServer);if(layers!=null){var root=new Ext.tree.TreeNode({text:Locale.getText("txt_mapas"),allowDrag:false,expanded:true,expandChildNodes:true,allowDrop:false,allowChildren:true,leaf:false,qtip:Locale.getText("txt_mapas")});this.tree.getRootNode().destroy();this.tree.setRootNode(root);for(var i=0;i<layers.length;i++){var layerNode=new Ext.tree.TreeNode({text:layers[i].title,allowDrag:false,expanded:false,expandChildNodes:false,allowDrop:false,allowChildren:false,leaf:true,iconCls:'layerNode',qtip:layers[i].title});root.appendChild(layerNode);}}},loadMap:function(){var selmodel=this.tree.getSelectionModel();var selectedNode=selmodel.getSelectedNode();if(selectedNode){this.ideol.load(selectedNode.attributes.url,selectedNode.text);}
else{IDEOL.UtilUI.showMessageWindow(Locale.getText("txt_error"),Locale.getText("msg_seleccionar_mapa_cargar"),Ext.MessageBox.ERROR);}},initComponent:function(){ExtWMS.Panel.CapabilitiesPanel.superclass.initComponent.call(this);this.on('render',function(panel){this.loadTree("http://services.iver.es/geoserver/wms");this.add(this.tree);},this);this.tree.on('click',function(node,event){if(this.selectedNode!=node){this.selectedNode=node;}},this);}});Ext.namespace("ExtStreetView.Window");ExtStreetView.Window.Window=new function(){this.streetViewPanorama=null;this.streetViewclient=null;this.panel=new Ext.Panel({height:375,width:500,layout:'fit',bodyCfg:{cls:'x-panel-body'}});this.panel.on("resize",function(panel,adjWidth,adjHeight,rawWidth,rawHeight){if(this.streetViewPanorama)
this.streetViewPanorama.checkResize();},this);this.win=new Ext.Window({layout:'fit',modal:false,title:'StreetView',constrain:true,maximizable:true,resizable:true,draggable:true,collapsible:false,closeAction:"hide",plain:true,border:false,items:[this.panel],buttons:[{text:Locale.getText("txt_cerrar"),scope:this,handler:function(){this.win.hide();}}]});this.createStreetViewPanorama=function(){this.streetViewPanorama=new GStreetviewPanorama(this.panel.body.dom,{zoom:0});};this.createStreetViewclient=function(){this.streetViewclient=new GStreetviewClient();};this.moveTo=function(lonlat,projection){if(this.streetViewclient!=null&&lonlat!=null){lonlat.transform(projection,new OpenLayers.Projection('EPSG:4326'));glonlat=new GLatLng(lonlat.lat,lonlat.lon);this.streetViewclient.getNearestPanoramaLatLng(glonlat,function(nearGlonlat){if((typeof nearGlonlat!='undefined')&&nearGlonlat!=null){var win=ExtStreetView.Window.Window.win;var streetViewPanorama=ExtStreetView.Window.Window.streetViewPanorama;if(!win.isVisible()){win.show();win.center();}
if(!streetViewPanorama){ExtStreetView.Window.Window.createStreetViewPanorama();ExtStreetView.Window.Window.streetViewPanorama.setLocationAndPOV(nearGlonlat);}
else
streetViewPanorama.setLocationAndPOV(nearGlonlat);}
else{IDEOL.UtilUI.showMessageWindow(Locale.getText("txt_informacion"),Locale.getText("msg_sin_imagen_streetview_ubicacion"),Ext.MessageBox.WARNING);}});}};this.show=function(lonlat,projection){if(!this.streetViewclient)
this.createStreetViewclient();this.moveTo(lonlat,projection);};};Ext.namespace("ExtExport.Window");ExtExport.Window.SaveFile=function(){this.ideol=null;this.contentFile=null;this.fileManager=new IDEOL.Manager.File();this.nameTextField=new Ext.form.TextField({xtype:'textfield',fieldLabel:Locale.getText("txt_nombre"),id:'name',name:'name',allowBlank:false,blankText:Locale.getText("msg_introducir_nombre"),enableKeyEvents:true,anchor:'95%'});this.nameTextField.on('keypress',function(object,event){if(event.getCharCode()==event.ENTER)
this.saveFile();},this);this.form=new Ext.FormPanel({width:300,frame:true,autoHeight:true,bodyStyle:'padding: 10px 10px 0 10px;',labelWidth:50,defaults:{anchor:'92%',allowBlank:false,msgTarget:'side'},items:[this.nameTextField]});this.win=new Ext.Window({layout:'fit',bodyStyle:'padding: 2px 2px 2px',modal:true,title:Locale.getText("txt_guardar_fichero"),id:'saveFileWin',constrainHeader:true,width:300,autoHeight:true,maximizable:false,resizable:false,draggable:true,closeAction:"hide",plain:true,border:false,items:[this.form],buttons:[{text:Locale.getText("txt_guardar"),scope:this,handler:function(){if(this.form.getForm().isValid()){this.saveFile();}}},{text:Locale.getText("txt_cerrar"),scope:this,handler:function(){this.win.hide();}}]});this.setIDEOL=function(ideol){this.ideol=ideol;};this.setContentFile=function(contentFile){this.contentFile=contentFile;},this.saveFile=function(){this.win.hide();this.ideol.mask.show();var values=this.form.getForm().getValues();var url=this.fileManager.saveFile(this.contentFile,values.name+".cml");this.ideol.mask.hide();if(url==null){IDEOL.UtilUI.showMessageWindow(Locale.getText("txt_informacion"),Locale.getText("msg_error_contactar_servicio"),Ext.MessageBox.ERROR);}
else{window.open(url);}};this.show=function(){this.form.getForm().reset();this.win.show();this.win.expand();this.nameTextField.focus('',10);};};Ext.namespace("ExtSearchAtlas.Panel.Agrupaciones");ExtSearchAtlas.Panel.Agrupaciones.Direccion=Ext.extend(Ext.FormPanel,{frame:true,title:Locale.getText("txt_direccion"),originalTitle:Locale.getText("txt_direccion"),autoWidth:true,height:95,buttonAlign:'center',labelWidth:70,layer:Config.ExtSearchAtlas.WFSLayers.MUNICIPIOS,mask:null,wfsManager:new IDEOL.Manager.WFS(),filterManager:new IDEOL.Manager.Filter(),direccionTextField:new Ext.form.TextField({fieldLabel:Locale.getText("txt_direccion"),name:'direccion',enableKeyEvents:true,anchor:'95%'}),storeMunicipios:new Ext.data.Store({reader:new Ext.data.JsonReader({},['nombre']),sortInfo:{field:'nombre',direction:'ASC'}}),storeProvincias:new Ext.data.SimpleStore({fields:['codigo','nombre'],data:[['00','--- '+Locale.getText("txt_seleccionar")+' ---'],['03','Alicante'],['12','Castellón'],['46','Valencia']]}),comboMunicipios:new Ext.form.ComboBox({displayField:'nombre',fieldLabel:Locale.getText("txt_municipio"),name:'municipio',mode:'local',triggerAction:'all',selectOnFocus:true,editable:false,anchor:'95%'}),comboProvincias:new Ext.form.ComboBox({displayField:'nombre',fieldLabel:Locale.getText("txt_provincia"),value:'--- '+Locale.getText("txt_seleccionar")+' ---',name:'nombre',mode:'local',typeAhead:true,forceSelection:true,triggerAction:'all',selectOnFocus:true,editable:false,anchor:'95%'}),keyEventHandler:function(object,event){this.updateTitleColor();},getMunicipios:function(wfsFeatures){var blankFeature={nombre:'--- '+Locale.getText("txt_seleccionar")+' ---'};var municipios=[blankFeature];for(i=0;i<wfsFeatures.length;i++){var municipio=wfsFeatures[i].data;municipios.push(municipio);}
return municipios;},onWFSQuerySuccess:function(wfsFeatures){var municipios=this.getMunicipios(wfsFeatures);this.loadComboMunicipios(municipios);this.mask.hide();},onWFSQueryFailure:function(response){this.mask.hide();IDEOL.UtilUI.showMessageWindow(Locale.getText("txt_informacion"),Locale.getText("msg_error_realizar_consulta"),Ext.MessageBox.ERROR);},loadComboMunicipios:function(municipios){this.storeMunicipios.loadData(municipios);},requestFeatures:function(codprov){this.mask.show();var attributes=this.storeMunicipios.fields.keys;var filter=this.filterManager.getComparisonFilter(OpenLayers.Filter.Comparison.EQUAL_TO,'codprov',codprov,false);this.wfsManager.getFeaturesByFilter(this.layer,attributes,filter,this.onWFSQuerySuccess,this.onWFSQueryFailure,this);},updateTitleColor:function(){var update=false;var provincia=this.comboProvincias.getValue();var municipio=this.comboMunicipios.getValue();var direccion=this.direccionTextField.getValue();if(provincia!=null&&provincia.trim()!=""&&provincia!='--- '+Locale.getText("txt_seleccionar")+' ---'){update=true;}
else if(direccion!=null&&direccion.trim()!=""){update=true;}
if(update){this.setTitle('<span style="color: green;">'+this.originalTitle+'</span>');}
else{this.setTitle(this.originalTitle);}},initialize:function(){this.on('render',function(panel){this.mask=new Ext.LoadMask(this.body);},this);this.comboProvincias.store=this.storeProvincias;this.comboMunicipios.store=this.storeMunicipios;this.comboProvincias.on('select',function(combo,record,index){this.storeMunicipios.removeAll();this.comboMunicipios.setValue("");this.updateTitleColor();if(record.data.codigo!='00'){this.requestFeatures(record.data.codigo);}},this);this.comboMunicipios.on('select',function(combo,record,index){this.updateTitleColor();},this);this.direccionTextField.on('keyup',function(object,event){this.keyEventHandler(object,event);},this);this.add(this.comboProvincias);this.add(this.comboMunicipios);this.add(this.direccionTextField);},initComponent:function(){ExtSearchAtlas.Panel.Agrupaciones.Direccion.superclass.initComponent.call(this);this.initialize();}});Ext.namespace("ExtSearchAtlas.Window");ExtSearchAtlas.Window.DataView=OpenLayers.Class({filterManager:new IDEOL.Manager.Filter(),WFSLAYERS_ESTABLECIMIENTOS:Config.ExtSearchAtlas.WFSLayers.ESTABLECIMIENTOS.name,WFSLAYERS_CONCENTRACIONES_COMERCIALES:Config.ExtSearchAtlas.WFSLayers.CONCENTRACIONES_COMERCIALES.name,WFSLAYERS_MUNICIPIOS:Config.ExtSearchAtlas.WFSLayers.MUNICIPIOS.name,WFSLAYERS_COMERCIOS_INNOVACION:Config.ExtSearchAtlas.WFSLayers.COMERCIOS_INNOVACION.name,WFSLAYERS_ANTENAS_LOCALES:Config.ExtSearchAtlas.WFSLayers.ANTENAS_LOCALES.name,WFSLAYERS_CAMARAS_COMERCIO:Config.ExtSearchAtlas.WFSLayers.CAMARAS_COMERCIO.name,TEMPLATE_DATAVIEW_PATH_ESTABLECIMIENTOS:Config.ExtSearchAtlas.TEMPLATE_DATAVIEW_PATH_ESTABLECIMIENTOS,TEMPLATE_DATAVIEW_PATH_AGRUPACIONES:Config.ExtSearchAtlas.TEMPLATE_DATAVIEW_PATH_AGRUPACIONES,TEMPLATE_DATAVIEW_PATH_CAMARAS:Config.ExtSearchAtlas.TEMPLATE_DATAVIEW_PATH_CAMARAS,TEMPLATE_DATAVIEW_PATH_ANTENAS:Config.ExtSearchAtlas.TEMPLATE_DATAVIEW_PATH_ANTENAS,TEMPLATE_DATAVIEW_PATH_MUNICIPIOS:Config.ExtSearchAtlas.TEMPLATE_DATAVIEW_PATH_MUNICIPIOS,TEMPLATE_DATAVIEW_PATH_COMERCIOS:Config.ExtSearchAtlas.TEMPLATE_DATAVIEW_PATH_COMERCIOS,storeConcentraciones:new Ext.data.Store({reader:new Ext.data.JsonReader({},['id','empresa','sector','nombre','numpol','ciudad','provincia','web','pdf','the_geom'])}),storeEstablecimientos:new Ext.data.Store({reader:new Ext.data.JsonReader({},['id','rotulo','sigla','nomcall','numpol','km','cp','provincia','municipio','nom_agrup','num_local','dactividad','tipo_patec','long_fach','refcat','foto1','foto2','the_geom'])}),storeAgrupaciones:new Ext.data.Store({reader:new Ext.data.JsonReader({},['id','nombre','sigla','nomvia','numpol','km','cp','municipio','provincia','tipo_centr','directorio','plant_tota','aparcamien','pl_ap_tot','pl_ap_int','pl_ap_ext','foto1','foto2','the_geom'])}),storeCamaras:new Ext.data.Store({reader:new Ext.data.JsonReader({},['nombre','direccion','codpostal','provincia','municipio','email','web','the_geom'])}),storeAntenas:new Ext.data.Store({reader:new Ext.data.JsonReader({},['nom_antena','perso_cont','direccion','cp','municipio','provincia','telefono','horario','the_geom'])}),storeMunicipios:new Ext.data.Store({reader:new Ext.data.JsonReader({},['nombre','ine','the_geom'])}),storeComercios:new Ext.data.Store({reader:new Ext.data.JsonReader({},['id','empresa','sector','nombre','numpol','ciudad','provincia','web','pdf','the_geom'])}),tplEstablecimientos:null,tplAgrupaciones:null,tplCamaras:null,tplAntenas:null,tplMunicipios:null,tplComercios:null,layer:null,map:null,wfsManager:null,drawManager:null,wktFormat:null,establecimientosManager:null,mask:null,arrayData:null,fichaWindow:null,streetViewWindow:null,dataView:null,panel:null,win:null,streetViewButton:null,buscarButton:null,fichaButton:null,cerrarButton:null,initialize:function(map){this.createComponents(map);this.prepareComponents();this.prepareTemplates();},createComponents:function(map){this.map=map;this.wfsManager=new IDEOL.Manager.WFS();this.drawManager=IDEOL.Manager.Draw.getInstance();this.wktFormat=new OpenLayers.Format.WKT();this.establecimientosManager=new ExtSearchAtlas.Manager.Establecimientos(this.map);this.fichaWindow=new IDEOL.Tool.HTMLTemplateView();this.streetViewWindow=ExtStreetView.Window.Window;this.dataView=new Ext.DataView({autoWidth:true,autoHeight:true,singleSelect:true,multiSelect:false,overClass:'x-view-over',itemSelector:'div.search-item',emptyText:'No items to display'});this.panel=new Ext.Panel({id:'ea-view',layout:'fit',frame:true,width:450,height:250,autoScroll:true});this.win=new Ext.Window({layout:'fit',bodyStyle:'padding: 2px 2px 2px',modal:false,title:Locale.getText("txt_informacion"),titleCollapse:true,constrainHeader:true,maximizable:false,resizable:false,draggable:true,collapsible:true,closeAction:"hide",plain:true,border:false});},prepareComponents:function(){this.panel.add(this.dataView);this.win.add(this.panel);this.fichaButton=this.win.addButton({text:Locale.getText("txt_ficha")},function(){this.requestShowFicha();},this);this.streetViewButton=this.win.addButton({text:Locale.getText("txt_streetview")},function(){this.showStreetView();},this);this.buscarButton=this.win.addButton({text:Locale.getText("txt_localizar")},function(){this.locateElement();},this);this.cerrarButton=this.win.addButton({text:Locale.getText("txt_cerrar")},function(){this.win.hide();},this);},prepareTemplates:function(){var tplMunicipiosContent=this.getTplContent(this.TEMPLATE_DATAVIEW_PATH_MUNICIPIOS);this.tplMunicipios=new Ext.XTemplate(tplMunicipiosContent);var tplAntenasContent=this.getTplContent(this.TEMPLATE_DATAVIEW_PATH_ANTENAS);this.tplAntenas=new Ext.XTemplate(tplAntenasContent);var tplCamarasContent=this.getTplContent(this.TEMPLATE_DATAVIEW_PATH_CAMARAS);this.tplCamaras=new Ext.XTemplate(tplCamarasContent);var tplAgrupacionesContent=this.getTplContent(this.TEMPLATE_DATAVIEW_PATH_AGRUPACIONES);this.tplAgrupaciones=new Ext.XTemplate(tplAgrupacionesContent);var tplEstablecimientosContent=this.getTplContent(this.TEMPLATE_DATAVIEW_PATH_ESTABLECIMIENTOS);this.tplEstablecimientos=new Ext.XTemplate(tplEstablecimientosContent);var tplComerciosContent=this.getTplContent(this.TEMPLATE_DATAVIEW_PATH_COMERCIOS);this.tplComercios=new Ext.XTemplate(tplComerciosContent);},getTplContent:function(contentURL){var content;var request=OpenLayers.Request.GET({url:contentURL,success:function(response){content=response.responseText;},failure:function(response){content=null;},async:false});return content;},getGeometryFromRecord:function(record){var geometryWKT=record.get("the_geom");var geometry=this.wktFormat.read(geometryWKT);return geometry;},showStreetView:function(){var cont=this.dataView.store.getCount();var records=this.dataView.getSelectedRecords();var record=records[0];if(record==null&&cont>1)
{IDEOL.UtilUI.showMessageWindow(Locale.getText("txt_informacion"),Locale.getText("msg_seleccionar_registro_para_street_view"),Ext.MessageBox.WARNING);}
else
{if(cont==1)
record=this.dataView.store.getAt(0);var geom=this.getGeometryFromRecord(record);var bounds=geom.geometry.getBounds();var lonlat=bounds.getCenterLonLat();this.streetViewWindow.show(lonlat,this.layer.projection);};},onEstablecimientosWFSQuerySuccess:function(establecimientos){this.mask.hide();this.agrupacion.data.establecimientos=[];if(establecimientos.length>0){this.agrupacion.data.establecimientos=establecimientos;}
this.fichaWindow.show(this.layer.name,this.agrupacion,Config.ExtSearchAtlas.TEMPLATE_PATH_AGRUPACIONES);},requestEstablecimientosForAgrupacion:function(idagrupacion){this.mask.show();var attributes=['rotulo','dactividad'];var filter=this.filterManager.getComparisonFilter(OpenLayers.Filter.Comparison.EQUAL_TO,'cod_agrup',idagrupacion,true);this.establecimientosManager.getEstablecimientos(attributes,filter,this.onEstablecimientosWFSQuerySuccess,this.onWFSQueryFailure,this);},onCompleteFeatureWFSQuerySuccess:function(wfsFeatures){var completeFeature=null;this.mask.hide();if(wfsFeatures.length>0){completeFeature=wfsFeatures[0];var layerName=this.layer.name;if(layerName==this.WFSLAYERS_CONCENTRACIONES_COMERCIALES){this.agrupacion=completeFeature;this.requestEstablecimientosForAgrupacion(this.agrupacion.data.id);}
else if(layerName==this.WFSLAYERS_ESTABLECIMIENTOS){this.fichaWindow.show(this.layer.name,completeFeature,Config.ExtSearchAtlas.TEMPLATE_PATH_ESTABLECIMIENTOS);}
else
this.fichaWindow.show(this.layer.name,completeFeature,Config.ExtSearchAtlas.TEMPLATE_PATH_MUNICIPIOS);}},requestCompleteFeature:function(id,value){this.mask.show();var attributes="";var filter=this.filterManager.getComparisonFilter(OpenLayers.Filter.Comparison.EQUAL_TO,id,value,true);this.wfsManager.getFeaturesByFilter(this.layer,attributes,filter,this.onCompleteFeatureWFSQuerySuccess,this.onWFSQueryFailure,this);},requestShowFicha:function(){var cont=this.dataView.store.getCount();var records=this.dataView.getSelectedRecords();var record=records[0];if(record==null&&cont>1)
{IDEOL.UtilUI.showMessageWindow(Locale.getText("txt_informacion"),Locale.getText("msg_seleccionar_registro_para_ficha"),Ext.MessageBox.WARNING);}
else
{if(cont==1)
record=this.dataView.store.getAt(0);if(this.dataView.store.id==2){this.requestCompleteFeature("ine",record.get("ine"));}
else
this.requestCompleteFeature("id",record.get("id"));}},locateElement:function(){var cont=this.dataView.store.getCount();var records=this.dataView.getSelectedRecords();var record=records[0];if(record==null&&cont>1)
{IDEOL.UtilUI.showMessageWindow(Locale.getText("txt_informacion"),Locale.getText("msg_seleccionar_elemento_localizar"),Ext.MessageBox.WARNING);}
else
{if(cont==1)
record=this.dataView.store.getAt(0);var geom=this.getGeometryFromRecord(record);var bounds=geom.geometry.getBounds();var lonlat=bounds.getCenterLonLat();this.drawManager.drawMarker(lonlat,this.layer.projection.getCode(),true,true);};},getPreparedFeatures:function(wfsFeatures){var features=[];for(i=0;i<wfsFeatures.length;i++){var feature=wfsFeatures[i].data;feature.the_geom=wfsFeatures[i].geometry;features.push(feature);}
return features;},onWFSBBoxQuerySuccess:function(wfsFeatures){this.showResults(wfsFeatures);this.mask.hide();},onWFSBBoxQueryFailure:function(response){this.mask.hide();IDEOL.UtilUI.showMessageWindow(Locale.getText("txt_informacion"),Locale.getText("msg_error_realizar_consulta_bbox"),Ext.MessageBox.ERROR);},showResults:function(wfsFeatures){var store;var tpl;var features=this.getPreparedFeatures(wfsFeatures);if(this.layer.name==this.WFSLAYERS_ESTABLECIMIENTOS){tpl=this.tplEstablecimientos;store=this.storeEstablecimientos;store.id=0;this.fichaButton.show();this.buscarButton.show();this.streetViewButton.show();}
else if(this.layer.name==this.WFSLAYERS_CONCENTRACIONES_COMERCIALES){tpl=this.tplAgrupaciones;store=this.storeAgrupaciones;store.id=1;this.fichaButton.show();this.buscarButton.show();this.streetViewButton.show();}
else if(this.layer.name==this.WFSLAYERS_CAMARAS_COMERCIO){tpl=this.tplCamaras;store=this.storeCamaras;this.fichaButton.hide();this.buscarButton.show();this.streetViewButton.show();}
else if(this.layer.name==this.WFSLAYERS_ANTENAS_LOCALES){tpl=this.tplAntenas;store=this.storeAntenas;this.fichaButton.hide();this.buscarButton.show();this.streetViewButton.show();}
else if(this.layer.name==this.WFSLAYERS_MUNICIPIOS){tpl=this.tplMunicipios;store=this.storeMunicipios;store.id=2;this.fichaButton.show();this.buscarButton.hide();this.streetViewButton.hide();}
else if(this.layer.name==this.WFSLAYERS_COMERCIOS_INNOVACION){tpl=this.tplComercios;store=this.storeComercios;this.fichaButton.hide();this.buscarButton.show();this.streetViewButton.show();}
store.removeAll();store.loadData(features);this.dataView.tpl=tpl;this.dataView.setStore(store);},doSearch:function(){if(this.dataView.store!=null)
this.dataView.store.removeAll();this.mask.show();this.wfsManager.getFeaturesByBBOX(this.layer,this.bounds,this.onWFSBBoxQuerySuccess,this.onWFSBBoxQueryFailure,this);},show:function(layer,bounds){if(layer&&bounds){this.layer=layer;this.win.setTitle(Locale.getText("txt_informacion")+" - "+this.layer.name);this.bounds=bounds;this.showWindow();this.mask=new Ext.LoadMask(this.panel.body);this.doSearch();}},showWindow:function(){this.win.show();this.win.expand();},setFichaType:function(param){}});Ext.namespace("ExtSearchAtlas.Window");ExtSearchAtlas.Window.ESearch=OpenLayers.Class({layer:Config.ExtSearchAtlas.WFSLayers.ESTABLECIMIENTOS,wfsManager:new IDEOL.Manager.WFS(),filterManager:new IDEOL.Manager.Filter(),tabPanel:null,columns:Config.ExtSearchAtlas.Columns.ESTABLECIMIENTOS,panelNombre:null,panelDireccion:null,panelActividad:null,panelAgrupacion:null,buscarButton:new Ext.Button({text:Locale.getText("txt_buscar")}),cerrarButton:new Ext.Button({text:Locale.getText("txt_cerrar")}),win:null,gridResultWindow:null,initialize:function(options){OpenLayers.Util.extend(this,options);this.createComponents();this.prepareComponents();},createComponents:function(){this.wfsManager=new IDEOL.Manager.WFS();this.establecimientosManager=new ExtSearchAtlas.Manager.Establecimientos();this.tabPanel=new ExtSearchAtlas.Panel.Establecimientos.Tab();this.panelNombre=new ExtSearchAtlas.Panel.Establecimientos.Nombre();this.panelDireccion=new ExtSearchAtlas.Panel.Establecimientos.Direccion();this.panelActividad=new ExtSearchAtlas.Panel.Establecimientos.Actividad();this.panelAgrupacion=new ExtSearchAtlas.Panel.Establecimientos.Agrupacion();this.win=new Ext.Window({layout:'fit',bodyStyle:'padding: 2px 2px 2px',modal:false,title:Locale.getText("msg_busqueda_establecimientos"),titleCollapse:true,constrainHeader:true,width:340,autoHeight:true,expandOnShow:true,maximizable:false,collapsible:true,resizable:false,draggable:true,closeAction:"hide",plain:true,border:false,items:[this.tabPanel],buttons:[this.buscarButton,this.cerrarButton]});},prepareComponents:function(){this.tabPanel.add(this.panelNombre);this.tabPanel.add(this.panelDireccion);this.tabPanel.add(this.panelActividad);this.tabPanel.add(this.panelAgrupacion);this.panelNombre.nombreTextField.on('keypress',function(object,event){this.keyEventHandler(object,event);},this);this.panelDireccion.direccionTextField.on('keypress',function(object,event){this.keyEventHandler(object,event);},this);this.buscarButton.on('click',function(){this.doSearch();},this);this.cerrarButton.on('click',function(){this.win.hide();},this);},keyEventHandler:function(object,event){if(event.getCharCode()==event.ENTER)
this.doSearch();},getFilter:function(){var filter=null;var filters=[];var rotulo=null;rotulo=this.panelNombre.nombreTextField.getValue();if(rotulo!=null&&rotulo.trim()!=""){var filter=this.filterManager.getComparisonFilter(OpenLayers.Filter.Comparison.LIKE,'rotulo',"*"+rotulo+"*",false);filters.push(filter);}
var provincia=null;provincia=this.panelDireccion.comboProvincias.getValue();if(provincia!=null&&provincia.trim()!=""&&provincia!='--- '+Locale.getText("txt_seleccionar")+' ---'){var filter=this.filterManager.getComparisonFilter(OpenLayers.Filter.Comparison.LIKE,'provincia',provincia,false);filters.push(filter);var municipio=null;municipio=this.panelDireccion.comboMunicipios.getValue();var filter=this.filterManager.getComparisonFilter(OpenLayers.Filter.Comparison.LIKE,'municipio','',false);if(municipio!=null&&municipio.trim()!=""&&municipio!='--- '+Locale.getText("txt_seleccionar")+' ---'){filter.value=municipio;}
else{filter.value='*';}
filters.push(filter);}
var direccion=null;direccion=this.panelDireccion.direccionTextField.getValue();if(direccion!=null&&direccion.trim()!=""){var filter=this.filterManager.getComparisonFilter(OpenLayers.Filter.Comparison.LIKE,'nomcall',"*"+direccion+"*",false);filters.push(filter);}
var actividad=null;actividad=this.panelActividad.comboActividades.getValue();if(actividad!=null&&actividad.trim()!=""&&actividad!='--- '+Locale.getText("txt_seleccionar")+' ---'){var filter=this.filterManager.getComparisonFilter(OpenLayers.Filter.Comparison.EQUAL_TO,'dactividad',actividad,false);filters.push(filter);}
var agrupacion=null;agrupacion=this.panelAgrupacion.comboAgrupaciones.getValue();if(agrupacion!=null&&agrupacion.trim()!=""&&agrupacion!='--- '+Locale.getText("txt_seleccionar")+' ---'){var filter=this.filterManager.getComparisonFilter(OpenLayers.Filter.Comparison.EQUAL_TO,'nom_agrup',agrupacion,false);filters.push(filter);}
filter=this.filterManager.getLogicalFilter(OpenLayers.Filter.Logical.AND,filters);return filter;},doSearch:function(){var filter=this.getFilter();this.gridResultWindow.show(this.layer,this.columns,filter);},show:function(){this.win.show();this.win.expand();this.panelNombre.nombreTextField.focus(false,700);},CLASS_NAME:"ExtSearchAtlas.Window.ESearch"});Ext.namespace("ExtExport.Panel");ExtExport.Panel.InfoReport=Ext.extend(Ext.FormPanel,{frame:true,bodyStyle:'padding: 2px 2px 2px 2px',autoHeight:true,autoWidth:true,buttonAlign:'center',labelAlign:'top',comboSize:new Ext.form.ComboBox({displayField:'size',fieldLabel:Locale.getText("txt_tamanyo"),name:'size',mode:'local',store:new Ext.data.SimpleStore({fields:['size'],data:[['A4'],['A3']]}),value:'A4',typeAhead:true,forceSelection:true,triggerAction:'all',allowBlank:false,selectOnFocus:true,editable:false,anchor:'30%'}),tituloTextField:new Ext.form.TextField({fieldLabel:Locale.getText("txt_titulo"),anchor:'100%',enableKeyEvents:true,allowBlank:false}),descripcionTextArea:new Ext.form.TextArea({fieldLabel:Locale.getText("txt_descripcion"),anchor:'100%',enableKeyEvents:true}),initComponent:function(){ExtExport.Panel.InfoReport.superclass.initComponent.call(this);this.prepareComponents();},prepareComponents:function(){this.add(this.tituloTextField);this.add(this.descripcionTextArea);this.add(this.comboSize);}});Ext.namespace("ExtSearchAtlas.Button");ExtSearchAtlas.Button.ASearch=Ext.extend(Ext.Toolbar.Button,{iconCls:'ExtSearchAtlas_Button_ASearch_Icon',tooltip:Locale.getText("msg_busqueda_concentraciones"),initComponent:function(){ExtSearchAtlas.Button.ASearch.superclass.initComponent.call(this);}});Ext.namespace("ExtSearchAtlas.Panel.Establecimientos");ExtSearchAtlas.Panel.Establecimientos.Agrupacion=Ext.extend(Ext.FormPanel,{frame:true,title:Locale.getText("txt_agrupacion"),originalTitle:Locale.getText("txt_agrupacion"),autoWidth:true,height:95,buttonAlign:'center',labelWidth:70,layer:Config.ExtSearchAtlas.WFSLayers.ESTABLECIMIENTOS,mask:null,wfsManager:new IDEOL.Manager.WFS(),filterManager:new IDEOL.Manager.Filter(),storeAgrupaciones:new Ext.data.Store({reader:new Ext.data.JsonReader({id:'nom_agrup'},['nom_agrup']),sortInfo:{field:'nom_agrup',direction:'ASC'}}),comboAgrupaciones:new Ext.form.ComboBox({displayField:'nom_agrup',valueField:'nom_agrup',fieldLabel:Locale.getText("txt_agrupacion"),name:'agrupacion',mode:'local',typeAhead:false,triggerAction:'all',selectOnFocus:true,editable:false,anchor:'95%'}),getAgrupaciones:function(wfsFeatures){var blankFeature={nom_agrup:'--- '+Locale.getText("txt_seleccionar")+' ---'};var agrupaciones=[blankFeature];for(i=0;i<wfsFeatures.length;i++){var agrupacion=wfsFeatures[i].data;agrupaciones.push(agrupacion);}
return agrupaciones;},onWFSQuerySuccess:function(wfsFeatures){var agrupaciones=this.getAgrupaciones(wfsFeatures);this.loadCombo(agrupaciones);this.mask.hide();},onWFSQueryFailure:function(response){this.mask.hide();IDEOL.UtilUI.showMessageWindow(Locale.getText("txt_informacion"),Locale.getText("msg_error_realizar_consulta"),Ext.MessageBox.ERROR);},loadCombo:function(agrupaciones){this.storeAgrupaciones.loadData(agrupaciones);},requestFeatures:function(){this.mask.show();var attributes=this.storeAgrupaciones.fields.keys;var filter=this.filterManager.getComparisonFilter(OpenLayers.Filter.Comparison.LIKE,'nom_agrup','*',false);this.wfsManager.getFeaturesByFilter(this.layer,attributes,filter,this.onWFSQuerySuccess,this.onWFSQueryFailure,this);},initialize:function(){this.comboAgrupaciones.store=this.storeAgrupaciones;this.add(this.comboAgrupaciones);this.on('render',function(panel){this.mask=new Ext.LoadMask(this.body);},this);this.on('afterrender',function(panel){this.requestFeatures();},this);this.comboAgrupaciones.on('select',function(combo,record,index){if(record.data.nom_agrup!='--- '+Locale.getText("txt_seleccionar")+' ---'){this.setTitle('<span style="color: green;">'+this.originalTitle+'</span>');}
else{this.setTitle(this.originalTitle);}},this);},initComponent:function(){ExtSearchAtlas.Panel.Establecimientos.Agrupacion.superclass.initComponent.call(this);this.initialize();}});Ext.namespace("ExtExport.Button.ExportMenu");ExtExport.Button.ExportMenu=Ext.extend(Ext.Toolbar.Button,{iconCls:'exportIcon',tooltip:{title:Locale.getText("txt_exportar_importar"),text:Locale.getText("msg_exportar_importar")},ideol:null,saveFileWindow:null,uploadFileWindow:null,infoReportWindow:null,wmcManager:new IDEOL.Manager.WMC(),printerManager:new IDEOL.Manager.Print.Print(),menu:new Ext.menu.Menu(),contextMenu:new Ext.menu.Menu(),menuContextItem:new Ext.menu.Item({text:Locale.getText('txt_wmc'),iconCls:'importWMC'}),importContextItem:new Ext.menu.Item({text:Locale.getText('txt_importar'),iconCls:'importWMC'}),exportContextItem:new Ext.menu.Item({text:Locale.getText('txt_exportar'),iconCls:'exportWMC'}),exportImageItem:new Ext.menu.Item({text:Locale.getText('txt_exportar_imagen'),iconCls:'exportImage'}),exportPdfItem:new Ext.menu.Item({text:Locale.getText('txt_exportar_pdf'),iconCls:'exportPDF'}),initComponent:function(){ExtExport.Button.ExportMenu.superclass.initComponent.call(this);this.createComponents();this.prepareComponents();},createComponents:function(){this.saveFileWindow=new ExtExport.Window.SaveFile();this.uploadFileWindow=new ExtExport.Window.UploadFile();this.infoReportWindow=new ExtExport.Window.InfoReport();},setIDEOL:function(ideol){this.ideol=ideol;this.saveFileWindow.setIDEOL(this.ideol);this.uploadFileWindow.setIDEOL(this.ideol);this.infoReportWindow.setMap(this.ideol.map);},prepareComponents:function(){this.importContextItem.on('click',function(object,event){this.menu.hide();this.importContext();},this);this.exportContextItem.on('click',function(object,event){this.menu.hide();this.exportContext();},this);this.exportImageItem.on('click',function(object,event){this.menu.hide();this.exportImage();},this);this.exportPdfItem.on('click',function(object,event){this.menu.hide();if(Config.ExtExport.REPORT_DETAIL)
this.exportDetailReport();else
this.exportPdf();},this);this.contextMenu.add(this.importContextItem);this.contextMenu.add(this.exportContextItem);this.menuContextItem.menu=this.contextMenu;this.menu.add(this.menuContextItem);this.menu.add(this.exportImageItem);this.menu.add(this.exportPdfItem);},importContext:function(){this.uploadFileWindow.show();},exportContext:function(){var wmcString=this.wmcManager.getWMCStringMap(this.ideol.map);this.saveFileWindow.setContentFile(wmcString);this.saveFileWindow.show();},onPrintReportImageSuccess:function(fileURL){this.ideol.mask.hide();window.open(fileURL);},onPrintReportFailure:function(){this.ideol.mask.hide();IDEOL.UtilUI.showMessageWindow(Locale.getText("txt_informacion"),Locale.getText("msg_error_preparar_documento"),Ext.MessageBox.ERROR);},exportImage:function(){var loadMessage=Locale.getText("msg_preparando_imagen")+" ...";this.ideol.mask.show(loadMessage);var printRequest=new IDEOL.Manager.Print.PrintRequest();printRequest.project=Config.ExtExport.REPORT_NAME;printRequest.mapWMC=this.wmcManager.getWMCStringMap(this.ideol.map);printRequest.image=true;this.printerManager.printReport(printRequest,this.onPrintReportImageSuccess,this.onPrintReportFailure,this);},onPrintReportSuccess:function(fileURL){this.ideol.mask.hide();window.open(fileURL);},exportPdf:function(){var loadMessage=Locale.getText("msg_preparando_documento")+" ..."
this.ideol.mask.show(loadMessage);var printRequest=new IDEOL.Manager.Print.PrintRequest();printRequest.project=Config.ExtExport.REPORT_NAME;printRequest.mapWMC=this.wmcManager.getWMCStringMap(this.ideol.map);this.printerManager.printReport(printRequest,this.onPrintReportSuccess,this.onPrintReportFailure,this);},exportDetailReport:function(){this.infoReportWindow.show();}});Ext.namespace("ExtWMS.Button");ExtWMS.Button.Info=Ext.extend(Ext.Toolbar.Button,{iconCls:'infoWMS',tooltip:{title:Locale.getText("txt_informacion_wms"),text:Locale.getText("msg_informacion_wms_desc")},toggleGroup:'map',initComponent:function(){ExtWMS.Button.Info.superclass.initComponent.call(this);}});Ext.namespace("ExtSearchAtlas.Panel.Agrupaciones");ExtSearchAtlas.Panel.Agrupaciones.Tab=Ext.extend(Ext.TabPanel,{activeTab:0,border:false,autoHeight:true,initComponent:function(){ExtSearchAtlas.Panel.Agrupaciones.Tab.superclass.initComponent.call(this);}});Ext.namespace("ExtSearchAtlas.Manager");ExtSearchAtlas.Manager.Establecimientos=OpenLayers.Class({layer:Config.ExtSearchAtlas.WFSLayers.ESTABLECIMIENTOS,wfsManager:new IDEOL.Manager.WFS(),initialize:function(){},getEstablecimientos:function(attributes,filter,success,failure,scope){this.wfsManager.getFeaturesByFilter(this.layer,attributes,filter,function(wfsFeatures){var establecimientos=this.getPreparedEstablecimientos(wfsFeatures);success.apply(scope,[establecimientos]);},function(response){failure.apply(scope,[response]);},this);},getPreparedEstablecimientos:function(wfsFeatures){var establecimientos=[];for(i=0;i<wfsFeatures.length;i++){var establecimiento=wfsFeatures[i].data;establecimientos.push(establecimiento);}
return establecimientos;},CLASS_NAME:"ExtSearchAtlas.Manager.Establecimientos"});Ext.namespace("ExtMoveToLonLat.Window");ExtMoveToLonLat.Window.Projection=function(){this.drawManager=IDEOL.Manager.Draw.getInstance(),this.storeProjections=new Ext.data.SimpleStore({fields:['desc','projection'],data:[['EPSG:23030 (UTM30N)','EPSG:23030'],['EPSG:4326 (Lat-Long)','EPSG:4326']]}),this.comboProjections=new Ext.form.ComboBox({width:125,store:this.storeProjections,displayField:'desc',valueField:'projection',fieldLabel:Locale.getText("txt_proyeccion"),name:'nombre',mode:'local',typeAhead:false,triggerAction:'all',allowBlank:false,selectOnFocus:true,editable:false,anchor:'95%'}),this.comboProjections.on('beforerender',function(combo){this.comboProjections.setValue('EPSG:23030');},this);this.longitudTextField=new Ext.form.NumberField({fieldLabel:'X / '+Locale.getText("txt_longitud"),name:'longitud',allowBlank:false,allowDecimals:true,decimalPrecision:7,allowNegative:true,enableKeyEvents:true,anchor:'95%'});this.latitudTextField=new Ext.form.NumberField({fieldLabel:'Y / '+Locale.getText("txt_latitud"),name:'latitud',allowBlank:false,allowDecimals:true,decimalPrecision:7,allowNegative:true,enableKeyEvents:true,anchor:'95%'});this.latitudTextField.on('keypress',function(object,event){if(event.getCharCode()==event.ENTER)
this.moveToLonLat();},this);this.form=new Ext.FormPanel({width:300,frame:true,autoHeight:true,bodyStyle:'padding: 2px 2px 0 2px;',items:[this.comboProjections,this.longitudTextField,this.latitudTextField]});this.win=new Ext.Window({layout:'fit',bodyStyle:'padding: 2px 2px 2px',modal:false,title:Locale.getText("msg_centrado_coordenadas"),constrainHeader:true,width:300,autoHeight:true,maximizable:false,resizable:false,draggable:true,closeAction:"hide",plain:true,border:false,items:[this.form],buttons:[{text:Locale.getText("txt_centrar"),scope:this,handler:function(){this.moveToLonLat();}},{text:Locale.getText("txt_cerrar"),scope:this,handler:function(){this.win.hide();}}]});this.moveToLonLat=function(){if(this.form.getForm().isValid()){var longitud=this.longitudTextField.getValue();var latitud=this.latitudTextField.getValue();var srs=this.comboProjections.getValue();var lonlat=new OpenLayers.LonLat(longitud,latitud);this.drawManager.drawMarker(lonlat,srs,true,true);}};this.show=function(){this.form.getForm().reset();this.win.show();this.win.expand();this.longitudTextField.focus('',10);};};Ext.namespace("ExtMunicipios.Panel");ExtMunicipios.Panel.Search=Ext.extend(Ext.Panel,{title:Locale.getText('txt_municipios'),border:false,layout:'fit',iconCls:'municipiosClient',layer:Config.ExtMunicipios.WFSLayers.MUNICIPIOS,drawManager:IDEOL.Manager.Draw.getInstance(),wfsManager:new IDEOL.Manager.WFS(),filterManager:new IDEOL.Manager.Filter(),selectedMunicipio:null,mask:null,map:null,storeMunicipios:new Ext.data.Store({reader:new Ext.data.JsonReader({},[Config.ExtMunicipios.MUNICIPIO_FIELD_NAME,Config.ExtMunicipios.MUNICIPIO_FIELD_GEOM]),sortInfo:{field:Config.ExtMunicipios.MUNICIPIO_FIELD_NAME,direction:'ASC'}}),storeProvincias:new Ext.data.SimpleStore({fields:['codigo','nombre'],data:Config.ExtMunicipios.PROVINCIAS}),comboMunicipios:new Ext.form.ComboBox({displayField:Config.ExtMunicipios.MUNICIPIO_FIELD_NAME,fieldLabel:Locale.getText("txt_municipio"),name:'nombre',mode:'local',typeAhead:false,triggerAction:'all',allowBlank:false,selectOnFocus:true,editable:false,anchor:'100%'}),comboProvincias:new Ext.form.ComboBox({displayField:'nombre',fieldLabel:Locale.getText("txt_provincia"),name:'nombre',mode:'local',typeAhead:true,forceSelection:true,triggerAction:'all',allowBlank:false,selectOnFocus:true,editable:false,anchor:'100%'}),form:new Ext.form.FormPanel({autoHeight:true,labelAlign:'top',frame:true,bodyStyle:'padding:5px 5px 0',buttonAlign:'center',defaultButton:0}),initComponent:function(){ExtMunicipios.Panel.Search.superclass.initComponent.call(this);this.initialize();},initialize:function(){this.on('render',function(panel){this.mask=new Ext.LoadMask(this.body);},this);this.form.add(this.comboProvincias);this.form.add(this.comboMunicipios);this.form.addButton({text:Locale.getText("txt_localizar")},function(button,event){this.locate();},this);this.add(this.form);this.comboMunicipios.store=this.storeMunicipios;this.comboMunicipios.store.on('load',function(comboBox){if(this.comboMunicipios.list){this.comboMunicipios.list.setWidth('auto');this.comboMunicipios.innerList.setWidth('auto');}},this);this.comboMunicipios.on('select',function(comboBox,record,index){this.selectedMunicipio=this.comboMunicipios.store.getAt(index);},this);this.comboProvincias.store=this.storeProvincias;this.comboProvincias.on('select',function(combo,record,index){this.storeMunicipios.removeAll();this.comboMunicipios.setValue("");this.requestFeatures(record.data.codigo);},this);},locate:function(){if(this.selectedMunicipio!=null){var geometryWKT=this.selectedMunicipio.get(Config.ExtMunicipios.MUNICIPIO_FIELD_GEOM);var WKTFormat=new OpenLayers.Format.WKT();var feature=WKTFormat.read(geometryWKT);this.drawManager.drawObjects([feature],this.layer.projection.getCode(),true,true);}},getMunicipios:function(wfsFeatures){var municipios=[];for(i=0;i<wfsFeatures.length;i++){var municipio=wfsFeatures[i].data;municipio.the_geom=wfsFeatures[i].geometry;municipios.push(municipio);}
return municipios;},onWFSQuerySuccess:function(wfsFeatures){var municipios=this.getMunicipios(wfsFeatures);this.loadCombo(municipios);this.mask.hide();},onWFSQueryFailure:function(response){this.mask.hide();IDEOL.UtilUI.showMessageWindow(Locale.getText("txt_informacion"),Locale.getText("msg_error_realizar_consulta"),Ext.MessageBox.ERROR);},loadCombo:function(actividades){this.storeMunicipios.loadData(actividades);},requestFeatures:function(codprov){this.mask.show();var attributes=this.storeMunicipios.fields.keys;var filter=this.filterManager.getComparisonFilter(OpenLayers.Filter.Comparison.EQUAL_TO,Config.ExtMunicipios.MUNICIPIO_FIELD_IDPROVINCIA,codprov,false);this.wfsManager.getFeaturesByFilter(this.layer,attributes,filter,this.onWFSQuerySuccess,this.onWFSQueryFailure,this);}});
