Revision 210

View differences:

branches/v02_desarrollo/libraries/libCq CMS for java.old/src/org/cresques/io/DgnFile.java
39 39
		// TODO Ap?ndice de m?todo generado autom?ticamente
40 40
		return null;
41 41
	}
42

  
43
	/* (non-Javadoc)
44
	 * @see org.cresques.io.GeoFile#close()
45
	 */
46
	public void close() {
47
		// TODO Auto-generated method stub
48
		
49
	}
42 50
}
branches/v02_desarrollo/libraries/libCq CMS for java.old/src/org/cresques/io/GeoFile.java
50 50
	
51 51
	public Extent getExtent() { return extent; }
52 52
	abstract public GeoFile load();
53
	abstract public void close();
53 54
	
54 55
	abstract public IObjList getObjects();
55 56
	
branches/v02_desarrollo/libraries/libCq CMS for java.old/src/org/cresques/io/TifGeoRefFile.java
110 110
		// TODO Auto-generated method stub
111 111
		
112 112
	}
113

  
114
	/* (non-Javadoc)
115
	 * @see org.cresques.io.GeoRasterFile#close()
116
	 */
117
	public void close() {
118
	}
119

  
120
	/* (non-Javadoc)
121
	 * @see org.cresques.io.GeoRasterFile#updateImage(int, int, org.cresques.cts.ICoordTrans, java.awt.Image, int)
122
	 */
123
	public Image updateImage(int width, int height, ICoordTrans rp, Image img, int flags) {
124
		// TODO Auto-generated method stub
125
		return null;
126
	}
113 127
}
branches/v02_desarrollo/libraries/libCq CMS for java.old/src/org/cresques/io/EcwFile.java
83 83
	public void setView(Extent e) { v = new Extent(e); }
84 84
	public Extent getView() { return v; }
85 85
	
86
	public void setTransparency(boolean t) {
87
		doTransparency = t;
88
		tFilter = new PixelFilter(255);
89
	}
90
	public void setTransparency(int t ) {
91
		doTransparency = true;
92
		tFilter = new SimplePixelFilter(255 - t);
93
	}
94
	public boolean getTransparency() { return doTransparency; }
95
	public void setAlpha(int alpha) {
96
		if (!doTransparency) setTransparency(255 - alpha);
97
		else tFilter.setAlpha(alpha);
98
	}
99
	public int getAlpha() { return tFilter.getAlpha(); }
100
	
101 86
	/**
102 87
	 * Carga un ECW.
103 88
	 * 
......
138 123
		// Ancho m?ximo (~2500 px)
139 124
		final static int MAX_WIDTH = 1536;
140 125
		// Alto m?ximo (no hay l?mite)
141
		final static int MAX_HEIGHT = 20000;
126
		final static int MAX_HEIGHT = 1536;
142 127
		Point pos;
143 128
		Extent v;
144 129
		int width, height;
145
		boolean mustResize = true;
130
		boolean mustResize = false;
146 131
		public ChunkFrame(Extent vista, int w, int h) {
147 132
			v = vista;
148 133
			width = w;
......
163 148
			// Calcula el n? de chunks (filas y columnas)
164 149
			int numCol = (sz.width / MAX_WIDTH), numRow = (sz.height / MAX_HEIGHT);
165 150
			if (sz.width -(numCol*MAX_WIDTH) > 0) numCol++;
166
			if (sz.height-(numRow*MAX_HEIGHT) > 0) numRow++;
151
			if (sz.height - (numRow*MAX_HEIGHT) > 0) numRow++;
167 152
			frames = new ChunkFrame[numCol*numRow];
168 153

  
169 154
			// Coprobaci?n previa para resolver el bug#1
170 155
			JNCSDatasetPoint ptMin = file.convertWorldToDataset(v.minX(), v.minY());
171 156
			JNCSDatasetPoint ptMax = file.convertWorldToDataset(v.maxX(), v.maxY());
172
			System.out.println("Dataset coords Width = "+(ptMax.x-ptMin.x)+", px width ="+sz.width);
157
			System.out.println("Dataset coords Width = "+(ptMax.x-ptMin.x)+", px width = "+sz.width+
158
					" px heigh = "+sz.height);
173 159
			// BEGIN Cambiando para soportar e < 1:1
174 160
			// TODO Mejorarlo para que los PAN con un zoom muy grande sean correctos
175 161
			if ((ptMax.x-ptMin.x)<sz.width) {
......
181 167
				f.v = new Extent(v);
182 168
			} else {
183 169
				// Calcula cada chunk
184
				double step = ((double) ptMax.x-ptMin.x)/sz.getWidth();
170
				double stepx = ((double) ptMax.x-ptMin.x)/sz.getWidth();
171
				double stepy = ((double) ptMax.y-ptMin.y)/sz.getHeight();
185 172
				int h = sz.height;
186 173
				for (int r=0; r<numRow; r++) {
187 174
					int w = sz.width;
......
191 178
						f.pos = new Point(c*MAX_WIDTH, r*MAX_HEIGHT);
192 179
						// Tama?o del chunk
193 180
						f.width = Math.min(MAX_WIDTH, w);
194
						f.height = Math.min(MAX_WIDTH, h);
181
						f.height = Math.min(MAX_HEIGHT, h);
195 182
						// Extent del chunk
196
						int x1 = ptMin.x+(int) (f.pos.x*step);
197
						int x2 = x1+(int)(f.width*step);
198
						int y1 = ptMax.y;
199
						int y2 = ptMin.y;
183
						int x1 = ptMin.x+(int) (f.pos.x*stepx);
184
						int x2 = x1+(int)(f.width*stepx);
185
						int y1 = ptMax.y-(int) (f.pos.y*stepy); //ptMax.y;
186
						int y2 = y1-(int)(f.height*stepy);//ptMin.y;
200 187
						JNCSWorldPoint pt1 = file.convertDatasetToWorld(x1, y1);
201 188
						JNCSWorldPoint pt2 = file.convertDatasetToWorld(x2, y2);
202 189
						f.v = new Extent(pt1.x, pt1.y, pt2.x, pt2.y); // Hay que calcularlo
......
225 212
	public synchronized Image updateImage(int width, int height, ICoordTrans rp) {
226 213
		// TODO reproyectar para devolver el trozo de imagen pedida sobre ...
227 214
		// la proyecci?n de destino.
215
		int line = 0; 
228 216
		boolean mustResize = false;
229 217
		Dimension fullSize = null;
230 218
		Image ecwImage = null;
......
233 221
			double dFileAspect, dWindowAspect;
234 222
			//double dWorldTLX, dWorldTLY, dWorldBRX, dWorldBRY;
235 223
			int bandlist[];
236
			int line, pRGBArray[] = null;
224
			int pRGBArray[] = null;
237 225

  
238 226
			// Work out the correct aspect for the setView call.
239 227
			dFileAspect = (double)v.width()/(double)v.height();
......
246 234
			}
247 235

  
248 236
			fullSize = new Dimension(width, height);
237
			System.out.println("fullSize = ("+width+","+height+")");
249 238
			// Peta en los peque?os ... arreglar antes de meter del todo
250 239
			ChunkFrame frames[] = ChunkFrame.computeFrames(file, v, fullSize);
251 240
			if (frames.length == 1) {
252 241
				width = frames[0].width; height = frames[0].height;
242
				System.out.println("frameSize = ("+width+","+height+")");
253 243
				//System.out.println("Cambio el ancho total a ("+width+","+height+")");
254 244
			}
255 245
			
......
284 274
				file.setView(file.numBands, bandlist, 
285 275
					f.v.minX(), f.v.maxY(), f.v.maxX(), f.v.minY(),
286 276
					f.width, f.height);
277
				System.out.println("f.Size = ("+f.width+","+f.height+")");
278

  
287 279
	
288 280
				// Read the scan lines
289
				for (line=0; line < height; line++) {
281
				for (line=0; line < f.height; line++) {
290 282
					file.readLineRGBA(pRGBArray);
291 283
					// Prueba de sustituci?n de color transparente
292 284
					if (doTransparency) {
......
307 299
		} catch (com.ermapper.ecw.JNCSInvalidSetViewException e) {
308 300
			System.err.println(errorMessage);
309 301
			e.printStackTrace(); */
