From: <emm...@us...> - 2009-01-08 16:45:27
|
Revision: 4337 http://fudaa.svn.sourceforge.net/fudaa/?rev=4337&view=rev Author: emmanuel_martin Date: 2009-01-08 16:45:23 +0000 (Thu, 08 Jan 2009) Log Message: ----------- Mise ?\195?\160 jour de l'exporteur mascaret. Modified Paths: -------------- branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretWriter.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/Controller1d.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/UtilsProfil1d.java Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretWriter.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretWriter.java 2009-01-08 15:58:18 UTC (rev 4336) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretWriter.java 2009-01-08 16:45:23 UTC (rev 4337) @@ -23,7 +23,7 @@ import org.fudaa.ctulu.gis.GISGeometryFactory; import org.fudaa.ctulu.gis.GISPoint; import org.fudaa.ctulu.gis.GISPolyligne; -import org.fudaa.ctulu.gis.GISZoneCollectionLigneBrisee; +import org.fudaa.ctulu.gis.GISZoneCollection; import com.vividsolutions.jts.geom.Coordinate; import com.vividsolutions.jts.geom.CoordinateSequence; @@ -32,7 +32,7 @@ /** * Ecrit au format mascaret 1d et 2d. * @author Emmanuel MARTIN - * @version $Id:$ + * @version $Id$ */ public class MascaretWriter extends FileWriteOperationAbstract { @@ -47,10 +47,10 @@ * Cette classe permet \xE0 l'exporteur de selectionner les * profils \xE0 exporter. G\xE9n\xE9ralement les profiles invalides sont ignor\xE9s. * @author Emmanuel MARTIN - * @version $Id:$ + * @version $Id$ */ public interface FunctorSelectProfil { - public boolean exportProfil(GISZoneCollectionLigneBrisee _zone, int _idxProfil); + public boolean exportProfil(GISZoneCollection _zone, int _idxProfil); } public MascaretWriter() {} @@ -79,7 +79,7 @@ if(((Object[])_o).length!=4) throw new IllegalArgumentException("Il doit y avoir 4 param\xE8tres dans _o."); String nomBief=(String)((Object[])_o)[0]; - GISZoneCollectionLigneBrisee[] zones=(GISZoneCollectionLigneBrisee[])((Object[])_o)[1]; + GISZoneCollection[] zones=(GISZoneCollection[])((Object[])_o)[1]; FunctorSelectProfil selectorProfil=(FunctorSelectProfil)((Object[])_o)[2]; version_=(String)((Object[])_o)[3]; if (nomBief==null) @@ -152,9 +152,9 @@ * @throws MascaretDataError * @throws MascaretDataIncomplete */ - private void generateMascaretProfilAbstractRepresentations(String _nomBief, GISZoneCollectionLigneBrisee[] _zones, FunctorSelectProfil _selectorProfil) throws MascaretDataError, MascaretDataIncomplete{ + private void generateMascaretProfilAbstractRepresentations(String _nomBief, GISZoneCollection[] _zones, FunctorSelectProfil _selectorProfil) throws MascaretDataError, MascaretDataIncomplete{ // Recherche de l'axe hydraulique \\ - GISZoneCollectionLigneBrisee zoneAxeHydraulique=null; + GISZoneCollection zoneAxeHydraulique=null; int indexAxeHydraulique=-1; for (int i=0; i<_zones.length; i++) { int idxAttNature=_zones[i].getIndiceOf(GISAttributeConstants.NATURE); @@ -172,7 +172,7 @@ throw new MascaretDataIncomplete("Il n'y a pas d'axes hydrauliques."); // Recherche des profils \\ - List<GISZoneCollectionLigneBrisee> profils=new ArrayList<GISZoneCollectionLigneBrisee>(); + List<GISZoneCollection> profils=new ArrayList<GISZoneCollection>(); List<Integer> indexProfils=new ArrayList<Integer>(); for (int i=0; i<_zones.length; i++) { int idxAttNature=_zones[i].getIndiceOf(GISAttributeConstants.NATURE); @@ -189,23 +189,19 @@ int countNoName=1; GISPolyligne axeHydraulique=(GISPolyligne)zoneAxeHydraulique.getGeometry(indexAxeHydraulique); for (int i=0;i<profils.size();i++) { - GISZoneCollectionLigneBrisee zoneProfil=profils.get(i); + GISZoneCollection zoneProfil=profils.get(i); int idxProfil=indexProfils.get(i); GISPolyligne profil=(GISPolyligne) zoneProfil.getGeometry(idxProfil); MascaretProfilAbstractRepresentation profilAbs=new MascaretProfilAbstractRepresentation(); // Information globales sur le profil \\ // Nom bief - if(_nomBief.contains(" ")) - throw new MascaretDataError("Le nom du bief ne doit pas contenir d'espace."); - profilAbs.nomBief=_nomBief; + profilAbs.nomBief=_nomBief.replace(' ', '_'); // Nom profil int idxTitle=zoneProfil.getIndiceOf(GISAttributeConstants.TITRE); if(idxTitle!=-1){ String nomProfil=(String) zoneProfil.getValue(idxTitle, idxProfil); - if(nomProfil.contains(" ")) - throw new MascaretDataError("Le nom du profil ne doit pas contenir d'espace."); - profilAbs.nomProfil=nomProfil; + profilAbs.nomProfil=nomProfil.replace(' ', '_'); } else profilAbs.nomProfil="No_Name_"+countNoName++; @@ -238,38 +234,30 @@ ArrayList<Integer> seps=new ArrayList<Integer>(); //INTERSECTION_RIVE_GAUCHE int idxInterRiveG=zoneProfil.getIndiceOf(GISAttributeConstants.INTERSECTION_RIVE_GAUCHE); - Coordinate intersectionRiveGauche; Integer idxRG=-1; if(idxInterRiveG!=-1) { - intersectionRiveGauche=(Coordinate) zoneProfil.getValue(idxInterRiveG, idxProfil); - idxRG=idxIntersection(coordSeq, intersectionRiveGauche); + idxRG=(Integer) zoneProfil.getValue(idxInterRiveG, idxProfil); seps.add(idxRG); } //INTERSECTION_RIVE_DROITE int idxInterRiveD=zoneProfil.getIndiceOf(GISAttributeConstants.INTERSECTION_RIVE_DROITE); - Coordinate intersectionRiveDroite; Integer idxRD=-1; if(idxInterRiveD!=-1) { - intersectionRiveDroite=(Coordinate) zoneProfil.getValue(idxInterRiveD, idxProfil); - idxRD=idxIntersection(coordSeq, intersectionRiveDroite); + idxRD=(Integer) zoneProfil.getValue(idxInterRiveD, idxProfil); seps.add(idxRD); } //INTERSECTION_LIMITE_STOCKAGE_GAUCHE int idxInterStockageG=zoneProfil.getIndiceOf(GISAttributeConstants.INTERSECTION_LIMITE_STOCKAGE_GAUCHE); - Coordinate intersectionStockageGauche; Integer idxSG=-1; if(idxInterStockageG!=-1) { - intersectionStockageGauche=(Coordinate) zoneProfil.getValue(idxInterStockageG, idxProfil); - idxSG=idxIntersection(coordSeq, intersectionStockageGauche); + idxSG=(Integer) zoneProfil.getValue(idxInterStockageG, idxProfil); seps.add(idxSG); } //INTERSECTION_LIMITE_STOCKAGE_DROITE int idxInterStockageD=zoneProfil.getIndiceOf(GISAttributeConstants.INTERSECTION_LIMITE_STOCKAGE_DROITE); - Coordinate intersectionStockageDroit; Integer idxSD=-1; if(idxInterStockageD!=-1) { - intersectionStockageDroit=(Coordinate) zoneProfil.getValue(idxInterStockageD, idxProfil); - idxSD=idxIntersection(coordSeq, intersectionStockageDroit); + idxSD=(Integer) zoneProfil.getValue(idxInterStockageD, idxProfil); seps.add(idxSD); } if(idxRG==-1&&idxRD!=-1||idxRG!=-1&&idxRD==-1) @@ -281,9 +269,9 @@ // Bathy Topo ou Stockage if(sepsT.length==4){ int j; - for(j=0;j<sepsT[0];j++) + for(j=0;j<=sepsT[0];j++) profilAbs.bathyOuTopoOuStockage.add('S'); - for(;j<sepsT[1];j++) + for(;j<=sepsT[1];j++) profilAbs.bathyOuTopoOuStockage.add('T'); for(;j<sepsT[2];j++) profilAbs.bathyOuTopoOuStockage.add('B'); @@ -292,10 +280,10 @@ for(;j<coordSeq.size();j++) profilAbs.bathyOuTopoOuStockage.add('S'); } - if(sepsT.length==2) { + else if(sepsT.length==2) { if(sepsT[0]==idxRG||sepsT[0]==idxRD){ int j; - for(j=0;j<sepsT[0];j++) + for(j=0;j<=sepsT[0];j++) profilAbs.bathyOuTopoOuStockage.add('T'); for(;j<sepsT[1];j++) profilAbs.bathyOuTopoOuStockage.add('B'); @@ -304,7 +292,7 @@ } else{ int j; - for(j=0;j<sepsT[0];j++) + for(j=0;j<=sepsT[0];j++) profilAbs.bathyOuTopoOuStockage.add('S'); for(;j<sepsT[1];j++) profilAbs.bathyOuTopoOuStockage.add('B'); Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/Controller1d.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/Controller1d.java 2009-01-08 15:58:18 UTC (rev 4336) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/Controller1d.java 2009-01-08 16:45:23 UTC (rev 4337) @@ -32,6 +32,7 @@ import org.fudaa.ctulu.CtuluListSelectionListener; import org.fudaa.ctulu.CtuluNamedCommand; import org.fudaa.ctulu.gis.GISAttributeConstants; +import org.fudaa.ctulu.gis.GISZoneCollection; import org.fudaa.ctulu.gis.GISZoneCollectionLigneBrisee; import org.fudaa.dodico.mascaret.io.MascaretWriter; import org.fudaa.ebli.calque.ZCalqueAffichageDonneesInterface; @@ -367,13 +368,13 @@ mascaretWriter.setFile(vueExport.getFile()); Bief bief=controllerBief_.getSelectedBief(); if(bief==null) { - appli_.warn(FudaaLib.getS("Attention"), FudaaLib.getS("Il n'y a pas de bief \xE0 exporter.")); + appli_.warn(FudaaLib.getS("Attention"), FudaaLib.getS("Il n'y a pas de bief selectionn\xE9.")); return; } - Object[] zones=new Object[]{bief.axeHydraulique_.getGeomData(), bief.lignesDirectrices_.getGeomData(), + GISZoneCollection[] zones=new GISZoneCollection[]{bief.axeHydraulique_.getGeomData(), bief.lignesDirectrices_.getGeomData(), bief.limitesStockages_.getGeomData(), bief.profils_.getGeomData(), bief.rives_.getGeomData()}; MascaretWriter.FunctorSelectProfil functorSelectProfil=new MascaretWriter.FunctorSelectProfil() { - public boolean exportProfil(GISZoneCollectionLigneBrisee _zone, int _idxProfil) { + public boolean exportProfil(GISZoneCollection _zone, int _idxProfil) { return UtilsProfil1d.isProfilCorrect(_zone, _idxProfil); } }; Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/UtilsProfil1d.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/UtilsProfil1d.java 2009-01-08 15:58:18 UTC (rev 4336) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/UtilsProfil1d.java 2009-01-08 16:45:23 UTC (rev 4337) @@ -10,7 +10,7 @@ import org.fudaa.ctulu.gis.GISCoordinateSequenceContainerInterface; import org.fudaa.ctulu.gis.GISGeometryFactory; import org.fudaa.ctulu.gis.GISPoint; -import org.fudaa.ctulu.gis.GISZoneCollectionLigneBrisee; +import org.fudaa.ctulu.gis.GISZoneCollection; import org.fudaa.fudaa.commun.FudaaLib; import com.vividsolutions.jts.geom.Coordinate; @@ -30,7 +30,7 @@ /** * Retourne vrai si le profil est correct. */ - static public boolean isProfilCorrect(GISZoneCollectionLigneBrisee _zone, int _idxProfil) { + static public boolean isProfilCorrect(GISZoneCollection _zone, int _idxProfil) { CoordinateSequence seq=((GISCoordinateSequenceContainerInterface)_zone.getGeometry(_idxProfil)).getCoordinateSequence(); // Verifie qu'on a bien au minimum deux points. \\ if (seq.size()<2) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |