1 | package org.medias.eccad.presentation.bean; |
---|
2 | |
---|
3 | import java.util.LinkedList; |
---|
4 | import java.util.List; |
---|
5 | import java.util.Map; |
---|
6 | |
---|
7 | import javax.faces.component.UIInput; |
---|
8 | import javax.faces.component.UIOutput; |
---|
9 | import javax.faces.component.UISelectItem; |
---|
10 | import javax.faces.component.UISelectOne; |
---|
11 | import javax.faces.context.FacesContext; |
---|
12 | import javax.faces.event.ActionEvent; |
---|
13 | import javax.faces.event.ValueChangeEvent; |
---|
14 | import javax.faces.model.SelectItem; |
---|
15 | import javax.servlet.http.HttpSession; |
---|
16 | |
---|
17 | |
---|
18 | import org.medias.eccad.helpers.LoggerPerso; |
---|
19 | import org.medias.eccad.metier.ServiceMetier; |
---|
20 | import org.medias.eccad.metier.dessinCarte.ServiceCarte; |
---|
21 | import org.medias.eccad.metier.generationRaster.ServiceRaster; |
---|
22 | import org.medias.eccad.metier.statistique.ServiceStatistique; |
---|
23 | import org.medias.eccad.modele.Parametre; |
---|
24 | import org.medias.eccad.modele.Produit; |
---|
25 | import org.medias.eccad.modele.StatReponse; |
---|
26 | import org.medias.eccad.modele.Zone; |
---|
27 | import org.medias.eccad.persistance.dao.GrilleDAO; |
---|
28 | import org.medias.eccad.persistance.exception.PersistanceException; |
---|
29 | import org.medias.eccad.presentation.traducteur.TraducteurCarte; |
---|
30 | import org.springframework.beans.factory.xml.XmlBeanFactory; |
---|
31 | |
---|
32 | |
---|
33 | public class CarteBean extends AbstractVueBean { |
---|
34 | |
---|
35 | private XmlBeanFactory xmlbean; |
---|
36 | |
---|
37 | private String url; |
---|
38 | private ServiceMetier smp; |
---|
39 | private ServiceCarte serv_carte; |
---|
40 | private String parametre; |
---|
41 | private String produit; |
---|
42 | private Zone zone_affichee; |
---|
43 | private Zone zone_click; |
---|
44 | private int clicX; |
---|
45 | private int clicY; |
---|
46 | private String visu; |
---|
47 | private String url_legend; |
---|
48 | |
---|
49 | private UIOutput northbc; |
---|
50 | private UIOutput southbc; |
---|
51 | private UIOutput eastbc; |
---|
52 | private UIOutput westbc; |
---|
53 | |
---|
54 | private boolean gridOn; |
---|
55 | private boolean statOn; |
---|
56 | |
---|
57 | private List<SelectItem> liste_colormap; |
---|
58 | private Long colormap_id; |
---|
59 | private UISelectOne colormapUI; |
---|
60 | |
---|
61 | private String statistique; |
---|
62 | private UISelectOne statistiqueUI; |
---|
63 | |
---|
64 | private int nbrGrille; |
---|
65 | |
---|
66 | private String mapTitle; |
---|
67 | private UIOutput mapTitleUI; |
---|
68 | |
---|
69 | private double minParam; |
---|
70 | private UIInput minParamUI; |
---|
71 | private double maxParam; |
---|
72 | private UIInput maxParamUI; |
---|
73 | |
---|
74 | private Long nbrClasses; |
---|
75 | private UISelectOne nbrClassesUI; |
---|
76 | |
---|
77 | private double resolution; |
---|
78 | |
---|
79 | private String pixelCenter; |
---|
80 | private double centerLat; |
---|
81 | private double centerLon; |
---|
82 | private double centerLatClick; |
---|
83 | private double centerLonClick; |
---|
84 | |
---|
85 | private UIOutput pixelCenterUI; |
---|
86 | |
---|
87 | |
---|
88 | /** |
---|
89 | * Initialisation de la carte |
---|
90 | * |
---|
91 | */ |
---|
92 | public CarteBean() { |
---|
93 | controleSession(); |
---|
94 | CritereBean critereBean = (CritereBean)((HttpSession)FacesContext.getCurrentInstance().getExternalContext().getSession(false)).getAttribute("critereBean"); |
---|
95 | smp = critereBean.getSmp(); |
---|
96 | serv_carte = new ServiceCarte(); |
---|
97 | initStatistiqueList(); |
---|
98 | clicX = -1; |
---|
99 | clicY = -1; |
---|
100 | |
---|
101 | centerLatClick = 0; |
---|
102 | centerLonClick = 0; |
---|
103 | |
---|
104 | nbrGrille = 0; |
---|
105 | } |
---|
106 | |
---|
107 | |
---|
108 | /** |
---|
109 | * Dessin de la carte avec les valeurs par défaut |
---|
110 | * Permet de mettre en place la liste des statistiques disponible ainsi que celle des colormap |
---|
111 | * Il détecte également quel est le type de produit visualisé (temporelle, classe, unique) |
---|
112 | * @param event |
---|
113 | */ |
---|
114 | public void dessinCarteInitiale(ActionEvent event) { |
---|
115 | CritereBean critereBean = (CritereBean)((HttpSession)FacesContext.getCurrentInstance().getExternalContext().getSession(false)).getAttribute("critereBean"); |
---|
116 | LoggerPerso.log(CarteBean.class, LoggerPerso.DEBUG , "dessin initial"); |
---|
117 | Produit prod = smp.getProduitById(critereBean.getProduit().intValue()); |
---|
118 | initStatistiqueList(); |
---|
119 | critereBean.majGrille(); |
---|
120 | zone_affichee = new Zone(critereBean.getNorthbc(), critereBean.getSouthbc(), critereBean.getEastbc(), critereBean.getWestbc()); |
---|
121 | nbrGrille = critereBean.getListe_grille().size(); |
---|
122 | |
---|
123 | LoggerPerso.log(CarteBean.class, LoggerPerso.DEBUG , "nbr grilles ="+nbrGrille); |
---|
124 | LoggerPerso.log(CarteBean.class, LoggerPerso.DEBUG , "id parametre="+critereBean.getParametre().intValue()); |
---|
125 | // récupération des informations sur les données |
---|
126 | Parametre param = smp.getParametreById(critereBean.getParametre().intValue()); |
---|
127 | parametre = param.getNom(); |
---|
128 | |
---|
129 | produit = prod.getNom(); |
---|
130 | LoggerPerso.log(CarteBean.class, LoggerPerso.DEBUG , "produit="+produit); |
---|
131 | LoggerPerso.log(CarteBean.class, LoggerPerso.DEBUG , "produit type="+prod.getType()); |
---|
132 | visu = smp.getVisuByTypeProduct(prod.getType()).getPage_jsp(); |
---|
133 | majColorMap(-1); |
---|
134 | |
---|
135 | if (statistiqueUI != null) |
---|
136 | statistiqueUI.setValue("none"); |
---|
137 | statistique = "none"; |
---|
138 | dessinCarte(event); |
---|
139 | } |
---|
140 | |
---|
141 | |
---|
142 | /** |
---|
143 | * Change le mode de visualisation de statistique en normal |
---|
144 | * @param event |
---|
145 | */ |
---|
146 | public void stopStatistique(ActionEvent event) { |
---|
147 | initStatistiqueList(); |
---|
148 | majColorMap(-1); |
---|
149 | CritereBean critereBean = (CritereBean)((HttpSession)FacesContext.getCurrentInstance().getExternalContext().getSession(false)).getAttribute("critereBean"); |
---|
150 | if (critereBean.getGrille() == null) |
---|
151 | url = "/images/nodata.png"; |
---|
152 | else |
---|
153 | setImageURL(critereBean.getGrille().longValue(), false); |
---|
154 | clicX = -1; |
---|
155 | clicY = -1; |
---|
156 | } |
---|
157 | |
---|
158 | /** |
---|
159 | * permet de savoir si les statistiques font partie d'une exception (par exemple si elles vont utiliser une colormap dynamique) |
---|
160 | * il faudrai modifier cela car ce n'est pas propre du tout |
---|
161 | * de plus il faut penser à le modifier au niveau du service carte dans la fonction getLegendStat |
---|
162 | * @param a_tester |
---|
163 | * @return |
---|
164 | */ |
---|
165 | private boolean testStatistique(String a_tester) { |
---|
166 | return (a_tester.equals("ecartCarte") || a_tester.equals("moyenneCarte") || a_tester.equals("sommeCarte")); |
---|
167 | } |
---|
168 | |
---|
169 | /** |
---|
170 | * Activer lors du changement de la statistique visualisé |
---|
171 | * @param event |
---|
172 | */ |
---|
173 | public void changeStatistique(ValueChangeEvent event) { |
---|
174 | LoggerPerso.log(CarteBean.class,LoggerPerso.DEBUG, "change statistique"); |
---|
175 | CritereBean critereBean = (CritereBean)((HttpSession)FacesContext.getCurrentInstance().getExternalContext().getSession(false)).getAttribute("critereBean"); |
---|
176 | |
---|
177 | if (testStatistique(statistiqueUI.getValue().toString())) |
---|
178 | majColorMapStat(); |
---|
179 | else |
---|
180 | if (testStatistique(statistique)) |
---|
181 | majColorMap(critereBean.getGrille().longValue()); |
---|
182 | |
---|
183 | if (critereBean.getGrille() == null) |
---|
184 | url = "/images/nodata.png"; |
---|
185 | else |
---|
186 | setImageURL(critereBean.getGrille().longValue(), false); |
---|
187 | } |
---|
188 | |
---|
189 | /** |
---|
190 | * Modification de la grille sélectionnée |
---|
191 | * @param event |
---|
192 | */ |
---|
193 | public void dessinCarte(ValueChangeEvent event) { |
---|
194 | CritereBean critereBean = (CritereBean)((HttpSession)FacesContext.getCurrentInstance().getExternalContext().getSession(false)).getAttribute("critereBean"); |
---|
195 | |
---|
196 | if (testStatistique(statistique)) |
---|
197 | majColorMap(critereBean.getGrille().longValue()); |
---|
198 | |
---|
199 | zone_affichee = new Zone(critereBean.getNorthbc(), critereBean.getSouthbc(), critereBean.getEastbc(), critereBean.getWestbc()); |
---|
200 | critereBean.setGrille((Long)event.getNewValue()); |
---|
201 | |
---|
202 | initStatistiqueList(); |
---|
203 | |
---|
204 | setImageURL((Long)event.getNewValue(), false); |
---|
205 | } |
---|
206 | |
---|
207 | |
---|
208 | |
---|
209 | |
---|
210 | /** |
---|
211 | * Modification de la colormap |
---|
212 | * @param event |
---|
213 | */ |
---|
214 | public void changeColormap(ValueChangeEvent event) { |
---|
215 | CritereBean critereBean = (CritereBean)((HttpSession)FacesContext.getCurrentInstance().getExternalContext().getSession(false)).getAttribute("critereBean"); |
---|
216 | if (critereBean.getGrille() == null) |
---|
217 | url = "/images/nodata.png"; |
---|
218 | else |
---|
219 | setImageURL(critereBean.getGrille().longValue(), false); |
---|
220 | |
---|
221 | clicX = -1; |
---|
222 | clicY = -1; |
---|
223 | } |
---|
224 | |
---|
225 | /** |
---|
226 | * Modification de la colormap |
---|
227 | * @param event |
---|
228 | */ |
---|
229 | public void changeColormapDynamic(ValueChangeEvent event) { |
---|
230 | CritereBean critereBean = (CritereBean)((HttpSession)FacesContext.getCurrentInstance().getExternalContext().getSession(false)).getAttribute("critereBean"); |
---|
231 | if (critereBean.getGrille() == null) |
---|
232 | url = "/images/nodata.png"; |
---|
233 | else |
---|
234 | setImageURL(critereBean.getGrille().longValue(), false); |
---|
235 | |
---|
236 | clicX = -1; |
---|
237 | clicY = -1; |
---|
238 | } |
---|
239 | |
---|
240 | /** |
---|
241 | * Sur clique sur la carte |
---|
242 | * @param event |
---|
243 | */ |
---|
244 | public void dessinCarte(ActionEvent event) { |
---|
245 | CritereBean critereBean = (CritereBean)((HttpSession)FacesContext.getCurrentInstance().getExternalContext().getSession(false)).getAttribute("critereBean"); |
---|
246 | if (critereBean.getGrille() == null) |
---|
247 | url = "/images/nodata.png"; |
---|
248 | else{ |
---|
249 | //init resol |
---|
250 | resolution = serv_carte.getResolution(critereBean.getGrille().longValue()); |
---|
251 | setImageURL(critereBean.getGrille().longValue(), true); |
---|
252 | } |
---|
253 | clicX = -1; |
---|
254 | clicY = -1; |
---|
255 | } |
---|
256 | |
---|
257 | /** |
---|
258 | * permet de charger la colormap en fonction de la grille visualisée |
---|
259 | * @param oid l'identifiant de la grille |
---|
260 | */ |
---|
261 | private void majColorMap(long identifiant) { |
---|
262 | CritereBean critereBean = (CritereBean)((HttpSession)FacesContext.getCurrentInstance().getExternalContext().getSession(false)).getAttribute("critereBean"); |
---|
263 | if (identifiant == -1 && critereBean.getGrille() != null) |
---|
264 | identifiant = critereBean.getGrille().intValue(); |
---|
265 | |
---|
266 | liste_colormap = smp.getListMappingColor(identifiant); |
---|
267 | |
---|
268 | if (liste_colormap.size() != 0) { |
---|
269 | colormap_id = (Long) liste_colormap.get(0).getValue(); |
---|
270 | if (colormapUI != null) |
---|
271 | colormapUI.setValue(colormap_id); |
---|
272 | } |
---|
273 | } |
---|
274 | |
---|
275 | /** |
---|
276 | * Permet d'obtenir les colormaps disponible pour les statistiques |
---|
277 | * |
---|
278 | */ |
---|
279 | private void majColorMapStat() { |
---|
280 | // FIXME : normalement il faudrai que la base de donnée retourne les colormaps qui correspondent au produit utilisé... |
---|
281 | liste_colormap = smp.getListColorDynamique(); |
---|
282 | /*SelectItem temp = null; |
---|
283 | if (testStatistique(statistiqueUI.getValue().toString())) { |
---|
284 | for (SelectItem iterable_element : liste_colormap) { |
---|
285 | if (iterable_element.getLabel().equalsIgnoreCase("logarithm")) |
---|
286 | temp = iterable_element; |
---|
287 | } |
---|
288 | liste_colormap = new LinkedList<SelectItem>(); |
---|
289 | if (temp == null) { |
---|
290 | LoggerPerso.log(CarteBean.class, LoggerPerso.ERROR, "erreur fatale pas de colormap lineaire !!!"); |
---|
291 | throw new RuntimeException("erreur fatale pas de colormap lineaire !!!"); |
---|
292 | } |
---|
293 | liste_colormap.add(temp); |
---|
294 | }*/ |
---|
295 | |
---|
296 | |
---|
297 | if (liste_colormap.size() != 0) { |
---|
298 | colormap_id = (Long) liste_colormap.get(0).getValue(); |
---|
299 | if (colormapUI != null) |
---|
300 | colormapUI.setValue(colormap_id); |
---|
301 | } |
---|
302 | } |
---|
303 | |
---|
304 | /** |
---|
305 | * Permet d'obtenir un identifiant unique pour générée une image |
---|
306 | * @return un identifiant unique |
---|
307 | */ |
---|
308 | private String getIdUnique() { |
---|
309 | HttpSession session = (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false); |
---|
310 | if (session==null) |
---|
311 | return ""; |
---|
312 | |
---|
313 | String imageID; |
---|
314 | |
---|
315 | |
---|
316 | imageID = session.getId() + session.getLastAccessedTime() ; |
---|
317 | |
---|
318 | return imageID; |
---|
319 | } |
---|
320 | |
---|
321 | /** |
---|
322 | * Permet de générer l'image. |
---|
323 | * Cette fonction détecte s'il s'agit d'une statistique ou d'une carte normale, leur traitement sera différent par la suite |
---|
324 | * @param id_grille de la grille |
---|
325 | * @param updateAffiche détermine si la zone affichée sera mise à jour ou non (zoom, déplacement, etc...) |
---|
326 | */ |
---|
327 | private void setImageURL(Long id_grille, boolean updateAffiche) { |
---|
328 | CritereBean critereBean = (CritereBean)((HttpSession)FacesContext.getCurrentInstance().getExternalContext().getSession(false)).getAttribute("critereBean"); |
---|
329 | if (smp == null) { |
---|
330 | smp = critereBean.getSmp(); |
---|
331 | LoggerPerso.log(CarteBean.class, LoggerPerso.DEBUG, "smp null dans setImageURL"); |
---|
332 | } |
---|
333 | |
---|
334 | if (statistique.equals("none")) |
---|
335 | mapTitle = parametre + " : " + produit; |
---|
336 | else |
---|
337 | mapTitle = "statistics on " + parametre + " : " + produit; |
---|
338 | LoggerPerso.log(CarteBean.class, LoggerPerso.DEBUG, "mapTitleUI :: " + mapTitleUI); |
---|
339 | if (mapTitleUI != null) |
---|
340 | mapTitleUI.setValue(mapTitle); |
---|
341 | |
---|
342 | if (colormapUI != null) |
---|
343 | colormap_id = (Long) colormapUI.getValue(); |
---|
344 | if (colormap_id == null) |
---|
345 | colormap_id = new Long(-1); |
---|
346 | |
---|
347 | |
---|
348 | Zone zone_selection = new Zone(critereBean.getNorthbc(), critereBean.getSouthbc(), critereBean.getEastbc(), critereBean.getWestbc()); |
---|
349 | LoggerPerso.log(CarteBean.class, LoggerPerso.DEBUG, "\nstatistiqueUI="+statistiqueUI); |
---|
350 | if (statistiqueUI != null && !statistiqueUI.getValue().toString().equals("none")) { |
---|
351 | gridOn = false; |
---|
352 | statOn = true; |
---|
353 | gestionCarteStat(updateAffiche); |
---|
354 | |
---|
355 | |
---|
356 | zone_affichee = serv_carte.getCarteCoordinate(); |
---|
357 | |
---|
358 | |
---|
359 | } |
---|
360 | else { |
---|
361 | gridOn = true; |
---|
362 | statOn = false; |
---|
363 | if (clicX != -1 && clicY != -1) |
---|
364 | makeZoom(id_grille, getIdUnique(), resolution); |
---|
365 | else { |
---|
366 | |
---|
367 | |
---|
368 | //pixelCenterUI.setValue(pixelCenter); |
---|
369 | |
---|
370 | if (updateAffiche) {//=========================== ici |
---|
371 | url =serv_carte.getCarte(id_grille, colormap_id.longValue(), zone_selection, getIdUnique()).getUrlImage(); |
---|
372 | |
---|
373 | centerLatClick = 0; |
---|
374 | centerLonClick = 0; |
---|
375 | } |
---|
376 | else{ |
---|
377 | url = serv_carte.getCarte(id_grille, colormap_id.longValue(), null, getIdUnique()).getUrlImage(); |
---|
378 | |
---|
379 | } |
---|
380 | |
---|
381 | } |
---|
382 | url_legend = serv_carte.getLegend(id_grille, colormap_id.longValue()); |
---|
383 | |
---|
384 | |
---|
385 | |
---|
386 | zone_affichee = serv_carte.getCarteCoordinate(); |
---|
387 | LoggerPerso.log(CarteBean.class, LoggerPerso.DEBUG, "************DEBUT " + id_grille); |
---|
388 | |
---|
389 | |
---|
390 | |
---|
391 | zone_click = new Zone(centerLatClick, centerLatClick , centerLonClick, centerLonClick); |
---|
392 | |
---|
393 | StatReponse statReponse = serv_carte.getStatReponse(id_grille, colormap_id.longValue(), zone_click); |
---|
394 | |
---|
395 | String aPixelCenter = (String)Double.toString(statReponse.getCenter()); |
---|
396 | |
---|
397 | |
---|
398 | pixelCenter = fixeDecimal(aPixelCenter); |
---|
399 | centerLat = statReponse.getCenterLat(); |
---|
400 | centerLon = statReponse.getCenterLon(); |
---|
401 | LoggerPerso.log(CarteBean.class, LoggerPerso.DEBUG, "***********pixelCenter :: " +pixelCenter); |
---|
402 | LoggerPerso.log(CarteBean.class, LoggerPerso.DEBUG, "***********centerLat :: " +centerLat ); |
---|
403 | LoggerPerso.log(CarteBean.class, LoggerPerso.DEBUG, "***********centerLon :: " +centerLon); |
---|
404 | |
---|
405 | } |
---|
406 | |
---|
407 | if (northbc != null) { |
---|
408 | northbc.setValue(zone_affichee.getNorthbcN()); |
---|
409 | southbc.setValue(zone_affichee.getSouthbcN()); |
---|
410 | eastbc.setValue(zone_affichee.getEastbcN()); |
---|
411 | westbc.setValue(zone_affichee.getWestbcN()); |
---|
412 | } |
---|
413 | |
---|
414 | |
---|
415 | LoggerPerso.log(LoggerPerso.class, LoggerPerso.DEBUG, "zonnnnnnnnnnnnnnnnnnnnnnnne affichee: getEastbcN "+ zone_affichee.getEastbcN()); |
---|
416 | LoggerPerso.log(LoggerPerso.class, LoggerPerso.DEBUG, "zonnnnnnnnnnnnnnnnnnnnnnnne affichee: getWestbcN "+ zone_affichee.getWestbcN()); |
---|
417 | LoggerPerso.log(LoggerPerso.class, LoggerPerso.DEBUG, "zonnnnnnnnnnnnnnnnnnnnnnnne affichee: getNorthbcN "+ zone_affichee.getNorthbcN()); |
---|
418 | LoggerPerso.log(LoggerPerso.class, LoggerPerso.DEBUG, "zonnnnnnnnnnnnnnnnnnnnnnnne affichee: getSouthbcN "+ zone_affichee.getSouthbcN()); |
---|
419 | |
---|
420 | |
---|
421 | //pixelCenter = serv_carte.getCarte(id_grille, colormap_id, zone_affichee, getIdUnique()+1).getCenter(); |
---|
422 | //LoggerPerso.log(CarteBean.class, LoggerPerso.DEBUG, "pixelCenter zoom :: " + pixelCenter); |
---|
423 | LoggerPerso.log(CarteBean.class, LoggerPerso.DEBUG, "************setImageURL.zone :: " + zone_affichee); |
---|
424 | LoggerPerso.log(CarteBean.class, LoggerPerso.DEBUG, "************FIN " ); |
---|
425 | |
---|
426 | } |
---|
427 | |
---|
428 | /** |
---|
429 | * Permet de zoomer |
---|
430 | * @param id_grille |
---|
431 | * @param imageID |
---|
432 | */ |
---|
433 | public void makeZoom(long id_grille, String imageID, double resol) { |
---|
434 | |
---|
435 | /* StatReponse statReponse = serv_carte.getCarte(id_grille, colormap_id.longValue(), zone_selection, getIdUnique()); |
---|
436 | pixelCenter = statReponse.getCenter(); |
---|
437 | centerLat = statReponse.getCenterLat(); |
---|
438 | centerLon = statReponse.getCenterLon();*/ |
---|
439 | LoggerPerso.log(CarteBean.class, LoggerPerso.DEBUG, "-------------------------------------------> clicX :: " +clicX); |
---|
440 | LoggerPerso.log(CarteBean.class, LoggerPerso.DEBUG, "-------------------------------------------> clicY :: " + clicY); |
---|
441 | |
---|
442 | Zone aZone = serv_carte.getCarteCoordinate(); |
---|
443 | LoggerPerso.log(CarteBean.class, LoggerPerso.DEBUG, "-------------------------------------------> getEastbc :: " +aZone.getEastbc()); |
---|
444 | LoggerPerso.log(CarteBean.class, LoggerPerso.DEBUG, "-------------------------------------------> getNorthbc :: " +aZone.getNorthbc() ); |
---|
445 | LoggerPerso.log(CarteBean.class, LoggerPerso.DEBUG, "-------------------------------------------> getSouthbc :: " +aZone.getSouthbc()); |
---|
446 | LoggerPerso.log(CarteBean.class, LoggerPerso.DEBUG, "-------------------------------------------> getWestbc :: " +aZone.getWestbc() ); |
---|
447 | |
---|
448 | serv_carte.zoomCarte(2, clicX, clicY, resol); |
---|
449 | url = serv_carte.getCarte(id_grille, colormap_id, null, imageID).getUrlImage(); |
---|
450 | } |
---|
451 | |
---|
452 | /** |
---|
453 | * Permet de générer une carte statistique |
---|
454 | * @param updateAffiche permet de savoir si la zone visualisé doit être modifié ou non |
---|
455 | */ |
---|
456 | public void gestionCarteStat(boolean updateAffiche) { |
---|
457 | CritereBean critereBean = (CritereBean)((HttpSession)FacesContext.getCurrentInstance().getExternalContext().getSession(false)).getAttribute("critereBean"); |
---|
458 | /* |
---|
459 | * Traduction des paramêtres... Bon ça serai mieux de faire ça dans un traducteur dédié quand même :) |
---|
460 | */ |
---|
461 | Map<String, String> critere = new TraducteurCarte().tradCritere2Stat(critereBean, this); |
---|
462 | Long id_param = critereBean.getParametre(); |
---|
463 | Long id_produit = critereBean.getProduit(); |
---|
464 | Zone zone_selection = new Zone(critereBean.getNorthbc(), critereBean.getSouthbc(), critereBean.getEastbc(), critereBean.getWestbc()); |
---|
465 | |
---|
466 | String url_retourne; |
---|
467 | if (clicX != -1 && clicY != -1) { // en cas de zoom |
---|
468 | serv_carte.zoomCarte(2, clicX, clicY, resolution); |
---|
469 | url_retourne = serv_carte.getCarteStat(critere, id_param, id_produit, getColormap_id(), getStatistiqueUI().getValue().toString(), getIdUnique(), null).getUrlImage(); |
---|
470 | |
---|
471 | |
---|
472 | |
---|
473 | } |
---|
474 | else if (updateAffiche) { // sans zoom mais on fait un update sur la zone affiché (on revient sur la zone sélectionnée) |
---|
475 | Map<String, String> critere2 = new TraducteurCarte().tradCritere2StatReinit(critereBean, this); |
---|
476 | url_retourne = serv_carte.getCarteStat(critere2, id_param, id_produit, getColormap_id(), getStatistiqueUI().getValue().toString(), getIdUnique(), zone_selection).getUrlImage(); |
---|
477 | |
---|
478 | centerLatClick = 0; |
---|
479 | centerLonClick = 0; |
---|
480 | } |
---|
481 | else // sans zoom et on reste sur la zone actuellement visible |
---|
482 | url_retourne = serv_carte.getCarteStat(critere, id_param, id_produit, getColormap_id(), getStatistiqueUI().getValue().toString(), getIdUnique(), null).getUrlImage(); |
---|
483 | |
---|
484 | |
---|
485 | |
---|
486 | ////system.out.println(url_retourne); |
---|
487 | clicX = -1; |
---|
488 | clicY = -1; |
---|
489 | |
---|
490 | url = url_retourne; |
---|
491 | LoggerPerso.log(CarteBean.class, LoggerPerso.DEBUG, "::CarteBean::ChangeStatistique::ok::\n" + critere + "::" + id_param + "::" + id_produit + "::" + getStatistiqueUI().getValue().toString()); |
---|
492 | url_legend = serv_carte.getLegendStat(critereBean.getGrille().longValue(), colormap_id.longValue(), getStatistiqueUI().getValue().toString(), getIdUnique()); |
---|
493 | if (mapTitleUI != null) |
---|
494 | mapTitleUI.setValue("statitics on " + parametre + " : " + produit); |
---|
495 | mapTitle = "statitics on " + parametre + " : " + produit; |
---|
496 | |
---|
497 | ///initialisation du pixel du centre de la zone |
---|
498 | |
---|
499 | |
---|
500 | zone_affichee = serv_carte.getCarteCoordinate(); |
---|
501 | LoggerPerso.log(CarteBean.class, LoggerPerso.DEBUG, "************DEBUT " ); |
---|
502 | CritereBean critereBeanProvisoire = new CritereBean(); |
---|
503 | critereBeanProvisoire.setBegDate(critereBean.getBegDate()); |
---|
504 | critereBeanProvisoire.setEndDate(critereBean.getEndDate()); |
---|
505 | |
---|
506 | Zone zone_click = new Zone(centerLatClick, centerLatClick , centerLonClick, centerLonClick); |
---|
507 | |
---|
508 | critereBeanProvisoire.setEastbc(zone_click.getEastbc()); |
---|
509 | critereBeanProvisoire.setWestbc(zone_click.getWestbc()); |
---|
510 | critereBeanProvisoire.setNorthbc(zone_click.getNorthbc()); |
---|
511 | critereBeanProvisoire.setSouthbc(zone_click.getSouthbc()); |
---|
512 | |
---|
513 | Map<String, String> critereProvisoire = new TraducteurCarte().tradCritere2StatReinit(critereBeanProvisoire, this); |
---|
514 | |
---|
515 | StatReponse statReponse = serv_carte.getStatReponse(critereProvisoire, id_param, id_produit, getColormap_id(), getStatistiqueUI().getValue().toString(), getIdUnique(), null); |
---|
516 | |
---|
517 | |
---|
518 | String aPixelCenter = (String)Double.toString(statReponse.getCenter()); |
---|
519 | |
---|
520 | pixelCenter = fixeDecimal(aPixelCenter); |
---|
521 | centerLat = statReponse.getCenterLat(); |
---|
522 | centerLon = statReponse.getCenterLon(); |
---|
523 | LoggerPerso.log(CarteBean.class, LoggerPerso.DEBUG, "***********pixelCenter stat :: " +pixelCenter); |
---|
524 | LoggerPerso.log(CarteBean.class, LoggerPerso.DEBUG, "***********centerLat stat :: " +centerLat ); |
---|
525 | LoggerPerso.log(CarteBean.class, LoggerPerso.DEBUG, "***********centerLon stat :: " +centerLon); |
---|
526 | } |
---|
527 | |
---|
528 | /** |
---|
529 | * initialise la valeur de statistique sélectionnée |
---|
530 | * |
---|
531 | */ |
---|
532 | private void initStatistiqueList() { |
---|
533 | gridOn = true; |
---|
534 | statOn = false; |
---|
535 | if (statistiqueUI != null) |
---|
536 | statistiqueUI.setValue("none"); |
---|
537 | statistique = "none"; |
---|
538 | } |
---|
539 | |
---|
540 | |
---|
541 | |
---|
542 | |
---|
543 | |
---|
544 | |
---|
545 | private String fixeDecimal(String entree) { |
---|
546 | LoggerPerso.log(ServiceStatistique.class, LoggerPerso.DEBUG, "-------------------------------------******------>entree "+entree); |
---|
547 | if (entree == null) |
---|
548 | return "nc"; |
---|
549 | int index = entree.lastIndexOf("."); |
---|
550 | int indexE = entree.lastIndexOf("E"); |
---|
551 | LoggerPerso.log(ServiceStatistique.class, LoggerPerso.DEBUG, "entree --lll-->2 "+indexE+" "+index+" "+entree.length()); |
---|
552 | if ( indexE == -1 && index != -1 && entree.length() >= index + 5) |
---|
553 | entree = entree.substring(0, entree.lastIndexOf(".")+5); |
---|
554 | if ( indexE != -1 && index != -1 && entree.length() >= index + 5) |
---|
555 | { |
---|
556 | String aEntree = entree; |
---|
557 | LoggerPerso.log(ServiceStatistique.class, LoggerPerso.DEBUG, "aEntree "+aEntree.lastIndexOf("E")+" "+aEntree.length()+" "+aEntree.lastIndexOf("E")+" "+aEntree.length()); |
---|
558 | aEntree=aEntree.substring(aEntree.lastIndexOf("E"), aEntree.lastIndexOf("E")+aEntree.length()-aEntree.lastIndexOf("E")); |
---|
559 | entree = entree.substring(0, entree.lastIndexOf(".")+5)+aEntree; |
---|
560 | } |
---|
561 | LoggerPerso.log(ServiceStatistique.class, LoggerPerso.DEBUG, "entree "+entree); |
---|
562 | return entree; |
---|
563 | } |
---|
564 | |
---|
565 | |
---|
566 | /*===================================================== |
---|
567 | * Getter and Setter |
---|
568 | ======================================================*/ |
---|
569 | |
---|
570 | public String getParametre() { |
---|
571 | controleSession(); |
---|
572 | return parametre; |
---|
573 | } |
---|
574 | |
---|
575 | public void setParametre(String parametre) { |
---|
576 | this.parametre = parametre; |
---|
577 | } |
---|
578 | |
---|
579 | public String getProduit() { |
---|
580 | return produit; |
---|
581 | } |
---|
582 | |
---|
583 | public void setProduit(String produit) { |
---|
584 | this.produit = produit; |
---|
585 | } |
---|
586 | |
---|
587 | public String getVisu() { |
---|
588 | return visu; |
---|
589 | } |
---|
590 | |
---|
591 | public void setVisu(String visu) { |
---|
592 | this.visu = visu; |
---|
593 | } |
---|
594 | |
---|
595 | public String getUrl_legend() { |
---|
596 | return url_legend; |
---|
597 | } |
---|
598 | |
---|
599 | public void setUrl_legend(String url_legend) { |
---|
600 | this.url_legend = url_legend; |
---|
601 | } |
---|
602 | |
---|
603 | public UIOutput getEastbc() { |
---|
604 | return eastbc; |
---|
605 | } |
---|
606 | |
---|
607 | public void setEastbc(UIOutput eastbc) { |
---|
608 | this.eastbc = eastbc; |
---|
609 | } |
---|
610 | |
---|
611 | public UIOutput getNorthbc() { |
---|
612 | return northbc; |
---|
613 | } |
---|
614 | |
---|
615 | public void setNorthbc(UIOutput northbc) { |
---|
616 | this.northbc = northbc; |
---|
617 | } |
---|
618 | |
---|
619 | public UIOutput getSouthbc() { |
---|
620 | return southbc; |
---|
621 | } |
---|
622 | |
---|
623 | public void setSouthbc(UIOutput southbc) { |
---|
624 | this.southbc = southbc; |
---|
625 | } |
---|
626 | |
---|
627 | public UIOutput getWestbc() { |
---|
628 | return westbc; |
---|
629 | } |
---|
630 | |
---|
631 | public void setWestbc(UIOutput westbc) { |
---|
632 | this.westbc = westbc; |
---|
633 | } |
---|
634 | |
---|
635 | public UISelectOne getColormapUI() { |
---|
636 | return colormapUI; |
---|
637 | } |
---|
638 | |
---|
639 | public void setColormapUI(UISelectOne colormapUI) { |
---|
640 | this.colormapUI = colormapUI; |
---|
641 | } |
---|
642 | |
---|
643 | public String getUrl() { |
---|
644 | return url; |
---|
645 | } |
---|
646 | |
---|
647 | public void setUrl(String url) { |
---|
648 | this.url = url; |
---|
649 | } |
---|
650 | public Long getColormap_id() { |
---|
651 | return colormap_id; |
---|
652 | } |
---|
653 | |
---|
654 | public void setColormap_id(Long colormap_id) { |
---|
655 | this.colormap_id = colormap_id; |
---|
656 | } |
---|
657 | |
---|
658 | public List<SelectItem> getListe_colormap() { |
---|
659 | return liste_colormap; |
---|
660 | } |
---|
661 | |
---|
662 | public void setListe_colormap(List<SelectItem> liste_colormap) { |
---|
663 | this.liste_colormap = liste_colormap; |
---|
664 | } |
---|
665 | |
---|
666 | public int getClicX() { |
---|
667 | return clicX; |
---|
668 | } |
---|
669 | |
---|
670 | public void setClicX(int clicX) { |
---|
671 | this.clicX = clicX; |
---|
672 | } |
---|
673 | |
---|
674 | public int getClicY() { |
---|
675 | return clicY; |
---|
676 | } |
---|
677 | |
---|
678 | public void setClicY(int clicY) { |
---|
679 | this.clicY = clicY; |
---|
680 | } |
---|
681 | |
---|
682 | public Zone getZone_affichee() { |
---|
683 | return zone_affichee; |
---|
684 | } |
---|
685 | |
---|
686 | public void setZone_affichee(Zone zone_affichee) { |
---|
687 | this.zone_affichee = zone_affichee; |
---|
688 | } |
---|
689 | |
---|
690 | public String getStatistique() { |
---|
691 | return statistique; |
---|
692 | } |
---|
693 | |
---|
694 | public void setStatistique(String statistique) { |
---|
695 | this.statistique = statistique; |
---|
696 | } |
---|
697 | |
---|
698 | public UISelectOne getStatistiqueUI() { |
---|
699 | return statistiqueUI; |
---|
700 | } |
---|
701 | |
---|
702 | public void setStatistiqueUI(UISelectOne statistiqueUI) { |
---|
703 | this.statistiqueUI = statistiqueUI; |
---|
704 | } |
---|
705 | |
---|
706 | public int getNbrGrille() { |
---|
707 | return nbrGrille; |
---|
708 | } |
---|
709 | |
---|
710 | public void setNbrGrille(int nbrGrille) { |
---|
711 | this.nbrGrille = nbrGrille; |
---|
712 | } |
---|
713 | |
---|
714 | public boolean isGridOn() { |
---|
715 | return gridOn; |
---|
716 | } |
---|
717 | |
---|
718 | public void setGridOn(boolean gridOn) { |
---|
719 | this.gridOn = gridOn; |
---|
720 | } |
---|
721 | |
---|
722 | public boolean isStatOn() { |
---|
723 | return statOn; |
---|
724 | } |
---|
725 | |
---|
726 | public void setStatOn(boolean statOn) { |
---|
727 | this.statOn = statOn; |
---|
728 | } |
---|
729 | |
---|
730 | |
---|
731 | public String getMapTitle() { |
---|
732 | return mapTitle; |
---|
733 | } |
---|
734 | |
---|
735 | |
---|
736 | public void setMapTitle(String mapTitle) { |
---|
737 | this.mapTitle = mapTitle; |
---|
738 | } |
---|
739 | |
---|
740 | |
---|
741 | public UIOutput getMapTitleUI() { |
---|
742 | return mapTitleUI; |
---|
743 | } |
---|
744 | |
---|
745 | |
---|
746 | public void setMapTitleUI(UIOutput mapTitleUI) { |
---|
747 | this.mapTitleUI = mapTitleUI; |
---|
748 | } |
---|
749 | |
---|
750 | |
---|
751 | public double getMinParam() { |
---|
752 | return minParam; |
---|
753 | } |
---|
754 | |
---|
755 | public void setMinParam(double aMinParam) { |
---|
756 | this.minParam = aMinParam; |
---|
757 | } |
---|
758 | public UIInput getMinParamUI() { |
---|
759 | return minParamUI; |
---|
760 | } |
---|
761 | |
---|
762 | public void setMinParamUI(UIInput aMinParamUI) { |
---|
763 | this.minParamUI = aMinParamUI; |
---|
764 | } |
---|
765 | public double getMaxParam() { |
---|
766 | return maxParam; |
---|
767 | } |
---|
768 | |
---|
769 | public void setMaxParam(double aMaxParam) { |
---|
770 | this.maxParam = aMaxParam; |
---|
771 | } |
---|
772 | public UIInput getMaxParamUI() { |
---|
773 | return maxParamUI; |
---|
774 | } |
---|
775 | |
---|
776 | public void setMaxParamUI(UIInput aMaxParamUI) { |
---|
777 | this.maxParamUI = aMaxParamUI; |
---|
778 | } |
---|
779 | |
---|
780 | public Long getNbrClasses() { |
---|
781 | return nbrClasses; |
---|
782 | } |
---|
783 | |
---|
784 | public void setNbrClasses(Long aNbrClasses) { |
---|
785 | this.nbrClasses = aNbrClasses; |
---|
786 | } |
---|
787 | |
---|
788 | public UISelectOne getNbrClassesUI() { |
---|
789 | return nbrClassesUI; |
---|
790 | } |
---|
791 | |
---|
792 | public void setNbrClassesUI(UISelectOne aNbrClassesUI) { |
---|
793 | this.nbrClassesUI = aNbrClassesUI; |
---|
794 | } |
---|
795 | |
---|
796 | public String getPixelCenter() { |
---|
797 | return pixelCenter; |
---|
798 | } |
---|
799 | public void setPixelCenter(String aPixelCenter) { |
---|
800 | this.pixelCenter = aPixelCenter; |
---|
801 | } |
---|
802 | |
---|
803 | public double getCenterLon() { |
---|
804 | return centerLon; |
---|
805 | } |
---|
806 | public void setCenterLon(double aCenterLon) { |
---|
807 | this.centerLon = aCenterLon; |
---|
808 | } |
---|
809 | |
---|
810 | public double getCenterLat() { |
---|
811 | return centerLat; |
---|
812 | } |
---|
813 | public void setCenterLat(double aCenterLat) { |
---|
814 | this.centerLat = aCenterLat; |
---|
815 | } |
---|
816 | |
---|
817 | public double getCenterLonClick() { |
---|
818 | return centerLonClick; |
---|
819 | } |
---|
820 | public void setCenterLonClick(double aCenterLonClick) { |
---|
821 | this.centerLonClick = aCenterLonClick; |
---|
822 | } |
---|
823 | |
---|
824 | public double getCenterLatClick() { |
---|
825 | return centerLatClick; |
---|
826 | } |
---|
827 | public void setCenterLatClick(double aCenterLatClick) { |
---|
828 | this.centerLatClick = aCenterLatClick; |
---|
829 | } |
---|
830 | |
---|
831 | public UIOutput PixelCenterUI() { |
---|
832 | return pixelCenterUI; |
---|
833 | } |
---|
834 | |
---|
835 | public void setPixelCenterUI(UIOutput aPixelCenterUI) { |
---|
836 | this.pixelCenterUI = aPixelCenterUI; |
---|
837 | } |
---|
838 | |
---|
839 | |
---|
840 | public double getResolution() { |
---|
841 | return resolution; |
---|
842 | } |
---|
843 | public void setResolution(double aResolution) { |
---|
844 | this.resolution = aResolution; |
---|
845 | } |
---|
846 | |
---|
847 | } |
---|
848 | |
---|
849 | |
---|