302
		} catch(com.ermapper.ecw.JNCSException e) { //java.lang.ArrayIndexOutOfBoundsException:
303
			bErrorOnOpen = true;
304
			System.err.println("EcwFile JNCS Error en la l?nea "+line+"/"+height);
305
			System.err.println(e.getMessage());
306
			e.printStackTrace();
307
		} catch(java.lang.ArrayIndexOutOfBoundsException e) { //:
308
			bErrorOnOpen = true;
309
			System.err.println("EcwFile ArrayIndex Error en la l?nea "+line+"/"+height);
310
			System.err.println(e.getMessage());
311
			e.printStackTrace();
310 312
		} catch(Exception e) {
311 313
			bErrorOnOpen = true;
312 314
			errorMessage = e.getMessage();
......
315 317
			e.printStackTrace();
316 318
		}
317 319
		lastRefreshPercent = file.getPercentComplete();
320
		System.out.println("Leido al "+lastRefreshPercent+" %.");
318 321
		return ecwImage;
319 322
	}
320 323
	
......
349 352
	public void refreshUpdate(int nWidth, int nHeight, int dDatasetTLX, int dDatasetTLY, int dDatasetBRX, int dDatasetBRY) {
350 353
		System.out.println("EcwFile: se actualiza 2");
351 354
	}
355

  
356
	/* (non-Javadoc)
357
	 * @see org.cresques.io.GeoRasterFile#updateImage(int, int, org.cresques.cts.ICoordTrans, java.awt.Image, int)
358
	 */
359
	public Image updateImage(int width, int height, ICoordTrans rp, Image img, int flags) {
360
		// TODO Auto-generated method stub
361
		return null;
362
	}
352 363
}
branches/v02_desarrollo/libraries/libCq CMS for java.old/src/org/cresques/io/GmlFile.java
259 259
		collection.reProject(rp);
260 260
		setProjection(rp.getPDest());
261 261
	}
262

  
263
	/* (non-Javadoc)
264
	 * @see org.cresques.io.GeoFile#close()
265
	 */
266
	public void close() {
267
		// TODO Auto-generated method stub
268
		
269
	}
262 270
	
263 271
	
264 272
}
branches/v02_desarrollo/libraries/libCq CMS for java.old/src/org/cresques/io/DxfFile.java
664 664
		System.out.println("Dxf: reproyectando ...");
665 665
		entityMaker.reProject(rp);
666 666
	}
667

  
668
	/* (non-Javadoc)
669
	 * @see org.cresques.io.GeoFile#close()
670
	 */
671
	public void close() {
672
		// TODO Auto-generated method stub
673
		
674
	}
