|
From: <bma...@us...> - 2008-06-27 15:25:45
|
Revision: 3665
http://fudaa.svn.sourceforge.net/fudaa/?rev=3665&view=rev
Author: bmarchan
Date: 2008-06-27 08:25:48 -0700 (Fri, 27 Jun 2008)
Log Message:
-----------
Track#32, Track#33 : Lecture des lignes directrices + des noms de geometries
Modified Paths:
--------------
branches/Br_FudaaModeleur_TF/fudaa_devel/dodico/src/org/fudaa/dodico/rubar/io/RubarStReader.java
branches/Br_FudaaModeleur_TF/fudaa_devel/fudaa/src/org/fudaa/fudaa/sig/wizard/FSigFileLoaderRubarSt.java
Modified: branches/Br_FudaaModeleur_TF/fudaa_devel/dodico/src/org/fudaa/dodico/rubar/io/RubarStReader.java
===================================================================
--- branches/Br_FudaaModeleur_TF/fudaa_devel/dodico/src/org/fudaa/dodico/rubar/io/RubarStReader.java 2008-06-27 15:22:32 UTC (rev 3664)
+++ branches/Br_FudaaModeleur_TF/fudaa_devel/dodico/src/org/fudaa/dodico/rubar/io/RubarStReader.java 2008-06-27 15:25:48 UTC (rev 3665)
@@ -11,21 +11,27 @@
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.LineString;
+import org.fudaa.ctulu.CtuluLib;
import org.fudaa.ctulu.CtuluLibString;
import org.fudaa.ctulu.gis.GISAttributeConstants;
import org.fudaa.ctulu.gis.GISAttributeInterface;
+import org.fudaa.ctulu.gis.GISAttributeModel;
+import org.fudaa.ctulu.gis.GISGeometry;
import org.fudaa.ctulu.gis.GISLib;
import org.fudaa.ctulu.gis.GISZoneCollectionLigneBrisee;
import org.fudaa.dodico.fortran.FileOpReadCharSimpleAbstract;
/**
- * @author fred deniger
+ * Un reader pour un fichier Rubar (ST, ou CN).
+ * @author fred deniger, Bertrand Marchand
* @version $Id: RubarStReader.java,v 1.5 2007-06-11 13:07:05 deniger Exp $
*/
public class RubarStReader extends FileOpReadCharSimpleAbstract {
@@ -48,7 +54,14 @@
return _s.equals(sep_) || _s.equals(sep1_);
}
+ /**
+ * Lit les profils et les lignes directrices.
+ * @return Un tableau GISZoneCollectionLigneBrisee[2]. [0] : la collection des profils, [1] : la collection de lignes directrices.
+ */
protected Object internalRead() {
+ // Remarque : Cette impl\xE9mentation empeche des noms semblables (les noms sont stock\xE9s comme cl\xE9 de Map) sur les lignes
+ // directrices (ce qui peut \xEAtre normal puisque c'est le m\xEAme nom en un point de chaque profil qui permet de constituer
+ // la ligne.
if (in_ == null) {
return null;
}
@@ -58,15 +71,21 @@
in_.setJumpCommentLine(true);
final List lignes = new ArrayList(200);
+ final List names=new ArrayList(200);
final List coordinatesEnCours = new ArrayList();
+ // Contient les listes de coordonn\xE9es pour les lignes directrices (Map<String,ArrayList<Coordinate>> en Java 1.5)
+ final Map mdirs=new HashMap(20);
- final int[] fmt = new int[] { 13, 13, 13, 3 };
+ final int[] fmt = new int[] { 13, 13, 13, 1, 3 };
+ final int[] fmt1Line=new int[]{6,6,6,6,13,1,42};
Coordinate last = null;
+ String name="";
try {
while (true) {
if (isSt_) {
- in_.readLine();
+ in_.readFields(fmt1Line);
+ name=in_.stringField(6).trim();
}
String first = CtuluLibString.EMPTY_STRING;
String sec = CtuluLibString.EMPTY_STRING;
@@ -78,6 +97,18 @@
coordinatesEnCours.add(coordinate);
}
last = coordinate;
+
+ // Ligne directrice eventuelle. Pas de controle que la ligne directrice est bien sur tous les profils.
+ String namedir=in_.stringField(4).trim();
+ if (!"".equals(namedir)) {
+ List coordldir=(List)mdirs.get(namedir);
+ if (coordldir==null) {
+ coordldir=new ArrayList(200);
+ mdirs.put(namedir,coordldir);
+ }
+ coordldir.add(coordinate.clone());
+ }
+
in_.readFields(fmt);
first = in_.stringField(0);
sec = in_.stringField(1);
@@ -85,6 +116,12 @@
final LineString str = GISLib.createLineOrLinearFromList(coordinatesEnCours);
if (str != null) {
lignes.add(str);
+ if ("".equals(name)) {
+ names.add(CtuluLib.getS("_P")+((GISGeometry)str).getId());
+ }
+ else {
+ names.add(name);
+ }
}
coordinatesEnCours.clear();
}
@@ -96,14 +133,51 @@
final LineString str = GISLib.createLineOrLinearFromList(coordinatesEnCours);
if (str != null) {
lignes.add(str);
+ if ("".equals(name)) {
+ names.add(CtuluLib.getS("_P")+((GISGeometry)str).getId());
+ }
+ else {
+ names.add(name);
+ }
}
+
+ GISZoneCollectionLigneBrisee[] ret=new GISZoneCollectionLigneBrisee[2];
+ // Profils
if (lignes.size() > 0) {
- final GISZoneCollectionLigneBrisee res = new GISZoneCollectionLigneBrisee(null);
- res.setAttributes(new GISAttributeInterface[] { GISAttributeConstants.BATHY }, null);
- res.addAllLineStringClosedOrNode((LineString[]) lignes.toArray(new LineString[lignes.size()]), null);
- res.postImport(0);
- return res;
+ final GISZoneCollectionLigneBrisee zligs = new GISZoneCollectionLigneBrisee(null);
+ zligs.addAllLineStringClosedOrNode((LineString[]) lignes.toArray(new LineString[lignes.size()]), null);
+ zligs.setAttributes(new GISAttributeInterface[] { GISAttributeConstants.BATHY, GISAttributeConstants.TITRE}, null);
+ zligs.postImport(0);
+
+ // Affectation de l'attribut titre.
+ GISAttributeModel attmod=zligs.getModel(GISAttributeConstants.TITRE);
+ for (int i=0; i<names.size(); i++) {
+ attmod.setObject(i,attmod.getAttribute().createDataForGeom(names.get(i),1),null);
+ }
+ ret[0]=zligs;
}
- return null;
+
+ // Lignes directrices
+ if (mdirs.size()>0) {
+ final GISZoneCollectionLigneBrisee zdirs = new GISZoneCollectionLigneBrisee(null);
+ // Pour \xEAtre sur de la correspondance nom/coordonn\xE9es
+ String[] namedirs=(String[])mdirs.keySet().toArray(new String[0]);
+ LineString[] ldirs=new LineString[namedirs.length];
+ for (int i=0; i<namedirs.length; i++) {
+ ldirs[i]=GISLib.createLineOrLinearFromList((List)(mdirs.get(namedirs[i])));
+ }
+
+ zdirs.addAllLineStringClosedOrNode(ldirs, null);
+ zdirs.setAttributes(new GISAttributeInterface[] { GISAttributeConstants.BATHY, GISAttributeConstants.TITRE}, null);
+ zdirs.postImport(0);
+
+ // Affectation de l'attribut titre.
+ GISAttributeModel attmod=zdirs.getModel(GISAttributeConstants.TITRE);
+ for (int i=0; i<namedirs.length; i++) {
+ attmod.setObject(i,attmod.getAttribute().createDataForGeom(namedirs[i],1),null);
+ }
+ ret[1]=zdirs;
+ }
+ return ret;
}
}
Modified: branches/Br_FudaaModeleur_TF/fudaa_devel/fudaa/src/org/fudaa/fudaa/sig/wizard/FSigFileLoaderRubarSt.java
===================================================================
--- branches/Br_FudaaModeleur_TF/fudaa_devel/fudaa/src/org/fudaa/fudaa/sig/wizard/FSigFileLoaderRubarSt.java 2008-06-27 15:22:32 UTC (rev 3664)
+++ branches/Br_FudaaModeleur_TF/fudaa_devel/fudaa/src/org/fudaa/fudaa/sig/wizard/FSigFileLoaderRubarSt.java 2008-06-27 15:25:48 UTC (rev 3665)
@@ -52,17 +52,21 @@
_analyze.merge(op.getAnalyze());
return;
}
- final GISZoneCollectionLigneBrisee res = (GISZoneCollectionLigneBrisee) op.getSource();
- if (res==null || res.getNumGeometries() == 0) {
- return;
+ final GISZoneCollectionLigneBrisee[] res = (GISZoneCollectionLigneBrisee[]) op.getSource();
+
+ boolean blines=false;
+ final GISVisitorCount counter=new GISVisitorCount();
+ for (int i=0; i<res.length; i++) {
+ if (res[i]==null||res[i].getNumGeometries()==0) continue;
+ blines=true;
+ res[i].accept(counter);
+ _r.nbPoint_+=counter.nbPt_;
+ _r.nbPointTotal_+=counter.nbPt_;
+ _r.nbPolygones_+=counter.nbPolygone_;
+ _r.nbPolylignes_+=counter.nbPolyligne_;
+ _r.ligneModel_.add(res[i]);
}
- _r.addUsedAttributes(new GISAttributeInterface[] { GISAttributeConstants.BATHY });
- final GISVisitorCount counter = new GISVisitorCount();
- res.accept(counter);
- _r.nbPoint_ += counter.nbPt_;
- _r.nbPointTotal_ += counter.nbPt_;
- _r.nbPolygones_ += counter.nbPolygone_;
- _r.nbPolylignes_ += counter.nbPolyligne_;
- _r.ligneModel_.add(res);
+ if (blines)
+ _r.addUsedAttributes(new GISAttributeInterface[]{GISAttributeConstants.BATHY, GISAttributeConstants.TITRE});
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|