Revision 4254
org.gvsig.raster.tools/tags/org.gvsig.raster.tools-2.2.17/org.gvsig.raster.tools.main/buildNumber.properties | ||
---|---|---|
1 |
#maven.buildNumber.plugin properties file |
|
2 |
#Mon Jun 25 09:20:23 CEST 2012 |
|
3 |
buildNumber=5 |
|
0 | 4 |
org.gvsig.raster.tools/tags/org.gvsig.raster.tools-2.2.17/org.gvsig.raster.tools.main/src/main/java/org/gvsig/raster/tools/algorithm/TestMaskthreholdOutPutLayerReplicate.java | ||
---|---|---|
1 |
package org.gvsig.raster.tools.algorithm; |
|
2 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
5 |
* of the Valencian Government (CIT) |
|
6 |
* |
|
7 |
* This program is free software; you can redistribute it and/or |
|
8 |
* modify it under the terms of the GNU General Public License |
|
9 |
* as published by the Free Software Foundation; either version 2 |
|
10 |
* of the License, or (at your option) any later version. |
|
11 |
* |
|
12 |
* This program is distributed in the hope that it will be useful, |
|
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15 |
* GNU General Public License for more details. |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License |
|
18 |
* along with this program; if not, write to the Free Software |
|
19 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
20 |
* MA 02110-1301, USA. |
|
21 |
* |
|
22 |
*/ |
|
23 |
|
|
24 |
|
|
25 |
import java.io.File; |
|
26 |
|
|
27 |
import org.gvsig.fmap.dal.DALLocator; |
|
28 |
import org.gvsig.fmap.dal.DataManager; |
|
29 |
import org.gvsig.fmap.dal.DataStore; |
|
30 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
|
31 |
import org.gvsig.fmap.dal.coverage.RasterManager; |
|
32 |
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException; |
|
33 |
import org.gvsig.fmap.dal.coverage.store.parameter.RasterDataParameters; |
|
34 |
import org.gvsig.fmap.dal.coverage.util.ProviderServices; |
|
35 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
36 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
|
37 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
|
38 |
import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException; |
|
39 |
import org.gvsig.raster.cache.tile.impl.TileCacheDefaultImplLibrary; |
|
40 |
import org.gvsig.raster.fmap.layers.DefaultFLyrRaster; |
|
41 |
import org.gvsig.raster.fmap.layers.FLyrRaster; |
|
42 |
import org.gvsig.raster.gdal.io.DefaultGdalIOLibrary; |
|
43 |
import org.gvsig.raster.impl.RasterDefaultImplLibrary; |
|
44 |
import org.gvsig.raster.tools.algorithm.base.RasterBaseAlgorithmLibrary; |
|
45 |
import org.gvsig.raster.tools.algorithm.base.process.ProcessException; |
|
46 |
import org.gvsig.raster.tools.algorithm.base.process.RasterProcess; |
|
47 |
import org.gvsig.raster.tools.algorithm.maskthreshold.MaskthresholdAlgorithmLibrary; |
|
48 |
import org.gvsig.raster.tools.algorithm.maskthreshold.MaskthresholdProcess; |
|
49 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
|
50 |
|
|
51 |
/** |
|
52 |
* @author gvSIG Team |
|
53 |
* @version $Id$ |
|
54 |
* |
|
55 |
*/ |
|
56 |
@SuppressWarnings("unused") |
|
57 |
public class TestMaskthreholdOutPutLayerReplicate { |
|
58 |
private static int pos = 5; |
|
59 |
|
|
60 |
private static String file1 = "/home/nacho/images/PNOA/PNOA06-08/2006_clip.tif"; |
|
61 |
private static String file2 = "/home/nacho/images/PNOA/PNOA06-08/2006_NDVI.tif"; |
|
62 |
public static DataManager datamanager = DALLocator.getDataManager(); |
|
63 |
public FLyrRaster lyr = null; |
|
64 |
private RasterManager rManager = RasterLocator.getManager(); |
|
65 |
private int[] drawableBands = { 0, 1, 2 }; |
|
66 |
|
|
67 |
public static void main(String[] args) { |
|
68 |
try { |
|
69 |
new DefaultLibrariesInitializer().fullInitialize(true); |
|
70 |
} catch(Exception e) { |
|
71 |
e.printStackTrace(); |
|
72 |
} |
|
73 |
new TileCacheDefaultImplLibrary(); |
|
74 |
new RasterDefaultImplLibrary(); |
|
75 |
new DefaultGdalIOLibrary(); |
|
76 |
new MaskthresholdAlgorithmLibrary().doPostInitialize(); |
|
77 |
new TestMaskthreholdOutPutLayerReplicate().start(); |
|
78 |
} |
|
79 |
|
|
80 |
public void start() { |
|
81 |
FLyrRaster lyr1 = null; |
|
82 |
FLyrRaster lyr2 = null; |
|
83 |
FLyrRaster lyr3 = null; |
|
84 |
try { |
|
85 |
lyr1 = createLayerRaster("Input1", new File(file1)); |
|
86 |
lyr2 = createLayerRaster("Input2", new File(file2)); |
|
87 |
lyr3 = createLayerRaster("Input3", new File(file1)); |
|
88 |
|
|
89 |
RasterProcess task; |
|
90 |
try { |
|
91 |
task = RasterBaseAlgorithmLibrary.getManager().createRasterTask("MaskthresholdProcess"); |
|
92 |
} catch (ProcessException e1) { |
|
93 |
e1.printStackTrace(); |
|
94 |
return; |
|
95 |
} |
|
96 |
|
|
97 |
task.addParam(MaskthresholdProcess.RASTER_STORE1, lyr1.getDataStore()); |
|
98 |
task.addParam(MaskthresholdProcess.RASTER_STORE2, lyr2.getDataStore()); |
|
99 |
task.addParam(MaskthresholdProcess.RASTER_STORE3, lyr3.getDataStore()); |
|
100 |
task.addParam(MaskthresholdProcess.PATH, "/tmp/MaskthreholdTest.tif"); |
|
101 |
task.addParam(MaskthresholdProcess.THRESHOLD, 0); |
|
102 |
task.addParam(MaskthresholdProcess.BAND1, 0); |
|
103 |
task.addParam(MaskthresholdProcess.BAND2, 0); |
|
104 |
task.addParam(MaskthresholdProcess.BAND3, -1); //Las salida ser? de todas las bandas del datastore 3 |
|
105 |
task.addParam(MaskthresholdProcess.OPERATION, 0); |
|
106 |
task.addParam(MaskthresholdProcess.SATISFY_METHOD, 4); |
|
107 |
task.execute(); |
|
108 |
} catch (LoadLayerException e) { |
|
109 |
e.printStackTrace(); |
|
110 |
} catch (ProcessException e) { |
|
111 |
e.printStackTrace(); |
|
112 |
} catch (ProcessInterruptedException e) { |
|
113 |
e.printStackTrace(); |
|
114 |
} |
|
115 |
} |
|
116 |
|
|
117 |
@SuppressWarnings("deprecation") |
|
118 |
public FLyrRaster createLayerRaster(String layerName, File file) |
|
119 |
throws LoadLayerException { |
|
120 |
ProviderServices provServ = |
|
121 |
RasterLocator.getManager().getProviderServices(); |
|
122 |
RasterDataParameters storeParameters = |
|
123 |
provServ.createParameters(file.getName()); |
|
124 |
storeParameters.setURI(file.getPath()); |
|
125 |
|
|
126 |
DataManager dataManager = DALLocator.getDataManager(); |
|
127 |
DataStore dataStore = null; |
|
128 |
try { |
|
129 |
dataStore = dataManager.createStore(storeParameters); |
|
130 |
} catch (ValidateDataParametersException e) { |
|
131 |
throw new LoadLayerException("Error al cargar la capa."); |
|
132 |
} catch (InitializeException e) { |
|
133 |
throw new LoadLayerException("Error al cargar la capa."); |
|
134 |
} catch (ProviderNotRegisteredException e) { |
|
135 |
throw new LoadLayerException("Error al cargar la capa."); |
|
136 |
} |
|
137 |
|
|
138 |
DefaultFLyrRaster lyr = new DefaultFLyrRaster(); |
|
139 |
lyr.setName(layerName); |
|
140 |
lyr.setDataStore(dataStore); |
|
141 |
return lyr; |
|
142 |
} |
|
143 |
|
|
144 |
} |
|
0 | 145 |
org.gvsig.raster.tools/tags/org.gvsig.raster.tools-2.2.17/org.gvsig.raster.tools.main/src/main/java/org/gvsig/raster/tools/algorithm/TestMaskthreholdOutPutLayerThreshold.java | ||
---|---|---|
1 |
package org.gvsig.raster.tools.algorithm; |
|
2 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
5 |
* of the Valencian Government (CIT) |
|
6 |
* |
|
7 |
* This program is free software; you can redistribute it and/or |
|
8 |
* modify it under the terms of the GNU General Public License |
|
9 |
* as published by the Free Software Foundation; either version 2 |
|
10 |
* of the License, or (at your option) any later version. |
|
11 |
* |
|
12 |
* This program is distributed in the hope that it will be useful, |
|
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15 |
* GNU General Public License for more details. |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License |
|
18 |
* along with this program; if not, write to the Free Software |
|
19 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
20 |
* MA 02110-1301, USA. |
|
21 |
* |
|
22 |
*/ |
|
23 |
|
|
24 |
|
|
25 |
import java.io.File; |
|
26 |
|
|
27 |
import org.gvsig.fmap.dal.DALLocator; |
|
28 |
import org.gvsig.fmap.dal.DataManager; |
|
29 |
import org.gvsig.fmap.dal.DataStore; |
|
30 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
|
31 |
import org.gvsig.fmap.dal.coverage.RasterManager; |
|
32 |
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException; |
|
33 |
import org.gvsig.fmap.dal.coverage.store.parameter.RasterDataParameters; |
|
34 |
import org.gvsig.fmap.dal.coverage.util.ProviderServices; |
|
35 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
36 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
|
37 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
|
38 |
import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException; |
|
39 |
import org.gvsig.raster.cache.tile.impl.TileCacheDefaultImplLibrary; |
|
40 |
import org.gvsig.raster.fmap.layers.DefaultFLyrRaster; |
|
41 |
import org.gvsig.raster.fmap.layers.FLyrRaster; |
|
42 |
import org.gvsig.raster.gdal.io.DefaultGdalIOLibrary; |
|
43 |
import org.gvsig.raster.impl.RasterDefaultImplLibrary; |
|
44 |
import org.gvsig.raster.tools.algorithm.base.RasterBaseAlgorithmLibrary; |
|
45 |
import org.gvsig.raster.tools.algorithm.base.process.ProcessException; |
|
46 |
import org.gvsig.raster.tools.algorithm.base.process.RasterProcess; |
|
47 |
import org.gvsig.raster.tools.algorithm.maskthreshold.MaskthresholdAlgorithmLibrary; |
|
48 |
import org.gvsig.raster.tools.algorithm.maskthreshold.MaskthresholdProcess; |
|
49 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
|
50 |
|
|
51 |
/** |
|
52 |
* Extracts vegetation using NDVI |
|
53 |
*/ |
|
54 |
@SuppressWarnings("unused") |
|
55 |
public class TestMaskthreholdOutPutLayerThreshold { |
|
56 |
private static int pos = 5; |
|
57 |
|
|
58 |
private static String file1 = "/home/nacho/images/PNOA/PNOA06-08/2006_clip.tif"; |
|
59 |
private static String file2 = "/home/nacho/images/PNOA/PNOA06-08/2006_NDVI.tif"; |
|
60 |
public static DataManager datamanager = DALLocator.getDataManager(); |
|
61 |
public FLyrRaster lyr = null; |
|
62 |
private RasterManager rManager = RasterLocator.getManager(); |
|
63 |
private int[] drawableBands = { 0, 1, 2 }; |
|
64 |
|
|
65 |
public static void main(String[] args) { |
|
66 |
try { |
|
67 |
new DefaultLibrariesInitializer().fullInitialize(true); |
|
68 |
} catch(Exception e) { |
|
69 |
e.printStackTrace(); |
|
70 |
} |
|
71 |
new TileCacheDefaultImplLibrary(); |
|
72 |
new RasterDefaultImplLibrary(); |
|
73 |
new DefaultGdalIOLibrary(); |
|
74 |
new MaskthresholdAlgorithmLibrary().doPostInitialize(); |
|
75 |
new TestMaskthreholdOutPutLayerThreshold().start(); |
|
76 |
} |
|
77 |
|
|
78 |
public void start() { |
|
79 |
FLyrRaster lyr1 = null; |
|
80 |
FLyrRaster lyr2 = null; |
|
81 |
FLyrRaster lyr3 = null; |
|
82 |
try { |
|
83 |
lyr1 = createLayerRaster("Input1", new File(file1)); |
|
84 |
lyr2 = createLayerRaster("Input2", new File(file2)); |
|
85 |
lyr3 = createLayerRaster("Input3", new File(file1)); |
|
86 |
|
|
87 |
RasterProcess task; |
|
88 |
try { |
|
89 |
task = RasterBaseAlgorithmLibrary.getManager().createRasterTask("MaskthresholdProcess"); |
|
90 |
} catch (ProcessException e1) { |
|
91 |
e1.printStackTrace(); |
|
92 |
return; |
|
93 |
} |
|
94 |
|
|
95 |
task.addParam(MaskthresholdProcess.RASTER_STORE1, lyr2.getDataStore()); |
|
96 |
task.addParam(MaskthresholdProcess.RASTER_STORE3, lyr3.getDataStore()); |
|
97 |
task.addParam(MaskthresholdProcess.PATH, "/tmp/MaskthreholdTest.tif"); |
|
98 |
task.addParam(MaskthresholdProcess.THRESHOLD, 0.0); |
|
99 |
task.addParam(MaskthresholdProcess.BAND1, 0); |
|
100 |
task.addParam(MaskthresholdProcess.BAND3, -1); //Las salida ser? de todas las bandas del datastore 3 |
|
101 |
task.addParam(MaskthresholdProcess.OPERATION, 1); |
|
102 |
task.addParam(MaskthresholdProcess.SATISFY_METHOD, 4); |
|
103 |
task.execute(); |
|
104 |
} catch (LoadLayerException e) { |
|
105 |
e.printStackTrace(); |
|
106 |
} catch (ProcessException e) { |
|
107 |
e.printStackTrace(); |
|
108 |
} catch (ProcessInterruptedException e) { |
|
109 |
e.printStackTrace(); |
|
110 |
} |
|
111 |
} |
|
112 |
|
|
113 |
@SuppressWarnings("deprecation") |
|
114 |
public FLyrRaster createLayerRaster(String layerName, File file) |
|
115 |
throws LoadLayerException { |
|
116 |
ProviderServices provServ = |
|
117 |
RasterLocator.getManager().getProviderServices(); |
|
118 |
RasterDataParameters storeParameters = |
|
119 |
provServ.createParameters(file.getName()); |
|
120 |
storeParameters.setURI(file.getPath()); |
|
121 |
|
|
122 |
DataManager dataManager = DALLocator.getDataManager(); |
|
123 |
DataStore dataStore = null; |
|
124 |
try { |
|
125 |
dataStore = dataManager.createStore(storeParameters); |
|
126 |
} catch (ValidateDataParametersException e) { |
|
127 |
throw new LoadLayerException("Error al cargar la capa."); |
|
128 |
} catch (InitializeException e) { |
|
129 |
throw new LoadLayerException("Error al cargar la capa."); |
|
130 |
} catch (ProviderNotRegisteredException e) { |
|
131 |
throw new LoadLayerException("Error al cargar la capa."); |
|
132 |
} |
|
133 |
|
|
134 |
DefaultFLyrRaster lyr = new DefaultFLyrRaster(); |
|
135 |
lyr.setName(layerName); |
|
136 |
lyr.setDataStore(dataStore); |
|
137 |
return lyr; |
|
138 |
} |
|
139 |
|
|
140 |
} |
|
0 | 141 |
org.gvsig.raster.tools/tags/org.gvsig.raster.tools-2.2.17/org.gvsig.raster.tools.main/src/main/java/org/gvsig/raster/tools/algorithm/TestMaskthreholdFixedValue.java | ||
---|---|---|
1 |
package org.gvsig.raster.tools.algorithm; |
|
2 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
5 |
* of the Valencian Government (CIT) |
|
6 |
* |
|
7 |
* This program is free software; you can redistribute it and/or |
|
8 |
* modify it under the terms of the GNU General Public License |
|
9 |
* as published by the Free Software Foundation; either version 2 |
|
10 |
* of the License, or (at your option) any later version. |
|
11 |
* |
|
12 |
* This program is distributed in the hope that it will be useful, |
|
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15 |
* GNU General Public License for more details. |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License |
|
18 |
* along with this program; if not, write to the Free Software |
|
19 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
20 |
* MA 02110-1301, USA. |
|
21 |
* |
|
22 |
*/ |
|
23 |
|
|
24 |
|
|
25 |
import java.io.File; |
|
26 |
|
|
27 |
import org.gvsig.fmap.dal.DALLocator; |
|
28 |
import org.gvsig.fmap.dal.DataManager; |
|
29 |
import org.gvsig.fmap.dal.DataStore; |
|
30 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
|
31 |
import org.gvsig.fmap.dal.coverage.RasterManager; |
|
32 |
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException; |
|
33 |
import org.gvsig.fmap.dal.coverage.store.parameter.RasterDataParameters; |
|
34 |
import org.gvsig.fmap.dal.coverage.util.ProviderServices; |
|
35 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
36 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
|
37 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
|
38 |
import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException; |
|
39 |
import org.gvsig.raster.cache.tile.impl.TileCacheDefaultImplLibrary; |
|
40 |
import org.gvsig.raster.fmap.layers.DefaultFLyrRaster; |
|
41 |
import org.gvsig.raster.fmap.layers.FLyrRaster; |
|
42 |
import org.gvsig.raster.gdal.io.DefaultGdalIOLibrary; |
|
43 |
import org.gvsig.raster.impl.RasterDefaultImplLibrary; |
|
44 |
import org.gvsig.raster.tools.algorithm.base.RasterBaseAlgorithmLibrary; |
|
45 |
import org.gvsig.raster.tools.algorithm.base.process.ProcessException; |
|
46 |
import org.gvsig.raster.tools.algorithm.base.process.RasterProcess; |
|
47 |
import org.gvsig.raster.tools.algorithm.maskthreshold.MaskthresholdAlgorithmLibrary; |
|
48 |
import org.gvsig.raster.tools.algorithm.maskthreshold.MaskthresholdProcess; |
|
49 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
|
50 |
|
|
51 |
/** |
|
52 |
* @author gvSIG Team |
|
53 |
* @version $Id$ |
|
54 |
* |
|
55 |
*/ |
|
56 |
@SuppressWarnings("unused") |
|
57 |
public class TestMaskthreholdFixedValue { |
|
58 |
private static int pos = 5; |
|
59 |
|
|
60 |
private static String file1 = "/home/nacho/images/PNOA/PNOA06-08/2006_clip.tif"; |
|
61 |
private static String file2 = "/home/nacho/images/PNOA/PNOA06-08/2006_NDVI.tif"; |
|
62 |
public static DataManager datamanager = DALLocator.getDataManager(); |
|
63 |
public FLyrRaster lyr = null; |
|
64 |
private RasterManager rManager = RasterLocator.getManager(); |
|
65 |
private int[] drawableBands = { 0, 1, 2 }; |
|
66 |
|
|
67 |
public static void main(String[] args) { |
|
68 |
try { |
|
69 |
new DefaultLibrariesInitializer().fullInitialize(true); |
|
70 |
} catch(Exception e) { |
|
71 |
e.printStackTrace(); |
|
72 |
} |
|
73 |
new TileCacheDefaultImplLibrary(); |
|
74 |
new RasterDefaultImplLibrary(); |
|
75 |
new DefaultGdalIOLibrary(); |
|
76 |
new MaskthresholdAlgorithmLibrary().doPostInitialize(); |
|
77 |
new TestMaskthreholdFixedValue().start(); |
|
78 |
} |
|
79 |
|
|
80 |
public void start() { |
|
81 |
FLyrRaster lyr1 = null; |
|
82 |
FLyrRaster lyr2 = null; |
|
83 |
try { |
|
84 |
lyr1 = createLayerRaster("Input1", new File(file1)); |
|
85 |
lyr2 = createLayerRaster("Input2", new File(file2)); |
|
86 |
|
|
87 |
RasterProcess task; |
|
88 |
try { |
|
89 |
task = RasterBaseAlgorithmLibrary.getManager().createRasterTask("MaskthresholdProcess"); |
|
90 |
} catch (ProcessException e1) { |
|
91 |
e1.printStackTrace(); |
|
92 |
return; |
|
93 |
} |
|
94 |
|
|
95 |
task.addParam(MaskthresholdProcess.RASTER_STORE1, lyr1.getDataStore()); |
|
96 |
task.addParam(MaskthresholdProcess.RASTER_STORE2, lyr2.getDataStore()); |
|
97 |
task.addParam(MaskthresholdProcess.PATH, "/tmp/MaskthreholdTest.tif"); |
|
98 |
task.addParam(MaskthresholdProcess.BAND1, 0); |
|
99 |
task.addParam(MaskthresholdProcess.BAND2, 0); |
|
100 |
task.addParam(MaskthresholdProcess.FIXED_VALUE, 80.0); |
|
101 |
task.addParam(MaskthresholdProcess.OPERATION, 0); |
|
102 |
task.addParam(MaskthresholdProcess.SATISFY_METHOD, 1); |
|
103 |
task.execute(); |
|
104 |
} catch (LoadLayerException e) { |
|
105 |
e.printStackTrace(); |
|
106 |
} catch (ProcessException e) { |
|
107 |
e.printStackTrace(); |
|
108 |
} catch (ProcessInterruptedException e) { |
|
109 |
e.printStackTrace(); |
|
110 |
} |
|
111 |
} |
|
112 |
|
|
113 |
@SuppressWarnings("deprecation") |
|
114 |
public FLyrRaster createLayerRaster(String layerName, File file) |
|
115 |
throws LoadLayerException { |
|
116 |
ProviderServices provServ = |
|
117 |
RasterLocator.getManager().getProviderServices(); |
|
118 |
RasterDataParameters storeParameters = |
|
119 |
provServ.createParameters(file.getName()); |
|
120 |
storeParameters.setURI(file.getPath()); |
|
121 |
|
|
122 |
DataManager dataManager = DALLocator.getDataManager(); |
|
123 |
DataStore dataStore = null; |
|
124 |
try { |
|
125 |
dataStore = dataManager.createStore(storeParameters); |
|
126 |
} catch (ValidateDataParametersException e) { |
|
127 |
throw new LoadLayerException("Error al cargar la capa."); |
|
128 |
} catch (InitializeException e) { |
|
129 |
throw new LoadLayerException("Error al cargar la capa."); |
|
130 |
} catch (ProviderNotRegisteredException e) { |
|
131 |
throw new LoadLayerException("Error al cargar la capa."); |
|
132 |
} |
|
133 |
|
|
134 |
DefaultFLyrRaster lyr = new DefaultFLyrRaster(); |
|
135 |
lyr.setName(layerName); |
|
136 |
lyr.setDataStore(dataStore); |
|
137 |
return lyr; |
|
138 |
} |
|
139 |
|
|
140 |
} |
|
0 | 141 |
org.gvsig.raster.tools/tags/org.gvsig.raster.tools-2.2.17/org.gvsig.raster.tools.main/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1"?> |
|
2 |
|
|
3 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> |
|
4 |
<modelVersion>4.0.0</modelVersion> |
|
5 |
<artifactId>org.gvsig.raster.tools.main</artifactId> |
|
6 |
<packaging>jar</packaging> |
|
7 |
<name>Raster tools Main</name> |
|
8 |
<version>2.2.0-SNAPSHOT</version> |
|
9 |
<description /> |
|
10 |
<parent> |
|
11 |
<groupId>org.gvsig</groupId> |
|
12 |
<artifactId>org.gvsig.desktop.plugin</artifactId> |
|
13 |
<version>2.0.12-SNAPSHOT</version> |
|
14 |
</parent> |
|
15 |
<scm> |
|
16 |
<connection>scm:svn:https://devel.gvsig.org/svn/gvsig-raster/org.gvsig.raster.tools/trunk/org.gvsig.raster.tools/org.gvsig.raster.tools.main</connection> |
|
17 |
<developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-raster/org.gvsig.raster.tools/trunk/org.gvsig.raster.tools/org.gvsig.raster.tools.main</developerConnection> |
|
18 |
<url>https://devel.gvsig.org/redmine/projects/gvsig-raster/repository/show/org.gvsig.raster.tools/trunk/org.gvsig.raster.tools/org.gvsig.raster.tools.main</url> |
|
19 |
</scm> |
|
20 |
<dependencyManagement> |
|
21 |
<dependencies> |
|
22 |
<dependency> |
|
23 |
<groupId>org.gvsig</groupId> |
|
24 |
<artifactId>org.gvsig.raster.tools</artifactId> |
|
25 |
<version>2.1.0-SNAPSHOT</version> |
|
26 |
<type>pom</type> |
|
27 |
<scope>import</scope> |
|
28 |
</dependency> |
|
29 |
</dependencies> |
|
30 |
</dependencyManagement> |
|
31 |
<dependencies> |
|
32 |
<dependency> |
|
33 |
<groupId>org.gvsig</groupId> |
|
34 |
<artifactId>org.gvsig.raster.swing.api</artifactId> |
|
35 |
<scope>compile</scope> |
|
36 |
</dependency> |
|
37 |
<dependency> |
|
38 |
<groupId>org.gvsig</groupId> |
|
39 |
<artifactId>org.gvsig.raster.swing.impl</artifactId> |
|
40 |
<scope>runtime</scope> |
|
41 |
</dependency> |
|
42 |
<dependency> |
|
43 |
<groupId>org.gvsig</groupId> |
|
44 |
<artifactId>org.gvsig.app.mainplugin</artifactId> |
|
45 |
<scope>compile</scope> |
|
46 |
</dependency> |
|
47 |
<dependency> |
|
48 |
<groupId>org.gvsig</groupId> |
|
49 |
<artifactId>org.gvsig.app.document.table.app.mainplugin</artifactId> |
|
50 |
<scope>compile</scope> |
|
51 |
</dependency> |
|
52 |
<dependency> |
|
53 |
<groupId>org.gvsig</groupId> |
|
54 |
<artifactId>org.gvsig.raster.lib.api</artifactId> |
|
55 |
<scope>compile</scope> |
|
56 |
</dependency> |
|
57 |
<dependency> |
|
58 |
<groupId>org.gvsig</groupId> |
|
59 |
<artifactId>org.gvsig.raster.fmap</artifactId> |
|
60 |
<scope>compile</scope> |
|
61 |
</dependency> |
|
62 |
<dependency> |
|
63 |
<groupId>org.gvsig</groupId> |
|
64 |
<artifactId>org.gvsig.raster.lib.impl</artifactId> |
|
65 |
<scope>compile</scope> |
|
66 |
</dependency> |
|
67 |
<dependency> |
|
68 |
<groupId>org.gvsig</groupId> |
|
69 |
<artifactId>org.gvsig.fmap.geometry</artifactId> |
|
70 |
<scope>compile</scope> |
|
71 |
</dependency> |
|
72 |
<dependency> |
|
73 |
<groupId>org.gvsig</groupId> |
|
74 |
<artifactId>org.gvsig.fmap.dal</artifactId> |
|
75 |
<scope>compile</scope> |
|
76 |
</dependency> |
|
77 |
<dependency> |
|
78 |
<groupId>org.gvsig</groupId> |
|
79 |
<artifactId>org.gvsig.fmap.dal.file</artifactId> |
|
80 |
<scope>compile</scope> |
|
81 |
</dependency> |
|
82 |
<dependency> |
|
83 |
<groupId>org.gvsig</groupId> |
|
84 |
<artifactId>org.gvsig.fmap.dal</artifactId> |
|
85 |
<classifier>spi</classifier> |
|
86 |
<scope>compile</scope> |
|
87 |
</dependency> |
|
88 |
<dependency> |
|
89 |
<groupId>org.gvsig</groupId> |
|
90 |
<artifactId>org.gvsig.fmap.mapcontext</artifactId> |
|
91 |
<scope>compile</scope> |
|
92 |
</dependency> |
|
93 |
<dependency> |
|
94 |
<groupId>org.gvsig</groupId> |
|
95 |
<artifactId>org.gvsig.fmap.control</artifactId> |
|
96 |
<scope>compile</scope> |
|
97 |
</dependency> |
|
98 |
<dependency> |
|
99 |
<groupId>org.gvsig</groupId> |
|
100 |
<artifactId>org.gvsig.utils</artifactId> |
|
101 |
<scope>compile</scope> |
|
102 |
</dependency> |
|
103 |
<dependency> |
|
104 |
<groupId>org.gvsig</groupId> |
|
105 |
<artifactId>org.gvsig.ui</artifactId> |
|
106 |
<scope>compile</scope> |
|
107 |
</dependency> |
|
108 |
<dependency> |
|
109 |
<groupId>org.gvsig</groupId> |
|
110 |
<artifactId>org.gvsig.symbology.lib.api</artifactId> |
|
111 |
<scope>compile</scope> |
|
112 |
</dependency> |
|
113 |
<dependency> |
|
114 |
<groupId>org.gvsig</groupId> |
|
115 |
<artifactId>org.gvsig.symbology.lib.impl</artifactId> |
|
116 |
<scope>compile</scope> |
|
117 |
</dependency> |
|
118 |
<dependency> |
|
119 |
<groupId>org.gvsig</groupId> |
|
120 |
<artifactId>org.gvsig.projection</artifactId> |
|
121 |
<scope>compile</scope> |
|
122 |
</dependency> |
|
123 |
<dependency> |
|
124 |
<groupId>org.gvsig</groupId> |
|
125 |
<artifactId>org.gvsig.metadata.lib.basic.api</artifactId> |
|
126 |
<scope>compile</scope> |
|
127 |
</dependency> |
|
128 |
<dependency> |
|
129 |
<groupId>org.gvsig</groupId> |
|
130 |
<artifactId>org.gvsig.raster.tools.algorithm.maskthreshold</artifactId> |
|
131 |
</dependency> |
|
132 |
<dependency> |
|
133 |
<groupId>org.gvsig</groupId> |
|
134 |
<artifactId>org.gvsig.raster.gdal.io</artifactId> |
|
135 |
</dependency> |
|
136 |
<dependency> |
|
137 |
<groupId>org.gvsig</groupId> |
|
138 |
<artifactId>org.gvsig.raster.cache.lib.api</artifactId> |
|
139 |
</dependency> |
|
140 |
<dependency> |
|
141 |
<groupId>org.gvsig</groupId> |
|
142 |
<artifactId>org.gvsig.raster.cache.lib.impl</artifactId> |
|
143 |
</dependency> |
|
144 |
<dependency> |
|
145 |
<groupId>org.gvsig</groupId> |
|
146 |
<artifactId>org.gvsig.tools.lib</artifactId> |
|
147 |
<scope>compile</scope> |
|
148 |
</dependency> |
|
149 |
</dependencies> |
|
150 |
</project> |
|
0 | 151 |
org.gvsig.raster.tools/tags/org.gvsig.raster.tools-2.2.17/org.gvsig.raster.tools.algorithm/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1"?> |
|
2 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> |
|
3 |
<modelVersion>4.0.0</modelVersion> |
|
4 |
<artifactId>org.gvsig.raster.tools.algorithm</artifactId> |
|
5 |
<packaging>pom</packaging> |
|
6 |
<name>org.gvsig.raster.tools.algorithm</name> |
|
7 |
<parent> |
|
8 |
<groupId>org.gvsig</groupId> |
|
9 |
<artifactId>org.gvsig.raster.tools</artifactId> |
|
10 |
<version>2.2.17</version> |
|
11 |
</parent> |
|
12 |
<dependencies> |
|
13 |
<dependency> |
|
14 |
<groupId>org.gvsig</groupId> |
|
15 |
<artifactId>org.gvsig.raster.lib.api</artifactId> |
|
16 |
<scope>compile</scope> |
|
17 |
</dependency> |
|
18 |
<dependency> |
|
19 |
<groupId>org.gvsig</groupId> |
|
20 |
<artifactId>org.gvsig.raster.lib.impl</artifactId> |
|
21 |
<scope>compile</scope> |
|
22 |
</dependency> |
|
23 |
<dependency> |
|
24 |
<groupId>org.gvsig</groupId> |
|
25 |
<artifactId>org.gvsig.metadata.lib.basic.api</artifactId> |
|
26 |
<scope>compile</scope> |
|
27 |
</dependency> |
|
28 |
<dependency> |
|
29 |
<groupId>org.gvsig</groupId> |
|
30 |
<artifactId>org.gvsig.raster.cache.lib.api</artifactId> |
|
31 |
<scope>compile</scope> |
|
32 |
</dependency> |
|
33 |
<!--<dependency> |
|
34 |
<groupId>org.gvsig</groupId> |
|
35 |
<artifactId>org.gvsig.jproj</artifactId> |
|
36 |
<classifier>${native_classifier}</classifier> |
|
37 |
<type>tar.gz</type> |
|
38 |
<scope>runtime</scope> |
|
39 |
</dependency>--> |
|
40 |
<dependency> |
|
41 |
<groupId>org.gvsig</groupId> |
|
42 |
<artifactId>org.gvsig.tools.lib</artifactId> |
|
43 |
<scope>compile</scope> |
|
44 |
</dependency> |
|
45 |
<dependency> |
|
46 |
<groupId>org.gvsig</groupId> |
|
47 |
<artifactId>org.gvsig.i18n</artifactId> |
|
48 |
<scope>compile</scope> |
|
49 |
</dependency> |
|
50 |
<dependency> |
|
51 |
<groupId>org.gvsig</groupId> |
|
52 |
<artifactId>org.gvsig.ui</artifactId> |
|
53 |
<scope>compile</scope> |
|
54 |
</dependency> |
|
55 |
|
|
56 |
<dependency> |
|
57 |
<groupId>org.gvsig</groupId> |
|
58 |
<artifactId>org.gvsig.projection.api</artifactId> |
|
59 |
<scope>compile</scope> |
|
60 |
</dependency> |
|
61 |
<dependency> |
|
62 |
<groupId>org.gvsig</groupId> |
|
63 |
<artifactId>org.gvsig.projection.cresques.impl</artifactId> |
|
64 |
<scope>runtime</scope> |
|
65 |
</dependency> |
|
66 |
<dependency> |
|
67 |
<groupId>org.gvsig</groupId> |
|
68 |
<artifactId>org.gvsig.compat.api</artifactId> |
|
69 |
<scope>compile</scope> |
|
70 |
</dependency> |
|
71 |
<dependency> |
|
72 |
<groupId>org.gvsig</groupId> |
|
73 |
<artifactId>org.gvsig.compat.se</artifactId> |
|
74 |
<scope>compile</scope> |
|
75 |
</dependency> |
|
76 |
<dependency> |
|
77 |
<groupId>org.gvsig</groupId> |
|
78 |
<artifactId>org.gvsig.fmap.dal.api</artifactId> |
|
79 |
<scope>compile</scope> |
|
80 |
</dependency> |
|
81 |
<dependency> |
|
82 |
<groupId>org.gvsig</groupId> |
|
83 |
<artifactId>org.gvsig.fmap.dal.impl</artifactId> |
|
84 |
<scope>compile</scope> |
|
85 |
</dependency> |
|
86 |
<dependency> |
|
87 |
<groupId>org.gvsig</groupId> |
|
88 |
<artifactId>org.gvsig.fmap.dal.file.lib</artifactId> |
|
89 |
<scope>compile</scope> |
|
90 |
</dependency> |
|
91 |
<dependency> |
|
92 |
<groupId>org.gvsig</groupId> |
|
93 |
<artifactId>org.gvsig.fmap.dal.spi</artifactId> |
|
94 |
<scope>compile</scope> |
|
95 |
</dependency> |
|
96 |
<dependency> |
|
97 |
<groupId>org.gvsig</groupId> |
|
98 |
<artifactId>org.gvsig.fmap.geometry.api</artifactId> |
|
99 |
<scope>compile</scope> |
|
100 |
</dependency> |
|
101 |
<!-- |
|
102 |
<dependency> |
|
103 |
<groupId>org.gvsig</groupId> |
|
104 |
<artifactId>org.gvsig.fmap.geometry.generalpath</artifactId> |
|
105 |
<scope>runtime</scope> |
|
106 |
</dependency> |
|
107 |
<dependency> |
|
108 |
<groupId>org.gvsig</groupId> |
|
109 |
<artifactId>org.gvsig.fmap.geometry.operation</artifactId> |
|
110 |
<scope>runtime</scope> |
|
111 |
</dependency> |
|
112 |
--> |
|
113 |
</dependencies> |
|
114 |
<modules> |
|
115 |
<module>org.gvsig.raster.tools.algorithm.swing</module> |
|
116 |
<module>org.gvsig.raster.tools.algorithm.maskthreshold</module> |
|
117 |
<module>org.gvsig.raster.tools.algorithm.layerdatatype</module> |
|
118 |
<module>org.gvsig.raster.tools.algorithm.saveraster</module> |
|
119 |
<!--<module>org.gvsig.raster.tools.algorithm.clip</module>--> |
|
120 |
</modules> |
|
121 |
</project> |
|
0 | 122 |
org.gvsig.raster.tools/tags/org.gvsig.raster.tools-2.2.17/org.gvsig.raster.tools.algorithm/org.gvsig.raster.tools.algorithm.clip/src/main/resources/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.raster.tools.algorithm.saveraster.ClipAlgorithmLibrary |
|
0 | 2 |
org.gvsig.raster.tools/tags/org.gvsig.raster.tools-2.2.17/org.gvsig.raster.tools.algorithm/org.gvsig.raster.tools.algorithm.clip/src/main/java/org/gvsig/raster/tools/algorithm/clip/ClipAlgorithmLibrary.java | ||
---|---|---|
1 |
/* |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2012 gvSIG Association. |
|
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 any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.raster.tools.algorithm.clip; |
|
25 |
|
|
26 |
import org.gvsig.i18n.Messages; |
|
27 |
import org.gvsig.raster.algorithm.RasterBaseAlgorithmLibrary; |
|
28 |
import org.gvsig.tools.library.AbstractLibrary; |
|
29 |
import org.gvsig.tools.library.LibraryException; |
|
30 |
|
|
31 |
/** |
|
32 |
* Initialization of ClipAlgorithmLibrary library. |
|
33 |
* |
|
34 |
* @author <a href="mailto:nachobrodin@gmail.com">Nacho Brodin</a> |
|
35 |
*/ |
|
36 |
public class ClipAlgorithmLibrary extends AbstractLibrary { |
|
37 |
public static final String PROCESS_LABEL = "ClipProcess"; |
|
38 |
|
|
39 |
@Override |
|
40 |
protected void doInitialize() throws LibraryException { |
|
41 |
// Nothing to do |
|
42 |
} |
|
43 |
|
|
44 |
@Override |
|
45 |
public void doPostInitialize() throws LibraryException { |
|
46 |
//Registers the process and its parameters |
|
47 |
RasterBaseAlgorithmLibrary.register(PROCESS_LABEL, ClipProcess.class); |
|
48 |
ClipProcess.registerParameters(); |
|
49 |
|
|
50 |
Messages.addResourceFamily( |
|
51 |
"org.gvsig.raster.tools.algorithm.clip", |
|
52 |
ClipAlgorithmLibrary.class.getClassLoader(), |
|
53 |
ClipAlgorithmLibrary.class.getClass().getName()); |
|
54 |
//registerGeoProcess(new ClipAlgorithmLibrary()); |
|
55 |
} |
|
56 |
} |
|
0 | 57 |
org.gvsig.raster.tools/tags/org.gvsig.raster.tools-2.2.17/org.gvsig.raster.tools.algorithm/org.gvsig.raster.tools.algorithm.clip/src/main/java/org/gvsig/raster/tools/algorithm/clip/ClipException.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* 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 |
*/ |
|
22 |
package org.gvsig.raster.tools.algorithm.clip; |
|
23 |
|
|
24 |
import org.gvsig.raster.algorithm.process.ProcessException; |
|
25 |
|
|
26 |
|
|
27 |
/** |
|
28 |
* This exception is thrown if happen problems processing data with this algorithm. |
|
29 |
* |
|
30 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
31 |
* |
|
32 |
*/ |
|
33 |
public class ClipException extends ProcessException { |
|
34 |
private static final long serialVersionUID = -3022090543908771484L; |
|
35 |
|
|
36 |
public ClipException(String msg){ |
|
37 |
super(msg); |
|
38 |
} |
|
39 |
|
|
40 |
public ClipException(String msg, Throwable e){ |
|
41 |
super(msg, e); |
|
42 |
} |
|
43 |
} |
|
0 | 44 |
org.gvsig.raster.tools/tags/org.gvsig.raster.tools-2.2.17/org.gvsig.raster.tools.algorithm/org.gvsig.raster.tools.algorithm.clip/src/main/java/org/gvsig/raster/tools/algorithm/clip/ClipProcess.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* 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 |
*/ |
|
22 |
package org.gvsig.raster.tools.algorithm.clip; |
|
23 |
|
|
24 |
import java.awt.geom.AffineTransform; |
|
25 |
import java.awt.geom.Point2D; |
|
26 |
import java.io.File; |
|
27 |
import java.io.IOException; |
|
28 |
import java.util.ArrayList; |
|
29 |
|
|
30 |
import org.gvsig.fmap.dal.DALLocator; |
|
31 |
import org.gvsig.fmap.dal.DataManager; |
|
32 |
import org.gvsig.fmap.dal.DataServerExplorer; |
|
33 |
import org.gvsig.fmap.dal.DataServerExplorerParameters; |
|
34 |
import org.gvsig.fmap.dal.coverage.RasterLibrary; |
|
35 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
|
36 |
import org.gvsig.fmap.dal.coverage.RasterManager; |
|
37 |
import org.gvsig.fmap.dal.coverage.dataset.Buffer; |
|
38 |
import org.gvsig.fmap.dal.coverage.datastruct.Extent; |
|
39 |
import org.gvsig.fmap.dal.coverage.datastruct.NoData; |
|
40 |
import org.gvsig.fmap.dal.coverage.datastruct.Params; |
|
41 |
import org.gvsig.fmap.dal.coverage.exception.InvalidSetViewException; |
|
42 |
import org.gvsig.fmap.dal.coverage.exception.NotSupportedExtensionException; |
|
43 |
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException; |
|
44 |
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException; |
|
45 |
import org.gvsig.fmap.dal.coverage.exception.RmfSerializerException; |
|
46 |
import org.gvsig.fmap.dal.coverage.process.BaseIncrementableTask; |
|
47 |
import org.gvsig.fmap.dal.coverage.store.DataServerWriter; |
|
48 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
|
49 |
import org.gvsig.fmap.dal.coverage.store.RasterQuery; |
|
50 |
import org.gvsig.fmap.dal.coverage.store.parameter.NewRasterStoreParameters; |
|
51 |
import org.gvsig.fmap.dal.coverage.store.parameter.RemoteStoreParameters; |
|
52 |
import org.gvsig.fmap.dal.coverage.store.props.ColorInterpretation; |
|
53 |
import org.gvsig.fmap.dal.coverage.store.props.ColorTable; |
|
54 |
import org.gvsig.fmap.dal.coverage.util.RasterUtils; |
|
55 |
import org.gvsig.fmap.dal.exception.CloseException; |
|
56 |
import org.gvsig.fmap.dal.exception.DataException; |
|
57 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
58 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
|
59 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
|
60 |
import org.gvsig.i18n.Messages; |
|
61 |
import org.gvsig.raster.algorithm.RasterBaseAlgorithmLibrary; |
|
62 |
import org.gvsig.raster.algorithm.process.RasterProcess; |
|
63 |
import org.gvsig.raster.fmap.layers.FLyrRaster; |
|
64 |
import org.gvsig.raster.fmap.roi.VectorialROI; |
|
65 |
|
|
66 |
/** |
|
67 |
* <code>ClippingProcess</code> es un proceso que usa un <code>Thread</code> |
|
68 |
* para aplicar un recorte a una capa y guardarlo en disco. Muestra una barra |
|
69 |
* de incremento informativa. |
|
70 |
* |
|
71 |
* @version 24/04/2007 |
|
72 |
* @author BorSanZa - Borja S?nchez Zamorano |
|
73 |
*/ |
|
74 |
public class ClipProcess extends RasterProcess { |
|
75 |
public static String LAYER = "Layer"; |
|
76 |
public static String PATH = "Path"; |
|
77 |
public static String FILENAME = "filename"; |
|
78 |
public static String TIME = "Time"; |
|
79 |
|
|
80 |
public static String SUFFIX = "suffix"; |
|
81 |
public static String PX_COORDS = "pixelcoordinates"; |
|
82 |
public static String WORLD_COORDS = "realcoordinates"; |
|
83 |
public static String DRAW_BANDS = "drawablebands"; |
|
84 |
public static String ONE_BY_BAND = "onelayerperband"; |
|
85 |
public static String INTERP_METHOD = "interpolationmethod"; |
|
86 |
public static String AT = "affinetransform"; |
|
87 |
public static String COLOR_INTERP = "colorInterpretation"; |
|
88 |
public static String SELECTED_ROIS = "selectedrois"; |
|
89 |
public static String RESOLUTION = "resolution"; |
|
90 |
public static String DRIVER_PARAMS = "driverparams"; |
|
91 |
|
|
92 |
private String fileName = ""; |
|
93 |
private String suffix = ".tif"; |
|
94 |
private FLyrRaster rasterSE = null; |
|
95 |
private boolean oneLayerPerBand = false; |
|
96 |
private int[] drawableBands = { 0, 1, 2 }; |
|
97 |
private double[] pValues = null; |
|
98 |
private int interpolationMethod = Buffer.INTERPOLATION_Undefined; |
|
99 |
private Params params = null; |
|
100 |
private ColorInterpretation colorInterp = null; |
|
101 |
private ArrayList<VectorialROI> selectedRois = null; |
|
102 |
private AffineTransform affineTransform = null; |
|
103 |
private double[] wcValues = null; |
|
104 |
private RasterManager rManager = RasterLocator.getManager(); |
|
105 |
private BaseIncrementableTask processIncrement = null; |
|
106 |
|
|
107 |
/** |
|
108 |
* Variables de la resoluci?n de salida |
|
109 |
*/ |
|
110 |
private int resolutionWidth = 0; |
|
111 |
private int resolutionHeight = 0; |
|
112 |
|
|
113 |
private Buffer buffer = null; |
|
114 |
|
|
115 |
/** |
|
116 |
* Par?metros obligatorios al proceso: |
|
117 |
* <UL> |
|
118 |
* <LI>filename: Nombre del fichero de salida</LI> |
|
119 |
* <LI>datawriter: Escritor de datos</LI> |
|
120 |
* <LI>viewname: Nombre de la vista sobre la que se carga la capa al acabar el proceso</LI> |
|
121 |
* <LI>pixelcoordinates: Coordenadas pixel del recorte (ulx, uly, lrx, lry)</LI> |
|
122 |
* <LI>layer: Capa de entrada para el recorte</LI> |
|
123 |
* <LI>drawablebands: Bandas de entrada</LI> |
|
124 |
* <LI>onelayerperband: booleano que informa de si escribimos una banda por fichero de salida o todas en un fichero</LI> |
|
125 |
* <LI>interpolationmethod: M?todo de interpolaci?n.</LI> |
|
126 |
* <LI>affinetransform: Transformaci?n que informa al dataset de salida de su referencia geografica</LI> |
|
127 |
* <LI>resolution: Ancho y alto de la capa de salida</LI> |
|
128 |
* </UL> |
|
129 |
*/ |
|
130 |
@SuppressWarnings("unchecked") |
|
131 |
public void init() { |
|
132 |
fileName = getStringParam(FILENAME); |
|
133 |
suffix = getStringParam(SUFFIX); |
|
134 |
pValues = getDoubleArrayParam(PX_COORDS); |
|
135 |
wcValues = getDoubleArrayParam(WORLD_COORDS); |
|
136 |
rasterSE = getParam(LAYER) != null ? (FLyrRaster) getParam(LAYER) : null; |
|
137 |
drawableBands = getIntArrayParam(DRAW_BANDS); |
|
138 |
oneLayerPerBand = getBooleanParam(ONE_BY_BAND); |
|
139 |
interpolationMethod = getIntParam(INTERP_METHOD); |
|
140 |
affineTransform = (AffineTransform)getParam(AT); |
|
141 |
colorInterp = (ColorInterpretation)getParam(COLOR_INTERP); |
|
142 |
selectedRois = (ArrayList<VectorialROI>)getParam(SELECTED_ROIS); |
|
143 |
if(getIntArrayParam(RESOLUTION) != null) { |
|
144 |
resolutionWidth = getIntArrayParam(RESOLUTION)[0]; |
|
145 |
resolutionHeight = getIntArrayParam(RESOLUTION)[1]; |
|
146 |
} |
|
147 |
params = (Params) getParam(DRIVER_PARAMS); |
|
148 |
} |
|
149 |
|
|
150 |
public static void registerParameters() { |
|
151 |
LAYER = RasterBaseAlgorithmLibrary.registerInputParameter(LAYER, FLyrRaster.class); |
|
152 |
SUFFIX = RasterBaseAlgorithmLibrary.registerInputParameter(SUFFIX, String.class); |
|
153 |
PX_COORDS = RasterBaseAlgorithmLibrary.registerInputParameter(PX_COORDS, double[].class); |
|
154 |
WORLD_COORDS = RasterBaseAlgorithmLibrary.registerInputParameter(WORLD_COORDS, double[].class); |
|
155 |
DRAW_BANDS = RasterBaseAlgorithmLibrary.registerInputParameter(DRAW_BANDS, int[].class); |
|
156 |
ONE_BY_BAND = RasterBaseAlgorithmLibrary.registerInputParameter(ONE_BY_BAND, Boolean.class); |
|
157 |
INTERP_METHOD = RasterBaseAlgorithmLibrary.registerInputParameter(INTERP_METHOD, Integer.class); |
|
158 |
AT = RasterBaseAlgorithmLibrary.registerInputParameter(AT, AffineTransform.class); |
|
159 |
COLOR_INTERP = RasterBaseAlgorithmLibrary.registerInputParameter(COLOR_INTERP, ColorInterpretation.class); |
|
160 |
SELECTED_ROIS = RasterBaseAlgorithmLibrary.registerInputParameter(SELECTED_ROIS, ArrayList.class); |
|
161 |
RESOLUTION = RasterBaseAlgorithmLibrary.registerInputParameter(RESOLUTION, int[].class); |
|
162 |
DRIVER_PARAMS = RasterBaseAlgorithmLibrary.registerOutputParameter(DRIVER_PARAMS, Params.class); |
|
163 |
|
|
164 |
PATH = RasterBaseAlgorithmLibrary.registerInputParameter(PATH, String.class); |
|
165 |
FILENAME = RasterBaseAlgorithmLibrary.registerOutputParameter(FILENAME, String.class); |
|
166 |
TIME = RasterBaseAlgorithmLibrary.registerOutputParameter(TIME, Long.class); |
|
167 |
} |
|
168 |
|
|
169 |
/** |
|
170 |
* Salva la tabla de color al fichero rmf. |
|
171 |
* @param fName |
|
172 |
* @throws ClipException |
|
173 |
* @throws IOException |
|
174 |
*/ |
|
175 |
private void saveToRmf(String fileName) throws ClipException { |
|
176 |
RasterDataStore rds = null; |
|
177 |
int limitNumberOfRequests = 20; |
|
178 |
while (rds == null && limitNumberOfRequests > 0) { |
|
179 |
try { |
|
180 |
rds = rasterSE.getDataStore(); |
|
181 |
} catch (IndexOutOfBoundsException e) { |
|
182 |
//En ocasiones, sobre todo con servicios remotos al pedir un datasource da una excepci?n de este tipo |
|
183 |
//se supone que es porque hay un refresco en el mismo momento de la petici?n por lo que como es m?s lento de |
|
184 |
//gestionar pilla a la capa sin datasources asociados ya que est? reasignandolo. Si volvemos a pedirlo debe |
|
185 |
//haberlo cargado ya. |
|
186 |
try { |
|
187 |
Thread.sleep(200); |
|
188 |
} catch (InterruptedException e1) { |
|
189 |
} |
|
190 |
} |
|
191 |
limitNumberOfRequests--; |
|
192 |
} |
|
193 |
|
|
194 |
if (rds == null) { |
|
195 |
//RasterToolsUtil.messageBoxError("error_load_layer", this, new Exception("Error writing RMF. limitNumberOfRequests=" + limitNumberOfRequests)); |
|
196 |
return; |
|
197 |
} |
|
198 |
|
|
199 |
// Guardamos en el RMF el valor NoData |
|
200 |
if(rasterSE.getNoDataValue() != null) { |
|
201 |
NoData nodata = (NoData)rasterSE.getNoDataValue(); |
|
202 |
nodata.setFileName(fileName); |
|
203 |
nodata.save(); |
|
204 |
} |
|
205 |
|
|
206 |
// Guardamos en el RMF la tabla de color |
|
207 |
ColorTable colorTable = rasterSE.getRender().getColorTable(); |
|
208 |
try { |
|
209 |
rManager.getProviderServices().saveObjectToRmfFile(fileName, ColorTable.class, colorTable); |
|
210 |
} catch (RmfSerializerException e) { |
|
211 |
throw new ClipException("error_salvando_rmf", e); |
|
212 |
} |
|
213 |
} |
|
214 |
|
|
215 |
/** |
|
216 |
* Tarea de recorte |
|
217 |
* @throws ClipException |
|
218 |
*/ |
|
219 |
@SuppressWarnings("deprecation") |
|
220 |
public void process() throws ProcessInterruptedException, ClipException { |
|
221 |
RasterDataStore dstoreCopy = null; |
|
222 |
RasterUtils util = RasterLocator.getManager().getRasterUtils(); |
|
223 |
|
|
224 |
try { |
|
225 |
long t2; |
|
226 |
long t1 = new java.util.Date().getTime(); |
|
227 |
|
|
228 |
try { |
|
229 |
Thread.sleep(1000); |
|
230 |
} catch (InterruptedException e1) { |
|
231 |
e1.printStackTrace(); |
|
232 |
} |
|
233 |
|
|
234 |
insertLineLog(Messages.getText("leyendo_raster")); |
|
235 |
|
|
236 |
dstoreCopy = rasterSE.getDataStore().newDataStore(); |
|
237 |
RasterQuery query = rManager.createQuery(); |
|
238 |
query.setDrawableBands(drawableBands); |
|
239 |
|
|
240 |
if(dstoreCopy.getParameters() instanceof RemoteStoreParameters && |
|
241 |
!((RemoteStoreParameters)dstoreCopy.getParameters()).isSizeFixed()) { |
|
242 |
insertLineLog(Messages.getText("downloading_image")); |
|
243 |
((RemoteStoreParameters)dstoreCopy.getParameters()).setWidth(resolutionWidth); |
|
244 |
((RemoteStoreParameters)dstoreCopy.getParameters()).setHeight(resolutionHeight); |
|
245 |
Extent bbox = RasterLocator.getManager().getDataStructFactory().createExtent(wcValues[0], wcValues[1], wcValues[2], wcValues[3]); |
|
246 |
query.setAreaOfInterest(bbox, resolutionWidth, resolutionHeight); |
|
247 |
try { |
|
248 |
buffer = dstoreCopy.query(query); |
|
249 |
} catch (InvalidSetViewException e) { |
|
250 |
throw new ClipException("No se ha podido asignar la vista al inicial el proceso de recorte.", e); |
|
251 |
} |
|
252 |
} else { |
|
253 |
if(interpolationMethod != Buffer.INTERPOLATION_Undefined) { |
|
254 |
try { |
|
255 |
if(pValues != null) { |
|
256 |
if (util.isBufferTooBig(new double[] { pValues[0], pValues[3], pValues[2], pValues[1] }, drawableBands.length)) |
|
257 |
query.setReadOnly(true); |
|
258 |
query.setAreaOfInterest((int)pValues[0], (int)pValues[1], (int)Math.abs(pValues[2] - pValues[0]) + 1, (int)Math.abs(pValues[3] - pValues[1]) + 1); |
|
259 |
} else if(wcValues != null) { |
|
260 |
query.setReadOnly(true); |
|
261 |
query.setAreaOfInterest(wcValues[0], wcValues[1], Math.abs(wcValues[0] - wcValues[2]), Math.abs(wcValues[1] - wcValues[3])); |
|
262 |
} |
|
263 |
buffer = dstoreCopy.query(query); |
|
264 |
} catch (InvalidSetViewException e) { |
|
265 |
throw new ClipException("No se ha podido asignar la vista al inicial el proceso de recorte.", e); |
|
266 |
} |
|
267 |
|
|
268 |
insertLineLog(Messages.getText("interpolando")); |
|
269 |
|
|
270 |
Buffer bufTmp = buffer; |
|
271 |
processIncrement = bufTmp.getIncrementableTask(Buffer.INCREMENTABLE_INTERPOLATION); |
|
272 |
buffer = bufTmp.getAdjustedWindow(resolutionWidth, resolutionHeight, interpolationMethod); |
|
273 |
if(bufTmp != buffer) |
|
274 |
bufTmp.dispose(); |
|
275 |
} else { |
|
276 |
try { |
|
277 |
if (util.isBufferTooBig(new double[] { 0, 0, resolutionWidth, resolutionHeight }, drawableBands.length)) |
|
278 |
query.setReadOnly(true); |
|
279 |
if(pValues != null) |
|
280 |
query.setAreaOfInterest((int)pValues[0], (int)pValues[3], (int)Math.abs(pValues[2] - pValues[0]) + 1, (int)Math.abs(pValues[1] - pValues[3]) + 1, resolutionWidth, resolutionHeight); |
|
281 |
else if(wcValues != null) { |
|
282 |
Extent bbox = RasterLocator.getManager().getDataStructFactory().createExtent(wcValues[0], wcValues[1], wcValues[2], wcValues[3]); |
|
283 |
query.setAreaOfInterest(bbox, resolutionWidth, resolutionHeight); |
|
284 |
} |
|
285 |
buffer = dstoreCopy.query(query); |
|
286 |
} catch (InvalidSetViewException e) { |
|
287 |
throw new ClipException("No se ha podido asignar la vista al inicial el proceso de recorte.", e); |
|
288 |
} |
|
289 |
} |
|
290 |
} |
|
291 |
|
|
292 |
//TODO: FUNCIONALIDAD: Poner los getWriter con la proyecci?n del fichero fuente |
|
293 |
|
|
294 |
if ((selectedRois != null) && (!query.isReadOnly())){ |
|
295 |
if (selectedRois.size() > 0){ |
|
296 |
int despX = 0; |
|
297 |
int despY = 0; |
|
298 |
if (pValues != null){ |
|
299 |
despX = (int)pValues[0]; |
|
300 |
despY = (int)pValues[1]; |
|
301 |
} else if (wcValues != null){ |
|
302 |
despX = (int)dstoreCopy.worldToRaster(new Point2D.Double(wcValues[0], wcValues[1])).getX(); |
|
303 |
despY = (int)dstoreCopy.worldToRaster(new Point2D.Double(wcValues[0], wcValues[1])).getY(); |
|
304 |
} |
|
305 |
drawOnlyROIs(buffer, selectedRois, despX, despY); |
|
306 |
} |
|
307 |
} |
|
308 |
|
|
309 |
|
|
310 |
insertLineLog(Messages.getText("salvando_imagen")); |
|
311 |
|
|
312 |
DataManager manager = DALLocator.getDataManager(); |
|
313 |
String provider = "Gdal Store"; |
|
314 |
DataServerExplorerParameters eparams = manager.createServerExplorerParameters("FilesystemExplorer"); |
|
315 |
|
|
316 |
String finalFileName = ""; |
|
317 |
NewRasterStoreParameters sparams = null; |
|
318 |
processIncrement = RasterLocator.getManager().createDataServerWriter(); |
|
319 |
if (oneLayerPerBand) { |
|
320 |
long[] milis = new long[drawableBands.length]; |
|
321 |
String[] fileNames = new String[drawableBands.length]; |
|
322 |
for (int i = 0; i < drawableBands.length; i++) { |
|
323 |
fileNames[i] = fileName + "_B" + drawableBands[i] + suffix; |
|
324 |
|
|
325 |
int index = fileNames[i].lastIndexOf(File.separator); |
|
326 |
if(index < 0) |
|
327 |
index = fileNames[i].length(); |
|
328 |
String path = fileNames[i].substring(0, index); |
|
329 |
String file = fileNames[i].substring(index + 1, fileNames[i].length()); |
|
330 |
|
|
331 |
eparams.setDynValue("initialpath", path); |
|
332 |
DataServerExplorer serverExplorer = manager.openServerExplorer(eparams.getExplorerName(), eparams); |
|
333 |
|
|
334 |
sparams = (NewRasterStoreParameters)serverExplorer.getAddParameters(provider); |
|
335 |
sparams.setDataServer((DataServerWriter)processIncrement); |
|
336 |
sparams.setDestination(path, file); |
|
337 |
sparams.setBuffer(buffer); |
|
338 |
sparams.setColorInterpretation(new String[]{ColorInterpretation.GRAY_BAND}); |
|
339 |
sparams.setWktProjection(dstoreCopy.getWktProjection()); |
|
340 |
sparams.setBand(i); |
|
341 |
sparams.setAffineTransform(affineTransform); |
|
342 |
sparams.setDriverParams(params); |
|
343 |
|
|
344 |
serverExplorer.add(provider, sparams, true); |
|
345 |
|
|
346 |
saveToRmf(fileNames[i]); |
|
347 |
t2 = new java.util.Date().getTime(); |
|
348 |
milis[i] = (t2 - t1); |
|
349 |
t1 = new java.util.Date().getTime(); |
|
350 |
} |
|
351 |
if (incrementableTask != null) { |
|
352 |
incrementableTask.processFinalize(); |
|
353 |
incrementableTask = null; |
|
354 |
} |
|
355 |
for (int i = 0; i < drawableBands.length; i++) { |
|
356 |
if (externalActions != null) |
|
357 |
externalActions.end(new Object[] { fileName + "_B" + drawableBands[i] + suffix, new Long(milis[i]) }); |
|
358 |
} |
|
359 |
} else { |
|
360 |
File f = new File(fileName); |
|
361 |
if (f.exists()) { |
|
362 |
f.delete(); |
|
363 |
} |
|
364 |
f = null; |
|
365 |
|
|
366 |
if(suffix != null) |
|
367 |
finalFileName = fileName.endsWith(suffix) ? fileName : fileName + suffix; |
|
368 |
else |
|
369 |
finalFileName = fileName; |
|
370 |
|
|
371 |
int index = finalFileName.lastIndexOf(File.separator); |
|
372 |
if(index < 0) |
|
373 |
index = finalFileName.length(); |
|
374 |
String path = finalFileName.substring(0, index); |
|
375 |
String file = finalFileName.substring(index + 1, finalFileName.length()); |
|
376 |
|
|
377 |
eparams.setDynValue("initialpath", path); |
|
378 |
DataServerExplorer serverExplorer = manager.openServerExplorer(eparams.getExplorerName(), eparams); |
|
379 |
|
|
380 |
try { |
|
381 |
provider = rManager.createWriter(finalFileName).getProviderName(); |
|
382 |
} catch (NotSupportedExtensionException e1) { |
|
383 |
throw new ClipException(Messages.getText("no_driver_escritura")); |
|
384 |
} catch (RasterDriverException e1) { |
|
385 |
throw new ClipException(Messages.getText("no_driver_escritura")); |
|
386 |
} |
|
387 |
|
|
388 |
sparams = (NewRasterStoreParameters)serverExplorer.getAddParameters(provider); |
|
389 |
sparams.setDataServer((DataServerWriter)processIncrement); |
|
390 |
sparams.setDestination(path, file); |
|
391 |
sparams.setBuffer(buffer); |
|
392 |
if(colorInterp != null) |
|
393 |
sparams.setColorInterpretation(colorInterp.getValues()); |
|
394 |
sparams.setWktProjection(dstoreCopy.getWktProjection()); |
|
395 |
sparams.setAffineTransform(affineTransform); |
|
396 |
sparams.setDriverParams(params); |
|
397 |
sparams.setBand(-1); |
|
398 |
|
|
399 |
serverExplorer.add(provider, sparams, true); |
|
400 |
|
|
401 |
saveToRmf(finalFileName); |
|
402 |
|
|
403 |
|
|
404 |
t2 = new java.util.Date().getTime(); |
|
405 |
if (incrementableTask != null) { |
|
406 |
incrementableTask.processFinalize(); |
|
407 |
incrementableTask = null; |
|
408 |
} |
|
409 |
//Damos tiempo a parar el Thread del incrementable para que no se cuelgue la ventana |
|
410 |
//El tiempo es como m?nimo el de un bucle del run de la tarea incrementable |
|
411 |
try { |
|
412 |
Thread.sleep(600); |
|
413 |
} catch (InterruptedException e) { |
|
414 |
throw new ProcessInterruptedException(e); |
|
415 |
} |
|
416 |
if (externalActions != null) |
|
417 |
externalActions.end(new Object[]{fileName, new Long((t2 - t1))}); |
|
418 |
} |
|
419 |
|
|
420 |
} catch (RasterDriverException e) { |
|
421 |
throw new ClipException(Messages.getText("error_writer")); |
|
422 |
} catch (ValidateDataParametersException e) { |
|
423 |
throw new ClipException(Messages.getText("error_georasterwriter")); |
|
424 |
} catch (ProviderNotRegisteredException e) { |
|
425 |
throw new ClipException(Messages.getText("error_georasterwriter")); |
|
426 |
} catch (InitializeException e) { |
|
427 |
throw new ClipException(Messages.getText("error_georasterwriter")); |
|
428 |
} catch (DataException e) { |
|
429 |
throw new ClipException(Messages.getText("error_georasterwriter")); |
|
430 |
} catch (Exception e) { |
|
431 |
e.printStackTrace(); |
|
432 |
} finally { |
|
433 |
if (dstoreCopy != null) |
|
434 |
try { |
|
435 |
dstoreCopy.close(); |
|
436 |
} catch (CloseException e) { |
|
437 |
throw new ClipException(Messages.getText("error_writer")); |
|
438 |
} |
|
439 |
buffer = null; |
|
440 |
} |
|
441 |
} |
|
442 |
|
|
443 |
|
|
444 |
/** |
|
445 |
* Acciones para poner a NoData los pixels que est?n fuera de las |
|
446 |
* regiones de inter?s seleccionadas. |
|
447 |
* @param buffer |
|
448 |
*/ |
|
449 |
private void drawOnlyROIs(Buffer buffer, ArrayList<VectorialROI> rois, int despX, int despY){ |
|
450 |
for (int i = 0 ; i < buffer.getWidth() ; i++){ |
|
451 |
for (int j = 0 ; j < buffer.getHeight() ; j++){ |
|
452 |
boolean inside = false; |
|
453 |
for (int k = 0 ; k < rois.size() ; k++){ |
|
454 |
VectorialROI roi = (VectorialROI)rois.get(k); |
|
455 |
//TODO: Hacer la comprobacion por coordenadas del mundo en lugar de coordenadas pixel. |
|
456 |
if (roi.isInGrid(i + despX, j + despY)){ |
|
457 |
inside = true; |
|
458 |
} |
|
459 |
} |
|
460 |
if (!inside){ |
|
461 |
for (int l = 0 ; l < buffer.getBandCount() ; l++){ |
|
462 |
if (buffer.getDataType() == Buffer.TYPE_BYTE){ |
|
463 |
buffer.setElem(j, i, l, |
|
464 |
buffer.getNoDataValue().isDefined() ? buffer.getNoDataValue().getValue().byteValue() : RasterLibrary.defaultByteNoDataValue); |
|
465 |
} else if (buffer.getDataType() == Buffer.TYPE_SHORT){ |
|
466 |
buffer.setElem(j, i, l, |
|
467 |
buffer.getNoDataValue().isDefined() ? buffer.getNoDataValue().getValue().shortValue() : RasterLibrary.defaultShortNoDataValue); |
|
468 |
} else if (buffer.getDataType() == Buffer.TYPE_INT){ |
|
469 |
buffer.setElem(j, i, l, |
|
470 |
buffer.getNoDataValue().isDefined() ? buffer.getNoDataValue().getValue().intValue() : RasterLibrary.defaultIntegerNoDataValue); |
|
471 |
} else if (buffer.getDataType() == Buffer.TYPE_FLOAT){ |
|
472 |
buffer.setElem(j, i, l, |
|
473 |
buffer.getNoDataValue().isDefined() ? buffer.getNoDataValue().getValue().floatValue() : RasterLibrary.defaultFloatNoDataValue); |
|
474 |
} else if (buffer.getDataType() == Buffer.TYPE_DOUBLE){ |
|
475 |
buffer.setElem(j, i, l, |
|
476 |
buffer.getNoDataValue().isDefined() ? buffer.getNoDataValue().getValue().doubleValue() : RasterLibrary.defaultDoubleNoDataValue); |
|
477 |
} |
|
478 |
} |
|
479 |
} |
|
480 |
} |
|
481 |
} |
|
482 |
} |
|
483 |
|
|
484 |
|
|
485 |
/* |
|
486 |
* (non-Javadoc) |
|
487 |
* @see org.gvsig.gui.beans.incrementabletask.IIncrementable#getPercent() |
|
488 |
*/ |
|
489 |
public int getPercent() { |
|
490 |
return (processIncrement != null) ? processIncrement.getPercent() : 0; |
|
491 |
} |
|
492 |
|
|
493 |
/* |
|
494 |
* (non-Javadoc) |
|
495 |
* @see org.gvsig.gui.beans.incrementabletask.IIncrementable#getTitle() |
Also available in: Unified diff