667 675
}
branches/v02_desarrollo/libraries/libCq CMS for java.old/src/org/cresques/io/DataSource.java
43 43
	public static String normalize(String path) {
44 44
		if (path.indexOf("[") >= 0) {
45 45
			DataSource ds = DataSource.getDSFromName(path);
46
			if (ds == null) return null;
46 47
			path = path.substring(0,path.indexOf("[")) + 
47 48
				ds.getPath() + path.substring(path.indexOf("]")+1);
48 49
			//System.out.println(path);
branches/v02_desarrollo/libraries/libCq CMS for java.old/src/org/cresques/io/ShpFile.java
99 99
	public void reProject(ICoordTrans rp) {
100 100
		// TODO metodo reProject pendiente de implementar
101 101
	}
102

  
103
	/* (non-Javadoc)
104
	 * @see org.cresques.io.GeoFile#close()
105
	 */
106
	public void close() {
107
		// TODO Auto-generated method stub
108
		
109
	}
102 110
}
branches/v02_desarrollo/libraries/libCq CMS for java.old/src/org/cresques/io/GeoRasterFile.java
31 31
 */
32 32

  
33 33
public abstract class GeoRasterFile extends GeoFile {
34
	public static final int RED_BAND	= 0x01;
35
	public static final int GREEN_BAND	= 0x02;
36
	public static final int BLUE_BAND	= 0x04;
34 37
	/**
35 38
	 * Filtro para raster.
36 39
	 * Permite eliminar la franja inutil alrededor de un raster girado o de
......
127 130
	protected int alpha = 0;
128 131
	protected PixelFilter tFilter = null;
129 132

  
133
	protected int rBandNr = 1, gBandNr = 1, bBandNr = 1;
134
	protected int bandCount = 1;
135

  
130 136
	static {
131 137
		supportedExtensions = new TreeMap();
132
		supportedExtensions.put("ecw",  EcwFile.class);
138
		if (System.getProperty("os.name").toUpperCase().startsWith("WIN")) {
139
			supportedExtensions.put("ecw",  EcwFile.class);
140
		}
133 141
		supportedExtensions.put("tif",  TifGeoRefFile.class);
134 142
		supportedExtensions.put("tiff", TifGeoRefFile.class);
135 143
		supportedExtensions.put("jpg",  TifGeoRefFile.class);
......
192 200
	 */
193 201
	public static void registerExtension(String ext, Class clase) {
194 202
		ext = ext.toLowerCase();
203
		System.out.println("RASTER: extension '"+ext+"' supported.");
195 204
		supportedExtensions.put(ext, clase);
196 205
	}
197 206
	
207
	/**
208
	 * Tipo de fichero soportado.
209
	 * Devuelve true si el tipo de fichero (extension) est? soportado, si no
210
	 * devuelve false.
211
	 * 
212
	 * @param fName Fichero raster
213
	 * @return  true si est? soportado, si no false.
214
 	 */
198 215
	
216
	public static boolean fileIsSupported(String fName) {
217
		String ext = fName.toLowerCase().substring(fName.lastIndexOf('.')+1);
218
		return supportedExtensions.containsKey(ext);
219
	}
220
	
221
	
199 222
	public GeoRasterFile(IProjection proj, String name) {
200 223
		super(proj, name);
201 224
	}
202 225
	
203 226
	abstract public GeoFile load();
204 227
	
228
	abstract public void close();
229
	
205 230
	public static PxContour getContour(String fName, String name, IProjection proj) {
206 231
		PxContour contour = null;
207 232
		return contour;
......
215 240
	abstract public void setView(Extent e);
216 241
	abstract public Extent getView();
217 242
	
218
	abstract public void setTransparency(boolean t);
219
	abstract public void setTransparency(int t);
243
	// TRANSPARENCIA. Versi?n de pruebas. Hay que verificar que se puede
244
	// tener filtros y valores alpha, que no es lento, y que no hay una manera
245
	// mejor de hacerlo.
246
	//abstract public void setTransparency(boolean t);
247
	//abstract public void setTransparency(int t);
248
	public void setTransparency(boolean t) {
249
		doTransparency = t;
250
		tFilter = new PixelFilter(255);
251
	}
252
	public void setTransparency(int t ) {
253
		doTransparency = true;
254
		tFilter = new SimplePixelFilter(255 - t);
255
	}
256
	public boolean getTransparency() { return doTransparency; }
257
	public void setAlpha(int alpha) {
258
		if (!doTransparency) setTransparency(255 - alpha);
259
		else tFilter.setAlpha(alpha);
260
	}
261
	public int getAlpha() { return tFilter.getAlpha(); }
220 262
	
263
	
221 264
	public void setUpdatable(Component c) { updatable = c; }
222 265
	
223 266
	abstract public Image updateImage(int width, int height, ICoordTrans rp);
267

  
268
	/**
269
	 * Actualiza la/s banda/s especificadas en la imagen.
270
	 * @param width		ancho
271
	 * @param height	alto
272
	 * @param rp		reproyecci?n
273
	 * @param img		imagen
274
	 * @param flags		que bandas [ RED_BAND | GREEN_BAND | BLUE_BAND ]
275
	 * @return		img
276
	 */
277
	abstract public Image updateImage(int width, int height, ICoordTrans rp, Image img, int flags);
278

  
279
	public int getBandCount() { return bandCount; }
280
	/**
281
	 * Asocia un colorBand al rojo, verde o azul.
282
	 * @param flag cual (o cuales) de las bandas.
283
	 * @param nBand	que colorBand
284
	 */
224 285
	
286
	public void setBand(int flag, int bandNr) {
287
		if ((flag & GeoRasterFile.RED_BAND) == GeoRasterFile.RED_BAND) rBandNr = bandNr;
288
		if ((flag & GeoRasterFile.GREEN_BAND) == GeoRasterFile.GREEN_BAND) gBandNr = bandNr;
289
		if ((flag & GeoRasterFile.BLUE_BAND) == GeoRasterFile.BLUE_BAND) bBandNr = bandNr;
290
	}
291

  
292
	/**
293
	 * Devuelve el colorBand activo en la banda especificada.
294
	 * @param flag banda.
295
	 */
296
	
297
	public int getBand(int flag) {
298
		if (flag == GeoRasterFile.RED_BAND) return rBandNr;
299
		if (flag == GeoRasterFile.GREEN_BAND) return gBandNr;
300
		if (flag == GeoRasterFile.BLUE_BAND) return bBandNr;
301
		return -1;
302
	}
225 303
	public IObjList getObjects() {
226 304
		// TODO hay que a?adir el raster a la lista de objetos
227 305
		IObjList oList = new PxObjList(proj);
branches/v02_desarrollo/libraries/libCq CMS for java.old/src/org/cresques/io/TrkFile.java
109 109
		line.reProject(rp);
110 110
		setProjection(rp.getPDest());
111 111
	}
112
	/* (non-Javadoc)
113
	 * @see org.cresques.io.GeoFile#close()
114
	 */
115
	public void close() {
116
		// TODO Auto-generated method stub
117
		
118
	}
112 119

  
113 120

  
114 121
}
branches/v02_desarrollo/libraries/libCq CMS for java.old/src/org/cresques/io/BookmarkList.java
23 23
class Bookmark {
24 24
	String folder;
25 25
	String name;
26
	String fName;
26
	String [] fName;
27 27
	String projName;
28 28
	IProjection proj;
29 29
	
30 30
	public Bookmark(String fld, String n, String f, IProjection p) {
31 31
		projName = null;
32
		folder = fld; name = n; fName = f; proj = p;
32
		fName = new String[1];
33
		folder = fld; name = n; fName[0] = f; proj = p;
33 34
	}
35
	public Bookmark(String fld, String n, String [] f, IProjection p) {
36
		projName = null;
37
		fName = new String[f.length];
38
		folder = fld; name = n; proj = p;
39
		for (int i=0; i<f.length; i++)
40
			fName[i] = f[i];
41
	}
34 42
}
35 43

  
36 44
public class BookmarkList extends TreeMap implements ActionListener {
......
48 56
		addEntry(new Bookmark(fld, n, f, p));
49 57
	}
50 58
	
59
	public void addEntry(String fld, String n, String [] f, IProjection p) {
60
		addEntry(new Bookmark(fld, n, f, p));
61
	}
62
	
51 63
	public void addEntry(Bookmark bookmark) {
52 64
		Vector vector;
53 65
		if (containsKey(bookmark.folder)) {
......
124 136
				it = new JMenuItem(bookmark.name);
125 137
				it.setActionCommand(i+"|"+folder);
126 138
				it.addActionListener(this);
127
				if (bookmark.fName.endsWith("tif"))
139
				if (bookmark.fName[0].endsWith("tif"))
128 140
					it.setIcon(tifIcon);
129
				else if (bookmark.fName.endsWith("ecw"))
141
				else if (bookmark.fName[0].endsWith("ecw"))
130 142
					it.setIcon(ecwIcon);
131
				else if (bookmark.fName.endsWith("gml"))
143
				else if (bookmark.fName[0].endsWith("gml"))
132 144
					it.setIcon(gmlIcon);
133
				else if (bookmark.fName.endsWith("dxf") || bookmark.fName.endsWith("DXF"))
145
				else if (bookmark.fName[0].endsWith("dxf") || bookmark.fName[0].endsWith("DXF"))
134 146
					it.setIcon(dxfIcon);
135 147
				else
136 148
					it.setIcon(fileIcon);
......
149 161
		int vectorPos = Integer.parseInt(cmd.substring(0,mark));
150 162
		cmd = cmd.substring(mark+1);
151 163
		Bookmark bookmark = (Bookmark) ((Vector) get(cmd)).get(vectorPos);
152
		app.loadFile(bookmark.fName, bookmark.proj);
164
		app.loadFile(bookmark.fName[0], bookmark.proj);
153 165
	}
154 166
}
155 167

  
branches/v02_desarrollo/libraries/libCq CMS for java.old/src/org/cresques/px/PxContour.java
6 6
import java.awt.FontMetrics;
7 7

  
8 8
import java.awt.geom.Point2D;
9
import java.util.Vector;
9 10

  
10 11
import org.cresques.cts.ICoordTrans;
11 12
import org.cresques.cts.IProjection;
......
67 68
			extent.add(v[i]);
68 69
		}
69 70
	}
70
	
71
	/**
72
	 * Vertices de un contorno.
73
	 * @return
74
	 */
75
	public Vector getVertex() {
76
		return polygon;
77
	}
71 78
	public String getName() { return name; }
72 79
	public Color c() {return pc;}
73 80
	public Color c(Color color) {this.pc = color; return pc;}
