Revision 203

View differences:

trunk/libraries/libCq CMS for java.old/src/org/cresques/geo/cover/Coverage.java
20 20
import org.cresques.geo.Projected;
21 21
import org.cresques.geo.Projection;
22 22
import org.cresques.geo.ReProjection;
23
import org.cresques.io.GeoRasterFile;
24
//import org.cresques.io.*;
23
import org.cresques.io.*;
25 24

  
26 25

  
27 26
class FileSupport {
......
40 39
 */
41 40

  
42 41
public class Coverage implements Projected {
43
/*	protected FileSupport [] fSupport = {
42
	protected FileSupport [] fSupport = {
44 43
		new FileSupport("ecw", EcwFile.class)
45
	};*/
44
	};
46 45
	// Nombre de la cobertura
47 46
	protected String name = "Orto ICV 1:5.000";
48 47
	// Direcci?n raiz de los datos
......
76 75
	 * Verifica si la extensi?n del fichero esta en la lista de ficheros soportados.
77 76
	 * @param fName
78 77
	 * @return
79
	 * / 
78
	 */
80 79
	private boolean isSupportedFile(String fName) {
81 80
		String fn = fName.toLowerCase();
82 81
		for (int i=0; i< fSupport.length; i++) 
83 82
			if (fn.endsWith(fSupport[i].extension))
84 83
				return true;
85 84
		return false;
86
	}*/
85
	}
87 86
	
88 87
	public void catalogue(String [] files) {
89 88
		for (int i=0; i<files.length; i++) {
......
160 159
	}
161 160
	
162 161
	public void generateMinuteoHoja(String hFName, Hoja h, PxLayer layer, PxLayer layer1) {
163
		GeoRasterFile eFile = null;
162
		EcwFile eFile = null;
164 163
		PxContour contour = null;
165 164
		String fName = null;
166 165
		File dir = new File(hFName);
......
170 169
		}
171 170
		if (dir.isDirectory()) {
172 171
		} else {
173
			if (!GeoRasterFile.fileIsSupported(hFName) ) return;
172
			if (!isSupportedFile(hFName) ) return;
174 173
			fName = hFName;
175 174
			System.out.println("Analizo '"+h.getName()+"' ...");
176
			eFile = GeoRasterFile.openFile(null, fName);
175
			eFile = new EcwFile(null, fName);
177 176
			contour = new PxContour(eFile.getExtent(), fName, h.getName(), h.getProjection());
178 177
			eFile.close();
179 178
			contour.c(color);
......
183 182
	}
184 183
	
185 184
	public void generateMinuteoHoja(String hName, String name, PxLayer layer, PxLayer layer1) {
186
		GeoRasterFile eFile = null;
185
		EcwFile eFile = null;
187 186
		PxContour contour = null;
188 187
		String fName = null;
189 188
		File dir = new File(hName);
......
194 193
		if (dir.isDirectory()) {
195 194
			FilenameFilter filter = new FilenameFilter() {
196 195
				public boolean accept(File dir, String fName) {
197
					return GeoRasterFile.fileIsSupported(fName);
196
					return isSupportedFile(fName);
198 197
				}
199 198
			};
200 199
			String [] files = dir.list(filter);
......
205 204
				for (int i=0; i<files.length; i++) {
206 205
					fName = hName+"/"+files[i];
207 206
					System.out.println("Analizo '"+fName+"' ...");
208
					eFile = GeoRasterFile.openFile(null, fName);
207
					eFile = new EcwFile(null, fName);
209 208
					contour = new PxContour(eFile.getExtent(), fName, files[i], proj);
210 209
					eFile.close();
211 210

  
......
222 221
				}
223 222
			}
224 223
		} else {
225
			if (!GeoRasterFile.fileIsSupported(hName) ) return;
224
			if (!isSupportedFile(hName) ) return;
226 225
			fName = hName;
227 226
			System.out.println("Analizo '"+name+"' ...");
228 227
			//contour = EcwFile.getContour(fName, name, proj);
229
			eFile = GeoRasterFile.openFile(null, fName);
228
			eFile = new EcwFile(null, fName);
230 229
			contour = new PxContour(eFile.getExtent(), fName, name, proj);
231 230
			eFile.close();
232 231
			contour.c(color);
......
270 269
		if (dir.isDirectory()) {
271 270
			FilenameFilter filter = new FilenameFilter() {
272 271
				public boolean accept(File dir, String fName) {
273
					return GeoRasterFile.fileIsSupported(fName);
272
					return isSupportedFile(fName);
274 273
				}
275 274
			};
276 275
			files = dir.list(filter);
......
293 292
			}
294 293
			app.setCurrentLayer(layer);
295 294
			fName = hDName;
296
			if (!GeoRasterFile.fileIsSupported(fName)) return;
295
			if (!isSupportedFile(fName)) return;
297 296
			System.out.println("Cargo ...'"+fName+"'");
298 297
			app.loadFile(fName, proj);
299 298
			//mapview.canvas.zoomExtents();
trunk/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();
54 53
	
55 54
	abstract public IObjList getObjects();
56 55
	
trunk/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
	}
127 113
}
trunk/libraries/libCq CMS for java.old/src/org/cresques/io/EcwFile.java
138 138
		// Ancho m?ximo (~2500 px)
