Changeset 70 for ether_eccad/trunk/ECCAD_INTERFACE/WEB-INF/src/org/medias/eccad/metier/statistique/ServiceStatistique.java
- Timestamp:
- 04/26/10 19:12:49 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ether_eccad/trunk/ECCAD_INTERFACE/WEB-INF/src/org/medias/eccad/metier/statistique/ServiceStatistique.java
r68 r70 5 5 import java.util.Map; 6 6 7 8 import org.medias.eccad.helpers.LoggerPerso;9 7 import org.medias.eccad.helpers.SpringBeanFactory; 10 import org.medias.eccad.helpers.XmlHelper;11 8 import org.medias.eccad.metier.generationRaster.GenerateurLegendRaster; 12 9 import org.medias.eccad.metier.generationRaster.GenerateurLegendeImg; 13 import org.medias.eccad.metier.generationRaster.GenerateurWorldFile;14 10 import org.medias.eccad.metier.generationRaster.InformationLegend; 15 11 import org.medias.eccad.metier.generationRaster.colorMap.ColorMapping; … … 20 16 import org.medias.eccad.modele.StatReponse; 21 17 import org.medias.eccad.modele.Valeur; 22 import org.medias.eccad.modele.Zone;23 18 import org.medias.eccad.persistance.dao.ColorTabDAO; 24 19 import org.medias.eccad.persistance.exception.PersistanceException; … … 35 30 } 36 31 37 public StatReponse getCarteStat(Map<String, String> criteres, long id_param, long id_produit, long id_colormap, String fonction, String id_unique) {38 String xml = traducteur.encodeCritere(criteres, id_param, id_produit, id_colormap, fonction);39 32 public StatReponse getCarteStat(Map<String, String> criteres, long id_param, long id_produit, long id_colormap, long id_classdis, long id_secteur, long id_rcp, String alt, String fonction, long maskId) { 33 String xml = traducteur.encodeCritere(criteres, id_param, id_produit, id_colormap, id_classdis, id_secteur, id_rcp, alt, fonction, maskId); 34 40 35 // TODO: ici modifier pour prendre en compte la librairie de jean-luc 41 36 //RasterDAO rasterdao = new RasterDAO(); 42 37 GrapheCGI rasterdao = new GrapheCGI(); 43 ////system.out.println(xml); 38 44 39 reponse = decodeReponse(rasterdao.getStatistique(xml)); 45 40 if (reponse.getError() != null && !reponse.getError().equals("")) 46 41 return null; 47 42 48 GenerateurWorldFile gen_worldfile = (GenerateurWorldFile) xmlbean.getBean("worldfile");49 gen_worldfile.setPasX(reponse.getCarte().getPasX());50 gen_worldfile.setPasY(reponse.getCarte().getPasY());51 gen_worldfile.setPixelY(reponse.getZone().getNorthbc() - (reponse.getCarte().getPasY()/2));52 gen_worldfile.setPixelX(reponse.getZone().getWestbc() + (reponse.getCarte().getPasY()/2));43 // GenerateurWorldFile gen_worldfile = (GenerateurWorldFile) xmlbean.getBean("worldfile"); 44 // gen_worldfile.setPasX(reponse.getCarte().getPasX()); 45 // gen_worldfile.setPasY(reponse.getCarte().getPasY()); 46 // gen_worldfile.setPixelY(reponse.getZone().getNorthbc() - (reponse.getCarte().getPasY()/2)); 47 // gen_worldfile.setPixelX(reponse.getZone().getWestbc() + (reponse.getCarte().getPasX()/2)); 53 48 54 55 String nom = reponse.getUrlImage(); 56 57 nom = nom.substring(0, nom.length()-4); 58 gen_worldfile.writeWorldFile(nom); 59 60 ////system.out.println(stat.getUrlImage()); 61 //return reponse.getUrlImage(); 49 // String nom = reponse.getUrlImage(); 50 51 // nom = nom.substring(0, nom.length()-4); 52 // gen_worldfile.writeWorldFile(nom); 53 54 //return reponse.getUrlImage(); 62 55 return reponse; 63 56 } 64 57 65 public String getLegend(String fichier, long id_colormap, long id_ grille) {66 LoggerPerso.log(ServiceStatistique.class, LoggerPerso.DEBUG, "retour getLegend " + reponse.getMaximal() +" " + reponse.getMinimal());67 ColorMapping colormap = getColorMap(id_colormap );58 public String getLegend(String fichier, long id_colormap, long id_classdis, long id_grille, String fonction) { 59 // LoggerPerso.log(ServiceStatistique.class, LoggerPerso.DEBUG, "retour getLegend " + reponse.getMaximal() + " " + reponse.getMinimal()); 60 ColorMapping colormap = getColorMap(id_colormap,id_classdis); 68 61 InformationLegend info_legend = new InformationLegend(); 69 62 GenerateurLegendRaster gen_legend = new GenerateurLegendeImg(); 70 71 gen_legend.genereLegendVertical(colormap, info_legend.getLegendDynamic(colormap.getColorTable(), reponse.getMaximal(), reponse.getMinimal()), info_legend.getInfoSup(id_grille ));63 64 gen_legend.genereLegendVertical(colormap, info_legend.getLegendDynamic(colormap.getColorTable(), reponse.getMaximal(), reponse.getMinimal()), info_legend.getInfoSup(id_grille,fonction)); 72 65 gen_legend.enregistreLegend(fichier+".legend.png"); 73 66 74 67 return fichier+".legend.png"; 75 68 } 76 77 public ResultatStat getStatistique(Map<String, String> criteres, long id_param, long id_produit, String fonction) {69 70 public ResultatStat getStatistique(Map<String, String> criteres, long id_param, long id_produit, long id_secteur, long id_rcp, String alt, String type, String fonction) { 78 71 //RasterDAO rasterdao = new RasterDAO(); 79 72 GrapheCGI rasterdao = new GrapheCGI(); 80 String xml = traducteur.encodeCritere(criteres, id_param, id_produit, new Long(-1), fonction); 81 //system.out.println(xml); 82 LoggerPerso.log(ServiceStatistique.class, LoggerPerso.DEBUG, ""); 73 String xml = traducteur.encodeCritere(criteres, id_param, id_produit, -1, -1, id_secteur, id_rcp, alt, fonction, 0); 83 74 reponse = decodeReponse(rasterdao.getStatistique(xml)); 84 75 if (reponse == null) 85 return new ResultatStat("0", "0", "0", "0", "0" );76 return new ResultatStat("0", "0", "0", "0", "0",type); 86 77 Map<String, String> map = reponse.getStatistique(); 87 return new ResultatStat(map.get("min"), map.get("max"), map.get("moyenne"), map.get("ecartType"), map.get("somme") );78 return new ResultatStat(map.get("min"), map.get("max"), map.get("moyenne"), map.get("ecartType"), map.get("somme"),type); 88 79 } 89 90 public String getGraphe(String identifiant, Map<String, String> criteres, long id_param, long id_produit, String fonction) {80 81 public String getGraphe(String identifiant, Map<String, String> criteres, long id_param, long id_produit, long id_secteur, long id_rcp, String alt, String param, String produit, String unite, String secteur, String rcp, String fonction) { 91 82 //RasterDAO rasterdao = new RasterDAO(); 92 83 GrapheCGI rasterdao = new GrapheCGI(); 93 String xml = traducteur.encodeCritere(criteres, id_param, id_produit, new Long(-1), fonction);94 LoggerPerso.log(ServiceStatistique.class, LoggerPerso.DEBUG, "xml ::\n" + xml);84 String xml = traducteur.encodeCritere(criteres, id_param, id_produit, -1, -1, id_secteur, id_rcp, alt, fonction, 0); 85 // LoggerPerso.log(ServiceStatistique.class, LoggerPerso.DEBUG, "xml ::\n" + xml); 95 86 String str_reponse = rasterdao.getStatistique(xml); 96 LoggerPerso.log(ServiceStatistique.class, LoggerPerso.DEBUG, "reception OK");87 // LoggerPerso.log(ServiceStatistique.class, LoggerPerso.DEBUG, "str_reponse ::\n" + str_reponse); 97 88 reponse = decodeReponse(str_reponse); 98 LoggerPerso.log(ServiceStatistique.class, LoggerPerso.DEBUG, "decodage OK");99 89 List<Valeur> graphe; 100 90 if (reponse == null) … … 102 92 else 103 93 graphe = reponse.getGraphe(); 104 105 return new ServiceGraphe().genereGraphe(identifiant, graphe );94 95 return new ServiceGraphe().genereGraphe(identifiant, graphe, param, produit, unite, secteur, rcp, alt); 106 96 } 107 108 109 97 110 98 public StatReponse decodeReponse(String reponse_xml) { 111 99 reponse = traducteur.getReponse(reponse_xml); 112 100 113 101 if (reponse.getError() != null && !reponse.getError().equals("")) 114 102 return null; 115 103 return reponse; 116 104 } 117 105 118 106 /** 119 107 * Interroge la base de données pour obtenir la table de couleur de la grille … … 122 110 * @return la table de couleur par défaut 123 111 */ 124 private ColorMapping getColorMap(long colormapid ) {112 private ColorMapping getColorMap(long colormapid, long classdisid) { 125 113 ColorTabDAO colorDAO = (ColorTabDAO) xmlbean.getBean("colorTabDAO"); 126 114 127 115 ColorTab colortab = null; 128 116 129 117 try { 130 colortab = colorDAO.getColorMapByID(colormapid );118 colortab = colorDAO.getColorMapByID(colormapid,classdisid); 131 119 } catch (PersistanceException e) { 132 120 e.printStackTrace(); 133 121 } 134 122 135 123 ColorMapping colormap = new ColorMappingLineaire(); 136 124 colormap.setColorTable(colortab);
Note: See TracChangeset
for help on using the changeset viewer.