branches/v02_desarrollo/libraries/libCq CMS for java.old/src/org/cresques/px/dxf/DxfFeatureMaker.java
19 19
import java.util.Iterator;
20 20
import java.util.Vector;
21 21
import java.awt.Graphics2D;
22
import java.awt.geom.GeneralPath;
23 22
import java.awt.geom.Point2D;
24 23

  
25 24
public class DxfFeatureMaker implements DxfFile.EntityFactory, Projected {
......
40 39
	FeatureCollection blk = null;
41 40
	Vector blkList = null;
42 41
	DxfTable layers = null;
43
	
44
	private Vector faces = null;
45
	private boolean hasFaces = false;
46
	private int facesIterador = 1;
47
	private Point2D facesFirstPoint = null;
48 42

  
49 43
	public DxfFeatureMaker(IProjection proj) {
50 44
		this.proj = proj;
......
134 128
			//feature.setProp("elevation", string);
135 129
			feaBordes.setProp("elevation", string);
136 130
			feaFondos.setProp("elevation", string);
137
		} else {
138
			Double doub = new Double(0.0);
139
			//feature.setProp("elevation", doub.toString());
140
			feaBordes.setProp("elevation", doub.toString());
141
			feaFondos.setProp("elevation", doub.toString());
142 131
		}
143 132
		if (grp.hasCode(70))
144 133
			flags = grp.getDataAsInt(70);
......
148 137
			xtruY = grp.getDataAsDouble(220);
149 138
		if (grp.hasCode(230))
150 139
			xtruZ = grp.getDataAsDouble(230);
151
		if ((flags & 0x01) == 0x01 || (flags & 0x40) == 0x40) {
140
		if ((flags & 0x01) == 0x00) {
152 141
			feaBordes.setGeometry(lineString);
142
			lastFeaBordes = feaBordes;
143
			isDoubleFeatured = false;
144
		} else if ((flags & 0x01) == 0x01) {
145
			feaBordes.setGeometry(lineString);
153 146
			feaFondos.setGeometry(polygon);
154 147
			lastFeaBordes = feaBordes;
155 148
			lastFeaFondos = feaFondos;
156 149
			isDoubleFeatured = true;
157
		} else if ((flags & 0x01) == 0x00) {
158
			feaBordes.setGeometry(lineString);
159
			lastFeaBordes = feaBordes;
160
			isDoubleFeatured = false;
161 150
		} else {
162 151
			System.out.println("Detectada una Polyline Flag que no corresponde");
163 152
			System.out.println("a una Polyline corriente, ni a una Closed Polyline");
......
172 161
				LineString lineString = (LineString)feaBordes.getGeometry();
173 162
				Polygon polygon = (Polygon)feaFondos.getGeometry();
174 163
				lineString.add(firstPt);
175
				// 041103: linea anulada porque hay pol?gonos en los que al final
176
				//		   a?ade el (0,0). Parece que a?adimos el punto inicial
177
				//		   del pol?gono una vez pero parece que el pol?gono, por
178
				//		   el hecho de ser pol?gono, ya se a?ade el punto inicial
179
				//		   al final, con lo que estamos duplicando el punto inicial
180
				//		   del pol?gono al final del mismo.
181
				//polygon.add(firstPt);
164
				polygon.add(firstPt);
182 165
				if (bulge!=0) {
183 166
					bulge = 0.0;
184 167
				}
185
				
186
				if (hasFaces) {
187
					System.out.println("Sabe que es un poligono.");
188
					System.out.println("POLYLINE: caras=" +faces.size()+", puntos="+ lineString.pointNr());
189
					LineString ls1 = new LineString();
190
					Polygon pl1 = new Polygon();
191
					LineString ls2 = new LineString();
192
					Polygon pl2 = new Polygon();
193
					LineString ls = new LineString();
194
					Polygon pl = new Polygon();
195
					int [] face;
196
					int i0, i1;
197
					Iterator iter = faces.iterator();
198
					while (iter.hasNext()) {
199
						face = (int []) iter.next();
200
						i0 = face[3];
201
						for (int i=0; i<4; i++) {
202
							i1 = face[i];
203
							if (i0 > 0) {
204
								if ((facesIterador%2)!=0) {
205
									System.out.println("endSeq(): hasFaces = " + hasFaces);
206
									ls1.add((Point2D)lineString.get(i0-1));
207
									pl1.add((Point2D)polygon.get(i0-1));
208
									//ls1.add((Point2D)lineString.get(Math.abs(i1)-1));
209
									//pl1.add((Point2D)polygon.get(Math.abs(i1)-1));									
210
								} else {
211
									ls2.add((Point2D)lineString.get(i0-1));
212
									pl2.add((Point2D)polygon.get(i0-1));
213
									//ls2.add((Point2D)lineString.get(Math.abs(i1)-1));
214
									//pl2.add((Point2D)polygon.get(Math.abs(i1)-1));									
215
								}
216
								facesIterador = facesIterador + 1;
217
							}
218
							i0 = i1;
219
						}
220
					}
221
					facesFirstPoint = new Point2D.Double(ls1.get(0).getX(), ls1.get(0).getY());
222
					for (int i=0;i<ls1.pointNr();i++) {
223
						ls.add(ls1.get(i));
224
						pl.add(pl1.get(i));
225
					}
226
					for (int i=ls2.pointNr()-1;i>0;i--) {
227
						ls.add(ls2.get(i));
228
						pl.add(pl2.get(i));
229
					}
230
					ls.add(facesFirstPoint);
231
					pl.add(facesFirstPoint);
232
					lastFeaBordes.setGeometry(ls);					
233
					lastFeaFondos.setGeometry(pl);					
234
				} else {
235
					lastFeaBordes.setGeometry(lineString);
236
					lastFeaFondos.setGeometry(polygon);
237
				}
238
				
168
				lastFeaBordes.setGeometry(lineString);
169
				lastFeaFondos.setGeometry(polygon);
239 170
				if (addingToBlock == false) {
240 171
					features.add(lastFeaBordes);
241 172
					features.add(lastFeaFondos);
......
255 186
				if (bulge!=0) {
256 187
					bulge = 0.0;
257 188
				}
258
				
259
				if (hasFaces) {
260
					System.out.println("POLYLINE: caras=" +faces.size()+", puntos="+ lineString.pointNr());
261
					LineString ls1 = new LineString();
262
					LineString ls2 = new LineString();
263
					LineString ls = new LineString();
264
					int [] face;
265
					int i0, i1;
266
					Iterator iter = faces.iterator();
267
					while (iter.hasNext()) {
268
						face = (int []) iter.next();
269
						i0 = face[3];
270
						for (int i=0; i<4; i++) {
271
							i1 = face[i];
272
							if (i0 > 0) {
273
								if ((facesIterador%2)!=0) {
274
									ls1.add((Point2D)lineString.get(i0-1));
275
									//ls.add((Point2D)lineString.get(Math.abs(i1)-1));
276
								} else {
277
									ls2.add((Point2D)lineString.get(i0-1));
278
									//ls.add((Point2D)lineString.get(Math.abs(i1)-1));
279
								}
280
								facesIterador = facesIterador + 1;
281
							}
282
							i0 = i1;
283
						}
284
					}
285
					facesFirstPoint = new Point2D.Double(ls1.get(0).getX(), ls1.get(0).getY());
286
					for (int i=0;i<ls1.pointNr();i++) {
287
						ls.add(ls1.get(i));
288
					}
289
					for (int i=ls2.pointNr()-1;i>0;i--) {
290
						ls.add(ls2.get(i));
291
					}
292
					ls.add(facesFirstPoint);
293
					lastFeaBordes.setGeometry(ls);					
294
				} else {
295
					lastFeaBordes.setGeometry(lineString);
296
				}
297
				
189
				lastFeaBordes.setGeometry(lineString);			
298 190
				if (addingToBlock == false) {
299 191
					features.add(lastFeaBordes);
300 192
				} else {
......
310 202
		xtruZ = 1.0;
311 203
		bulge = 0.0;
312 204
		isDoubleFeatured = false;
313
		hasFaces = false;
314
		facesIterador = 1;
315 205
	}
316 206
	
317 207
	public void addVertex(DxfGroupVector grp) throws Exception {
......
326 216
				feaBordes.setProp("layer", grp.getDataAsString(8));
327 217
				feaFondos.setProp("layer", grp.getDataAsString(8));
328 218
			}
329
			if (grp.hasCode(70)) {
330
				vFlags = grp.getDataAsInt(70);
331
			}
332 219
			x  = grp.getDataAsDouble(10);
333 220
			y  = grp.getDataAsDouble(20);
334 221
			if (grp.hasCode(30)) {
......
339 226
			Point2D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
340 227
			x = point_out.getX();
341 228
			y = point_out.getY();
342
			System.out.println("addVertex(): vFlags = " + vFlags);
343
			if ((vFlags & 0x80) == 0x80 && (vFlags & 0x40) == 0) {
344
				int [] face = {0,0,0,0};
345
				face[0] = grp.getDataAsInt(71);
346
				face[1] = grp.getDataAsInt(72);
347
				face[2] = grp.getDataAsInt(73);
348
				face[3] = grp.getDataAsInt(74);
349
				addFace(face);
350
			} else if ((vFlags & 0x10) == 0x10) {
351
				// Son vertices que se trataran cuando se implementen
352
				// los splines. En principio no se hace nada con ellos.
353
			} else {
229
			if (vFlags != 16) {
354 230
				Point2D pt = proj.createPoint( x, y);
355 231
				lineString.add(pt);
356 232
				polygon.add(pt);
......
367 243
						bulge_aux = grp.getDataAsDouble(42);
368 244
					} else { bulge_aux = 0.0; }
369 245
					//int cnt = lineString.pointNr();
370
					//System.out.println("addVertex(): lineString.pointNr() = " + lineString.pointNr());
246
					System.out.println("addVertex(): lineString.pointNr() = " + lineString.pointNr());
371 247
					lineString.remove(lineString.pointNr()-1);
372 248
					lineString.remove(lineString.pointNr()-1);
373
					//System.out.println("addVertex(): polygon.pointNr() = " + polygon.pointNr());
249
					System.out.println("addVertex(): polygon.pointNr() = " + polygon.pointNr());
374 250
					polygon.remove(polygon.pointNr()-1);
375 251
					polygon.remove(polygon.pointNr()-1);
376 252
					Vector arc = createArc(ptAnterior, pt, bulge);
......
413 289
			Point2D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
414 290
			x = point_out.getX();
415 291
			y = point_out.getY();
416
			if ((vFlags & 0x80) == 0x80 && (vFlags & 0x40) == 0) {
417
				int [] face = {0,0,0,0};
418
				face[0] = grp.getDataAsInt(71);
419
				face[1] = grp.getDataAsInt(72);
420
				face[2] = grp.getDataAsInt(73);
421
				face[3] = grp.getDataAsInt(74);
422
				addFace(face);
423
			} else if ((vFlags & 16) == 16) {
424
				// no se hace nada.
425
			} else {
292
			if (vFlags != 16) {
426 293
				Point2D pt = proj.createPoint( x, y);
427 294
				lineString.add(pt);
428 295
				//System.out.println("addVertex: pt = " + pt);
......
636 503
		y = grp.getDataAsDouble(21);
637 504
		if (grp.hasCode(31)) {
638 505
			z2 = grp.getDataAsDouble(31);
639
		} else {
640
			// Cuando no se especifican z para las lineas se asume que la
641
			// z es cero.
642
			Double doub = new Double(0.0);
643
			feature.setProp("elevation", doub.toString());
644 506
		}
645 507
		pt2 = proj.createPoint(x, y);
646 508
		if (grp.hasCode(210))
......
737 599
			Double doub = new Double(z);
738 600
			String string = doub.toString();
739 601
			feature.setProp("elevation", string);
740
		} else {
741
			Double doub = new Double(0.0);
742
			feature.setProp("elevation", doub.toString());
743 602
		}
744 603
		if (grp.hasCode(210))
745 604
			xtruX = grp.getDataAsDouble(210);
......
818 677
			Double doub = new Double(z);
819 678
			String string = doub.toString();
820 679
			feature.setProp("elevation", string);
821
		} else {
822
			Double doub = new Double(0.0);
823
			feature.setProp("elevation", doub.toString());
824 680
		}
825 681
		if (grp.hasCode(210))
826 682
			xtruX = grp.getDataAsDouble(210);
......
894 750
			String string = doub.toString();
895 751
			feaBordes.setProp("elevation", string);
896 752
			feaFondos.setProp("elevation", string);
897
		} else {
898
			Double doub = new Double(0.0);
899
			feaBordes.setProp("elevation", doub.toString());
900
			feaFondos.setProp("elevation", doub.toString());
901 753
		}
902 754
		if (grp.hasCode(40)) r = grp.getDataAsDouble(40);
903 755
		if (grp.hasCode(210))
......
979 831
			Double doub = new Double(z);
980 832
			String string = doub.toString();
981 833
			feature.setProp("elevation", string);
982
		} else {
983
			Double doub = new Double(0.0);
984
			feature.setProp("elevation", doub.toString());
985 834
		}
986 835
		if (grp.hasCode(40)) r = grp.getDataAsDouble(40);
987 836
		if (grp.hasCode(50)) empieza = grp.getDataAsDouble(50);
......
1098 947
			String string = doubz.toString();
1099 948
			feature.setProp("elevation", string);
1100 949
			secondFeat.setProp("elevation", string);
1101
		} else {
1102
			Double elev = new Double(z);
1103
			//feature.setProp("elevation", doub.toString());
1104
			feature.setProp("elevation", elev.toString());
1105
			secondFeat.setProp("elevation", elev.toString());
1106 950
		}
1107 951
		if (grp.hasCode(41)) {
1108 952
			scaleFactor.setLocation(grp.getDataAsDouble(41), scaleFactor.getY());
......
1193 1037
			String string = doub.toString();
1194 1038
			feaBordes.setProp("elevation", string);
1195 1039
			feaFondos.setProp("elevation", string);
1196
		} else {
1197
			Double doub = new Double(0.0);
1198
			feaBordes.setProp("elevation", doub.toString());
1199
			feaFondos.setProp("elevation", doub.toString());
1200 1040
		}
1201 1041
		pts[0] = proj.createPoint(x, y);
1202 1042
		x = grp.getDataAsDouble(11);
......
1410 1250
	}
1411 1251
	public void createAttrib(DxfGroupVector grp) throws Exception {
1412 1252
		// TODO
1413
		/*Feature attFeature = new Feature();
1253
		Feature attFeature = new Feature();
1414 1254
		lastFeaBordes = attFeature;
1415
		lastFeaBordes.setGeometry(new Point());*/
1255
		lastFeaBordes.setGeometry(new Point());
1416 1256
	}
1417 1257
	
1418 1258
	public void createBlock(DxfGroupVector grp) throws Exception {
......
1484 1324
			//blk.flags = grp.getDataAsInt(70);
1485 1325
			Integer blockFlags = new Integer(grp.getDataAsInt(70));
1486 1326
			blk.setProp("blockFlags", blockFlags.toString());
1487
			// 041103: Hoy por hoy esto no lo utilizamos.
1488 1327
		}
1489 1328
	}
1490 1329
	
......
1531 1370
		}