139 139
		final static int MAX_WIDTH = 1536;
140 140
		// Alto m?ximo (no hay l?mite)
141
		final static int MAX_HEIGHT = 1536;
141
		final static int MAX_HEIGHT = 20000;
142 142
		Point pos;
143 143
		Extent v;
144 144
		int width, height;
145
		boolean mustResize = false;
145
		boolean mustResize = true;
146 146
		public ChunkFrame(Extent vista, int w, int h) {
147 147
			v = vista;
148 148
			width = w;
......
163 163
			// Calcula el n? de chunks (filas y columnas)
164 164
			int numCol = (sz.width / MAX_WIDTH), numRow = (sz.height / MAX_HEIGHT);
165 165
			if (sz.width -(numCol*MAX_WIDTH) > 0) numCol++;
166
			if (sz.height - (numRow*MAX_HEIGHT) > 0) numRow++;
166
			if (sz.height-(numRow*MAX_HEIGHT) > 0) numRow++;
167 167
			frames = new ChunkFrame[numCol*numRow];
168 168

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

  
241 238
			// Work out the correct aspect for the setView call.
242 239
			dFileAspect = (double)v.width()/(double)v.height();
......
249 246
			}
250 247

  
251 248
			fullSize = new Dimension(width, height);
252
			System.out.println("fullSize = ("+width+","+height+")");
253 249
			// Peta en los peque?os ... arreglar antes de meter del todo
254 250
			ChunkFrame frames[] = ChunkFrame.computeFrames(file, v, fullSize);
255 251
			if (frames.length == 1) {
256 252
				width = frames[0].width; height = frames[0].height;
257
				System.out.println("frameSize = ("+width+","+height+")");
258 253
				//System.out.println("Cambio el ancho total a ("+width+","+height+")");
259 254
			}
260 255
			
......
289 284
				file.setView(file.numBands, bandlist, 
290 285
					f.v.minX(), f.v.maxY(), f.v.maxX(), f.v.minY(),
291 286
					f.width, f.height);
292
				System.out.println("f.Size = ("+f.width+","+f.height+")");
293

  
294 287
	
295 288
				// Read the scan lines
