/* * Copyright (C) 2009 drocklin * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package exports; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import java.io.Writer; import static org.codelutin.i18n.I18n._; import org.codelutin.math.matrix.*; import scripts.ResultName; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.codelutin.math.matrix.MatrixIterator; import org.codelutin.math.matrix.MatrixND; import fr.ifremer.isisfish.datastore.SimulationStorage; import fr.ifremer.isisfish.entities.Metier; import fr.ifremer.isisfish.entities.Population; import fr.ifremer.isisfish.entities.PopulationGroup; import fr.ifremer.isisfish.entities.Zone; import fr.ifremer.isisfish.export.Export; import fr.ifremer.isisfish.types.Date; import fr.ifremer.isisfish.util.Doc; import fr.ifremer.isisfish.entities.*; import fr.ifremer.isisfish.datastore.ResultStorage; /** * Debarquement.java * * Created: 16 décembre 2009 * * @author drocklin * @version $Revision: 1545 $ * * Last update: $Date: 16 décembre 2009 $ * by : $Author: drocklin $ */ public class Debarquement implements Export { /** to use log facility, just put in your code: log.info(\"...\"); */ private static Log log = LogFactory.getLog(Debarquement.class); public String [] necessaryResult = {ResultName.MATRIX_LANDING_PER_MET}; public String[] getNecessaryResult() { return this.necessaryResult; } public String getExportFilename() { return "Debarquement"; } public String getExtensionFilename() { return ".csv"; } public String getDescription() { return _("Debarquement de peche egal aux captures moins les rejets"); } public void export(SimulationStorage simulation, Writer out) throws Exception { Date lastDate = simulation.getResultStorage().getLastDate(); for (Population pop : simulation.getParameter().getPopulations()) { for (Date date = new Date(0); !date.after(lastDate); date = date .next()) { MatrixND mat = simulation.getResultStorage().getMatrix(date, pop, ResultName.MATRIX_LANDING_PER_MET); if (mat != null) { // can be null if simulation is stopped before last year simulation mat = mat.sumOverDim(0); //sum on strategy for (MatrixIterator i = mat.iterator(); i.hasNext();) { i.next(); Object[] sems = i.getSemanticsCoordinates(); Metier metier = (Metier) sems[1]; PopulationGroup group = (PopulationGroup) sems[2]; Zone zone = (Zone) sems[3]; double val = i.getValue(); out.write(pop.getName() + ";" + metier.getName() + ";" + group.getId() + ";" + zone.getName() + ";" + date.getDate() + ";" + val + "\n"); } } } } } }