1532 1371
	}
1533 1372
    
1534
	private void gestionaInsert(Feature feature) {
1373
	public void gestionaInsert(Feature feature) {
1535 1374
		Feature feature2 = null;
1536 1375
		Point point = null;
1537 1376
		LineString lineString = null;
......
1691 1530
			}
1692 1531
		}
1693 1532
	}
1694
	
1695
	private void addFace(int [] face) {
1696
		hasFaces = true;
1697
		if (faces == null)
1698
			faces = new Vector();
1699
		faces.add(face);
1700
	}
1701 1533

  
1702 1534
	/* (non-Javadoc)
1703 1535
	 * @see org.cresques.io.DxfFile.EntityFactory#getExtent()
branches/v02_desarrollo/libraries/libCq CMS for java.old/src/org/cresques/px/PxRaster.java
11 11
import java.awt.Graphics2D;
12 12
import java.awt.Image;
13 13

  
14
import java.awt.image.BufferedImage;
14 15
import java.awt.image.ImageObserver;
16
import java.util.Date;
15 17
import java.util.Vector;
16 18

  
17 19
import org.cresques.cts.ICoordTrans;
......
25 27
	protected GeoRasterFile geoFile = null;
26 28
	protected ImageObserver component = null;
27 29
	Vector pts = null;
30
	// Soporte para n bandas, visibles de 3 en 3, en ficheros separados
31
	protected GeoRasterFile [] colorBand = null;
32
	protected int rBand = 1, gBand = 2, bBand = 3;
28 33
	
29 34
	int transparente = 0x10ffff80;
30 35

  
......
63 68
		//setView(new Extent(x, y, x+4200, y-4200),"Huelva capital");
64 69
	}*/
