Revision 25419

View differences:

branches/v10/extensions/DielmoOpenLidar/src/com/dielmo/gvsig/lidar/Strategies/LidarWatcher.java
1
/* DielmoOpenLiDAR
2
 *
3
 * Copyright (C) 2008 DIELMO 3D S.L. (DIELMO) and Infrastructures  
4
 * and Transports Department of the Valencian Government (CIT)
5
 * 
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 * 
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 * 
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
 * MA  02110-1301, USA.
20
 *
21
 * For more information, contact:
22
 *
23
 * DIELMO 3D S.L.
24
 * Plaza Vicente Andr?s Estell?s 1 Bajo E
25
 * 46950 Xirivella, Valencia
26
 * SPAIN
27
 *   
28
 * +34 963137212
29
 * dielmo@dielmo.com
30
 * www.dielmo.com
31
 * 
32
 * or
33
 * 
34
 * Generalitat Valenciana
35
 * Conselleria d'Infraestructures i Transport
36
 * Av. Blasco Ib??ez, 50
37
 * 46010 VALENCIA
38
 * SPAIN
39
 *
40
 * +34 963862235
41
 * gvsig@gva.es
42
 * www.gvsig.gva.es
43
 */
44

  
45
/*
46
 * AUTHORS (In addition to DIELMO and CIT):
47
 *  
48
 */
49

  
50
package com.dielmo.gvsig.lidar.Strategies;
51

  
52
import com.dielmo.gvsig.lidar.drivers.LiDARDriver;
53
import com.dielmo.gvsig.lidar.extensions.LiDAR_Mapping;
54
import com.iver.cit.gvsig.fmap.layers.CancelationException;
55
import com.iver.cit.gvsig.fmap.layers.FLyrVect;
56
import com.iver.cit.gvsig.fmap.layers.LayerCollectionEvent;
57
import com.iver.cit.gvsig.fmap.layers.LayerCollectionListener;
58
import com.iver.cit.gvsig.fmap.layers.LayerPositionEvent;
59

  
60
public class LidarWatcher implements LayerCollectionListener {
61

  
62
	private static LidarWatcher theInstance = null;
63
	
64
	public static LidarWatcher getInstance() {
65
		if (theInstance == null)
66
			theInstance = new LidarWatcher();
67
		return theInstance;
68
	}
69
	
70
	LidarWatcher() {
71

  
72
	}
73
	
74
	public void layerAdded(LayerCollectionEvent e) {
75
	 
76
		if (LiDARDriver.isLidarLayer(e.getAffectedLayer())){
77
			FLyrVect lyrVect = (FLyrVect) e.getAffectedLayer();		
78
			if (lyrVect.getStrategy() != null)
79
				if (!(lyrVect.getStrategy() instanceof LiDARStrategy)) {
80
					LiDAR_Mapping map = new LiDAR_Mapping();
81
					int grosor = map.getSizePixel();
82
					LiDARStrategy lidarStrategy = new LiDARStrategy(lyrVect,grosor);
83
					lyrVect.setStrategy(lidarStrategy);
84
				}
85
		}
86

  
87
	}
88

  
89
	public void layerAdding(LayerCollectionEvent e) throws CancelationException {
90
		// TODO Auto-generated method stub
91

  
92
	}
93

  
94
	public void layerMoved(LayerPositionEvent e) {
95
		// TODO Auto-generated method stub
96

  
97
	}
98

  
99
	public void layerMoving(LayerPositionEvent e) throws CancelationException {
100
		// TODO Auto-generated method stub
101

  
102
	}
103

  
104
	public void layerRemoved(LayerCollectionEvent e) {
105
		// TODO Auto-generated method stub
106
	}
107

  
108
	public void layerRemoving(LayerCollectionEvent e)
109
			throws CancelationException {
110
		// TODO Auto-generated method stub
111

  
112
	}
113

  
114
	public void visibilityChanged(LayerCollectionEvent e)
115
			throws CancelationException {
116
		// TODO Auto-generated method stub
117

  
118
	}
119

  
120
}
branches/v10/extensions/DielmoOpenLidar/src/com/dielmo/gvsig/lidar/Strategies/LiDARStrategy.java
1
/* DielmoOpenLiDAR
2
 *
3
 * Copyright (C) 2008 DIELMO 3D S.L. (DIELMO) and Infrastructures  
4
 * and Transports Department of the Valencian Government (CIT)
5
 * 
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 * 
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 * 
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
 * MA  02110-1301, USA.
20
 *
21
 * For more information, contact:
22
 *
23
 * DIELMO 3D S.L.
24
 * Plaza Vicente Andr?s Estell?s 1 Bajo E
25
 * 46950 Xirivella, Valencia
26
 * SPAIN
27
 *   
28
 * +34 963137212
29
 * dielmo@dielmo.com
30
 * www.dielmo.com
31
 * 
32
 * or
33
 * 
34
 * Generalitat Valenciana
35
 * Conselleria d'Infraestructures i Transport
36
 * Av. Blasco Ib??ez, 50
37
 * 46010 VALENCIA
38
 * SPAIN
39
 *
40
 * +34 963862235
41
 * gvsig@gva.es
42
 * www.gvsig.gva.es
43
 */
44

  
45
/*
46
 * AUTHORS (In addition to DIELMO and CIT):
47
 *  
48
 */
