svn-gvsig-desktop / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / saveraster / operations / CopyDatasetThread.java @ 11392
History | View | Annotate | Download (2.84 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*/
|
19 |
package org.gvsig.rastertools.saveraster.operations; |
20 |
|
21 |
import java.io.IOException; |
22 |
|
23 |
import org.gvsig.raster.dataset.io.GdalWriter; |
24 |
|
25 |
import com.iver.cit.gvsig.fmap.ViewPort; |
26 |
|
27 |
import es.gva.cit.jgdal.Gdal; |
28 |
import es.gva.cit.jgdal.GdalDriver; |
29 |
import es.gva.cit.jgdal.GdalException; |
30 |
|
31 |
/**
|
32 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
33 |
*
|
34 |
* Esta clase copia un dataset desde disco en un formato soportado por Gdal
|
35 |
* a otro especificado.
|
36 |
*/
|
37 |
class CopyDatasetThread extends Thread{ |
38 |
|
39 |
private GdalDriver driver = null; |
40 |
private String fDstName = null; |
41 |
private String fSrcName = null; |
42 |
private ViewPort vp = null; |
43 |
private String[] driverProps = null; |
44 |
private String extension = null; |
45 |
private double maxPercentBar = 0D; |
46 |
private boolean runCopy = false; |
47 |
|
48 |
/**
|
49 |
* Constructor
|
50 |
* @param src Nombre del fichero fuente
|
51 |
* @param dst Nombre del fichero destino
|
52 |
* @param viewPort Viewport
|
53 |
* @param dp DriverProperties
|
54 |
* @param drvName Nombre del driver de Gdal
|
55 |
* @param extens Extensi?n del fichero
|
56 |
*/
|
57 |
public CopyDatasetThread(String src, String dst, ViewPort viewPort, String[] dp, |
58 |
String drvName, String extens){ |
59 |
fSrcName = src; |
60 |
fDstName = dst; |
61 |
vp = viewPort; |
62 |
this.driverProps = dp;
|
63 |
this.extension = extens;
|
64 |
try{
|
65 |
driver = Gdal.getDriverByName(drvName); |
66 |
}catch(GdalException exc){
|
67 |
System.err.println("No se ha podido obtener el driver."); |
68 |
} |
69 |
runCopy = true;
|
70 |
} |
71 |
|
72 |
/**
|
73 |
* Funci?n que realiza la copia del dataset
|
74 |
*/
|
75 |
public void copy(){ |
76 |
try{
|
77 |
GdalWriter.createCopy( driver, |
78 |
fDstName, |
79 |
fSrcName, |
80 |
false,
|
81 |
driverProps, |
82 |
vp.getProjection()); |
83 |
}catch(IOException ev){ |
84 |
ev.printStackTrace(); |
85 |
}catch(GdalException ev){
|
86 |
ev.printStackTrace(); |
87 |
} |
88 |
runCopy = false;
|
89 |
} |
90 |
|
91 |
/**
|
92 |
* El thread maneja el incremento de la barra
|
93 |
*/
|
94 |
public void run(){ |
95 |
|
96 |
} |
97 |
|
98 |
/**
|
99 |
* Asigna el porcentaje m?ximo a la barra
|
100 |
* @param max Porcentaje m?ximo de la barra
|
101 |
*/
|
102 |
public void setMaxPercentBar(double max){ |
103 |
this.maxPercentBar = max;
|
104 |
} |
105 |
} |