65 70
	
71
	public PxRaster(IProjection proj, String [] fnames, ImageObserver component) {
72
		this.proj = proj;
73
		this.component = component;
74
		colorBand = new GeoRasterFile[fnames.length];
75
		for (int i=0; i<fnames.length; i++) {
76
    		colorBand[i] = GeoRasterFile.openFile(proj, fnames[i]);//loadECW(fname);
77
    		colorBand[i].setUpdatable((Component) component);
78
    		setExtent(colorBand[i].getExtent());
79
    		colorBand[i].setView(colorBand[i].getExtent());
80
		}
81
		extentOrig = extent;
82
		if (fnames.length >= 3) {
83
			this.setBand(GeoRasterFile.RED_BAND, 1);
84
			this.setBand(GeoRasterFile.GREEN_BAND, 2);
85
			this.setBand(GeoRasterFile.BLUE_BAND, 3);
86
		} else {
87
			this.setBand(GeoRasterFile.RED_BAND|GeoRasterFile.GREEN_BAND|GeoRasterFile.BLUE_BAND, 1);
88
		}
89
	}
90
	
66 91
	public PxRaster(GeoRasterFile eFile, ImageObserver component, Extent view) {
67 92
		geoFile = eFile;//loadECW(fname);
68 93
		this.component = component;
......
70 95
		eFile.setView(view);
71 96
		extentOrig = extent;
72 97
	}
98
	
99
	public int getBandCount() { return geoFile.getBandCount(); }
100
	
101
	/**
102
	 * Asocia un colorBand al rojo, verde o azul.
103
	 * @param flag cual (o cuales) de las bandas.
104
	 * @param nBand	que colorBand
105
	 */
106
	
107
	public void setBand(int flag, int nBand) {
108
		if ((flag & GeoRasterFile.RED_BAND) == GeoRasterFile.RED_BAND) rBand = nBand;
109
		if ((flag & GeoRasterFile.GREEN_BAND) == GeoRasterFile.GREEN_BAND) gBand = nBand;
110
		if ((flag & GeoRasterFile.BLUE_BAND) == GeoRasterFile.BLUE_BAND) bBand = nBand;
111
	}
73 112

  
113
	/**
114
	 * Devuelve el colorBand activo en la banda especificada.
115
	 * @param flag banda.
116
	 */
117
	
118
	public int getBand(int flag) {
119
		if (flag == GeoRasterFile.RED_BAND) return rBand;
120
		if (flag == GeoRasterFile.GREEN_BAND) return gBand;
121
		if (flag == GeoRasterFile.BLUE_BAND) return bBand;
122
		return -1;
123
	}
124

  
74 125
	public String getFName() {
75 126
		return geoFile.getName();
76 127
	}
......
150 201
	 */	
151 202

  
152 203
	public void draw(Graphics2D g, ViewPortData vp) {
204
		Image geoImage = null;
205
		long t2, t1 = new Date().getTime();
153 206
		System.out.println("PxRaster.draw(): vp.extent = "+ vp.getExtent());
154 207
		System.out.println("PxRaster.draw():    extent = "+ getExtent());
155 208
		if (vp.getExtent().minX()> extent.maxX()) return;
......
169 222
		int wImg = (int) Math.abs(w*scalex), hImg = (int) Math.abs(h*scaley);
170 223
		System.out.println("Sz=("+wImg+","+hImg+"); scale=("+scalex+","+scaley+")");
171 224
		if (wImg <= 0 || hImg <= 0) return;
172
		Image geoImage = geoFile.updateImage(wImg, hImg, rp);
173 225
		
174 226
		Point2D.Double pt = new Point2D.Double(x, y+h);
175 227
		try {
176 228
			System.out.println("Dibujando PxRaster: pt0 = "+pt);
177 229
			vp.mat.transform(pt, pt);
178 230
			System.out.println("Dibujando PxRaster: pt1 = "+pt);
179
			if (geoImage != null) {
231
			if (geoFile != null) { // Una sola banda
232
        		geoImage = geoFile.updateImage(wImg, hImg, rp);
180 233
				System.out.println("Dibujando PxRaster ...");
181 234

  
182 235
				g.drawImage(geoImage, (int) Math.round(pt.getX()), (int) Math.round(pt.getY()), component);
183
				System.out.println("Dibujando PxRaster: Hecho.");
184
			} else {
236
				t2 = new Date().getTime();
237
				System.out.println("Dibujando PxRaster: "+(t2-t1)/1000D+", secs.");
238
			} else if (colorBand != null) { // multiBands
239
				System.out.println("Dibujando PxRaster ...");
240
    			//if (doTransparency)
241
    				geoImage = new BufferedImage(wImg, hImg, BufferedImage.TYPE_INT_ARGB);
242
    			//else
243
    			//	geoImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
244
        		colorBand[rBand].updateImage(wImg, hImg, rp, geoImage, GeoRasterFile.RED_BAND);
245
        		colorBand[gBand].updateImage(wImg, hImg, rp, geoImage, GeoRasterFile.GREEN_BAND);
246
        		colorBand[bBand].updateImage(wImg, hImg, rp, geoImage, GeoRasterFile.BLUE_BAND);
247

  
248
				g.drawImage(geoImage, (int) Math.round(pt.getX()), (int) Math.round(pt.getY()), component);
249
				t2 = new Date().getTime();
250
				System.out.println("Dibujando PxRaster: "+(t2-t1)/1000D+", secs.");
251
			
252
			} else { // no cargada
185 253
				System.err.println("Dibujando PxRaster: Foto no cargada.");
186 254
			}
187 255
		} catch (Exception e) {
branches/v02_desarrollo/libraries/libCq CMS for java.old/src/org/cresques/cts/IProjection.java
26 26
	public Color getGridColor();
27 27
	public GeoPoint toGeo(Point2D pt);
28 28
	public Point2D fromGeo(Point2D gPt, Point2D mPt);
29
	public double getScale(double minX, double maxX, double width, double dpi);
29 30
}
branches/v02_desarrollo/libraries/libCq CMS for java.old/src/org/cresques/cts/ProjectionPool.java
45 45
		data.put("ed50utm31", cs);
46 46

  
47 47
		cs = (new CSUTM(CSDatum.wgs84, 30)).toGeo();
48
		cs.setAbrev("wgs84geo");
48
		cs.setAbrev("4326");
49 49
		data.put(cs.getAbrev(), cs);
50
		data.put("wgs84geo", cs);
50 51
		
52
		cs = new CSUTM(CSDatum.wgs84, 28);
53
		cs.setAbrev("2054");
54
		data.put(cs.getAbrev(), cs);
55
		data.put("wgs84utm28", cs);
56
		
57
		cs = new CSUTM(CSDatum.wgs84, 29);
58
		cs.setAbrev("2056");
59
		data.put(cs.getAbrev(), cs);
60
		data.put("wgs84utm29", cs);
61
		
51 62
		cs = new CSUTM(CSDatum.wgs84, 30);
52
		cs.setAbrev("wgs84utm30");
63
		cs.setAbrev("2058");
53 64
		data.put(cs.getAbrev(), cs);
65
		data.put("wgs84utm30", cs);
54 66
		
67
		cs = new CSUTM(CSDatum.wgs84, 31);
68
		cs.setAbrev("2060");
69
		data.put(cs.getAbrev(), cs);
70
		data.put("wgs84utm31", cs);
71
		
72
		cs = new CSUTM(CSDatum.wgs84, 32);
73
		cs.setAbrev("2062");
74
		data.put(cs.getAbrev(), cs);
75
		data.put("wgs84utm32", cs);
76
		
55 77
		cs = CSGaussPt.hgd73;
56 78
		cs.setAbrev("GT2hgd73");
57 79
		data.put(cs.getAbrev(), cs);
branches/v02_desarrollo/libraries/libCq CMS for java.old/src/org/cresques/cts/gt2/CSUTM.java
3 3
 */
4 4
package org.cresques.cts.gt2;
5 5

  
6
import java.awt.geom.Point2D;
7

  
6 8
import org.geotools.cs.AxisInfo;
7 9
import org.geotools.cs.FactoryException;
8 10
import org.geotools.cs.GeographicCoordinateSystem;
......
39 41
			e.printStackTrace();
40 42
		}
41 43
	}