296
				for (line=0; line < f.height; line++) {
289
				for (line=0; line < height; line++) {
297 290
					file.readLineRGBA(pRGBArray);
298 291
					// Prueba de sustituci?n de color transparente
299 292
					if (doTransparency) {
......
314 307
		} catch (com.ermapper.ecw.JNCSInvalidSetViewException e) {
315 308
			System.err.println(errorMessage);
316 309
			e.printStackTrace(); */
317
		} catch(com.ermapper.ecw.JNCSException e) { //java.lang.ArrayIndexOutOfBoundsException:
318
			bErrorOnOpen = true;
319
			System.err.println("EcwFile JNCS Error en la l?nea "+line+"/"+height);
320
			System.err.println(e.getMessage());
321
			e.printStackTrace();
322
		} catch(java.lang.ArrayIndexOutOfBoundsException e) { //:
323
			bErrorOnOpen = true;
324
			System.err.println("EcwFile ArrayIndex Error en la l?nea "+line+"/"+height);
325
			System.err.println(e.getMessage());
326
			e.printStackTrace();
327 310
		} catch(Exception e) {
328 311
			bErrorOnOpen = true;
329 312
			errorMessage = e.getMessage();
......
332 315
			e.printStackTrace();
333 316
		}
334 317
		lastRefreshPercent = file.getPercentComplete();
335
		System.out.println("Leido al "+lastRefreshPercent+" %.");
336 318
		return ecwImage;
337 319
	}
338 320
	
......
367 349
	public void refreshUpdate(int nWidth, int nHeight, int dDatasetTLX, int dDatasetTLY, int dDatasetBRX, int dDatasetBRY) {
368 350
		System.out.println("EcwFile: se actualiza 2");
369 351
	}
370

  
371
	/* (non-Javadoc)
372
	 * @see org.cresques.io.GeoRasterFile#updateImage(int, int, org.cresques.cts.ICoordTrans, java.awt.Image, int)
373
	 */
374
	public Image updateImage(int width, int height, ICoordTrans rp, Image img, int flags) {
375
		// TODO Auto-generated method stub
376
		return null;
377
	}
378 352
}
trunk/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
	}
270 262
	
271 263
	
272 264
}
trunk/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
	}
675 667
}
trunk/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
	}
110 102
}
trunk/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;
37 34
	/**
38 35
	 * Filtro para raster.
39 36
	 * Permite eliminar la franja inutil alrededor de un raster girado o de
......
132 129

  
133 130
	static {
134 131
		supportedExtensions = new TreeMap();
135
		if (System.getProperty("os.name").toUpperCase().startsWith("WIN")) {
136
			supportedExtensions.put("ecw",  EcwFile.class);
137
		}
132
		supportedExtensions.put("ecw",  EcwFile.class);
138 133
		supportedExtensions.put("tif",  TifGeoRefFile.class);
139 134
		supportedExtensions.put("tiff", TifGeoRefFile.class);
140 135
		supportedExtensions.put("jpg",  TifGeoRefFile.class);
......
197 192
	 */
198 193
	public static void registerExtension(String ext, Class clase) {
199 194
		ext = ext.toLowerCase();
200
		System.out.println("RASTER: extension '"+ext+"' supported.");
201 195
		supportedExtensions.put(ext, clase);
202 196
	}
203 197
	
204
	/**
205
	 * Tipo de fichero soportado.
206
	 * Devuelve true si el tipo de fichero (extension) est? soportado, si no
207
	 * devuelve false.
208
	 * 
209
	 * @param fName Fichero raster
210
	 * @return  true si est? soportado, si no false.
211
 	 */
212 198
	
213
	public static boolean fileIsSupported(String fName) {
214
		String ext = fName.toLowerCase().substring(fName.lastIndexOf('.')+1);
215
		return supportedExtensions.containsKey(ext);
216
	}
217
	
218
	
219 199
	public GeoRasterFile(IProjection proj, String name) {
220 200
		super(proj, name);
221 201
	}
222 202
	
223 203
	abstract public GeoFile load();
224 204
	
225
	abstract public void close();
226
	