49

  
50
package com.dielmo.gvsig.lidar.Strategies;
51

  
52
import java.awt.Graphics2D;
53
import java.awt.geom.Point2D;
54
import java.awt.geom.Rectangle2D;
55
import java.awt.image.BufferedImage;
56

  
57
import org.cresques.cts.ICoordTrans;
58

  
59
import com.iver.andami.PluginServices;
60
import com.iver.cit.gvsig.fmap.DriverException;
61
import com.iver.cit.gvsig.fmap.ViewPort;
62
import com.iver.cit.gvsig.fmap.core.FPoint2D;
63
import com.iver.cit.gvsig.fmap.core.IGeometry;
64
import com.iver.cit.gvsig.fmap.core.ISymbol;
65
import com.iver.cit.gvsig.fmap.drivers.DriverAttributes;
66
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
67
import com.iver.cit.gvsig.fmap.layers.FBitSet;
68
import com.iver.cit.gvsig.fmap.layers.FLayer;
69
import com.iver.cit.gvsig.fmap.layers.ReadableVectorial;
70
import com.iver.cit.gvsig.fmap.layers.SelectableDataSource;
71
import com.iver.cit.gvsig.fmap.layers.layerOperations.AlphanumericData;
72
import com.iver.cit.gvsig.fmap.layers.layerOperations.ClassifiableVectorial;
73
import com.iver.cit.gvsig.fmap.layers.layerOperations.SingleLayer;
74
import com.iver.cit.gvsig.fmap.operations.strategies.DefaultStrategy;
75
import com.iver.cit.gvsig.fmap.operations.strategies.FeatureVisitor;
76
import com.iver.cit.gvsig.fmap.operations.strategies.VisitException;
77
import com.iver.cit.gvsig.fmap.rendering.VectorialLegend;
78
import com.iver.cit.gvsig.project.documents.view.gui.View;
79
import com.iver.utiles.swing.threads.Cancellable;
80
import com.iver.utiles.swing.threads.CancellableMonitorable;
81

  
82
/**
83
 * Esta clase se encargar? de dibujar las capas LiDAR
84
 * 
85
 * @author Jos? Carlos Garcia
86
 */