44
	public double getScale(double minX, double maxX, double w, double dpi) {
45
		double scale = super.getScale(minX, maxX, w, dpi);
46
		if (projCS != null) { // Es geogr?fico; calcula la escala.
47
			scale = (maxX-minX)*	// metros
48
			(dpi / 2.54 * 100.0)/	// px / metro
49
			w;						// pixels
50
		}
51
		return scale;
52
	}
42 53
	public String toString() {
43 54
		return projCS.toString();
44 55
	}
branches/v02_desarrollo/libraries/libCq CMS for java.old/src/org/cresques/cts/gt2/CoordSys.java
107 107
		// TODO Ap?ndice de m?todo generado autom?ticamente
108 108
		return null;
109 109
	}
110
	
111
	public double getScale(double minX, double maxX, double w, double dpi) {
112
		double scale = 0D;
113
		if (projCS == null) { // Es geogr?fico; calcula la escala.
114
			scale = (maxX - minX)*		// grados
115
			// 1852.0 metros x minuto de meridiano
116
			(dpi / 2.54 * 100.0 * 1852.0 * 60.0)/	// px / metro
117
			w;										// pixels
118
		}
119
		return scale;
120
	}
110 121

  
111 122

  
112 123
}
branches/v02_desarrollo/libraries/libCq CMS for java.old/src/org/cresques/geo/Gauss.java
86 86
		grid.setColor(gridColor);
87 87
		grid.draw(g, vp);
88 88
	}
89

  
90
	/* (non-Javadoc)
91
	 * @see org.cresques.cts.IProjection#getScale(double, double, double, double)
92
	 */
93
	public double getScale(double minX, double maxX, double width, double dpi) {
94
		// TODO Auto-generated method stub
95
		return -1D;
96
	}
89 97
}
90 98

  
branches/v02_desarrollo/libraries/libCq CMS for java.old/src/org/cresques/geo/Geodetic.java
167 167
		grid.setColor(gridColor);
168 168
		grid.draw(g, vp);
169 169
	}
170

  
171
	/* (non-Javadoc)
172
	 * @see org.cresques.cts.IProjection#getScale(double, double, double, double)
173
	 */
174
	public double getScale(double minX, double maxX, double width, double dpi) {
175
		double scale = (maxX-minX)*		// grados
176
		// 1852.0 metros x minuto de meridiano
177
		(dpi / 2.54 * 100.0 * 1852.0 * 60.0)/	// px / metro
178
		width;								// pixels
179
		return scale;
180
	}
170 181
}
branches/v02_desarrollo/libraries/libCq CMS for java.old/src/org/cresques/geo/CCLambert.java
87 87
		grid.draw(g, vp);
88 88
	}
89 89

  
90
	/* (non-Javadoc)
91
	 * @see org.cresques.cts.IProjection#getScale(double, double, double, double)
92
	 */
93
	public double getScale(double minX, double maxX, double width, double dpi) {
94
		// TODO Auto-generated method stub
95
		return -1D;
96
	}
97

  
90 98
}
branches/v02_desarrollo/libraries/libCq CMS for java.old/src/org/cresques/geo/cover/Coverage.java
5 5
 */
6 6
package org.cresques.geo.cover;
7 7

  
8
import java.util.ArrayList;
8 9
import java.util.Hashtable;
9 10
import java.util.Enumeration;
10 11

  
......
17 18
import org.cresques.ui.CQApp;
18 19
import org.cresques.cts.ICoordTrans;
19 20
import org.cresques.cts.IProjection;
21
import org.cresques.cts.ProjectionPool;
22
import org.cresques.cts.gt2.CoordSys;
23
import org.cresques.cts.gt2.CoordTrans;
20 24
import org.cresques.geo.Projected;
21 25
import org.cresques.geo.Projection;
22 26
import org.cresques.geo.ReProjection;
23
import org.cresques.io.*;
27
import org.cresques.io.GeoRasterFile;
28
//import org.cresques.io.*;
24 29

  
25 30

  
26
class FileSupport {
31
/*class FileSupport {
27 32
	String extension;
28 33
	Class supportClass;
29 34
	public FileSupport(String e, Class c) {
30 35
		extension = e;
31 36
		supportClass = c;
32 37
	}
33
};
38
};*/
34 39

  
35 40
/**
36 41
 * Cobertura espacial
......
39 44
 */
40 45

  
41 46
public class Coverage implements Projected {
42
	protected FileSupport [] fSupport = {
47
	boolean debug = true;
48
/*	protected FileSupport [] fSupport = {
43 49
		new FileSupport("ecw", EcwFile.class)
44
	};
50
	};*/
45 51
	// Nombre de la cobertura
46 52
	protected String name = "Orto ICV 1:5.000";
47 53
	// Direcci?n raiz de los datos
......
49 55
	protected int	nLevels = 1;
50 56
	protected String hojaPrefix = "";
51 57
	protected Hashtable hojas = null;
52
;
58
	private Hashtable files = null;
59

  
53 60
	protected PxObjList marcos;
54 61
	
55
	protected Color color = null;
56
	protected Color fillColor = null;
62
	public Color color = null;
63
	public Color fillColor = null;
57 64
	protected boolean loadable = true;
58 65
	
66
	private String fType = "";
67
	
59 68
	protected IProjection proj = null;
60 69
	
70
	private boolean available = true;
71
	
61 72
	public Coverage() {
62 73
		hojas = new Hashtable();
74
		files = new Hashtable();
63 75
	}
64 76
	
65 77
	public String getName() { return name; }
......
72 84
	}
73 85
	
74 86
	/**
75
	 * Verifica si la extensi?n del fichero esta en la lista de ficheros soportados.
76
	 * @param fName
77
	 * @return
87
	 * Asigna el estado de disponibilidad.
88
	 * Cuando una cobertura no esta disponible (la unidad est?
89
	 * inactiva, no tiene ficheros, etc...) deber? ponerse a false.
90
	 * Es true por defecto
91
	 * @param av Disponibilidad.
78 92
	 */
79
	private boolean isSupportedFile(String fName) {
80
		String fn = fName.toLowerCase();
81
		for (int i=0; i< fSupport.length; i++) 
82
			if (fn.endsWith(fSupport[i].extension))
83
				return true;
84
		return false;
85
	}
93
	public void setAvailable(boolean av) { available = av; }
94
	/**
95
	 * Devuelve el estado de disponibilidad. 
96
	 * @return Disponibilidad.
97
	 */
98
	public boolean getAvailable() { return available; }
86 99
	
100
	/**
101
	 * Especifica el tipo de los ficheros que forman la cobertura.
102
	 * Es un string que ser? procesado por la aplicaci?n. La clase
103
	 * Coverage no hace ning?n tratamiento de este valor.
104
	 * @param fType Tipo de ficheros.
105
	 */
106
	public void setFileType(String fType) { this.fType = fType; }
107
	
108
	/**
109
	 * Devuelve el tipo de fichero.
110
	 * @return Tipo de fichero.
111
	 */
112
	public String getFileType() { return fType; }
113
	
87 114
	public void catalogue(String [] files) {
115
		String hName = null;
88 116
		for (int i=0; i<files.length; i++) {
89
			hojas.put(hojaPrefix+files[i],files[i]);
117
			hName = hojaPrefix+files[i];
118
			hojas.put(hName, files[i]);
119
			if (debug) System.out.println("Coverage: hojas.put('"+hName+"'");
90 120
		}
91 121
	}
92 122

  
93 123
	public void catalogue() {
94 124
		catalogue(dName);
95 125
	}
96
	
126
	/**
127
	 * Hace el cat?logo a partir de la lista de ficheros.
128
	 * @param files
129
	 */
97 130
	public void catalogueList(String [][] files) {
98
		Projection prj;
131
		IProjection prj = proj;
132
		String hName = null;
99 133
		for (int i=0; i<files.length; i++) {
100 134
			if (files[i][2] != null)
101
				prj = (Projection) Projection.getProjectionByName(proj.getDatum(), files[i][2]);
102
			else
103
				prj = ((Projection) proj);
104
			hojas.put(files[i][0],new Hoja(prj, files[i][1], files[i][0]));
135
				if (proj instanceof Projection)
136
					prj = (Projection) Projection.getProjectionByName(proj.getDatum(), files[i][2]);
137
    			else if (proj instanceof CoordSys)
138
    				prj = ProjectionPool.get(files[i][2]);
139
    		hName = files[i][0];
140
			hojas.put(hName, new Hoja(prj, files[i][1], files[i][0]));
141
			if (debug) System.out.println("Coverage: hojas.put('"+hName+"'");
105 142
		}
106 143
	}
107

  
144
	
145
	/**
146
	 * Hace el cat?logo recorriendo un directorio.
147
	 * @param dName
148
	 */
108 149
	public void catalogue(String dName) {
109 150
		System.out.println("Catalogando '"+dName+"' ...");
110 151
		File dir = new File(dName);
......
118 159
		} 
119 160
	}
120 161
	
162
	/**
163
	 * Genera el minuteo, reproyectado.
164
	 * @param targetProj proyeccion de destino
165
	 * @return array de minuteos
166
	 */
167
	
168
	public IObjList[] generateMinuteo(IProjection targetProj) {
169
		IObjList [] minuteo = new IObjList[nLevels];
170
		for (int i=0; i<minuteo.length; i++)
171
			minuteo[i] = new PxObjList();
172
		if (hojas.size()== 0)
173
			catalogue(this.dName);
174
		marcos = new PxObjList();
175
		IObjList layer = minuteo[0], layer1 = null;
176
		if (nLevels > 1) layer1 = minuteo[1];
177
		
178
		Enumeration enum = hojas.keys();
179
		String hName, hCode;
180
		Hoja h;
181
		Object obj = null; 
182
		while (enum.hasMoreElements()) {
183
			hName = (String) enum.nextElement();
184
			obj = hojas.get(hName);
185
			if (obj.getClass() == String.class) {
186
				hCode = (String) obj;
187
				generateMinuteoHoja(dName+"/"+hCode, hName, layer, layer1);
188
			} else if (obj.getClass() == Hoja.class) {
189
				h = (Hoja) obj;
190
				generateMinuteoHoja(dName+"/"+h.getCode(), h, layer, layer1);
191
			}
192
		}
193
		//app.setCurrentMinuteo(layer);
194
		if (proj != targetProj) {
195
			ICoordTrans rp = null;
196
			if (proj instanceof Projection)
197
				rp = new ReProjection(((Projection) proj), ((Projection) targetProj));
198
			else if (proj instanceof CoordSys)
199
				rp = new CoordTrans((CoordSys) proj, (CoordSys) targetProj);
200
			layer.reProject(rp);
201
			if (layer1 != null) layer1.reProject(rp);
202
		}
203
		
204
		return minuteo;
205
	}
206
	
121 207
	public void generateMinuteo(CQApp app, String lName, String lName1) {
122 208
		PxLayer layer1 = null;
123 209
		if (color == null) color = new Color(64,220,64,255);
......
158 244
		}
159 245
	}