227 205
	public static PxContour getContour(String fName, String name, IProjection proj) {
228 206
		PxContour contour = null;
229 207
		return contour;
......
243 221
	public void setUpdatable(Component c) { updatable = c; }
244 222
	
245 223
	abstract public Image updateImage(int width, int height, ICoordTrans rp);
246

  
247
	/**
248
	 * Actualiza la/s banda/s especificadas en la imagen.
249
	 * @param width		ancho
250
	 * @param height	alto
251
	 * @param rp		reproyecci?n
252
	 * @param img		imagen
253
	 * @param flags		que bandas [ RED_BAND | GREEN_BAND | BLUE_BAND ]
254
	 * @return		img
255
	 */
256
	abstract public Image updateImage(int width, int height, ICoordTrans rp, Image img, int flags);
257 224
	
258 225
	public IObjList getObjects() {
259 226
		// TODO hay que a?adir el raster a la lista de objetos
trunk/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
	}
119 112

  
120 113

  
121 114
}
trunk/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
	}
50 42
}
trunk/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;
22 23
import java.awt.geom.Point2D;
23 24

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

  
43 49
	public DxfFeatureMaker(IProjection proj) {
44 50
		this.proj = proj;
......
137 143
			xtruY = grp.getDataAsDouble(220);
138 144
		if (grp.hasCode(230))
139 145
			xtruZ = grp.getDataAsDouble(230);
140
		if ((flags & 0x01) == 0x00) {
146
		if ((flags & 0x01) == 0x01 || (flags & 0x40) == 0x40) {
141 147
			feaBordes.setGeometry(lineString);
142
			lastFeaBordes = feaBordes;
143
			isDoubleFeatured = false;
144
		} else if ((flags & 0x01) == 0x01) {
145
			feaBordes.setGeometry(lineString);
146 148
			feaFondos.setGeometry(polygon);
147 149
			lastFeaBordes = feaBordes;
148 150
			lastFeaFondos = feaFondos;
149 151
			isDoubleFeatured = true;
152
		} else if ((flags & 0x01) == 0x00) {
153
			feaBordes.setGeometry(lineString);
154
			lastFeaBordes = feaBordes;
155
			isDoubleFeatured = false;
150 156
		} else {
151 157
			System.out.println("Detectada una Polyline Flag que no corresponde");
152 158
			System.out.println("a una Polyline corriente, ni a una Closed Polyline");
......
165 171
				if (bulge!=0) {
166 172
					bulge = 0.0;
167 173
				}
168
				lastFeaBordes.setGeometry(lineString);
169
				lastFeaFondos.setGeometry(polygon);
174
				
175
				if (hasFaces) {
176
					System.out.println("Sabe que es un poligono.");
177
					System.out.println("POLYLINE: caras=" +faces.size()+", puntos="+ lineString.pointNr());
178
					LineString ls1 = new LineString();
179
					Polygon pl1 = new Polygon();
180
					LineString ls2 = new LineString();
181
					Polygon pl2 = new Polygon();
182
					LineString ls = new LineString();
183
					Polygon pl = new Polygon();
184
					int [] face;
185
					int i0, i1;
186
					Iterator iter = faces.iterator();
187
					while (iter.hasNext()) {
188
						face = (int []) iter.next();
189
						i0 = face[3];
190
						for (int i=0; i<4; i++) {
191
							i1 = face[i];
192
							if (i0 > 0) {
193
								if ((facesIterador%2)!=0) {
194
									System.out.println("endSeq(): hasFaces = " + hasFaces);
195
									ls1.add((Point2D)lineString.get(i0-1));
196
									pl1.add((Point2D)polygon.get(i0-1));
197
									//ls1.add((Point2D)lineString.get(Math.abs(i1)-1));
198
									//pl1.add((Point2D)polygon.get(Math.abs(i1)-1));									
199
								} else {
200
									ls2.add((Point2D)lineString.get(i0-1));
201
									pl2.add((Point2D)polygon.get(i0-1));
202
									//ls2.add((Point2D)lineString.get(Math.abs(i1)-1));
203
									//pl2.add((Point2D)polygon.get(Math.abs(i1)-1));									
204
								}
205
								facesIterador = facesIterador + 1;
206
							}
207
							i0 = i1;
208
						}
209
					}
210
					facesFirstPoint = new Point2D.Double(ls1.get(0).getX(), ls1.get(0).getY());
211
					for (int i=0;i<ls1.pointNr();i++) {
212
						ls.add(ls1.get(i));
213
						pl.add(pl1.get(i));
214
					}
215
					for (int i=ls2.pointNr()-1;i>0;i--) {
216
						ls.add(ls2.get(i));
217
						pl.add(pl2.get(i));
218
					}
219
					ls.add(facesFirstPoint);
220
					pl.add(facesFirstPoint);
221
					lastFeaBordes.setGeometry(ls);					
222
					lastFeaFondos.setGeometry(pl);					
223
				} else {
224
					lastFeaBordes.setGeometry(lineString);
225
					lastFeaFondos.setGeometry(polygon);
226
				}
227
				
170 228
				if (addingToBlock == false) {
171 229
					features.add(lastFeaBordes);
172 230
					features.add(lastFeaFondos);
......
186 244
				if (bulge!=0) {
187 245
					bulge = 0.0;
188 246
				}
189
				lastFeaBordes.setGeometry(lineString);			
247
				
248
				if (hasFaces) {
249
					System.out.println("POLYLINE: caras=" +faces.size()+", puntos="+ lineString.pointNr());
250
					LineString ls1 = new LineString();
251
					LineString ls2 = new LineString();
252
					LineString ls = new LineString();
253
					int [] face;
254
					int i0, i1;
255
					Iterator iter = faces.iterator();
256
					while (iter.hasNext()) {
257
						face = (int []) iter.next();
258
						i0 = face[3];
259
						for (int i=0; i<4; i++) {
260
							i1 = face[i];
261
							if (i0 > 0) {
262
								if ((facesIterador%2)!=0) {
263
									ls1.add((Point2D)lineString.get(i0-1));
264
									//ls.add((Point2D)lineString.get(Math.abs(i1)-1));
265
								} else {
266
									ls2.add((Point2D)lineString.get(i0-1));
267
									//ls.add((Point2D)lineString.get(Math.abs(i1)-1));
268
								}
269
								facesIterador = facesIterador + 1;
270
							}
271
							i0 = i1;
272
						}
273
					}
274
					facesFirstPoint = new Point2D.Double(ls1.get(0).getX(), ls1.get(0).getY());
275
					for (int i=0;i<ls1.pointNr();i++) {
276
						ls.add(ls1.get(i));
277
					}
278
					for (int i=ls2.pointNr()-1;i>0;i--) {
279
						ls.add(ls2.get(i));
280
					}
281
					ls.add(facesFirstPoint);
282
					lastFeaBordes.setGeometry(ls);					
283
				} else {
284
					lastFeaBordes.setGeometry(lineString);
285
				}
286
				
190 287
				if (addingToBlock == false) {
191 288
					features.add(lastFeaBordes);
192 289
				} else {
......
202 299
		xtruZ = 1.0;
203 300
		bulge = 0.0;
204 301
		isDoubleFeatured = false;
302
		hasFaces = false;
303
		facesIterador = 1;
205 304
	}
206 305
	
207 306
	public void addVertex(DxfGroupVector grp) throws Exception {
......
216 315
				feaBordes.setProp("layer", grp.getDataAsString(8));
217 316
				feaFondos.setProp("layer", grp.getDataAsString(8));
218 317
			}
318
			if (grp.hasCode(70)) {
319
				vFlags = grp.getDataAsInt(70);
320
			}
219 321
			x  = grp.getDataAsDouble(10);
220 322
			y  = grp.getDataAsDouble(20);
221 323
			if (grp.hasCode(30)) {
......
226 328
			Point2D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
227 329
			x = point_out.getX();
228 330
			y = point_out.getY();
229
			if (vFlags != 16) {
331
			System.out.println("addVertex(): vFlags = " + vFlags);
332
			if ((vFlags & 0x80) == 0x80 && (vFlags & 0x40) == 0) {
333
				int [] face = {0,0,0,0};
334
				face[0] = grp.getDataAsInt(71);
335
				face[1] = grp.getDataAsInt(72);
336
				face[2] = grp.getDataAsInt(73);
337
				face[3] = grp.getDataAsInt(74);
338
				addFace(face);
339
			} else if ((vFlags & 0x10) == 0x10) {
340
				// Son vertices que se trataran cuando se implementen
341
				// los splines. En principio no se hace nada con ellos.
342
			} else {
230 343
				Point2D pt = proj.createPoint( x, y);
231 344
				lineString.add(pt);
232 345
				polygon.add(pt);
......
243 356
						bulge_aux = grp.getDataAsDouble(42);
244 357
					} else { bulge_aux = 0.0; }
245 358
					//int cnt = lineString.pointNr();
246
					System.out.println("addVertex(): lineString.pointNr() = " + lineString.pointNr());
359
					//System.out.println("addVertex(): lineString.pointNr() = " + lineString.pointNr());
247 360
					lineString.remove(lineString.pointNr()-1);
248 361
					lineString.remove(lineString.pointNr()-1);
249
					System.out.println("addVertex(): polygon.pointNr() = " + polygon.pointNr());
362
					//System.out.println("addVertex(): polygon.pointNr() = " + polygon.pointNr());
250 363
					polygon.remove(polygon.pointNr()-1);
251 364
					polygon.remove(polygon.pointNr()-1);
252 365
					Vector arc = createArc(ptAnterior, pt, bulge);
......
289 402
			Point2D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
290 403
			x = point_out.getX();
291 404
			y = point_out.getY();
292
			if (vFlags != 16) {
405
			if ((vFlags & 0x80) == 0x80 && (vFlags & 0x40) == 0) {
406
				int [] face = {0,0,0,0};
407
				face[0] = grp.getDataAsInt(71);
408
				face[1] = grp.getDataAsInt(72);
409
				face[2] = grp.getDataAsInt(73);
410
				face[3] = grp.getDataAsInt(74);
411
				addFace(face);
412
			} else if ((vFlags & 16) == 16) {
413
				// no se hace nada.
414
			} else {
293 415
				Point2D pt = proj.createPoint( x, y);
294 416
				lineString.add(pt);
295 417
				//System.out.println("addVertex: pt = " + pt);
......
1370 1492
		}
1371 1493
	}
1372 1494
    
1373
	public void gestionaInsert(Feature feature) {
1495
	private void gestionaInsert(Feature feature) {
1374 1496
		Feature feature2 = null;
1375 1497
		Point point = null;
1376 1498
		LineString lineString = null;
......
1530 1652
			}
1531 1653
		}
1532 1654
	}
1655
	
1656
	private void addFace(int [] face) {
1657
		hasFaces = true;
1658
		if (faces == null)
1659
			faces = new Vector();
1660
		faces.add(face);
1661
	}
1533 1662

  
1534 1663
	/* (non-Javadoc)
1535 1664
	 * @see org.cresques.io.DxfFile.EntityFactory#getExtent()
trunk/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;
15 14
import java.awt.image.ImageObserver;
16
import java.util.Date;
17 15
import java.util.Vector;
18 16

  
19 17
import org.cresques.cts.ICoordTrans;
......
27 25
	protected GeoRasterFile geoFile = null;
28 26
	protected ImageObserver component = null;
29 27
	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 = -1, bBand = -1;
33 28
	
34 29
	int transparente = 0x10ffff80;
35 30

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

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

  
123 74
	public String getFName() {
124 75
		return geoFile.getName();
125 76
	}
......
199 150
	 */	
200 151

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

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

  
246
				g.drawImage(geoImage, (int) Math.round(pt.getX()), (int) Math.round(pt.getY()), component);
247
				t2 = new Date().getTime();
248
				System.out.println("Dibujando PxRaster: "+(t2-t1)/1000D+", secs.");
249
			
250
			} else { // no cargada
183
				System.out.println("Dibujando PxRaster: Hecho.");
184
			} else {
251 185
				System.err.println("Dibujando PxRaster: Foto no cargada.");
252 186
			}
253 187
		} catch (Exception e) {

Also available in: Unified diff