87
public class LiDARStrategy extends DefaultStrategy {
88
	
89
	int maxGrosor;
90
	ViewPort viewportCapa;
91
	
92
	/**
93
	 * Crea un nuevo LiDARStrategy.
94
	 * 
95
	 * @param layer
96
	 */
97
	public LiDARStrategy(FLayer layer, int grosor) {
98
		super(layer);
99
		viewportCapa = ((View) PluginServices.getMDIManager().getActiveWindow()).getMapControl().getViewPort();
100
		maxGrosor=grosor;
101
	}
102

  
103
	/**
104
	 * Recorre las features de la capa vectorial invocando el m?todo visit del
105
	 * visitador que se pasa como par?metro, que es el que realizar? la
106
	 * operaci?n relacionada con la geometry.
107
	 * 
108
	 * @param visitor
109
	 * @param cancel
110
	 * @throws DriverException
111
	 * @throws VisitException
112
	 */
113
	public void process(FeatureVisitor visitor, CancellableMonitorable cancel) throws DriverException, VisitException {
114
		try {
115

  
116
			FLayer capa = getCapa();
117
			if (visitor.start(capa)) {
118
				ReadableVectorial va = ((SingleLayer) capa).getSource();
119
				ICoordTrans ct = getCapa().getCoordTrans();
120
				va.start();
121
				
122
				if(va.getFullExtent().intersects(viewportCapa.getAdjustedExtent())){
123
				
124
					for (int i = 0; i < va.getShapeCount(); i++) {
125
						if(cancel != null){
126
							cancel.reportStep();
127
						}
128
						if(verifyCancelation(cancel, va, visitor))
129
							return;
130
					    IGeometry geom = va.getShape(i);
131
					    if (ct != null) {
132
							geom.reProject(ct);
133
						}
134
	
135
						visitor.visit(geom, i);
136
					}	
137
				}
138
				
139
				va.stop();
140
//				logger.info("visitor.stop()");
141
				visitor.stop(capa);
142
			}
143
		} catch (DriverIOException e) {
144
			throw new DriverException(e);
145
		}
146
	}
147
	
148
	/**
149
	 * Dibuja la capa vectorial asociada al Strategy en la imagen que se pasa
150
	 * como par?metro.
151
	 *
152
	 * @param image
153
	 * @param g
154
	 * @param viewPort
155
	 * @param cancel
156
	 *
157
	 * @throws DriverException
158
	 */
159
	public void draw(BufferedImage image, Graphics2D g, ViewPort viewPort,
160
			Cancellable cancel) throws DriverException {
161
		try {
162
			ReadableVectorial rvLiDAR = ((SingleLayer) getCapa()).getSource();
163
			ICoordTrans ct = getCapa().getCoordTrans();
164
			// logger.info("adapter.start()");
165
			rvLiDAR.start();
166

  
167
			// logger.info("getCapa().getRecordset().start()");
168
			SelectableDataSource dsLidar = ((AlphanumericData) getCapa())
169
					.getRecordset();
170
			if (dsLidar != null)
171
				dsLidar.start();
172

  
173
			int numRowsLidar;
174
			Rectangle2D extent = viewPort.getAdjustedExtent();
175
			Rectangle2D fullExtent = getCapa().getFullExtent();
176
			if (!extent.intersects(fullExtent))
177
				return;
178
			// ati = viewPort.getAffineTransform();
179

  
180
			numRowsLidar = rvLiDAR.getShapeCount();
181
			// TODO: A revisar si es o no conveniente este sistema
182
			// de comunicaci?n con los drivers.
183
			DriverAttributes attr = rvLiDAR.getDriverAttributes();
184
			boolean bMustClone = false;
185
			if (attr != null) {
186
				if (attr.isLoadedInMemory()) {
187
					bMustClone = attr.isLoadedInMemory();
188
				}
189
			}
190

  
191
			VectorialLegend l = (VectorialLegend) ((ClassifiableVectorial) getCapa()).getLegend();
192
			FBitSet bitSet = dsLidar.getSelection();
193

  
194
			//ajustamos el increment en funci?n del tama?o de pixel de la vista
195
			double resolucion = viewPort.getDist1pixel();
196
			
197
			int increment = 0;
198
			if (resolucion < 25)
199
				increment = (int) Math.floor(resolucion*(resolucion/3));
200
			else					
201
				increment = (int) Math.ceil(numRowsLidar / ((fullExtent.getWidth()/resolucion) * (fullExtent.getHeight()/resolucion))*(resolucion/30));
202
			
203
//			if (incrementAux > increment)
204
//				increment = incrementAux;
205
			
206
			if (increment < 1)
207
				increment = 1;
208

  
209
			//para que al menos pinte 5 puntos
210
			if (increment > numRowsLidar/5)
211
				increment = (int) Math.floor(numRowsLidar/5);
212

  
213
			int incrementAux = increment;
214
			int incrementFast = 400;
215
			
216
			if (incrementFast < incrementAux)
217
				incrementFast = incrementAux;
218
			
219
			// limites de incremento.
220
			int limiteIncremento = incrementFast*10;
221
			int limiteIncrementoFast=incrementFast*11;
222
			
223
		
224
			//ajustamos el grosor del punto en funci?n del tama?o de pixel de la vista
225
			int grosor;
226
			if (resolucion > 0 && resolucion < 25)
227
				grosor = (int) Math.round(1/(resolucion*1.5));
228
			else
229
				if(resolucion >= 25 && resolucion < 250)
230
					grosor=1;
231
				else
232
					if(resolucion >= 250)
233
						grosor=0;
234
					else {
235
						
236
						grosor=maxGrosor;
237
					}
238
				
239
			// maximo 10 de grosor
240
			if (grosor > maxGrosor)
241
				grosor = maxGrosor; 
242
			
243
			// minimo 0 de grosor
244
			if(grosor<0)
245
				grosor=0;
246

  
247
			int ii,jj,pixX,pixY;
248
			
249
			//contIN es el contador de puntos que caen dentro de la vista
250
			long contIN=0;
251
			
252
			//contIN es el contador de puntos que caen fuera de la vista
253
			long contOUT=0;
254
			
255
			// recorremos por incrementos
256
			for (int i = 0; i < numRowsLidar; i += increment) {
257

  
258
				// si se cancela salir del bucle
259
				if (cancel.isCanceled()) {
260
					break;
261
				}
262
				
263
				// obtener la geometria del punto i
264
				IGeometry geom = rvLiDAR.getShape(i);
265

  
266
				if (geom == null) {
267
					continue;
268
				}
269

  
270
				if (ct != null) {
271
					if (bMustClone)
272
						geom = geom.cloneGeometry();
273
					geom.reProject(ct);
274
				}
275

  
276
				ISymbol symbol = l.getSymbol(i);
277

  
278
				if (symbol == null)
279
					continue;
280
				if (bitSet != null)
281
					if (bitSet.get(i)) {
282
						symbol = symbol.getSymbolForSelection();
283
					}
284

  
285
				if (symbol != null) {
286
					// geom.draw(g, viewPort, symbol);
287
					FPoint2D p = (FPoint2D) geom.getInternalShape();
288
					Point2D.Double pOrig = new Point2D.Double(p.getX(), p.getY());
289
					Point2D pDest, pDest2;
290

  
291
					pDest = viewPort.getAffineTransform().transform(pOrig,null);
292
					pDest2 = g.getTransform().transform(pDest, null);
293

  
294
					pixX = (int) pDest2.getX();
295
					pixY = (int) pDest2.getY();
296
					if (symbol == null)
297
						continue;
298
					
299
					// pinta el pixel del grosor correspendiente
300
					if ((pixX > grosor) && (pixX < image.getWidth()-grosor) && (pixY > grosor) && (pixY < image.getHeight()-grosor)) {
301
						if (grosor == 0)
302
							image.setRGB(pixX, pixY, symbol.getOnePointRgb());
303
						else{
304
							for (ii=-grosor;ii<=grosor;ii++){
305
								for (jj=-grosor;jj<=grosor;jj++){
306
									image.setRGB(pixX+ii, pixY+jj, symbol.getOnePointRgb());
307
								}
308
							}
309
						}
310
					}
311
					
312
					// si cae dentro de la vista
313
					if ((pixX > 1-incrementFast) && (pixX < image.getWidth()+incrementFast) && (pixY > 1-incrementFast) && (pixY < image.getHeight()-1+incrementFast)) {
314
						
315
						// El primer punto despues de no entrar ningun punto tras limiteIncrementoFast cambiara el incremento
316
						// y retrasara el indice de recorrido de puntos.
317
						if (contIN == 0){
318
							
319
							increment = incrementAux;
320
							if (i>limiteIncremento)
321
								i=i-limiteIncremento;
322
						}
323

  
324
						// si el punto cae dentro de la vista +/- incrementFast incrementamos contIN.
325
						contIN ++;
326
						contOUT=0;
327
						
328
					} else { // si caen fuera de la vista y supera el limiteIncrementoFast indicado nos pasamos al incremento rapido
329
						if (contOUT == limiteIncrementoFast){
330
							
331
							contIN=0;
332
							increment = incrementFast;
333
						}
334
						
335
						contOUT++;
336
					}
337
				}
338
			}
339
/*
340
			increment = incrementAux;
341
			if (increment > 10)
342
			{
343
				for (int i = sc-increment/2; i > 0; i -= increment) {
344
					if (cancel.isCanceled()) {
345
						break;
346
					}
347
					IGeometry geom = adapter.getShape(i);
348
	
349
					if (geom == null) {
350
						continue;
351
					}
352
	
353
					if (ct != null) {
354
						if (bMustClone)
355
							geom = geom.cloneGeometry();
356
						geom.reProject(ct);
357
					}
358
	
359
					ISymbol symbol = l.getSymbol(i);
360
	
361
					if (symbol == null)
362
						continue;
363
					if (bitSet != null)
364
						if (bitSet.get(i)) {
365
							symbol = symbol.getSymbolForSelection();
366
						}
367
					if (symbol != null) {
368
						// geom.draw(g, viewPort, symbol);
369
						FPoint2D p = (FPoint2D) geom.getInternalShape();
370
						Point2D.Double pOrig = new Point2D.Double(p.getX(), p.getY());
371
						Point2D pDest, pDest2;
372
	
373
						pDest = viewPort.getAffineTransform().transform(pOrig,
374
								null);
375
						pDest2 = g.getTransform().transform(pDest, null);
376
	
377
						pixX = (int) pDest2.getX();
378
						pixY = (int) pDest2.getY();
379
						if (symbol == null)
380
							continue;
381
						
382
						if ((pixX > grosor) && (pixX < image.getWidth()-grosor) && (pixY > grosor) && (pixY < image.getHeight()-grosor)) 
383
						{
384
							for (ii=-grosor;ii<=grosor;ii++)
385
							{
386
								for (jj=-grosor;jj<=grosor;jj++)
387
								{
388
									image.setRGB(pixX+ii, pixY+jj, symbol.getOnePointRgb());
389
								}
390
							}
391
						}
392
						
393
						if ((pixX > 1-incrementFast) && (pixX < image.getWidth()+incrementFast) && (pixY > 1-incrementFast) && (pixY < image.getHeight()-1+incrementFast)) 
394
						{
395
							if (contIN == 0)
396
							{
397
								increment = incrementAux;
398
								if (i>incrementFast*10)
399
									i=i-incrementFast*10;
400
							}
401
							
402
							contIN ++;
403
							contOUT=0;
404
						}
405
						else
406
						{
407
							if (contOUT == incrementFast*11)
408
							{
409
								contIN=0;
410
								increment = incrementFast;
411
							}
412
							
413
							contOUT++;
414
						}
415
					}
416
				}
417
			}
418
			*/
419
			// logger.info("getCapa().getRecordset().stop()");
420
			if (dsLidar != null)
421
				dsLidar.stop();
422

  
423
			// logger.debug("adapter.stop()");
424
			rvLiDAR.stop();
425
			// TODO: A revisar si es o no conveniente este sistema
426
			// de comunicaci?n con los drivers.
427
			// DriverAttributes attr = adapter.getDriverAttributes();
428
			/*
429
			 * if (attr != null) { if (attr.isLoadedInMemory()) { // Quitamos lo
430
			 * de la reproyecci?n al vuelo para que // solo se haga una vez.
431
			 * getCapa().setCoordTrans(null); } }
432
			 */
433

  
434
		} catch (DriverIOException e) {
435
			throw new DriverException(e);
436
		} catch (com.hardcode.gdbms.engine.data.driver.DriverException e) {
437
			throw new DriverException(e);
438
		} catch (DriverException e) {
439
			throw new DriverException(e);
440
		}
441
	}
442
}
branches/v10/extensions/DielmoOpenLidar/src/com/dielmo/gvsig/lidar/drivers/LiDARDriver.java
1
/* DielmoOpenLiDAR
2
 *
3
 * Copyright (C) 2008 DIELMO 3D S.L. (DIELMO) and Infrastructures  
4
 * and Transports Department of the Valencian Government (CIT)
5
 * 
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 * 
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 * 
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
 * MA  02110-1301, USA.
20
 *
21
 * For more information, contact:
22
 *
23
 * DIELMO 3D S.L.
24
 * Plaza Vicente Andr?s Estell?s 1 Bajo E
25
 * 46950 Xirivella, Valencia
26
 * SPAIN
27
 *   
28
 * +34 963137212
29
 * dielmo@dielmo.com
30
 * www.dielmo.com
31
 * 
32
 * or
33
 * 
34
 * Generalitat Valenciana
35
 * Conselleria d'Infraestructures i Transport
36
 * Av. Blasco Ib??ez, 50
37
 * 46010 VALENCIA
38
 * SPAIN
39
 *
40
 * +34 963862235
41
 * gvsig@gva.es
42
 * www.gvsig.gva.es
43
 */