160 246
	
161
	public void generateMinuteoHoja(String hFName, Hoja h, PxLayer layer, PxLayer layer1) {
162
		EcwFile eFile = null;
247
	public void generateMinuteoHoja(String hFName, Hoja h, IObjList layer, IObjList layer1) {
248
		GeoRasterFile eFile = null;
163 249
		PxContour contour = null;
164 250
		String fName = null;
165 251
		File dir = new File(hFName);
......
169 255
		}
170 256
		if (dir.isDirectory()) {
171 257
		} else {
172
			if (!isSupportedFile(hFName) ) return;
258
			if (!GeoRasterFile.fileIsSupported(hFName) ) return;
173 259
			fName = hFName;
174 260
			System.out.println("Analizo '"+h.getName()+"' ...");
175
			eFile = new EcwFile(null, fName);
261
			eFile = GeoRasterFile.openFile(null, fName);
176 262
			contour = new PxContour(eFile.getExtent(), fName, h.getName(), h.getProjection());
263
    		if (proj != h.getProjection()) {
264
    			ICoordTrans rp = null;
265
    			if (proj instanceof Projection)
266
    				rp = new ReProjection(((Projection) h.getProjection()), ((Projection) proj));
267
    			else if (proj instanceof CoordSys)
268
    				rp = new CoordTrans((CoordSys) h.getProjection(), (CoordSys) proj);
269
    			contour.reProject(rp);
270
    		}
177 271
			eFile.close();
178 272
			contour.c(color);
179 273
			contour.fillColor(fillColor);
......
181 275
		}		
182 276
	}
183 277
	
184
	public void generateMinuteoHoja(String hName, String name, PxLayer layer, PxLayer layer1) {
185
		EcwFile eFile = null;
278
	public void generateMinuteoHoja(String hName, String name, IObjList layer, IObjList layer1) {
279
		GeoRasterFile eFile = null;
186 280
		PxContour contour = null;
187 281
		String fName = null;
188 282
		File dir = new File(hName);
......
193 287
		if (dir.isDirectory()) {
194 288
			FilenameFilter filter = new FilenameFilter() {
195 289
				public boolean accept(File dir, String fName) {
196
					return isSupportedFile(fName);
290
					return GeoRasterFile.fileIsSupported(fName);
197 291
				}
198 292
			};
199 293
			String [] files = dir.list(filter);
......
204 298
				for (int i=0; i<files.length; i++) {
205 299
					fName = hName+"/"+files[i];
206 300
					System.out.println("Analizo '"+fName+"' ...");
207
					eFile = new EcwFile(null, fName);
301
					eFile = GeoRasterFile.openFile(null, fName);
208 302
					contour = new PxContour(eFile.getExtent(), fName, files[i], proj);
209 303
					eFile.close();
210 304

  
......
221 315
				}
222 316
			}
223 317
		} else {
224
			if (!isSupportedFile(hName) ) return;
318
			if (!GeoRasterFile.fileIsSupported(hName) ) return;
225 319
			fName = hName;
226 320
			System.out.println("Analizo '"+name+"' ...");
227 321
			//contour = EcwFile.getContour(fName, name, proj);
228
			eFile = new EcwFile(null, fName);
322
			eFile = GeoRasterFile.openFile(null, fName);
229 323
			contour = new PxContour(eFile.getExtent(), fName, name, proj);
230 324
			eFile.close();
231 325
			contour.c(color);
......
235 329
		}		
236 330
	}
237 331
	
332
	/**
333
	 * Devuelve los ficheros que incluye la hoja.
334
	 * @param hoja hoja que se busca.
335
	 * @return nombre(s) de fichero(s).
336
	 */
337
	
338
	public ArrayList getFileNames(String hoja) {
339
		ArrayList fNames = new ArrayList();
340
		
341
		if (!loadable) return null;
342
		String fName = null;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff