OpenLayers.Util.extend(OpenLayers.Lang.de,{'Overview Map':'Übersichtkarte','Coordinates (m): ':'Koordinaten (m): ','Layer Tree':'Themen','Map Queries':'Suchen','Print':'Drucken','Background':'Hintergrund','Nationales Maps':'Landeskarte','Aerial Images':'Swissimage','None':'Keine','Gemeinde':'Gemeinde','Bezirk':'Bezirk','Kanton':'Kantone','Schweiz':'Schweiz','Measure':'Messgeräte','Pan':'','Distance measurement (double-click to terminate)':'Entfernungmessgeräte (Doppelklick zu beenden)','Area measurement (double-click to terminate)':'Flächenmessgeräte (Doppelklick zu beenden)','zoomin':'Hinneinzoomen','zoomout':'Herauszoomen','Full extent':'Zum Start','Next view':'Vorwärts','Previous view':'Rückwärts','Save context':'Context speichern','Locate by coordinates':'','Locate':''});OpenLayers.Util.extend(OpenLayers.Lang.en,{'Coordinates (m): ':'','Full extent':'','zoomout':'Zoom out','zoomin':'Zoom in','Koordinaten (m): ':'','Seuche id':'','Seuchen grouppe':'Group','Seuche':'','Datum':'Date','Background':'','Nationales Maps':'','Aerial Images':'','None':'','Communes':'','District':'','Cantons':'','Land':'Countries','Locate by coordinates':'Recenter on Coordinates','Locate':'Recenter'});OpenLayers.Util.extend(OpenLayers.Lang.fr,{'Overview Map':'Carte de référence','Coordinates':'Coordonnées','Coordinates (m): ':'Coordonnées (m): ','Map':'Carte','Layer Tree':'Arbre des couches','Print':'Impression','Map Queries':'Interrogation','Background':'Fonds de carte','Nationales Maps':'Cartes nationales','Grays Nationales Maps':'Cartes nationales noir/blanc','Aerial Images':'Images aeriennes','None':'Aucun','Gemeinde':'Commune','Bezirk':'District','Kanton':'Canton','Schweiz':'Suisse','Measure':'Mesure','searcher':'Informations','Pan':'Déplacement','Vue general':'Vue générale','Distance measurement (double-click to terminate)':'Mesure de distance (double-cliquer pour terminer)','Area measurement (double-click to terminate)':'Mesure de surface (double-cliquer pour terminer)','Zoom arriere':'Zoom arrière','Zoom avant':'Zoom avant','Previous view':'Vue précédente','Next view':'Vue suivante','Locate by coordinates':'Recenter par coordonnées','Locate':'Recentrage','address':'Rue','numero':'Numéro','Parcelle non trouvee':'Parcelle non trouvée'});OpenLayers.Util.extend(OpenLayers.Lang.it,{'Coordinates (m): ':'Coordinata (m): ','Full extent':'','zoomout':'','zoomin':'','Koordinaten (m): ':'','Print':'Stampare','Layer Tree':'Temi','Background':'Sfondo cartografico','Nationales Maps':'Carta pixel','Aerial Images':'Immagini aeree','None':'Nessuno sfondo cartografico','Gemeinde':'Comuni','Bezirk':'Distretti','Kanton':'Cantoni','Schweiz':'Svizzera','Locate by coordinates':'','Locate':''});ModelMain=OpenLayers.Class({config:{},urlParams:{},layertree:null,map:null,layout:null,tooltips:null,measure:null,initialize:function(){this.urlParams=OpenLayers.Util.getParameters(location.search);this.setConfig();this.initLang();this.setLayertree();this.setMap();this.setMeasure();this.setLayout();},setConfig:function(){if(typeof(project_config)=='undefined'){OpenLayers.Console.error('project_config is missing');return;}
this.config=project_config;},initLang:function(){if(this.urlParams.lang){OpenLayers.Lang.setCode(this.urlParams.lang);}else{OpenLayers.Lang.setCode($('lang').value);}},setLayertree:function(){this.layertree=new ModelLayerTree(this);},setMap:function(){this.map=new ModelMap(this);},setLayout:function(){this.layout=new ModelLayout(this);},setTooltips:function(){this.tooltips=new ModelTooltips(this);},setMeasure:function(){this.measure=new ModelMeasure(this);},getLocale:function(){var code=OpenLayers.Lang.getCode();if(OpenLayers.Util.indexOf(['de','fr','it'],code)!=-1){return code+'_CH';}else{return'de_CH';}}});ModelMap=OpenLayers.Class({main:null,map:null,initialize:function(main){this.main=main;this.initMap();},initMap:function(){Ext.BLANK_IMAGE_URL="mfbase/ext/resources/images/default/s.gif";OpenLayers.IMAGE_RELOAD_ATTEMPTS=1;OpenLayers.DOTS_PER_INCH=254;OpenLayers.Util.onImageLoadError=function(){this._attempts=(this._attempts)?(this._attempts+1):1;if(this._attempts<=OpenLayers.IMAGE_RELOAD_ATTEMPTS){this.src=this.src;}
this.style.display="none";};var options={projection:"EPSG:21781",units:"m",maxExtent:new OpenLayers.Bounds.fromArray(this.main.config.maxExtent),restrictedExtent:new OpenLayers.Bounds.fromArray(this.main.config.maxExtent),scales:this.main.config.scales,theme:null};options.controls=[new OpenLayers.Control.Navigation(),new OpenLayers.Control.ScaleLine(),new OpenLayers.Control.MousePosition({div:$('mousepos'),numDigits:0,prefix:OpenLayers.i18n('Coordinates (m): ')}),new OpenLayers.Control.Scale($('scale'),{updateScale:function(){var scale=this.map.getScale();if(!scale){return;}
this.element.innerHTML=OpenLayers.i18n("scale",{scaleDenom:OpenLayers.Number.format(scale,0,"'")});}})];this.map=new OpenLayers.Map('map',options);var OLlayers=this.main.layertree.getOlLayers();this.map.addLayers(OLlayers);if(this.main.config.initialExtent){var initialBounds=new OpenLayers.Bounds.fromArray(this.main.config.initialExtent);this.map.zoomToExtent(initialBounds);}else if(this.main.config.initialScale){if(this.main.config.initialLonLat){var target=new OpenLayers.LonLat(this.main.config.initialLonLat[0],this.main.config.initialLonLat[1]);}else{var initialBounds=new OpenLayers.Bounds.fromArray(this.main.config.maxExtent);var target=initialBounds.getCenterLonLat();}
this.map.moveTo(target,this.getZoomForScale(this.main.config.initialScale));}else{this.map.zoomToMaxExtent();}},getZoomForScale:function(scale){var zoom=0;for(var i=0;i<this.map.scales.length;i++){if(this.map.scales[i]==scale){zoom=i;}}
return zoom;}});ModelLayerTree=OpenLayers.Class({main:null,mfModel:[],olOverviewMapLayer:null,olLayers:[],baseUrl:'',initialize:function(main){this.main=main;this.baseLayerSource=this.main.config.localTilecacheUrl
this.applicativeLayerSource=this.main.config.localTilecacheUrl
this.mfModel=[{text:'Cadastre - voirie',id:'cadastre',iconCls:'voidIcon',leaf:true,checked:false,expanded:true,children:[{text:'Parcellaire',id:'cadastre_parcellaire',iconCls:'voidIcon',leaf:true,checked:true,expanded:true,maxScale:10000,children:[{layerName:'Vecteur:cad_parv',text:'Parcelles',id:'cadastre_parcellaire_parcelles',checked:true,icon:'mapfishModelPeitrequin/img/parcelle.png',iconCls:'customClass',children:[{text:"Droit distinct permanant",id:"cadastre_parcellaire_parcelles_droit",leaf:true,iconCls:'customClass',icon:'mapfishModelPeitrequin/img/parcelle_d.png'},{text:"Parcelle",id:"cadastre_parcellaire_parcelles_parcelle",leaf:true,iconCls:'customClass',icon:'mapfishModelPeitrequin/img/parcelle_p.png'}]},{layerName:'Vecteur:cad_parv_numero',text:'N° de parcelle',id:'cadastre_parcellaire_num',checked:true,icon:'mapfishModelPeitrequin/img/num_parcelle.png',iconCls:'customClass',maxScale:2000},{layerName:'Vecteur:cad_parv_point',text:'Points limites',id:'cadastre_parcellaire_lim',checked:false,icon:'mapfishModelPeitrequin/img/point_limit.png',iconCls:'customClass',maxScale:2000}]},{text:"Couverture du sol",id:"cadastre_couverture",leaf:true,iconCls:'voidIcon',checked:false,expanded:false,maxScale:10000,children:[{text:"Couverture du sol",id:"cadastre_couverture_couverture",leaf:true,iconCls:'voidIcon',checked:false,expanded:false,children:[{layerName:'Vecteur:cad_bat_hs_cadastre',text:'Bâtiments hors-sol',id:'cadastre_couverture_couverture_baths',iconCls:'customClass',icon:'mapfishModelPeitrequin/img/batimentsHS.png',checked:true},{layerName:'Vecteur:cad_bat_ss_cadastre',text:"Bâtiments sous-sol",id:'cadastre_couverture_couverture_batss',iconCls:'customClass',icon:'mapfishModelPeitrequin/img/batimentsSS.png',checked:true},{layerName:"Vecteur:movd_cad_couv",text:"Couvert",id:'cadastre_couverture_couverture_couvert',checked:false,iconCls:'customClass',icon:'mapfishModelPeitrequin/img/couvert.png'},{layerName:"Vecteur:movd_cad_couv_foret",text:"Forêt",id:'cadastre_couverture_couverture_foret',checked:false,iconCls:'customClass',icon:'mapfishModelPeitrequin/img/couvert_foret.png'},{layerName:"Vecteur:movd_cad_couv_eau",text:"Cours d'eau",id:'cadastre_couverture_couverture_eau',checked:false,iconCls:'customClass',icon:'mapfishModelPeitrequin/img/couvert_eau.png'},{layerName:"Vecteur:movd_cad_couv_divers",text:"Objets divers",id:'cadastre_couverture_couverture_divers',checked:false,iconCls:'customClass',icon:'mapfishModelPeitrequin/img/couvert_gris.png',children:[{text:"Route, chemin",id:'cadastre_couverture_couverture_divers_route',leaf:true,iconCls:'customClass',icon:'mapfishModelPeitrequin/img/couvert_gris.png'},{text:"Chemin de fer",id:'cadastre_couverture_couverture_divers_fer',leaf:true,iconCls:'customClass',icon:'mapfishModelPeitrequin/img/couvert_gris.png'},{text:"Accès place",id:'cadastre_couverture_couverture_divers_acces',leaf:true,iconCls:'customClass',icon:'mapfishModelPeitrequin/img/couvert_gris.png'},{text:"Détail de bâtiment",id:'cadastre_couverture_couverture_divers_detail',leaf:true,iconCls:'customClass',icon:'mapfishModelPeitrequin/img/couvert_gris.png'},{text:"Mur mitoyen",id:'cadastre_couverture_couverture_divers_murmit',leaf:true,iconCls:'customClass',icon:'mapfishModelPeitrequin/img/couvert_gris.png'},{text:"Escalier important",id:'cadastre_couverture_couverture_divers_esca',leaf:true,iconCls:'customClass',icon:'mapfishModelPeitrequin/img/couvert_gris.png'},{text:"Mur",id:'cadastre_couverture_couverture_divers_mur',leaf:true,iconCls:'customClass',icon:'mapfishModelPeitrequin/img/couvert_gris.png'},{text:"Mat, antenne",id:'cadastre_couverture_couverture_divers_mat',leaf:true,iconCls:'customClass',icon:'mapfishModelPeitrequin/img/couvert_gris.png'},{text:"Débarcadère",id:'cadastre_couverture_couverture_divers_deb',leaf:true,iconCls:'customClass',icon:'mapfishModelPeitrequin/img/couvert_gris.png'},{text:"Pont, passerelle",id:'cadastre_couverture_couverture_divers_pont',leaf:true,iconCls:'customClass',icon:'mapfishModelPeitrequin/img/couvert_gris.png'},{text:"Couvert indépendant",id:'cadastre_couverture_couverture_divers_couvind',leaf:true,iconCls:'customClass',icon:'mapfishModelPeitrequin/img/couvert_gris.png'},{text:"Tunnel, passage inférieur",id:'cadastre_couverture_couverture_divers_tunnel',leaf:true,iconCls:'customClass',icon:'mapfishModelPeitrequin/img/couvert_gris.png'},{text:"Sentier à ventiler",id:'cadastre_couverture_couverture_divers_sentier',leaf:true,iconCls:'customClass',icon:'mapfishModelPeitrequin/img/couvert_gris.png'},{text:"Bord de chaussée à ventiler",id:'cadastre_couverture_couverture_divers_bord',leaf:true,iconCls:'customClass',icon:'mapfishModelPeitrequin/img/couvert_gris.png'},{text:"Ilot à ventiler",id:'cadastre_couverture_couverture_divers_ilot',leaf:true,iconCls:'customClass',icon:'mapfishModelPeitrequin/img/couvert_gris.png'},{text:"Voie ferrée",id:'cadastre_couverture_couverture_divers_voie',leaf:true,iconCls:'customClass',icon:'mapfishModelPeitrequin/img/couvert_gris_trait.png'},{text:"Fontaine",id:'cadastre_couverture_couverture_divers_font',leaf:true,iconCls:'customClass',icon:'mapfishModelPeitrequin/img/couvert_bleu.png'},{text:"Ligne aérienne haute tension",id:'cadastre_couverture_couverture_divers_ligne',leaf:true,iconCls:'customClass',icon:'mapfishModelPeitrequin/img/couvert_gris_trait_alt.png'},{text:"Piscine",id:'cadastre_couverture_couverture_divers_pisc',leaf:true,iconCls:'customClass',icon:'mapfishModelPeitrequin/img/couvert_bleu.png'},{text:"Terrain de sport",id:'cadastre_couverture_couverture_divers_sport',leaf:true,iconCls:'customClass',icon:'mapfishModelPeitrequin/img/couvert_gris.png'},{text:"Eau à ventiler",id:'cadastre_couverture_couverture_divers_eau',leaf:true,iconCls:'customClass',icon:'mapfishModelPeitrequin/img/couvert_bleu.png'}]},{layerName:"Vecteur:movd_cad_labels",text:"Nom de rue et d'objet",id:'cadastre_couverture_couverture_nomrueobj',checked:false,maxScale:1000},{layerName:"Vecteur:movd_cad_labels_local",text:"Nom local",id:'cadastre_couverture_couverture_nomloc',checked:false,maxScale:5000}]},{layerName:"Vecteur:GrpConstruction",text:"Bâtiments projetés",id:'cadastre_couverture_batproj',icon:'mapfishModelPeitrequin/img/batimentsprojet.png',iconCls:'customClass',checked:true}]}]},{text:"Infrastructures",id:'infra',expanded:false,checked:false,iconCls:'voidIcon',maxScale:10000,children:[{text:"Assainissement",id:'infra_ass',expanded:false,checked:false,iconCls:'voidIcon',children:[{text:'Collecteur principal',id:'infra_ass_colprin',expanded:false,checked:false,iconCls:'voidIcon',children:[{layerName:'Vecteur:GrpAssainissPrinEU',text:'Eaux usées',id:'infra_ass_colprin_use',leaf:true,checked:false,iconCls:'voidIcon',children:[{text:'Collecteur',id:'infra_ass_colprin_use_col',icon:'mapfishModelPeitrequin/img/CollecteurPrincipalEU.png',iconCls:'customClass'},{text:'Collecteur (tracé supposé)',id:'infra_ass_colprin_use_colsup',icon:'mapfishModelPeitrequin/img/CollecteurPrincipalSupposeEU.png',iconCls:'customClass'},{text:'Chambre de visite',id:'infra_ass_colprin_use_cham',icon:'mapfishModelPeitrequin/img/RegardPrincipalEU.png',iconCls:'customClass'},{text:'Chambre de visite enterrée',id:'infra_ass_colprin_use_chament',icon:'mapfishModelPeitrequin/img/RegardEnterreEU.png',iconCls:'customClass'},{text:'Chambre de visite double (EU+EC)',id:'infra_ass_colprin_use_chamdbl',icon:'mapfishModelPeitrequin/img/RegardDouble.png',iconCls:'customClass'},{text:'Chambre de visite double (EU+EC) enterrée',id:'infra_ass_colprin_use_chamdblent',icon:'mapfishModelPeitrequin/img/RegardDoubleEnterre.png',iconCls:'customClass'}]},{layerName:'Vecteur:GrpAssainissPrinEC',text:'Eaux claires',id:'infra_ass_colprin_cl',checked:false,leaf:true,iconCls:'voidIcon',children:[{text:'Collecteur',id:'infra_ass_colprin_cl_col',icon:'mapfishModelPeitrequin/img/CollecteurPrincipalEC.png',iconCls:'customClass'},{text:'Collecteur (tracé supposé)',id:'infra_ass_colprin_cl_colsup',icon:'mapfishModelPeitrequin/img/CollecteurPrincipalSupposeEC.png',iconCls:'customClass'},{text:'Chambre de visite',id:'infra_ass_colprin_cl_cham',icon:'mapfishModelPeitrequin/img/RegardPrincipalEC.png',iconCls:'customClass'},{text:'Chambre de visite enterrée',id:'infra_ass_colprin_cl_chament',icon:'mapfishModelPeitrequin/img/RegardEnterreEC.png',iconCls:'customClass'}]}]},{text:'Raccordements privés',id:'infra_ass_priv',expanded:false,checked:false,iconCls:'voidIcon',maxScale:2000,children:[{layerName:'Vecteur:GrpAssainissPrivEU',text:'Eaux usées',id:'infra_ass_priv_use',leaf:true,checked:false,iconCls:'voidIcon',children:[{text:'Collecteur',id:'infra_ass_priv_use_col',icon:'mapfishModelPeitrequin/img/RaccordementEU.png',iconCls:'customClass'},{text:'Collecteur (tracé supposé)',id:'infra_ass_priv_use_colsup',icon:'mapfishModelPeitrequin/img/RaccordementSupposeEU.png',iconCls:'customClass'},{text:'Chambre de viste',id:'infra_ass_priv_use_cham',icon:'mapfishModelPeitrequin/img/RegardPriveEU.png',iconCls:'customClass'},{text:'Chambre de viste enterrée',id:'infra_ass_priv_use_chament',icon:'mapfishModelPeitrequin/img/RegardEnPriveEU.png',iconCls:'customClass'},{text:'Chambre de visite double (EU+EC)',id:'infra_ass_priv_use_chamdbl',icon:'mapfishModelPeitrequin/img/RegardDoublePrive.png',iconCls:'customClass'}]},{layerName:'Vecteur:GrpAssainissPrivEC',text:'Eaux claires',id:'infra_ass_priv_cl',leaf:true,checked:false,iconCls:'voidIcon',children:[{text:'Collecteur',id:'infra_ass_priv_cl_col',icon:'mapfishModelPeitrequin/img/RaccordementEC.png',iconCls:'customClass'},{text:'Collecteur (tracé supposé)',id:'infra_ass_priv_cl_colsup',icon:'mapfishModelPeitrequin/img/RaccordementSupposeEC.png',iconCls:'customClass'},{text:'Drainage',id:'infra_ass_priv_cl_drai',icon:'mapfishModelPeitrequin/img/Drainage.png',iconCls:'customClass'},{text:'Chambre de visite',id:'infra_ass_priv_cl_cham',icon:'mapfishModelPeitrequin/img/RegardPriveEC.png',iconCls:'customClass'},{text:'Chambre de visite enterrée',id:'infra_ass_priv_cl_chament',icon:'mapfishModelPeitrequin/img/RegardEnPriveEC.png',iconCls:'customClass'},{text:'Sac-grille / Gueule de loup',id:'infra_ass_priv_cl_gril',icon:'mapfishModelPeitrequin/img/Grille.png',iconCls:'customClass'},{text:'Puits perdu',id:'infra_ass_priv_cl_puit',icon:'mapfishModelPeitrequin/img/PuitsPerdu.png',iconCls:'customClass'}]}]}]},{text:"Eau potable",id:'infra_pot',expanded:false,checked:false,iconCls:'voidIcon',children:[{layerName:'Vecteur:GrpEauPotablePrin',text:'Conduites principales',id:'infra_pot_prin',leaf:true,checked:false,iconCls:'voidIcon',children:[{text:'Conduite',id:'infra_pot_prin_cond',icon:'mapfishModelPeitrequin/img/ConduitePrincipale.png',iconCls:'customClass'},{text:'Conduite (tracé supposé)',id:'infra_pot_prin_condsup',icon:'mapfishModelPeitrequin/img/ConduitePrincipaleSupposeeESP.png',iconCls:'customClass'},{text:'Vanne',id:'infra_pot_prin_van',icon:'mapfishModelPeitrequin/img/Vanne.png',iconCls:'customClass'},{text:'Borne hydrante',id:'infra_pot_prin_born',icon:'mapfishModelPeitrequin/img/BorneHydranteLegende.png',iconCls:'customClass'}]},{layerName:'Vecteur:GrpEauPotablePriv',text:'Raccordements privés',id:'infra_pot_priv',leaf:true,checked:false,iconCls:'voidIcon',maxScale:2000,children:[{text:'Conduite',id:'infra_pot_priv_cond',icon:'mapfishModelPeitrequin/img/Concession.png',iconCls:'customClass'},{text:'Vanne concession',id:'infra_pot_priv_van',icon:'mapfishModelPeitrequin/img/VanneConcession.png',iconCls:'customClass'},{text:'Compteur',id:'infra_pot_priv_comp',icon:'mapfishModelPeitrequin/img/Compteur.png',iconCls:'customClass'}]}]}]},{layerName:'Vecteur:SitVoAdressPoint',text:"Voirie",id:'voirie',expanded:false,checked:false,iconCls:"voidIcon",maxScale:5000,children:[{text:'Adresses',id:'voirie_add',leaf:true,checked:false,icon:'mapfishModelPeitrequin/img/adresse.png',iconCls:'customClass'}]},{text:"Aménagement du territoire",id:'terr',checked:false,iconCls:'voidIcon',leaf:true,maxScale:50000,children:[{text:'Protection des eaux',id:'terr_prot',iconCls:'voidIcon',checked:false,children:[{text:"Zones de protection des eaux",id:'terr_prot_zone',layerName:'Vecteur:GrpZoneProtectionEaux',leaf:true,checked:false,iconCls:'voidIcon',maxScale:25000,children:[{text:'S1',id:'terr_prot_zone_s1',icon:'mapfishModelPeitrequin/img/S1.png',iconCls:'customClass'},{text:'S2',id:'terr_prot_zone_s2',icon:'mapfishModelPeitrequin/img/S2.png',iconCls:'customClass'},{text:'S3',id:'terr_prot_zone_s3',icon:'mapfishModelPeitrequin/img/S3.png',iconCls:'customClass'}]},{layerName:"Vecteur:GrpSectProtectionEaux",text:"Secteurs de protection des eaux",id:'terr_prot_sec',leaf:true,checked:false,iconCls:'voidIcon',children:[{text:'A',id:'terr_prot_sec_a',icon:'mapfishModelPeitrequin/img/SectA.png',iconCls:'customClass'},{text:'B',id:'terr_prot_sec_b',icon:'mapfishModelPeitrequin/img/SectB.png',iconCls:'customClass'},{text:'C',id:'terr_prot_sec_c',icon:'mapfishModelPeitrequin/img/SectC.png',iconCls:'customClass'},{text:'S',id:'terr_prot_sec_s',icon:'mapfishModelPeitrequin/img/SectS.png',iconCls:'customClass'}]}]},{layerName:'Vecteur:Affectation',text:"Zones d'affectation",id:'terr_aff',leaf:true,checked:false,iconCls:'voidIcon',maxScale:25000,children:[{text:'Zone ancienne ville',id:'terr_aff_anc',icon:'mapfishModelPeitrequin/img/affectation_ancienne_ville.png',iconCls:'customClass'},{text:'Zone moyenne densité',id:'terr_aff_moy',icon:'mapfishModelPeitrequin/img/affectation_moyenne_densite.png',iconCls:'customClass'},{text:'Zone villas',id:'terr_aff_villa',icon:'mapfishModelPeitrequin/img/affectation_villas.png',iconCls:'customClass'},{text:'Zone littoral',id:'terr_aff_litt',icon:'mapfishModelPeitrequin/img/affectation_littoral.png',iconCls:'customClass'},{text:'Zone utilité publique',id:'terr_aff_pub',icon:'mapfishModelPeitrequin/img/affectation_utilite_publique.png',iconCls:'customClass'},{text:'Zone ferroviaire',id:'terr_aff_fer',icon:'mapfishModelPeitrequin/img/PartieZoneOccuperPlanSpec.png',iconCls:'customClass'},{text:'Zone verte',id:'terr_aff_vert',icon:'mapfishModelPeitrequin/img/affectation_verte.png',iconCls:'customClass'},{text:'Zone agricole',id:'terr_aff_agri',icon:'mapfishModelPeitrequin/img/affectation_agricole.png',iconCls:'customClass'},{text:'Zone viticole',id:'terr_aff_viti',icon:'mapfishModelPeitrequin/img/affectation_viticole.png',iconCls:'customClass'},{text:'Zone intermédiaire',id:'terr_aff_int',icon:'mapfishModelPeitrequin/img/affectation_intermediaire.png',iconCls:'customClass'},{text:'Aire forestière',id:'terr_aff_foret',icon:'mapfishModelPeitrequin/img/affectation_forestiere.png',iconCls:'customClass'},{text:'Plantation – Massif boisé',id:'terr_aff_plant',icon:'mapfishModelPeitrequin/img/affectation_plantation.png',iconCls:'customClass'}]}]},{layerName:'CN25_wms',id:'fond_cn',text:"Carte nationale (>5'000)",iconCls:'voidIcon',checked:false},{layerName:'imageswiss',id:'fond_photo',text:"Orthophotos",iconCls:'voidIcon',checked:true},{layerName:'white_layer',id:'fond_none',text:"Pas de fond de carte",iconCls:'voidIcon',checked:false}];this.olLayers=[new OpenLayers.Layer.WMS("Vecteur",this.applicativeLayerSource,{layers:['movd_cad_couv_foret','movd_cad_couv_eau','GrpConstruction','cad_bat_ss_cadastre','cad_bat_hs_cadastre','GrpZoneProtectionEaux','GrpSectProtectionEaux','Affectation','movd_cad_couv_divers','movd_cad_couv','cad_parv','GrpAssainissPrinEU','GrpAssainissPrinEC','GrpEauPotablePrin','GrpEauPotablePriv','cad_parv_point','SitVoAdressPoint','GrpAssainissPrivEU','GrpAssainissPrivEC','cad_parv_numero'],format:'image/png'},{isBaseLayer:false,visibility:true,alpha:true,buffer:0,ratio:1}),new OpenLayers.Layer("white_layer",{isBaseLayer:true,visibility:false}),new OpenLayers.Layer.TileCache("CN25_wms",this.main.config.commonTilecacheDirectUrl,'CN25',{maxExtent:new OpenLayers.Bounds(480000,122000,515000,158000),isBaseLayer:true,format:'image/jpeg',buffer:0,opacity:0.75}),new OpenLayers.Layer.TileCache("imageswiss",this.main.config.commonTilecacheDirectUrl,'imageswiss',{maxExtent:new OpenLayers.Bounds(480000,122000,515000,158000),isBaseLayer:true,format:'image/jpeg',buffer:0,opacity:0.75})];},getOverviewMap:function(){return new OpenLayers.Layer.Image("overview","ressources/keymap.png",new OpenLayers.Bounds(485000,65000,835000,298000),new OpenLayers.Size(150,99));},getModel:function(){return this.mfModel;},getOlLayers:function(){return this.olLayers;},getOlOverviewMapLayer:function(){return this.olOverviewMapLayer;},getLayerTree:function(){return this.main.layout.accordion.findById('layertree');},getPrintOverrides:function(){return{'Vecteur':{baseURL:this.main.config.WMSUrl}};}});ModelLayout=OpenLayers.Class({main:null,toolbar:{},accordion:{},mapComponent:{},treePanel:null,initialize:function(main){this.main=main;new Ext.Viewport({layout:'border',defaultType:'panel',items:[this.getViewportNorthItem(),this.getViewportCenterItem()]});this.initToolbarContent();},getViewportNorthItem:function(){return new Ext.BoxComponent({region:'north',el:'north'});},getViewportSouthItem:function(){return new Ext.BoxComponent({region:'south',el:'south'});},getViewportCenterItem:function(){return{region:'center',border:false,layout:'border',margins:'5 5 5 5',items:[this.getAccordion(),this.getPayload()]};},getPayload:function(){return{layout:'border',region:'center',border:false,margins:'0 0 0 0',items:[this.getMapComponent()]};},addSeparator:function(){this.toolbar.add(new Ext.Toolbar.Spacer());this.toolbar.add(new Ext.Toolbar.Separator());this.toolbar.add(new Ext.Toolbar.Spacer());},getToolbar:function(){this.toolbar=new mapfish.widgets.toolbar.Toolbar({map:this.main.map.map,configurable:false});this.toolbar.autoHeight=false;this.toolbar.height=25;return this.toolbar;},initToolbarContent:function(){this.initBrowsingToolbar();this.addSeparator();this.initQueryToolbar();this.addSeparator();this.initMeasureToolbar();this.addSeparator();this.initNavigationToolbar();this.initLoadingToolbar();this.toolbar.activate();},initLoadingToolbar:function(){this.toolbar.add(new Ext.Toolbar.Fill());this.toolbar.add(new mapfish.widgets.LoadingIndicator({map:this.main.map.map}));},initBrowsingToolbar:function(){this.toolbar.addControl(new OpenLayers.Control.ZoomToInitialExtent({map:this.main.map.map,config:this.main.config,utils:this.main.map,title:OpenLayers.i18n('Vue general')}),{iconCls:'zoomfull',toggleGroup:'map'});this.toolbar.addControl(new OpenLayers.Control.ZoomBox({title:OpenLayers.i18n('Zoom avant')}),{iconCls:'zoomin',toggleGroup:'map'});this.toolbar.addControl(new OpenLayers.Control.ZoomBox({out:true,title:OpenLayers.i18n('Zoom arriere')}),{iconCls:'zoomout',toggleGroup:'map'});this.toolbar.addControl(new OpenLayers.Control.DragPan({isDefault:true,title:OpenLayers.i18n('Pan')}),{iconCls:'pan',toggleGroup:'map'});},initMeasureToolbar:function(){this.toolbar.addControl(this.main.measure.getLengthCalculator(),{iconCls:'calculateLength',tooltip:OpenLayers.i18n('Distance measurement (double-click to terminate)'),toggleGroup:'map'});this.toolbar.addControl(this.main.measure.getAreaCalculator(),{iconCls:'calculateArea',tooltip:OpenLayers.i18n('Area measurement (double-click to terminate)'),toggleGroup:'map'});},initNavigationToolbar:function(){var nav=new OpenLayers.Control.NavigationHistory();this.main.map.map.addControl(nav);nav.activate();var listeners={activate:function(){this.enable();},deactivate:function(){this.disable();}};var back=this.toolbar.addButton({iconCls:'back',tooltip:OpenLayers.i18n('Previous view'),handler:nav.previous.trigger,disabled:true});nav.previous.events.on(OpenLayers.Util.extend(listeners,{scope:back}));var next=this.toolbar.addButton({iconCls:'next',tooltip:OpenLayers.i18n('Next view'),handler:nav.next.trigger,disabled:true});nav.next.events.on(OpenLayers.Util.extend(listeners,{scope:next}));},initQueryToolbar:function(){this.toolbar.addControl(Ext.getCmp('searcher').control,{iconCls:'interrogations',toggleGroup:'map',tooltip:OpenLayers.i18n('searcher')});},getMapComponent:function(){return{region:'center',xtype:'mapcomponent',map:this.main.map.map,tbar:this.getToolbar(),bbar:this.getMapInfo()};},getMapInfo:function(){return new Ext.BoxComponent({el:'mapinfo'});},getQueryResults:function(){return{region:'south',id:'queryResults',height:200,split:true,collapsible:true,collapsed:true,collapseMode:'mini',animCollapse:false,border:false};},initTreePanel:function(){this.treePanel=new mapfish.widgets.LayerTree({title:OpenLayers.i18n('Layer Tree'),id:'layertree',border:false,frame:false,autoHeight:true,bodyStyle:'padding: 3px;',map:this.main.map.map,model:this.main.layertree.getModel(),plugins:[mapfish.widgets.LayerTree.createContextualMenuPlugin(['opacitySlideDirect']),mapfish.widgets.LayerTree.createDisableLayersPlugin(254)]});return this.treePanel;},initLocatePeitrequin:function(){return{title:OpenLayers.i18n('Locate'),id:'locate',labelAlign:'top',xtype:'searchservicepeintrequin',border:false,defaultZoom:4,defaults:{anchor:'100%'},showCenter:true,map:this.main.map.map};},initPrintPanel:function(){return{title:OpenLayers.i18n('Print'),xtype:'print-simple',configUrl:this.main.config.printUrl+'/info.json',overrides:this.main.layertree.getPrintOverrides(),serviceParams:{locale:this.main.getLocale()},layerTree:this.treePanel,formConfig:{labelAlign:'top',defaults:{anchor:'100%'},items:[{xtype:'textfield',fieldLabel:OpenLayers.i18n('mf.print.mapTitle'),name:'mapTitle'},{xtype:'textarea',fieldLabel:OpenLayers.i18n('mf.print.comment'),name:'comment',height:50},{xtype:'hidden',name:'lang'+OpenLayers.Lang.getCode(),value:true},{xtype:'hidden',name:'copyright',id:'printCopyright',value:$('copyright').innerHTML}]}};},initQueryPeitrequin:function(){return{title:OpenLayers.i18n('Interrogation'),id:'searcher',xtype:'searcherpeitrequin',labelAlign:'top',border:false,layout:'fit',defaults:{anchor:'100%'},map:this.main.map.map};},initOverviewMapPanel:function(){return{title:OpenLayers.i18n('Overview Map'),contentEl:'overviewmap'};},getAccordion:function(){return{region:'west',collapsible:true,collapseMode:'mini',animCollapse:false,split:true,layout:'accordion',autoScroll:true,border:false,width:300,minSize:100,maxSize:380,layoutConfig:{animate:true},defaults:{border:false,frame:false,width:'auto',bodyStyle:'padding: 3px;',map:this.main.map.map},items:this.getPanels()};},getPanels:function(){return[this.initTreePanel(),this.initPrintPanel(),this.initLocatePeitrequin(),this.initQueryPeitrequin()];}});mapfish.widgets.LoadingIndicator=function(config){this.map=config.map;config.text=config.text?config.text:Ext.LoadMask.prototype.msg;mapfish.widgets.LoadingIndicator.superclass.constructor.call(this,config);Ext.get(this.el).addClass('loading');var listners={loadstart:this.increaseCounter,loadend:this.decreaseCounter,scope:this};this.map.events.on({preaddlayer:function(evt){if(evt.layer){evt.layer.events.on(listners);}},scope:this});for(var i=0;i<this.map.layers.length;i++){this.map.layers[i].events.on(listners);}};Ext.extend(mapfish.widgets.LoadingIndicator,Ext.Toolbar.TextItem,{counter:0,render:function(e){mapfish.widgets.LoadingIndicator.superclass.render.call(this,e);this.hide();},increaseCounter:function(evt){this.counter++;if(this.counter>0){this.show();}},decreaseCounter:function(evt){if(this.counter>0){this.counter--;}
if(this.counter==0){this.hide();}}});OpenLayers.Control.ZoomToInitialExtent=OpenLayers.Class(OpenLayers.Control,{config:null,utils:null,type:OpenLayers.Control.TYPE_BUTTON,trigger:function(){if(this.map){if(this.config.initialExtent){var initialBounds=new OpenLayers.Bounds.fromArray(this.config.initialExtent);this.map.zoomToExtent(initialBounds);}else if(this.config.initialScale){if(this.config.initialLonLat){var target=new OpenLayers.LonLat(this.config.initialLonLat[0],this.config.initialLonLat[1]);}else{var initialBounds=new OpenLayers.Bounds.fromArray(this.config.maxExtent);var target=initialBounds.getCenterLonLat();}
this.map.moveTo(target,this.utils.getZoomForScale(this.config.initialScale));}else{this.map.zoomToMaxExtent();}}},CLASS_NAME:"OpenLayers.Control.ZoomToInitialExtent"});ModelMeasure=OpenLayers.Class({main:null,prevPopup:null,options:null,lengthCalculator:null,areaCalculator:null,initialize:function(main){this.main=main;},getOptions:function(){if(!this.options){this.options={handlerOptions:{style:"default",layerOptions:{styleMap:this.getStyleMap()},persist:true},eventListeners:{'measure':this.renderMeasure,'measurepartial':this.clearMeasure,'deactivate':this.clearMeasure},scope:this};}
return this.options;},clearMeasure:function(){var th=this.scope||this;if(th.prevPopup){th.prevPopup.close();}
th.prevPopup=null;},createPopup:function(value){this.clearMeasure();var html=value;var popup=new Ext.Window({title:OpenLayers.i18n('Measure'),html:html,width:150,bodyStyle:'background-color: #FFFFD0;'});this.prevPopup=popup;popup.show();},renderMeasure:function(event){function calcVincenty(geometry){var dist=0;for(var i=1,l=geometry.components.length;i<l;i++){var first=geometry.components[i-1];var second=geometry.components[i];dist+=OpenLayers.Util.distVincenty({lon:first.x,lat:first.y},{lon:second.x,lat:second.y});}
return dist;}
var th=this.scope||this;var geometry=event.geometry;var units=event.units;var order=event.order;var measure=event.measure;var out="";if(order==1){out+=measure.toFixed(3)+" "+units;if(th.main.map.map.getProjection()=="EPSG:4326"){out+='<br />';out+='<a href="';out+=OpenLayers.i18n('http://en.wikipedia.org/wiki/Great_circle');out+='" target="_blank">';out+=OpenLayers.i18n('Great Circle Distance');out+='</a>: ';out+=calcVincenty(geometry).toFixed(3)+" km";}}else{out+=measure.toFixed(3)+" "+units+"<sup>2</sup>";}
th.createPopup(out);},getStyleMap:function(){var sketchSymbolizers={"Point":{pointRadius:4,graphicName:"square",fillColor:"white",fillOpacity:1,strokeWidth:1,strokeOpacity:1,strokeColor:"#FFFF00"},"Line":{strokeWidth:3,strokeOpacity:1,strokeColor:"#FFFF00"},"Polygon":{strokeWidth:2,strokeOpacity:1,strokeColor:"#FFFF00",fillColor:"white",fillOpacity:0.3}};var style=new OpenLayers.Style();style.addRules([new OpenLayers.Rule({symbolizer:sketchSymbolizers})]);return new OpenLayers.StyleMap({"default":style});},getLengthCalculator:function(){if(!this.lengthCalculator){this.lengthCalculator=new OpenLayers.Control.Measure(OpenLayers.Handler.Path,this.getOptions());}
return this.lengthCalculator;},getAreaCalculator:function(){if(!this.areaCalculator){this.areaCalculator=new OpenLayers.Control.Measure(OpenLayers.Handler.Polygon,this.getOptions());}
return this.areaCalculator;}});ModelTooltips=OpenLayers.Class({main:null,searcher:null,options:null,mediator:null,initialize:function(main){this.main=main;this.initTooltips();},displayTooltip:function(response){var tooltip=Ext.getCmp('searchertip');if(tooltip)
tooltip.destroy();if(!response.features||!(response.features.label||response.features.html||response.features.value))
return;var value=response.features.value;var html=OpenLayers.i18n(response.features.html);var title=OpenLayers.i18n(response.features.label);tooltip=new Ext.Tip({id:'searchertip',html:html,title:title});var mapxy=OpenLayers.Util.pagePosition(this.map.div);var position=this.map.getPixelFromLonLat(this.popupLonLat);tooltip.showAt([mapxy[0]+position.x+5,mapxy[1]+position.y+5]);},initTooltips:function(){this.options={url:'zonesismique',params:{maxfeatures:1},format:new OpenLayers.Format.JSON()};this.protocol=new mapfish.Protocol.MapFish({url:'zonesismique',params:{maxfeatures:1}});this.protocolEvents=new mapfish.Protocol.TriggerEventDecorator({protocol:this.protocol});OpenLayers.Protocol.HTTP.prototype.initialize.call(this.protocol,this.options);this.searcher=new mapfish.Searcher.Map({mode:mapfish.Searcher.Map.HOVER,delay:100,protocol:this.protocolEvents,displayDefaultPopup:false});this.main.map.map.addControl(this.searcher);this.main.map.map.events.on({mouseout:function(event){if(event.target==this.main.map.map.div){var tooltips=Ext.getCmp('searchertip');if(tooltips)
tooltips.destroy();}},scope:this});},setUrl:function(url){this.options.url=url;OpenLayers.Protocol.HTTP.prototype.initialize.call(this.protocol,this.options);},activate:function(){this.searcher.activate();this.protocolEvents.events.on({crudfinished:this.displayTooltip,scope:this.searcher});},deactivate:function(){this.searcher.deactivate();this.protocolEvents.events.on({crudfinished:this.displayTooltip,scope:this.searcher});var tooltip=Ext.getCmp('searchertip');if(tooltip)
tooltip.destroy();}});Ext.namespace('mapfish.widgets','mapfish.widgets.recenter');mapfish.widgets.recenter.Wspparcelle=function(config){Ext.apply(this,config);mapfish.widgets.recenter.Wspparcelle.superclass.constructor.call(this);};Ext.extend(mapfish.widgets.recenter.Wspparcelle,mapfish.widgets.recenter.Base,{getParcelleInput:function(){return new Ext.form.TextField({fieldLabel:OpenLayers.i18n('Parcelle'),name:'parcelle',value:'',listeners:{specialkey:function(textField,event){if(event.getKey()==event.ENTER){this.onParcelleInput(textField);}},scope:this}});},onParcelleInput:function(textField){if(!this.mask)this.initMask();this.mask.show();var tvalue=textField.getValue();if(tvalue==''){return;}
var url='parcelle/bbox/'+tvalue;OpenLayers.Request.GET({url:url,success:function(response){if(this.mask)this.mask.hide();var parser=new OpenLayers.Format.JSON();var bbox=parser.read(response.responseText);if(bbox==null){msg=OpenLayers.i18n('Parcelle non trouvee');this.showError(msg);return;}
var fbox=OpenLayers.Bounds.fromArray(bbox);this.recenterOnBbox(fbox);},failure:function(response){if(this.mask)this.mask.hide();var msg=this.errorMsg+"<br /><br />"+url+"<br /><br />";msg+=response.status+"<br />"+response.statusText;this.showError(msg);},scope:this});},initMask:function(){var mask=this.mask=new Ext.LoadMask(Ext.getCmp('locate').body,{msg:OpenLayers.Lang.translate('En chargement')});}});Ext.reg('searchservicepeintrequinparcelle',mapfish.widgets.recenter.Wspparcelle);Ext.namespace('mapfish.widgets','mapfish.widgets.recenter');mapfish.widgets.recenter.Wsp=function(config){Ext.apply(this,config);mapfish.widgets.recenter.Wsp.superclass.constructor.call(this);};Ext.extend(mapfish.widgets.recenter.Wsp,mapfish.widgets.recenter.Base,{wsRecenterstore:null,wsRecenterServicestore:null,wsRecenterCurrentService:null,errorMsg:OpenLayers.i18n('mf.recenter.ws.error'),currentWsRecenterCombo:null,storeAddress:null,storeNumero:null,selectedId:null,numeroCombo:null,addItems:function(){this.removeAll();this.selectedId=null;this.addressCombo=this.getAddressCombo();this.add(this.addressCombo);if(this.scales){this.addScaleCombo('Ws');}
foo=new mapfish.widgets.recenter.Wspparcelle;foo.map=this.map;this.parcelField=foo.getParcelleInput();this.add(this.parcelField);},getAddressCombo:function(){return new Ext.form.ComboBox({fieldLabel:OpenLayers.i18n('address'),name:'address',value:'',displayField:'voie',valueField:'id',mode:'remote',queryParam:'keyword',minChars:2,typeAhead:true,store:this.getStore('storeAddress'),listeners:{select:function(combo,record,index){this.onAddressSelect(combo);},specialkey:function(combo,event){if(event.getKey()==event.ENTER){this.onAddressSelect(combo);}},scope:this},forceSelection:true,hideTrigger:true});},getNumeroCombo:function(){return new Ext.form.ComboBox({id:'numeroCombo',fieldLabel:OpenLayers.i18n('numero'),name:'numero',value:'',displayField:'numero',valueField:'id',mode:'remote',queryParam:'numero',triggerAction:'all',editable:false,store:this.getStore('storeNumero'),listeners:{select:function(combo,record,index){this.onNumeroSelect(combo);},specialkey:function(combo,event){if(event.getKey()==event.ENTER){this.onNumeroSelect(combo);}},scope:this},forceSelection:true});},getTemplate:function(tplId){var tpl=new Ext.XTemplate('<tpl for=".">','<div class="x-combo-list-item">','<h3><span>{name}</span></h3>','</div>','</tpl>');return tpl;},getStore:function(storeId){if(!this.storeId){switch(storeId){case'storeAddress':this.initStoreAddress();break;case'storeNumero':this.initStoreNumero();break;}}
return this[storeId];},onAddressSelect:function(combo){if(combo.value.length==0){return;}
this.selectedId=combo.value;if(!this.numeroCombo){this.numeroCombo=this.getNumeroCombo();this.storeNumero.proxy.conn.method='POST';this.insert(1,this.numeroCombo);this.doLayout();}else{this.storeNumero.proxy.conn.url='adresse/numero/'+this.selectedId+'/';this.storeNumero.load();this.numeroCombo.reset();}},onNumeroSelect:function(combo){if(combo.value.length==0){return;}
OpenLayers.Request.GET({url:'adresse/location/'+combo.value+'/',success:function(response){var scale=1000;var zoom;var values=this.getForm().getValues();var f=new OpenLayers.Format.GeoJSON();var feature=f.read(response.responseText)[0];if(!feature){return;}
if(feature.geometry.CLASS_NAME=="OpenLayers.Geometry.Polygon"&&!!feature.geometry.getBounds()){this.recenterOnBbox(feature.geometry.getBounds());}else if(feature.geometry.CLASS_NAME=="OpenLayers.Geometry.Point"&&!!feature.geometry.x&&!!feature.geometry.y){var resolution=OpenLayers.Util.getResolutionFromScale(scale,this.map.units);zoom=this.map.getZoomForResolution(resolution);this.recenterOnCoords(feature.geometry.x,feature.geometry.y,zoom);}},failure:function(response){var msg=this.errorMsg+"<br /><br />"+url+"<br /><br />";msg+=response.status+"<br />"+response.statusText;this.showError(msg);},scope:this});},onWsRecenterSelect:function(combo){if(combo.value.length==0){return;}
var scaleField=this.wsRecenterCurrentService.scaleField||null;var url=this.wsRecenterCurrentService.url;url+=this.wsRecenterCurrentService.urlSuffixGeo+'?';url+=this.wsRecenterCurrentService.paramIdGeo+'='+combo.value;url+='&ref='+this.wsRecenterCurrentService.ref;url+=(scaleField)?'&scalefield='+(scaleField):'';OpenLayers.Request.GET({url:url,success:function(response){var values=this.getForm().getValues();var zoom;var f=new OpenLayers.Format.GeoJSON();var feature=f.read(response.responseText)[0];if(!feature){return;}
if(feature.geometry.CLASS_NAME=="OpenLayers.Geometry.Polygon"&&!!feature.geometry.getBounds()){this.recenterOnBbox(feature.geometry.getBounds());}else if(feature.geometry.CLASS_NAME=="OpenLayers.Geometry.Point"&&!!feature.geometry.x&&!!feature.geometry.y){if(this.scales&&values.scaleValue){var resolution=OpenLayers.Util.getResolutionFromScale(values.scaleValue,this.map.units);zoom=this.map.getZoomForResolution(resolution);}
if(scaleField){var scaleValue=feature.attributes[scaleField];var resolution=OpenLayers.Util.getResolutionFromScale(scaleValue,this.map.units);zoom=this.map.getZoomForResolution(resolution);}
this.recenterOnCoords(feature.geometry.x,feature.geometry.y,zoom);}},failure:function(response){var msg=this.errorMsg+"<br /><br />"+url+"<br /><br />";msg+=response.status+"<br />"+response.statusText;this.showError(msg);},scope:this});},initStoreAddress:function(){this.storeAddress=new Ext.data.JsonStore({url:'adresse/voie/',root:"results",id:"id",fields:['id','voie'],listeners:{loadexception:function(proxy,options,response){if(response.status<200||response.status>=300){var msg=this.errorMsg+"<br /><br />";msg+=this.wsRecenterstore.proxy.conn.url+"<br /><br />"
msg+=response.status+"<br />"+response.statusText;this.showError(msg);}},scope:this}});},initStoreNumero:function(){this.storeNumero=new Ext.data.JsonStore({url:'adresse/numero/'+this.selectedId+'/',root:"results",fields:['id','numero'],autoLoad:true,listeners:{loadexception:function(proxy,options,response){if(response.status<200||response.status>=300){var msg=this.errorMsg+"<br /><br />";msg+=this.wsRecenterstore.proxy.conn.url+"<br /><br />"
msg+=response.status+"<br />"+response.statusText;this.showError(msg);}},scope:this}});}});Ext.reg('searchservicepeintrequin',mapfish.widgets.recenter.Wsp);var SearcherPeitrequin=Ext.extend(Ext.Panel,{map:null,url:null,protocol:null,mediator:null,control:null,triggerEventProtocol:null,tree:null,mask:null,initComponent:function(){SearcherPeitrequin.superclass.initComponent.apply(this,arguments);this.protocol=new mapfish.Protocol.MapFish({url:"interrogations",params:{layers:this.getEnabledLayers,no_geom:true}});this.triggerEventProtocol=new mapfish.Protocol.TriggerEventDecorator({protocol:this.protocol});this.triggerEventProtocol.events.register('crudtriggered',this,function(){this.triggerEventProtocol.protocol.params.layers=this.getEnabledLayers();});this.triggerEventProtocol.events.register('crudfinished',this,this.onGotFeatures);var searcher=new mapfish.Searcher.Map({map:this.map,scope:this,searchTolerance:10,protocol:this.triggerEventProtocol});this.control=new SearchControl({searcher:searcher});},getEnabledLayers:function(){var layers=[];var olLayers=this.map.getLayersByClass('OpenLayers.Layer.WMS');for(var i=0;i<olLayers.length;++i){var cur=olLayers[i];if(cur.getVisibility()){for(var j=0;j<cur.params.LAYERS.length;++j){layers.push(cur.name+":"+cur.params.LAYERS[j]);}}}
return layers;},onGotFeatures:function(response){var features=response.features;this.clearTree();this.expand();if(!this.mask){this.mask=new Ext.LoadMask(this.getEl(),{msg:"En chargement..."});}
if(!features)return;this.mask.show();SearcherPeitrequin.features=features;var parentNodes={};var tree=this.getOrCreateTree();var root=tree.root;for(var i=0;i<features.length;++i){var feature=features[i];var type=feature.data.type_table;var parent=parentNodes[type];if(parent==null){var def=SearcherPeitrequin.tables[type];if(def==null)OpenLayers.Console.warn("Unknown table type: "+type);var text=def.plural;parent=new Ext.tree.TreeNode({id:type,text:text,leaf:false});root.appendChild(parent);parentNodes[type]=parent;}
parent.appendChild(this.createNode(feature,i+1));}
for(var key in parentNodes){var cur=parentNodes[key];var nbSub=cur.childNodes.length;cur.setText(cur.text+" ("+nbSub+")");if(nbSub<=1){cur.expand();}}
this.expand();this.mask.hide();},getOrCreateTree:function(){if(this.tree==null){var tree=this.tree=new Ext.tree.TreePanel({border:false,useArrows:true,autoScroll:true,containerScroll:true,rootVisible:false,root:new Ext.tree.TreeNode({id:0,text:'/',leaf:false})});this.add(tree)
this.doLayout();tree.on('click',this.nodeClick,this);}
return this.tree;},createNode:function(feature,id){var template=SearcherPeitrequin.tables[feature.data.type_table].treeTemplate;var html=template.applyTemplate(feature.data);var result=new Ext.tree.TreeNode({id:id,text:html,leaf:true});result.feature=feature;return result;},clearTree:function(){var tree=this.getOrCreateTree();var root=tree.root;var cur=null;while(root.childNodes.length>0){root.childNodes[0].remove()}},nodeClick:function(node,e){if(node.isLeaf()){this.showInfo(node);}},showInfo:function(node){var feature=node.feature;var type=feature.data.type_table;var template=SearcherPeitrequin.tables[type].detailTemplate;var html='<div class="interrogations-details">'+
template.applyTemplate(feature.data)+'</div>';var win=new Ext.Window({title:SearcherPeitrequin.tables[type].singular+': '+node.text,html:html,width:800,autoScroll:true,bodyStyle:'background-color: #FFFFD0;'});win.show(this);var el=win.body.first().last();win.setWidth(el.getSize(true).width+win.getFrameWidth());}});SearcherPeitrequin.tables={parcelles_polygon:{plural:'Parcelles',singular:'Parcelle',treeTemplate:new Ext.Template('<span>{pa_ident}</span>'),detailTemplate:new Ext.Template('<table>','<tr><th><b>Numéro de parcelle : </b></th><td>{pa_ident}</td></tr>','<tr><th><b>Surface technique [m²] : </b></th><td>{tech}</td></tr>','<tr><th><b>Registre Foncier : </b></th><td>{url}</a></td></tr>','</table>')}};var SearchControl=OpenLayers.Class(OpenLayers.Control,{searcher:null,initialize:function(options){OpenLayers.Control.prototype.initialize.apply(this,arguments);},activate:function(){if(OpenLayers.Control.prototype.activate.call(this)){this.searcher.activate();}},deactivate:function(){if(OpenLayers.Control.prototype.deactivate.call(this)){this.searcher.deactivate();}},CLASS_NAME:'SearchControl'});Ext.reg('searcherpeitrequin',SearcherPeitrequin);Ext.form.TriggerField.override({afterRender:function(){Ext.form.TriggerField.superclass.afterRender.call(this);var y;if(Ext.isIE&&!this.hideTrigger&&this.el.getY()!=(y=this.trigger.getY())){this.el.position();this.el.setY(y);}}});project_config={WMSUrl:'http://trelex.geocommunes.ch/wms',maxExtent:[502400,139650,506350,143800],scales:[1400000,1000000,500000,200000,150000,100000,75000,50000,25000,20000,15000,10000,5000,2000,1000,500,250],projectName:'peitrequin_trelex',printUrl:'/print',localTilecacheUrl:'/tilecache',localTilecacheDirectUrl:'/cache',commonTilecacheUrl:'http://common.geocommunes.ch/tilecache',commonTilecacheDirectUrl:'http://common.geocommunes.ch/cache'};ModelLayerTree.prototype.getModel=function(){for(var i=0;i<this.mfModel.length;i++){if(this.mfModel[i].id=='voirie'){this.mfModel[i]={layerName:'Vecteur:MovdAdressPoint',text:"Voirie",expanded:false,checked:false,iconCls:"voidIcon",maxScale:5000,children:[{text:'Adresses',leaf:true,checked:false,icon:'mapfishModelPeitrequin/img/adresse.png',iconCls:'customClass'}]}}
if(this.mfModel[i].id=='cadastre'){var newChildren=new Array();var currentChildren=this.mfModel[i].children[1].children[0].children;for(var j=0;j<currentChildren.length;j++){if(currentChildren[j].id!='cadastre_couverture_couverture_eau'){newChildren.push(currentChildren[j]);}}
this.mfModel[i].children[1].children[0].children=newChildren;}
if(this.mfModel[i].id=='infra'){var fontaine={layerName:"Vecteur:Grp_sit_if_fontaine",text:"Conduite de fontaines",id:'infra_font',checked:false,maxScale:2000,iconCls:'customClass',icon:'img/fontaine.png',children:[{text:"Vanne",id:'infra_font_vanne',leaf:true,iconCls:'customClass',icon:'mapfishModelPeitrequin/img/Vanne.png'},{text:"Conduite",id:'infra_font_cond',leaf:true,iconCls:'customClass',icon:'mapfishModelPeitrequin/img/Concession.png'}]}
var gaznat={layerName:"Vecteur:Grp_sit_if_gaznat",text:"Gazoduc / Fibre optique",id:'infra_gaznat',checked:false,maxScale:10000,iconCls:'customClass',icon:'img/gaznat.png',children:[{text:"Gazoduc",id:'infra_gaznat_gaz',leaf:true,iconCls:'customClass',icon:'img/gazoduc.png'},{text:"Fibre optique",id:'infra_gaznat_fib',leaf:true,iconCls:'customClass',icon:'img/fibre.png'}]}
var telecom={layerName:"Vecteur:Grp_sit_if_telecommand",text:"Télécommande",id:'infra_tele',checked:false,maxScale:10000,iconCls:'customClass',icon:'img/telecommand.png'}
this.mfModel[i].children.push(fontaine,gaznat,telecom);}
if(this.mfModel[i].id=='terr'){this.mfModel[i].children[1].children=[{text:'Zone village',icon:'mapfishModelPeitrequin/img/affectation_205_133_63.png',iconCls:'customClass'},{text:'Zone faible densité',icon:'mapfishModelPeitrequin/img/affectation_255_246_143.png',iconCls:'customClass'},{text:'Zone arborisée constructible',icon:'mapfishModelPeitrequin/img/affectation_238_220_130.png',iconCls:'customClass'},{text:'Zone chalet',icon:'mapfishModelPeitrequin/img/affectation_238_238_0.png',iconCls:'customClass'},{text:'Zone artisanale',icon:'mapfishModelPeitrequin/img/affectation_255_187_255.png',iconCls:'customClass'},{text:'Zone utilité publique',icon:'mapfishModelPeitrequin/img/affectation_151_255_255.png',iconCls:'customClass'},{text:'Zone agricole',icon:'mapfishModelPeitrequin/img/affectation_237_237_237.png',iconCls:'customClass'},{text:'Zone agricole protégée',icon:'mapfishModelPeitrequin/img/affectation_207_207_207.png',iconCls:'customClass'},{text:'Zone viticole',icon:'mapfishModelPeitrequin/img/affectation_lines.png',iconCls:'customClass'},{text:'Zone verdure',icon:'mapfishModelPeitrequin/img/affectation_193_255_193.png',iconCls:'customClass'},{text:'Zone à occuper par plan spécial',icon:'mapfishModelPeitrequin/img/affectation_line_45d_209_209_209.png',iconCls:'customClass'},{text:'Zone intermédiaire',icon:'mapfishModelPeitrequin/img/affectation_205_201_165.png',iconCls:'customClass'},{text:'Zone réserve naturelle',icon:'mapfishModelPeitrequin/img/affectation_cross_0_0_0.png',iconCls:'customClass'},{text:'Forêt',icon:'mapfishModelPeitrequin/img/affectation_124_252_0.png',iconCls:'customClass'}];}}
return this.mfModel;}
ModelLayerTree.prototype.getOlLayers=function(){this.olLayers[0]=new OpenLayers.Layer.WMS("Vecteur",this.applicativeLayerSource,{layers:['GrpZoneProtectionEaux','GrpConstruction','cad_bat_ss_cadastre','cad_bat_hs_cadastre','Affectation','movd_cad_couv_foret','movd_cad_couv_divers','movd_cad_couv','cad_parv','GrpAssainissPrinEU','GrpAssainissPrinEC','GrpEauPotablePrin','GrpEauPotablePriv','Grp_sit_if_fontaine','Grp_sit_if_gaznat','Grp_sit_if_telecommand','GrpSectProtectionEaux','cad_parv_point','MovdAdressPoint','GrpAssainissPrivEU','GrpAssainissPrivEC','cad_parv_numero','movd_cad_labels','movd_cad_labels_local'],format:'image/png'},{isBaseLayer:false,visibility:true,alpha:true,buffer:0,ratio:1})
return this.olLayers;}