44

  
45
/*
46
 * AUTHORS (In addition to DIELMO and CIT):
47
 *  
48
 */
49

  
50
package com.dielmo.gvsig.lidar.drivers;
51

  
52
import java.awt.geom.Point2D;
53
import java.awt.geom.Rectangle2D;
54
import java.io.File;
55
import java.io.FileInputStream;
56
import java.io.FileNotFoundException;
57
import java.io.FileOutputStream;
58
import java.io.IOException;
59
import java.nio.ByteOrder;
60
import java.nio.channels.FileChannel;
61
import java.util.Properties;
62

  
63
import com.dielmo.lidar.InicializeLidar;
64
import com.dielmo.lidar.LASHeader_1X;
65
import com.dielmo.lidar.LidarHeader;
66
import com.dielmo.lidar.LidarPoint;
67
import com.hardcode.driverManager.Driver;
68
import com.hardcode.gdbms.driver.DriverUtilities;
69
import com.hardcode.gdbms.engine.data.DataSourceFactory;
70
import com.hardcode.gdbms.engine.data.driver.DriverException;
71
import com.hardcode.gdbms.engine.data.driver.ObjectDriver;
72
import com.hardcode.gdbms.engine.data.edition.DataWare;
73
import com.hardcode.gdbms.engine.values.Value;
74
import com.iver.cit.gvsig.fmap.core.FShape;
75
import com.iver.cit.gvsig.fmap.core.IGeometry;
76
import com.iver.cit.gvsig.fmap.core.ShapeFactory;
77
import com.iver.cit.gvsig.fmap.drivers.BoundedShapes;
78
import com.iver.cit.gvsig.fmap.drivers.DriverAttributes;
79
import com.iver.cit.gvsig.fmap.drivers.FieldDescription;
80
import com.iver.cit.gvsig.fmap.drivers.ITableDefinition;
81
import com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver;
82
import com.iver.cit.gvsig.fmap.edition.EditionException;
83
import com.iver.cit.gvsig.fmap.edition.IRowEdited;
84
import com.iver.cit.gvsig.fmap.edition.ISpatialWriter;
85
import com.iver.cit.gvsig.fmap.edition.IWriteable;
86
import com.iver.cit.gvsig.fmap.edition.IWriter;
87
import com.iver.cit.gvsig.fmap.layers.FLayer;
88
import com.iver.cit.gvsig.fmap.layers.FLyrVect;
89
import com.iver.utiles.bigfile.BigByteBuffer2;
90

  
91
/**
92
 * Driver for managing original data LiDAR
93
 * 
94
 * @author Oscar Garcia
95
 */
96
public class LiDARDriver implements VectorialFileDriver, ObjectDriver, BoundedShapes,
97
IWriteable, ISpatialWriter {
98
	
99
	/**
100
	 * Driver name.
101
	 */
102
	public static final String driverName = "gvSIG LIDAR driver";
103
	// Variables para el manejo del fichero LiDAR
104
	
105
	/**
106
	 * LiDAR file.
107
	 */
108
	private File m_Fich;
109
	
110
	/**
111
	 * Temporal LiDAR file for writer. This is used in edition time.
112
	 */
113
	private File fTemp;
114
	
115
	/**
116
	 * 8 Kbytes buffer
117
	 */
118
	private BigByteBuffer2 bb;
119
	
120
	/**
121
	 * Channel to read, write and manipulate the LiDAR file 
122
	 */
123
	private FileChannel channel;
124
	
125
	/**
126
	 * management of input read data from LiDAR file. 
127
	 */
128
	private FileInputStream fin;
129
	
130
	// informacion del LiDAR
131
	/**
132
	 * fullExtent of LiDAR layer.
133
	 */
134
	private Rectangle2D fullExtent;
135
	
136
	/**
137
	 * Definition of one type of LiDAR point.
138
	 */
139
	private LidarPoint lp;
140
	
141
	/**
142
	 * Definition of one type of LiDAR header.
143
	 */
144
	private LidarHeader hdr;
145
	
146
	/**
147
	 * Description of fields LiDAR
148
	 */ 
149
	private FieldDescription[] fields;
150
	
151
	// Writer
152
	/**
153
	 * Writer assigned to LiDAR
154
	 */
155
	private LiDARWriter lidarWriter = new LiDARWriter();
156
	
157
	/**
158
	 * Temporal folder to work in edition mode.
159
	 */
160
	private static String tempDirectoryPath = System.getProperty("java.io.tmpdir");
161
	
162
	/**
163
	 * Function that test if passed layer is controlled by driver LiDARDriver
164
	 * 
165
	 * @param layer layer to test
166
	 * @return true if layer is controlled by driver LiDARDriver, false in other case
167
	 */
168
	public static boolean isLidarLayer(FLayer layer) {
169
		
170
		if (layer instanceof FLyrVect && layer.isAvailable()) {
171
			
172
			FLyrVect lyrVect = (FLyrVect) layer;
173
			//ReadableVectorial rv = lyrVect.getSource();
174
			//VectorialDriver driver = lyrVect.getSource().getDriver();
175
			Driver driver = lyrVect.getSource().getDriver();
176
			if(driver==null)
177
				return false;
178
			if (driver.getName().compareTo(driverName) == 0) {
179
				return true;
180
			}
181
		}
182
		return false;
183
	}
184
	
185
	/**
186
	 * return the LidarHeader of this layer
187
	 */
188
	public LidarHeader getLidarHeader() {
189
		return hdr;
190
	}
191
	
192
	/**
193
	 * return a new instance of LidarPoint type of this layer
194
	 */
195
	public LidarPoint getLidarPoint() {
196
		return lp;
197
	}
198
	
199
	// VectorialFileDriver Methods
200
	public void initialize() throws IOException {
201
		
202
		File file = new File(m_Fich.getAbsolutePath());
203
		hdr = InicializeLidar.InizializeLidarHeader(file);
204
		
205
		if(hdr == null)
206
			throw new IOException();
207
		
208
		lp = InicializeLidar.InizializeLidarPoint(file);
209
		
210
		if(lp == null)
211
			throw new IOException();
212
		
213
		// la informacion de fullExtent la contiene la cabecera
214
		fullExtent = new Rectangle2D.Double(hdr.getMinX(), hdr.getMinY(),
215
				(hdr.getMaxX()-hdr.getMinX()),
216
				(hdr.getMaxY()-hdr.getMinY()));
217
		
218
		// obtiene la estructura de tabla
219
		setFields();
220
	}
221

  
222
	/*
223
	 * (non-Javadoc)
224
	 *
225
	 * @see com.iver.cit.gvsig.fmap.drivers.MemoryDriver#accept(java.io.File)
226
	 */
227
	public boolean accept(File f) {
228
		return ((f.getName().toUpperCase().endsWith("LAS")) || (f.getName().toUpperCase().endsWith("BIN")));
229
	}
230

  
231
	public void close() throws IOException {
232

  
233
/*		IOException ret = null;
234

  
235
		try {
236
			channel.close();
237
		} catch (IOException e) {
238
			ret = e;
239
		} finally {
240
			try {
241
				fin.close();
242
			} catch (IOException e1) {
243
				ret = e1;
244
			}
245
		}
246

  
247
		if (ret != null) {
248
			throw ret;
249
		}
250
		else // Si todo ha ido bien, preparamos para liberar memoria.
251
        {
252
		    bb = null;
253
        }
254
		*/
255
	}
256

  
257
	public File getFile() {
258
		return m_Fich;
259
	}
260

  
261
	/*
262
	 * (non-Javadoc)
263
	 *
264
	 * @see com.iver.cit.gvsig.fmap.drivers.MemoryDriver#open(java.io.File)
265
	 */
266
	public void open(File f) throws IOException {
267
		m_Fich = f;
268
		
269
		fin = new FileInputStream(f);
270

  
271
		// Open the file and then get a channel from the stream
272
		channel = fin.getChannel();
273

  
274
		// Get the file's size and then map it into memory
275
		// bb = channel.map(FileChannel.MapMode.READ_ONLY, 0, size);
276
        bb = new BigByteBuffer2(channel, FileChannel.MapMode.READ_ONLY);
277
        bb.order(ByteOrder.LITTLE_ENDIAN);
278
	}
279

  
280
	/*
281
	 * (non-Javadoc)
282
	 *
283
	 * @see com.iver.cit.gvsig.fmap.drivers.VectorialDriver#getDriverAttributes()
284
	 */
285
	public DriverAttributes getDriverAttributes() {
286
		return null;
287
	}
288

  
289
	/* (non-Javadoc)
290
	 * @see com.iver.cit.gvsig.fmap.drivers.VectorialDriver#getFullExtent()
291
	 */
292
	public Rectangle2D getFullExtent() throws IOException {
293
		
294
		return fullExtent;
295
	}
296

  
297
	/* (non-Javadoc)
298
	 * @see com.iver.cit.gvsig.fmap.drivers.VectorialDriver#getShape(int)
299
	 */
300
	public IGeometry getShape(int index) {
301
		
302
		Point2D.Double p = null;
303
		p = lp.readPoint2D(bb, hdr, index);
304
		return ShapeFactory.createPoint2D(p.getX(), p.getY());
305
	}
306

  
307
	public int getShapeCount() throws IOException {	
308
		return (int)hdr.getNumPointsRecord();
309
	}
310

  
311
	/*
312
	 * (non-Javadoc)
313
	 *
314
	 * @see com.iver.cit.gvsig.fmap.drivers.MemoryDriver#getShapeType()
315
	 */
316
	public int getShapeType() {
317
		return FShape.POINT;
318
	}
319

  
320
	/**
321
	 * Indica si el fichero se puede modificar.
322
	 */
323
	public boolean isWritable() {
324
		return m_Fich.canWrite();
325
	}
326

  
327
	 /* (non-Javadoc)
328
     * @see com.iver.cit.gvsig.fmap.drivers.VectorialDriver#reLoad()
329
     */
330
    public void reload() throws DriverException, IOException {
331
    	
332
    	/*
333
    	 * Codigo para cerrar los ficheros antes de intentar recargarlos
334
    	 */
335
    	IOException ret = null;
336

  
337
		try {
338
			channel.close();
339
		} catch (IOException e) {
340
			ret = e;
341
		} finally {
342
			try {
343
				fin.close();
344
			} catch (IOException e1) {
345
				ret = e1;
346
			}
347
		}
348

  
349
		if (ret != null) {
350
			throw ret;
351
		} else { 
352
        
353
			// Si todo ha ido bien, preparamos para liberar memoria.
354
		    bb = null;
355
        }
356
    	
357
    	open(m_Fich);
358
		initialize();
359
    }
360

  
361
	/*
362
	 * (non-Javadoc)
363
	 *
364
	 * @see com.iver.cit.gvsig.fmap.drivers.MemoryDriver#getName()
365
	 */
366
	public String getName() {
367
		return driverName;
368
	}
369
	
370
	// ObjectDriver Methods			     		
371
	public int[] getPrimaryKeys() throws DriverException {
372
		// TODO Auto-generated method stub
373
		return null;
374
	}
375

  
376
	public void write(DataWare dataWare) throws DriverException {
377
		// TODO Auto-generated method stub
378
		
379
	}
380

  
381
	public void setDataSourceFactory(DataSourceFactory dsf) {
382
		// TODO Auto-generated method stub
383
	}
384

  
385
	public int getFieldCount() throws DriverException {
386
		return fields.length;
387
	}
388

  
389
	public String getFieldName(int fieldId) throws DriverException {
390
		return fields[fieldId].getFieldName();
391
	}
392

  
393
	public int getFieldType(int i) throws DriverException {
394
		return fields[i].getFieldType();
395
	}
396

  
397
	public Value getFieldValue(long rowIndex, int fieldId) throws DriverException {
398
		return lp.getFieldValueByIndex(bb, fieldId, hdr, rowIndex);
399
	}
400

  
401
	public int getFieldWidth(int i) throws DriverException {
402
		return fields[i].getFieldLength();
403
	}
404

  
405
	public long getRowCount() throws DriverException {
406
		return (int)hdr.getNumPointsRecord();
407
	}
408

  
409
	private void setFields(){
410
		fields = lp.getFieldDescription();
411
	}
412

  
413
	//IWriteable Methods
414
	public IWriter getWriter() {
415
		return this;
416
	}
417

  
418
	//ISpatialWriter Methods
419
	public boolean canWriteGeometry(int gvSIGgeometryType) {
420
		return lidarWriter.canWriteGeometry(gvSIGgeometryType);
421
	}
422

  
423
	public boolean canAlterTable() {
424
		return false;
425
	}
426

  
427
	public boolean canSaveEdits() {
428
		return lidarWriter.canSaveEdits();
429
	}
430

  
431
	public boolean canWriteAttribute(int sqlType) {
432
		return lidarWriter.canWriteAttribute(sqlType);
433
	}
434

  
435
	public String getCapability(String capability) {
436
		return lidarWriter.getCapability(capability);
437
	}
438
	
439
	public void setCapabilities(Properties capabilities) {
440
		lidarWriter.setCapabilities(capabilities);
441
	}
442

  
443
	public ITableDefinition getTableDefinition() {
444
		return lidarWriter.getTableDefinition();
445
	}
446

  
447
	public void initialize(ITableDefinition tableDefinition)
448
			throws EditionException {
449
		
450
		// escribe en un temporal el fichero.
451
		int aux = (int)(Math.random() * 1000);
452
		String extension;
453
		if(hdr instanceof LASHeader_1X)
454
			extension= ".las";
455
		else
456
			extension = ".bin";
457
		
458
		fTemp = new File(tempDirectoryPath + "/tmpLidar" + aux + extension);
459
		lidarWriter.setFile(fTemp);
460
		lidarWriter.setHeaderAndPoint(hdr, lp);
461
		lidarWriter.initialize(tableDefinition);
462
	}
463

  
464
	public boolean isWriteAll() {
465
		return true;
466
	}
467
	
468
	/**
469
	 * Trabajo a realizar antes de empezar a recorrer las geometrias.
470
	 */
471
	public void preProcess() throws EditionException {
472
		lidarWriter.preProcess();
473
	}
474

  
475
	/**
476
	 * Trabajo a realizar durante recorremos las geometrias.
477
	 */
478
	public void process(IRowEdited row) throws EditionException {
479
		lidarWriter.process(row);
480
	}
481
	
482
	/**
483
	 * Trabajo a realizar despues de terminar de recorrer las geometrias.
484
	 */
485
	public void postProcess() throws EditionException {
486
		lidarWriter.postProcess();
487

  
488
		try {
489
			
490
			// close();
491
			FileChannel fcinLidar = new FileInputStream(fTemp).getChannel();
492
			FileChannel fcoutLidar = new FileOutputStream(m_Fich).getChannel();
493
			DriverUtilities.copy(fcinLidar, fcoutLidar);
494

  
495
			// Borramos los temporales
496
			fTemp.delete();
497
			//reload();
498

  
499
		} catch (FileNotFoundException e) {
500
			throw new EditionException(e);
501
		} catch (IOException e) {
502
			throw new EditionException(e);
503
		} 
504
	}
505

  
506
	// BoundedShapes Methods
507
	public Rectangle2D getShapeBounds(int index) throws IOException {
508
		
509
		Point2D p = new Point2D.Double();
510
		Rectangle2D BoundingBox = new Rectangle2D.Double();
511
		
512
		p = lp.readPoint2D(bb, hdr, index);
513
		BoundingBox = new Rectangle2D.Double(p.getX() - 0.1,
514
				p.getY() - 0.1, 0.2, 0.2);
515
		
516
		return BoundingBox;
517
	}
518

  
519
	public int getShapeType(int index) {
520
		
521
		return FShape.POINT;
522
	}
523
}
branches/v10/extensions/DielmoOpenLidar/src/com/dielmo/gvsig/lidar/drivers/LiDARWriter.java
1
/* DielmoOpenLiDAR
2
 *
3
 * Copyright (C) 2008 DIELMO 3D S.L. (DIELMO) and Infrastructures  
4
 * and Transports Department of the Valencian Government (CIT)
5
 * 
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 * 
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 * 
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
 * MA  02110-1301, USA.
20
 *
21
 * For more information, contact:
22
 *
23
 * DIELMO 3D S.L.
24
 * Plaza Vicente Andr?s Estell?s 1 Bajo E
25
 * 46950 Xirivella, Valencia
26
 * SPAIN
27
 *   
28
 * +34 963137212
29
 * dielmo@dielmo.com
30
 * www.dielmo.com
31
 * 
32
 * or
33
 * 
34
 * Generalitat Valenciana
35
 * Conselleria d'Infraestructures i Transport
36
 * Av. Blasco Ib??ez, 50
37
 * 46010 VALENCIA
38
 * SPAIN
39
 *
40
 * +34 963862235
41
 * gvsig@gva.es
42
 * www.gvsig.gva.es
43
 */
44

  
45
/*
46
 * AUTHORS (In addition to DIELMO and CIT):
47
 *  
48
 */
49

  
50
package com.dielmo.gvsig.lidar.drivers;
51

  
52
import java.awt.geom.Rectangle2D;
53
import java.io.File;
54
import java.io.IOException;
55
import java.io.RandomAccessFile;
56
import java.nio.ByteBuffer;
57
import java.nio.channels.FileChannel;
58
import java.nio.channels.WritableByteChannel;
59
import java.sql.Types;
60

  
61
import com.dielmo.lidar.LidarHeader;
62
import com.dielmo.lidar.LidarPoint;
63
import com.hardcode.gdbms.engine.values.DoubleValue;
64
import com.hardcode.gdbms.engine.values.Value;
65
import com.hardcode.gdbms.engine.values.ValueFactory;
66
import com.iver.cit.gvsig.fmap.core.FShape;
67
import com.iver.cit.gvsig.fmap.core.IFeature;
68
import com.iver.cit.gvsig.fmap.core.IGeometry;
69
import com.iver.cit.gvsig.fmap.drivers.FieldDescription;
70
import com.iver.cit.gvsig.fmap.edition.EditionException;
71
import com.iver.cit.gvsig.fmap.edition.IRowEdited;
72
import com.iver.cit.gvsig.fmap.edition.ISpatialWriter;
73
import com.iver.cit.gvsig.fmap.edition.writers.AbstractWriter;
74

  
75
/**
76
 * Writer of LiDAR.
77
 * 
78
 * @author Oscar Garcia
79
 */
80
public class LiDARWriter extends AbstractWriter implements ISpatialWriter {
81

  
82
	private String lidarPath;
83
	private File file;
84
	private LidarHeader hdr;
85
	private LidarPoint lp;
86
	private int numRows;
87
	private ByteBuffer bb = null;
88
	private FileChannel lidarChannel;
89
	private Rectangle2D fullExtent;
90
	
91
	public LiDARWriter() {
92
		super();
93
	}
94

  
95
	/**
96
	 * La tabla Lidar no se deve alterar, por lo que
97
	 * Esta funcion devolvera false siempre.
98
	 */
99
	public boolean canAlterTable() {
100
		return false;
101
	}
102

  
103
	/**
104
	 * Informa de si el fichero se puede editar o no
105
	 */
106
	public boolean canSaveEdits() {
107
		return file.canWrite();
108
	}
109

  
110
	/**
111
	 * Indica que atributos se pueden cambiar.
112
	 */
113
	public boolean canWriteAttribute(int sqlType) {
114
		switch (sqlType) {
115
			case Types.DOUBLE:
116
			case Types.FLOAT:
117
			case Types.INTEGER:
118
			case Types.BIGINT:
119
				return true;
120
			case Types.DATE:
121
				return false;
122
			case Types.BIT:
123
			case Types.BOOLEAN:
124
				return false;
125
			case Types.VARCHAR:
126
			case Types.CHAR:
127
			case Types.LONGVARCHAR:
128
				return false; 
129
		}
130
		return false;
131
	}
132

  
133
	/**
134
	 * Seteamos el fichero sobre el que trabajaremos en la escritura.
135
	 * @param f fichero de trabajo.
136
	 */
137
	public void setFile(File f) {
138
		
139
		try {
140
			lidarPath = f.getAbsolutePath();
141
			lidarChannel = (FileChannel) getWriteChannel(lidarPath);
142
			file = f;
143
		} catch (IOException e) {
144
			// TODO Auto-generated catch block
145
			e.printStackTrace();
146
		}
147
	}
148
	
149
	/**
150
	 * Seteamos las caracteristicas del Lidar.
151
	 * @param h Cabecera lidar.
152
	 * @param p Punto lidar.
153
	 */
154
	public void setHeaderAndPoint(LidarHeader h, LidarPoint p) {
155
		hdr = h;
156
		lp = p;
157
	}
158
	
159
	/**
160
	 * Obtiene el canal de escritura.
161
	 * 
162
	 * @param path ruta del fichero en el que queremos obtener el canal de escritura.
163
	 * @return Canal de escritura del fichero dado.
164
	 * @throws IOException
165
	 */
166
	private WritableByteChannel getWriteChannel(String path)
167
	throws IOException {
168
		
169
		// FileChannel de escritura.
170
		WritableByteChannel channel;
171

  
172
		File f = new File(path);
173
		
174
		if (!f.exists()) {
175
			System.out.println("Creando fichero " + f.getAbsolutePath());
176
		
177
			// crear el fichero si no existia.
178
			if (!f.createNewFile()) {
179
				System.err.print("Error al crear el fichero " +
180
					f.getAbsolutePath());
181
				throw new IOException("Cannot create file " + f);
182
			}
183
		}
184
		
185
		// Obtenemos un canal de lectura escritura de acceso aleatorio.
186
		RandomAccessFile raf = new RandomAccessFile(f, "rw");
187
		channel = raf.getChannel();
188
		
189
		return channel;
190
	}
191

  
192
	/**
193
	 * devuelve true si puede escribir la geometria dada.
194
	 * Este driver solo devolvera true para las geomerias de punto.
195
	 */
196
	public boolean canWriteGeometry(int gvSIGgeometryType) {
197
		switch (gvSIGgeometryType) {
198
			case FShape.POINT:
199
				return true;
200
			case FShape.MULTIPOINT:
201
				return false;
202
		}
203
		return false;
204
	}
205

  
206
	/**
207
	 * Make sure our buffer is of size.
208
	 *
209
	 * @param size, size that buffer must contain
210
	 */
211
	private void checkShapeBuffer(int size) {
212
		if (bb.capacity() < size) {
213
			bb = ByteBuffer.allocateDirect(size);
214
		}
215
	}
216
	
217
	/**
218
	 * Drain internal buffers into underlying channels.
219
	 *
220
	 * @throws IOException DOCUMENT ME!
221
	 */
222
	private void drain() throws IOException {
223
		bb.flip();
224

  
225
		while (bb.remaining() > 0)
226
			lidarChannel.write(bb);
227

  
228
		bb.flip().limit(bb.capacity());
229
	}
230
	
231
	/**
232
	 * DOCUMENT ME!
233
	 */
234
	private void allocateBuffer() {
235
		bb = ByteBuffer.allocateDirect(16 * 1024);
236
	}
237
	
238
	/**
239
	 * Close the underlying Channels.
240
	 *
241
	 * @throws IOException DOCUMENT ME!
242
	 */
243
	public void close() throws IOException {
244
		lidarChannel.close();
245
		lidarChannel = null;
246
		bb = null;
247
	}
248
	
249
	// reservar bytes para la cabecera
250
	public void preProcess() throws EditionException {
251
		
252
		// Por ahora solo escribimos los primeros bytes
253
		// de las cabeceras. Luego en el postprocess los escribiremos
254
		// correctamente, con el numero de
255
		// registros que tocan.
256
		try {
257
			
258
			numRows = 0;
259
			if (bb == null) {
260
				allocateBuffer();
261
			}
262
			
263
			// Posicionamos al principio.
264
			bb.position(0);
265
			
266
			checkShapeBuffer((int)hdr.getOffsetData());
267
			byte b[] = new byte[(int) hdr.getOffsetData()];
268
			bb.put(b);
269
			lidarChannel.position(0);
270
			//hdr.writeLidarHeader(bb);
271
			fullExtent = null;
272
			drain();
273

  
274
			// seteamos la Z
275
			hdr.setMaxZ(Double.MIN_VALUE);
276
			hdr.setMinZ(Double.MAX_VALUE);
277
			
278
		} catch (IOException e) {
279
			// TODO Auto-generated catch block
280
			e.printStackTrace();
281
		}			
282
	}
283
	
284
	// cabecera
285
	public void postProcess() throws EditionException {
286
		
287
		if (bb == null) {
288
			allocateBuffer();
289
		}
290

  
291
		// seteamos la cabecera
292
		hdr.setNumPointsRecord(numRows);
293
		hdr.setMaxX(fullExtent.getMaxX());
294
		hdr.setMaxY(fullExtent.getMaxY());
295
		hdr.setMinX(fullExtent.getMinX());
296
		hdr.setMinY(fullExtent.getMinY());
297
		
298
		try {
299
			lidarChannel.position(0);
300
			hdr.writeLidarHeader(bb);
301
			
302
			drain();
303
			lidarChannel.close();
304
			
305
		} catch (IOException e) {
306
			// TODO Auto-generated catch block
307
			e.printStackTrace();
308
		}
309
	}
310
	
311
	// datos
312
	public void process(IRowEdited row) throws EditionException {
313

  
314
		if(row.getStatus() == IRowEdited.STATUS_DELETED) {
315
			return;
316
		}
317
		
318
		try {
319
			
320
			IFeature feat = (IFeature) row.getLinkedRow();
321
			IGeometry theGeom = feat.getGeometry();
322
			Value[] attrs = row.getAttributes();
323
			
324
			if (bb == null) {
325
				allocateBuffer();
326
				lidarChannel.position(0);
327
			}
328
			
329
			// must allocate enough for point
330
			checkShapeBuffer(lp.getSizeFormat());
331
			
332
			Rectangle2D boundsLidar = theGeom.getBounds2D();
333
			// NOTA: estamo suponiendo que la posicion 0 y la 1 siempe tendra los valores de x e y de la geometria.
334
			attrs[0]=ValueFactory.createValue(boundsLidar.getMinX());
335
			attrs[1]=ValueFactory.createValue(boundsLidar.getMinY());
336
			lp.setPoint(attrs, hdr);
337
			lp.WritePoint(bb);
338
			
339
			// NOTA: estamos suponiendo que la columna dos del valor de la tabla es la Z.. OJO, cambiar mas adelante, a?adir un get indexByName o algo parecido
340
			if(hdr.getMaxZ()<((DoubleValue)(attrs[2])).getValue() )
341
				hdr.setMaxZ(((DoubleValue)(attrs[2])).getValue());
342
			
343
			if(hdr.getMinZ()>((DoubleValue)(attrs[2])).getValue() )
344
				hdr.setMinZ(((DoubleValue)(attrs[2])).getValue());
345

  
346
			if (fullExtent == null) {
347
				fullExtent = boundsLidar;
348
			} else {
349
				
350
				fullExtent.add(boundsLidar);
351
			}
352
			
353
			drain();
354
			numRows++;
355
		
356
		} catch (IOException e) {
357
			// TODO Auto-generated catch block
358
			e.printStackTrace();
359
		}
360
	}
361

  
362
	public String getName() {
363
		return "LiDAR Writer";
364
	}
365

  
366
}
branches/v10/extensions/DielmoOpenLidar/src/com/dielmo/gvsig/lidar/extensions/Lidar_Preferences.java
1
/* DielmoOpenLiDAR
2
 *
3
 * Copyright (C) 2008 DIELMO 3D S.L. (DIELMO) and Infrastructures  
4
 * and Transports Department of the Valencian Government (CIT)
5
 * 
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 * 
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 * 
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
 * MA  02110-1301, USA.
20
 *
21
 * For more information, contact:
22
 *
23
 * DIELMO 3D S.L.
24
 * Plaza Vicente Andr?s Estell?s 1 Bajo E
25
 * 46950 Xirivella, Valencia
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff