Revision 33909
tags/v2_0_0_Build_2020/libraries/libRaster_io/src-test/org/gvsig/fmap/dal/coverage/dataset/io/TestIOMemoryRasterDriver.java | ||
---|---|---|
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.fmap.dal.coverage.dataset.io; |
|
20 |
|
|
21 |
import org.gvsig.raster.RasterLibrary; |
|
22 |
import org.gvsig.raster.buffer.BufferFactory; |
|
23 |
import org.gvsig.raster.buffer.RasterBuffer; |
|
24 |
import org.gvsig.raster.dataset.Band; |
|
25 |
import org.gvsig.raster.dataset.BandList; |
|
26 |
import org.gvsig.raster.dataset.BandNotFoundInListException; |
|
27 |
import org.gvsig.raster.dataset.IBuffer; |
|
28 |
import org.gvsig.raster.dataset.InvalidSetViewException; |
|
29 |
import org.gvsig.raster.dataset.NotSupportedExtensionException; |
|
30 |
import org.gvsig.raster.dataset.RasterDataset; |
|
31 |
import org.gvsig.raster.dataset.RasterDriverException; |
|
32 |
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase; |
|
33 |
/** |
|
34 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
35 |
*/ |
|
36 |
public class TestIOMemoryRasterDriver extends AbstractLibraryAutoInitTestCase { |
|
37 |
private String baseDir = "./test-images/"; |
|
38 |
private String path = baseDir + "miniRaster25x24.tif"; |
|
39 |
|
|
40 |
private RasterDataset f = null; |
|
41 |
private RasterDataset f1 = null; |
|
42 |
private BufferFactory ds = null; |
|
43 |
private BandList bandList = null; |
|
44 |
|
|
45 |
public void start() throws Exception { |
|
46 |
this.doSetUp(); |
|
47 |
try { |
|
48 |
this.testStack(); |
|
49 |
} catch (RasterDriverException e) { |
|
50 |
e.printStackTrace(); |
|
51 |
} |
|
52 |
} |
|
53 |
|
|
54 |
static { |
|
55 |
RasterLibrary.wakeUp(); |
|
56 |
} |
|
57 |
|
|
58 |
@Override |
|
59 |
protected void doSetUp() throws Exception { |
|
60 |
System.err.println("TestIOMemoryRasterDriver running..."); |
|
61 |
try { |
|
62 |
f1 = RasterDataset.open(null, path); |
|
63 |
} catch (NotSupportedExtensionException e1) { |
|
64 |
e1.printStackTrace(); |
|
65 |
} catch (RasterDriverException e1) { |
|
66 |
e1.printStackTrace(); |
|
67 |
} |
|
68 |
int[] drawableBands = {0, 1, 2}; |
|
69 |
ds = new BufferFactory(f1); |
|
70 |
ds.setDrawableBands(drawableBands); |
|
71 |
try { |
|
72 |
ds.setAreaOfInterest(0, 0, 25, 24); |
|
73 |
} catch (InvalidSetViewException e) { |
|
74 |
e.printStackTrace(); |
|
75 |
} catch (InterruptedException e) { |
|
76 |
e.printStackTrace(); |
|
77 |
} catch (RasterDriverException e) { |
|
78 |
e.printStackTrace(); |
|
79 |
} |
|
80 |
IBuffer buf = ds.getRasterBuf(); |
|
81 |
|
|
82 |
try { |
|
83 |
MemoryRasterDriverParam param = new MemoryRasterDriverParam(buf, ds.getDataSource().getExtent()); |
|
84 |
f = RasterDataset.open(null, param); |
|
85 |
} catch (NotSupportedExtensionException e1) { |
|
86 |
e1.printStackTrace(); |
|
87 |
} catch (RasterDriverException e1) { |
|
88 |
e1.printStackTrace(); |
|
89 |
} |
|
90 |
|
|
91 |
bandList = new BandList(); |
|
92 |
for(int i = 0; i < buf.getBandCount();i++){ |
|
93 |
try{ |
|
94 |
Band band = new Band(f.getFName(), i, f.getDataType()[i]); |
|
95 |
band.setPositionToDrawInBuffer(i); |
|
96 |
bandList.addBand(band, i); |
|
97 |
}catch(BandNotFoundInListException ex){ |
|
98 |
//No a?adimos la banda |
|
99 |
} |
|
100 |
} |
|
101 |
} |
|
102 |
|
|
103 |
private void dataTest1(IBuffer raster) { |
|
104 |
int band0[] = { 14, 97, 97, 119, 119, 93, 93, 58, 0, 0, 1, 1, 54, 54, 79, 69, 69, 59, 59, 61, 61, 75, 58, 58, 68, 14, 97, 97, 119, 119, 93, 93, 58, 0, 0, 1, 1, 54, 54, 79, 69, 69, 59, 59, 61, 61, 75, 58, 58, 68, 0, 58, 58, 71, 71, 33, 33, 16, 0, 0, 37, 37, 54, 54, 78, 74, 74, 69, 69, 38, 38, 53, 30, 30, 82, 0, 58, 58, 71, 71, 33, 33, 16, 0, 0, 37, 37, 54, 54, 78, 74, 74, 69, 69, 38, 38, 53, 30, 30, 82, 19, 88, 88, 65, 65, 23, 23, 0, 9, 9, 49, 49, 66, 66, 71, 66, 66, 70, 70, 48, 48, 77, 56, 56, 73, 19, 88, 88, 65, 65, 23, 23, 0, 9, 9, 49, 49, 66, 66, 71, 66, 66, 70, 70, 48, 48, 77, 56, 56, 73, 54, 83, 83, 58, 58, 21, 21, 0, 24, 24, 55, 55, 70, 70, 68, 74, 74, 83, 83, 56, 56, 88, 91, 91, 82, 82, 51, 51, 60, 60, 42, 42, 61, 64, 64, 65, 65, 65, 65, 62, 82, 82, 91, 91, 71, 71, 103, 97, 97, 78, 82, 51, 51, 60, 60, 42, 42, 61, 64, 64, 65, 65, 65, 65, 62, 82, 82, 91, 91, 71, 71, 103, 97, 97, 78, 86, 54, 54, 70, 70, 70, 70, 109, 97, 97, 80, 80, 65, 65, 63, 80, 80, 80, 80, 90, 90, 114, 116, 116, 111, 86, 54, 54, 70, 70, 70, 70, 109, 97, 97, 80, 80, 65, 65, 63, 80, 80, 80, 80, 90, 90, 114, 116, 116, 111, 66, 94, 94, 76, 76, 77, 77, 87, 75, 75, 82, 82, 81, 81, 91, 90, 90, 71, 71, 102, 102, 81, 58, 58, 0, 66, 94, 94, 76, 76, 77, 77, 87, 75, 75, 82, 82, 81, 81, 91, 90, 90, 71, 71, 102, 102, 81, 58, 58, 0, 56, 113, 113, 84, 84, 68, 68, 61, 57, 57, 88, 88, 92, 92, 116, 111, 111, 93, 93, 130, 130, 34, 17, 17, 0, 63, 106, 106, 97, 97, 62, 62, 66, 81, 81, 110, 110, 94, 94, 114, 120, 120, 124, 124, 172, 172, 22, 4, 4, 23, 63, 106, 106, 97, 97, 62, 62, 66, 81, 81, 110, 110, 94, 94, 114, 120, 120, 124, 124, 172, 172, 22, 4, 4, 23, 85, 109, 109, 53, 53, 79, 79, 112, 107, 107, 115, 115, 117, 117, 122, 149, 149, 178, 178, 178, 178, 152, 11, 11, 31, 85, 109, 109, 53, 53, 79, 79, 112, 107, 107, 115, 115, 117, 117, 122, 149, 149, 178, 178, 178, 178, 152, 11, 11, 31, 87, 110, 110, 96, 96, 86, 86, 118, 125, 125, 138, 138, 160, 160, 179, 194, 194, 222, 222, 235, 235, 222, 95, 95, 68, 87, 110, 110, 96, 96, 86, 86, 118, 125, 125, 138, 138, 160, 160, 179, 194, 194, 222, 222, 235, 235, 222, 95, 95, 68, 97, 175, 175, 234, 234, 154, 154, 140, 146, 146, 152, 152, 200, 200, 242, 248, 248, 250, 250, 246, 246, 215, 150, 150, 115, 119, 164, 164, 225, 225, 157, 157, 162, 166, 166, 142, 142, 180, 180, 235, 237, 237, 225, 225, 198, 198, 146, 135, 135, 129, 119, 164, 164, 225, 225, 157, 157, 162, 166, 166, 142, 142, 180, 180, 235, 237, 237, 225, 225, 198, 198, 146, 135, 135, 129, 129, 129, 129, 164, 164, 153, 153, 183, 183, 183, 128, 128, 134, 134, 171, 173, 173, 169, 169, 158, 158, 123, 141, 141, 145}; |
|
105 |
int band1[] = { 14, 101, 101, 127, 127, 108, 108, 75, 18, 18, 17, 17, 61, 61, 78, 65, 65, 59, 59, 65, 65, 84, 85, 85, 90, 14, 101, 101, 127, 127, 108, 108, 75, 18, 18, 17, 17, 61, 61, 78, 65, 65, 59, 59, 65, 65, 84, 85, 85, 90, 11, 86, 86, 102, 102, 61, 61, 39, 7, 7, 43, 43, 59, 59, 85, 83, 83, 82, 82, 52, 52, 70, 47, 47, 98, 11, 86, 86, 102, 102, 61, 61, 39, 7, 7, 43, 43, 59, 59, 85, 83, 83, 82, 82, 52, 52, 70, 47, 47, 98, 37, 115, 115, 94, 94, 47, 47, 6, 18, 18, 56, 56, 71, 71, 77, 75, 75, 82, 82, 63, 63, 96, 70, 70, 85, 37, 115, 115, 94, 94, 47, 47, 6, 18, 18, 56, 56, 71, 71, 77, 75, 75, 82, 82, 63, 63, 96, 70, 70, 85, 72, 108, 108, 79, 79, 37, 37, 4, 37, 37, 65, 65, 78, 78, 72, 81, 81, 93, 93, 71, 71, 107, 105, 105, 94, 100, 70, 70, 75, 75, 51, 51, 66, 81, 81, 79, 79, 73, 73, 66, 88, 88, 101, 101, 87, 87, 121, 112, 112, 93, 100, 70, 70, 75, 75, 51, 51, 66, 81, 81, 79, 79, 73, 73, 66, 88, 88, 101, 101, 87, 87, 121, 112, 112, 93, 104, 72, 72, 82, 82, 78, 78, 111, 115, 115, 96, 96, 75, 75, 69, 84, 84, 88, 88, 104, 104, 131, 129, 129, 124, 104, 72, 72, 82, 82, 78, 78, 111, 115, 115, 96, 96, 75, 75, 69, 84, 84, 88, 88, 104, 104, 131, 129, 129, 124, 84, 109, 109, 88, 88, 85, 85, 91, 94, 94, 97, 97, 91, 91, 98, 94, 94, 79, 79, 112, 112, 94, 65, 65, 0, 84, 109, 109, 88, 88, 85, 85, 91, 94, 94, 97, 97, 91, 91, 98, 94, 94, 79, 79, 112, 112, 94, 65, 65, 0, 72, 128, 128, 97, 97, 78, 78, 68, 76, 76, 103, 103, 104, 104, 125, 117, 117, 98, 98, 137, 137, 43, 26, 26, 3, 79, 121, 121, 110, 110, 75, 75, 77, 98, 98, 124, 124, 107, 107, 123, 127, 127, 129, 129, 178, 178, 29, 20, 20, 38, 79, 121, 121, 110, 110, 75, 75, 77, 98, 98, 124, 124, 107, 107, 123, 127, 127, 129, 129, 178, 178, 29, 20, 20, 38, 104, 130, 130, 74, 74, 97, 97, 126, 123, 123, 130, 130, 133, 133, 137, 161, 161, 187, 187, 180, 180, 153, 7, 7, 35, 104, 130, 130, 74, 74, 97, 97, 126, 123, 123, 130, 130, 133, 133, 137, 161, 161, 187, 187, 180, 180, 153, 7, 7, 35, 102, 124, 124, 109, 109, 95, 95, 126, 135, 135, 147, 147, 172, 172, 190, 205, 205, 228, 228, 237, 237, 222, 89, 89, 68, 102, 124, 124, 109, 109, 95, 95, 126, 135, 135, 147, 147, 172, 172, 190, 205, 205, 228, 228, 237, 237, 222, 89, 89, 68, 106, 182, 182, 236, 236, 151, 151, 134, 145, 145, 153, 153, 204, 204, 249, 254, 254, 255, 255, 247, 247, 215, 140, 140, 114, 120, 158, 158, 215, 215, 143, 143, 146, 159, 159, 136, 136, 181, 181, 238, 242, 242, 230, 230, 200, 200, 146, 126, 126, 124, 120, 158, 158, 215, 215, 143, 143, 146, 159, 159, 136, 136, 181, 181, 238, 242, 242, 230, 230, 200, 200, 146, 126, 126, 124, 122, 117, 117, 148, 148, 133, 133, 163, 173, 173, 122, 122, 132, 132, 173, 176, 176, 172, 172, 160, 160, 123, 133, 133, 140}; |
|
106 |
int band2[] = { 0, 68, 68, 88, 88, 67, 67, 31, 0, 0, 0, 0, 28, 28, 48, 36, 36, 31, 31, 38, 38, 57, 42, 42, 52, 0, 68, 68, 88, 88, 67, 67, 31, 0, 0, 0, 0, 28, 28, 48, 36, 36, 31, 31, 38, 38, 57, 42, 42, 52, 0, 37, 37, 42, 42, 23, 23, 31, 0, 0, 29, 29, 36, 36, 54, 52, 52, 56, 56, 35, 35, 60, 11, 11, 61, 0, 37, 37, 42, 42, 23, 23, 31, 0, 0, 29, 29, 36, 36, 54, 52, 52, 56, 56, 35, 35, 60, 11, 11, 61, 23, 70, 70, 38, 38, 13, 13, 0, 1, 1, 38, 38, 49, 49, 51, 48, 48, 58, 58, 42, 42, 76, 57, 57, 71, 23, 70, 70, 38, 38, 13, 13, 0, 1, 1, 38, 38, 49, 49, 51, 48, 48, 58, 58, 42, 42, 76, 57, 57, 71, 60, 69, 69, 36, 36, 10, 10, 0, 7, 7, 38, 38, 55, 55, 55, 63, 63, 69, 69, 42, 42, 75, 92, 92, 80, 86, 42, 42, 42, 42, 30, 30, 59, 39, 39, 44, 44, 50, 50, 52, 74, 74, 77, 77, 51, 51, 79, 83, 83, 64, 86, 42, 42, 42, 42, 30, 30, 59, 39, 39, 44, 44, 50, 50, 52, 74, 74, 77, 77, 51, 51, 79, 83, 83, 64, 88, 50, 50, 58, 58, 57, 57, 97, 73, 73, 60, 60, 51, 51, 55, 70, 70, 65, 65, 69, 69, 89, 111, 111, 107, 88, 50, 50, 58, 58, 57, 57, 97, 73, 73, 60, 60, 51, 51, 55, 70, 70, 65, 65, 69, 69, 89, 111, 111, 107, 62, 90, 90, 68, 68, 62, 62, 68, 62, 62, 68, 68, 67, 67, 80, 77, 77, 56, 56, 85, 85, 64, 75, 75, 12, 62, 90, 90, 68, 68, 62, 62, 68, 62, 62, 68, 68, 67, 67, 80, 77, 77, 56, 56, 85, 85, 64, 75, 75, 12, 46, 109, 109, 79, 79, 53, 53, 35, 56, 56, 82, 82, 80, 80, 98, 91, 91, 76, 76, 119, 119, 26, 21, 21, 2, 50, 102, 102, 92, 92, 47, 47, 37, 88, 88, 107, 107, 81, 81, 92, 96, 96, 106, 106, 164, 164, 22, 0, 0, 0, 50, 102, 102, 92, 92, 47, 47, 37, 88, 88, 107, 107, 81, 81, 92, 96, 96, 106, 106, 164, 164, 22, 0, 0, 0, 84, 111, 111, 55, 55, 75, 75, 103, 97, 97, 111, 111, 120, 120, 130, 159, 159, 184, 184, 177, 177, 148, 24, 24, 36, 84, 111, 111, 55, 55, 75, 75, 103, 97, 97, 111, 111, 120, 120, 130, 159, 159, 184, 184, 177, 177, 148, 24, 24, 36, 83, 107, 107, 91, 91, 76, 76, 105, 111, 111, 128, 128, 158, 158, 182, 201, 201, 228, 228, 236, 236, 220, 101, 101, 66, 83, 107, 107, 91, 91, 76, 76, 105, 111, 111, 128, 128, 158, 158, 182, 201, 201, 228, 228, 236, 236, 220, 101, 101, 66, 87, 166, 166, 222, 222, 136, 136, 118, 124, 124, 135, 135, 190, 190, 241, 250, 250, 254, 254, 249, 249, 215, 148, 148, 109, 102, 144, 144, 203, 203, 130, 130, 133, 141, 141, 120, 120, 167, 167, 227, 235, 235, 226, 226, 199, 199, 148, 127, 127, 118, 102, 144, 144, 203, 203, 130, 130, 133, 141, 141, 120, 120, 167, 167, 227, 235, 235, 226, 226, 199, 199, 148, 127, 127, 118, 106, 101, 101, 133, 133, 122, 122, 152, 161, 161, 108, 108, 119, 119, 160, 165, 165, 165, 165, 155, 155, 121, 130, 130, 134}; |
|
107 |
compareRaster(raster, band0, band1, band2); |
|
108 |
} |
|
109 |
|
|
110 |
private void dataTest2(IBuffer raster) { |
|
111 |
int band0[] = { 80, 80, 82, 82}; |
|
112 |
int band1[] = { 96, 96, 97, 97}; |
|
113 |
int band2[] = { 60, 60, 68, 68}; |
|
114 |
compareRaster(raster, band0, band1, band2); |
|
115 |
} |
|
116 |
|
|
117 |
private void dataTest3(IBuffer raster) { |
|
118 |
int band0[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; |
|
121 |
compareRaster(raster, band0, band1, band2); |
|
122 |
} |
|
123 |
|
|
124 |
private void dataTest4(IBuffer raster) { |
|
125 |
int band0[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; |
|
126 |
int band1[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; |
|
127 |
int band2[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; |
|
128 |
compareRaster(raster, band0, band1, band2); |
|
129 |
} |
|
130 |
|
|
131 |
private void dataTest5(IBuffer raster) { |
|
132 |
int band0[] = { 86, 86, 54, 54, 54, 54, 70, 70, 70, 70, 70, 70, 70, 70, 109, 109, 97, 97, 97, 97, 86, 86, 54, 54, 54, 54, 70, 70, 70, 70, 70, 70, 70, 70, 109, 109, 97, 97, 97, 97, 66, 66, 94, 94, 94, 94, 76, 76, 76, 76, 77, 77, 77, 77, 87, 87, 75, 75, 75, 75, 66, 66, 94, 94, 94, 94, 76, 76, 76, 76, 77, 77, 77, 77, 87, 87, 75, 75, 75, 75, 66, 66, 94, 94, 94, 94, 76, 76, 76, 76, 77, 77, 77, 77, 87, 87, 75, 75, 75, 75, 66, 66, 94, 94, 94, 94, 76, 76, 76, 76, 77, 77, 77, 77, 87, 87, 75, 75, 75, 75, 56, 56, 113, 113, 113, 113, 84, 84, 84, 84, 68, 68, 68, 68, 61, 61, 57, 57, 57, 57, 56, 56, 113, 113, 113, 113, 84, 84, 84, 84, 68, 68, 68, 68, 61, 61, 57, 57, 57, 57, 63, 63, 106, 106, 106, 106, 97, 97, 97, 97, 62, 62, 62, 62, 66, 66, 81, 81, 81, 81, 63, 63, 106, 106, 106, 106, 97, 97, 97, 97, 62, 62, 62, 62, 66, 66, 81, 81, 81, 81, 63, 63, 106, 106, 106, 106, 97, 97, 97, 97, 62, 62, 62, 62, 66, 66, 81, 81, 81, 81, 63, 63, 106, 106, 106, 106, 97, 97, 97, 97, 62, 62, 62, 62, 66, 66, 81, 81, 81, 81, 85, 85, 109, 109, 109, 109, 53, 53, 53, 53, 79, 79, 79, 79, 112, 112, 107, 107, 107, 107, 85, 85, 109, 109, 109, 109, 53, 53, 53, 53, 79, 79, 79, 79, 112, 112, 107, 107, 107, 107, 85, 85, 109, 109, 109, 109, 53, 53, 53, 53, 79, 79, 79, 79, 112, 112, 107, 107, 107, 107, 85, 85, 109, 109, 109, 109, 53, 53, 53, 53, 79, 79, 79, 79, 112, 112, 107, 107, 107, 107, 87, 87, 110, 110, 110, 110, 96, 96, 96, 96, 86, 86, 86, 86, 118, 118, 125, 125, 125, 125, 87, 87, 110, 110, 110, 110, 96, 96, 96, 96, 86, 86, 86, 86, 118, 118, 125, 125, 125, 125, 87, 87, 110, 110, 110, 110, 96, 96, 96, 96, 86, 86, 86, 86, 118, 118, 125, 125, 125, 125, 87, 87, 110, 110, 110, 110, 96, 96, 96, 96, 86, 86, 86, 86, 118, 118, 125, 125, 125, 125}; |
|
133 |
int band1[] = { 104, 104, 72, 72, 72, 72, 82, 82, 82, 82, 78, 78, 78, 78, 111, 111, 115, 115, 115, 115, 104, 104, 72, 72, 72, 72, 82, 82, 82, 82, 78, 78, 78, 78, 111, 111, 115, 115, 115, 115, 84, 84, 109, 109, 109, 109, 88, 88, 88, 88, 85, 85, 85, 85, 91, 91, 94, 94, 94, 94, 84, 84, 109, 109, 109, 109, 88, 88, 88, 88, 85, 85, 85, 85, 91, 91, 94, 94, 94, 94, 84, 84, 109, 109, 109, 109, 88, 88, 88, 88, 85, 85, 85, 85, 91, 91, 94, 94, 94, 94, 84, 84, 109, 109, 109, 109, 88, 88, 88, 88, 85, 85, 85, 85, 91, 91, 94, 94, 94, 94, 72, 72, 128, 128, 128, 128, 97, 97, 97, 97, 78, 78, 78, 78, 68, 68, 76, 76, 76, 76, 72, 72, 128, 128, 128, 128, 97, 97, 97, 97, 78, 78, 78, 78, 68, 68, 76, 76, 76, 76, 79, 79, 121, 121, 121, 121, 110, 110, 110, 110, 75, 75, 75, 75, 77, 77, 98, 98, 98, 98, 79, 79, 121, 121, 121, 121, 110, 110, 110, 110, 75, 75, 75, 75, 77, 77, 98, 98, 98, 98, 79, 79, 121, 121, 121, 121, 110, 110, 110, 110, 75, 75, 75, 75, 77, 77, 98, 98, 98, 98, 79, 79, 121, 121, 121, 121, 110, 110, 110, 110, 75, 75, 75, 75, 77, 77, 98, 98, 98, 98, 104, 104, 130, 130, 130, 130, 74, 74, 74, 74, 97, 97, 97, 97, 126, 126, 123, 123, 123, 123, 104, 104, 130, 130, 130, 130, 74, 74, 74, 74, 97, 97, 97, 97, 126, 126, 123, 123, 123, 123, 104, 104, 130, 130, 130, 130, 74, 74, 74, 74, 97, 97, 97, 97, 126, 126, 123, 123, 123, 123, 104, 104, 130, 130, 130, 130, 74, 74, 74, 74, 97, 97, 97, 97, 126, 126, 123, 123, 123, 123, 102, 102, 124, 124, 124, 124, 109, 109, 109, 109, 95, 95, 95, 95, 126, 126, 135, 135, 135, 135, 102, 102, 124, 124, 124, 124, 109, 109, 109, 109, 95, 95, 95, 95, 126, 126, 135, 135, 135, 135, 102, 102, 124, 124, 124, 124, 109, 109, 109, 109, 95, 95, 95, 95, 126, 126, 135, 135, 135, 135, 102, 102, 124, 124, 124, 124, 109, 109, 109, 109, 95, 95, 95, 95, 126, 126, 135, 135, 135, 135}; |
|
134 |
int band2[] = { 88, 88, 50, 50, 50, 50, 58, 58, 58, 58, 57, 57, 57, 57, 97, 97, 73, 73, 73, 73, 88, 88, 50, 50, 50, 50, 58, 58, 58, 58, 57, 57, 57, 57, 97, 97, 73, 73, 73, 73, 62, 62, 90, 90, 90, 90, 68, 68, 68, 68, 62, 62, 62, 62, 68, 68, 62, 62, 62, 62, 62, 62, 90, 90, 90, 90, 68, 68, 68, 68, 62, 62, 62, 62, 68, 68, 62, 62, 62, 62, 62, 62, 90, 90, 90, 90, 68, 68, 68, 68, 62, 62, 62, 62, 68, 68, 62, 62, 62, 62, 62, 62, 90, 90, 90, 90, 68, 68, 68, 68, 62, 62, 62, 62, 68, 68, 62, 62, 62, 62, 46, 46, 109, 109, 109, 109, 79, 79, 79, 79, 53, 53, 53, 53, 35, 35, 56, 56, 56, 56, 46, 46, 109, 109, 109, 109, 79, 79, 79, 79, 53, 53, 53, 53, 35, 35, 56, 56, 56, 56, 50, 50, 102, 102, 102, 102, 92, 92, 92, 92, 47, 47, 47, 47, 37, 37, 88, 88, 88, 88, 50, 50, 102, 102, 102, 102, 92, 92, 92, 92, 47, 47, 47, 47, 37, 37, 88, 88, 88, 88, 50, 50, 102, 102, 102, 102, 92, 92, 92, 92, 47, 47, 47, 47, 37, 37, 88, 88, 88, 88, 50, 50, 102, 102, 102, 102, 92, 92, 92, 92, 47, 47, 47, 47, 37, 37, 88, 88, 88, 88, 84, 84, 111, 111, 111, 111, 55, 55, 55, 55, 75, 75, 75, 75, 103, 103, 97, 97, 97, 97, 84, 84, 111, 111, 111, 111, 55, 55, 55, 55, 75, 75, 75, 75, 103, 103, 97, 97, 97, 97, 84, 84, 111, 111, 111, 111, 55, 55, 55, 55, 75, 75, 75, 75, 103, 103, 97, 97, 97, 97, 84, 84, 111, 111, 111, 111, 55, 55, 55, 55, 75, 75, 75, 75, 103, 103, 97, 97, 97, 97, 83, 83, 107, 107, 107, 107, 91, 91, 91, 91, 76, 76, 76, 76, 105, 105, 111, 111, 111, 111, 83, 83, 107, 107, 107, 107, 91, 91, 91, 91, 76, 76, 76, 76, 105, 105, 111, 111, 111, 111, 83, 83, 107, 107, 107, 107, 91, 91, 91, 91, 76, 76, 76, 76, 105, 105, 111, 111, 111, 111, 83, 83, 107, 107, 107, 107, 91, 91, 91, 91, 76, 76, 76, 76, 105, 105, 111, 111, 111, 111}; |
|
135 |
compareRaster(raster, band0, band1, band2); |
|
136 |
} |
|
137 |
|
|
138 |
private void dataTest6(IBuffer raster) { |
|
139 |
int band0[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; |
|
142 |
compareRaster(raster, band0, band1, band2); |
|
143 |
} |
|
144 |
|
|
145 |
private void dataTest7(IBuffer raster) { |
|
146 |
int band0[] = { 14, 93, 1, 69, 61, 19, 23, 49, 66, 48, 86, 70, 80, 80, 90, 63, 62, 110, 120, 172, 87, 86, 138, 194, 235}; |
|
147 |
int band1[] = { 14, 108, 17, 65, 65, 37, 47, 56, 75, 63, 104, 78, 96, 84, 104, 79, 75, 124, 127, 178, 102, 95, 147, 205, 237}; |
|
148 |
int band2[] = { 0, 67, 0, 36, 38, 23, 13, 38, 48, 42, 88, 57, 60, 70, 69, 50, 47, 107, 96, 164, 83, 76, 128, 201, 236}; |
|
149 |
compareRaster(raster, band0, band1, band2); |
|
150 |
} |
|
151 |
|
|
152 |
public void testStack() throws RasterDriverException { |
|
153 |
try { |
|
154 |
//************************************** |
|
155 |
//Prueba getWindowRaster(int x, int y, int w, int h, BandList bandList, IBuffer rasterBuf) |
|
156 |
//COMPLETA |
|
157 |
IBuffer buffer = RasterBuffer.getBuffer(f.getDataType()[0], 25, 24, 3, true); |
|
158 |
f.getWindowRaster(0, 0, 25, 24, bandList, buffer); |
|
159 |
dataTest1(buffer); |
|
160 |
|
|
161 |
//ZOOM |
|
162 |
buffer = RasterBuffer.getBuffer(f.getDataType()[0], 2, 2, 3, true); |
|
163 |
f.getWindowRaster(10, 10, 2, 2, bandList, buffer); |
|
164 |
dataTest2(buffer); |
|
165 |
|
|
166 |
//************************************** |
|
167 |
//Prueba de getWindowRaster(double minX, double minY, double maxX, double maxY, int bufWidth, int bufHeight, BandList bandList, IBuffer rasterBuf, boolean adjustToExtent) |
|
168 |
//EXTENT COMPLETO |
|
169 |
buffer = RasterBuffer.getBuffer(f.getDataType()[0], 25, 24, 3, true); |
|
170 |
f.getWindowRaster(f.getExtent().minX(), f.getExtent().minY(), f.getExtent().maxX(), f.getExtent().maxY(), 25, 24, bandList, buffer, true); |
|
171 |
dataTest3(buffer); |
|
172 |
|
|
173 |
//ZOOM + subsampling |
|
174 |
buffer = RasterBuffer.getBuffer(f.getDataType()[0], 8, 8, 3, true); |
|
175 |
f.getWindowRaster(Math.ceil(f.getExtent().minX()), Math.ceil(f.getExtent().minY()), Math.floor(f.getExtent().maxX()), Math.floor(f.getExtent().maxY()), 8, 8, bandList, buffer, true); |
|
176 |
dataTest4(buffer); |
|
177 |
|
|
178 |
//ZOOM + supersampling |
|
179 |
buffer = RasterBuffer.getBuffer(f.getDataType()[0], 20, 20, 3, true); |
|
180 |
f.getWindowRaster(Math.ceil(f.getExtent().minX()), Math.ceil(f.getExtent().minY()), Math.floor(f.getExtent().minX() + 10), Math.floor(f.getExtent().minY() + 10), 20, 20, bandList, buffer, true); |
|
181 |
dataTest5(buffer); |
|
182 |
|
|
183 |
//************************************** |
|
184 |
//Prueba de getWindowRaster(double x, double y, double w, double h, BandList bandList, IBuffer rasterBuf, boolean adjustToExtent) |
|
185 |
//COMPLETA |
|
186 |
buffer = RasterBuffer.getBuffer(f.getDataType()[0], 25, 24, 3, true); |
|
187 |
f.getWindowRaster(f.getExtent().minX(), f.getExtent().maxY(), f.getExtent().width(), f.getExtent().height(), bandList, buffer, true); |
|
188 |
dataTest6(buffer); |
|
189 |
|
|
190 |
//************************************** |
|
191 |
//Prueba de getWindowRaster(int x, int y, int w, int h, int bufWidth, int bufHeight, BandList bandList, IBuffer rasterBuf) |
|
192 |
//COMPLETA |
|
193 |
buffer = RasterBuffer.getBuffer(f.getDataType()[0], 5, 5, 3, true); |
|
194 |
f.getWindowRaster(0, 0, 25, 24, 5, 5, bandList, buffer); |
|
195 |
dataTest7(buffer); |
|
196 |
} catch (InterruptedException e) { |
|
197 |
e.printStackTrace(); |
|
198 |
} |
|
199 |
} |
|
200 |
|
|
201 |
public void compareRaster(IBuffer raster, int band0[], int band1[], int band2[]) { |
|
202 |
int cont = 0; |
|
203 |
for (int line = 0; line < raster.getHeight(); line++) { |
|
204 |
for (int col = 0; col < raster.getWidth(); col++) { |
|
205 |
assertEquals((int) (raster.getElemByte(line, col, 0) & 0xff), band0[cont]); |
|
206 |
assertEquals((int) (raster.getElemByte(line, col, 1) & 0xff), band1[cont]); |
|
207 |
assertEquals((int) (raster.getElemByte(line, col, 2) & 0xff), band2[cont]); |
|
208 |
cont++; |
|
209 |
} |
|
210 |
} |
|
211 |
} |
|
212 |
|
|
213 |
/** |
|
214 |
* Imprime todos los pixels de la fuente de datos en RGB |
|
215 |
*/ |
|
216 |
public void print(IBuffer raster) { |
|
217 |
System.out.println(""); |
|
218 |
for (int band = 0; band < 3; band++) { |
|
219 |
System.out.print("int band" + band + "[] = { "); |
|
220 |
int cont = 0; |
|
221 |
for (int line = 0; line < raster.getHeight(); line++) { |
|
222 |
for (int col = 0; col < raster.getWidth(); col++) { |
|
223 |
if (cont != 0) |
|
224 |
System.out.print(", "); |
|
225 |
System.out.print(((int) (raster.getElemByte(line, col, band) & 0xff))); |
|
226 |
cont++; |
|
227 |
} |
|
228 |
} |
|
229 |
System.out.println("};"); |
|
230 |
} |
|
231 |
} |
|
232 |
} |
tags/v2_0_0_Build_2020/libraries/libRaster_io/src/org/gvsig/fmap/dal/coverage/dataset/io/PngWriter.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2008 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.fmap.dal.coverage.dataset.io; |
|
20 |
|
|
21 |
import java.awt.geom.AffineTransform; |
|
22 |
import java.io.File; |
|
23 |
import java.io.IOException; |
|
24 |
|
|
25 |
import org.cresques.cts.IProjection; |
|
26 |
import org.gvsig.fmap.dal.coverage.dataset.io.features.PngFeatures; |
|
27 |
import org.gvsig.raster.dataset.GeoRasterWriter; |
|
28 |
import org.gvsig.raster.dataset.IDataWriter; |
|
29 |
import org.gvsig.raster.dataset.Params; |
|
30 |
import org.gvsig.raster.dataset.WriteFileFormatFeatures; |
|
31 |
import org.gvsig.raster.util.RasterUtilities; |
|
32 |
import org.gvsig.tools.ToolsLocator; |
|
33 |
import org.gvsig.tools.extensionpoint.ExtensionPoint; |
|
34 |
import org.gvsig.tools.extensionpoint.ExtensionPointManager; |
|
35 |
|
|
36 |
import es.gva.cit.jgdal.Gdal; |
|
37 |
import es.gva.cit.jgdal.GdalDriver; |
|
38 |
import es.gva.cit.jgdal.GdalException; |
|
39 |
/** |
|
40 |
* Driver para la escritura de Png. |
|
41 |
* Este driver utiliza GdalWriter para salvar Png. |
|
42 |
* La escritura de un png no es posible utilizando un servidor de datos |
|
43 |
* como el que usan los drivers comunes por lo que ser? necesario salvar antes |
|
44 |
* a Tif con el driver de Gdal para posteriormente convertir la imagen completa |
|
45 |
* a png. El problema que tiene es el mismo del jpg y es que el dataset solo soporta la |
|
46 |
* escritura rw y no rw+. |
|
47 |
* |
|
48 |
* @version 22/07/2008 |
|
49 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
50 |
*/ |
|
51 |
public class PngWriter extends GeoRasterWriter { |
|
52 |
|
|
53 |
// Datos de registro de drivers |
|
54 |
public static void register() { |
|
55 |
ExtensionPointManager extensionPoints =ToolsLocator.getExtensionPointManager(); |
|
56 |
ExtensionPoint point=extensionPoints.get("RasterWriter"); |
|
57 |
point.append("png", "", PngWriter.class); |
|
58 |
fileFeature.put("png", new PngFeatures()); |
|
59 |
} |
|
60 |
|
|
61 |
private GdalWriter gdalWriter = null; |
|
62 |
private String outTif = null; |
|
63 |
private String outPng = null; |
|
64 |
|
|
65 |
/** |
|
66 |
* Carga los par?metros de este driver. |
|
67 |
*/ |
|
68 |
public void loadParams(String ident) { |
|
69 |
WriteFileFormatFeatures wfff = (WriteFileFormatFeatures) fileFeature.get(ident); |
|
70 |
wfff.loadParams(); |
|
71 |
driverParams = wfff.getParams(); |
|
72 |
} |
|
73 |
|
|
74 |
/** |
|
75 |
* Constructor para la obtenci?n de par?metros del driver |
|
76 |
* @param drvType Tipo de driver |
|
77 |
*/ |
|
78 |
public PngWriter(String fileName) { |
|
79 |
ident = RasterUtilities.getExtensionFromFileName(fileName); |
|
80 |
driver = ((WriteFileFormatFeatures) fileFeature.get(ident)).getDriverName(); |
|
81 |
gdalWriter = new GdalWriter(fileName); |
|
82 |
|
|
83 |
loadParams(ident); |
|
84 |
} |
|
85 |
|
|
86 |
/** |
|
87 |
* Constructor para salvar datos servidos por el cliente |
|
88 |
* @param dataWriter Objeto servidor de datos para el driver de escritura |
|
89 |
* @param outSizeX N?mero de pixels en X de la imagen de salida |
|
90 |
* @param outSizeY N?mero de pixels en Y de la imagen de salida |
|
91 |
* @param outFilename Fichero de salida |
|
92 |
* @param extentMaxX Posici?n en X m?xima del extent |
|
93 |
* @param extentMinX Posici?n en X m?nima del extent |
|
94 |
* @param extentMaxY Posici?n en Y m?xima del extent |
|
95 |
* @param extentMinY Posici?n en Y m?nima del extent |
|
96 |
* @param nBands N?mero de bandas |
|
97 |
* @param drvType Tipo de driver |
|
98 |
* @throws GdalException |
|
99 |
* @throws IOException |
|
100 |
*/ |
|
101 |
public PngWriter(IDataWriter dataWriter, |
|
102 |
String outFileName, |
|
103 |
Integer nBands, |
|
104 |
AffineTransform at, |
|
105 |
Integer outSizeX, |
|
106 |
Integer outSizeY, |
|
107 |
Integer dataType, |
|
108 |
Params params, |
|
109 |
IProjection proj, |
|
110 |
Boolean geo)throws GdalException, IOException { |
|
111 |
ident = RasterUtilities.getExtensionFromFileName(outFileName); |
|
112 |
driver = ((WriteFileFormatFeatures) fileFeature.get(ident)).getDriverName(); |
|
113 |
outPng = outFileName; |
|
114 |
outTif = outFileName.substring(0, outFileName.lastIndexOf(".")); |
|
115 |
outTif += ".tif"; |
|
116 |
this.at = at; |
|
117 |
|
|
118 |
gdalWriter = new GdalWriter(dataWriter, outTif, nBands, at, outSizeX, outSizeY, dataType, params, proj, geo); |
|
119 |
if (params == null) |
|
120 |
loadParams(ident); |
|
121 |
else |
|
122 |
this.driverParams = params; |
|
123 |
} |
|
124 |
|
|
125 |
/** |
|
126 |
* Asigna el tipo de driver con el que se salvar? la imagen |
|
127 |
* @param drvType Tipo de driver |
|
128 |
*/ |
|
129 |
public void setDriverType(String drvType) { |
|
130 |
gdalWriter.setDriverType(drvType); |
|
131 |
} |
|
132 |
|
|
133 |
/** |
|
134 |
* Realiza la funci?n de compresi?n a partir de un GeoRasterFile. |
|
135 |
* @throws IOException |
|
136 |
*/ |
|
137 |
public void fileWrite() throws IOException, InterruptedException { |
|
138 |
gdalWriter.fileWrite(); |
|
139 |
} |
|
140 |
|
|
141 |
/** |
|
142 |
* Realiza una copia en el formato especificado. |
|
143 |
* @throws IOException |
|
144 |
*/ |
|
145 |
public static void createCopy(GdalDriver driverDst, String dst, String src, |
|
146 |
boolean bstrict, String[] params, IProjection proj) throws IOException, GdalException { |
|
147 |
GdalWriter.createCopy(driverDst, dst, src, bstrict, params, proj); |
|
148 |
} |
|
149 |
|
|
150 |
/** |
|
151 |
* Realiza la escritura de datos con los datos que le pasa el cliente. |
|
152 |
* @throws IOException |
|
153 |
*/ |
|
154 |
public void dataWrite() throws IOException, InterruptedException { |
|
155 |
if(colorInterp != null) |
|
156 |
gdalWriter.setColorBandsInterpretation(colorInterp.getValues()); |
|
157 |
gdalWriter.dataWrite(); |
|
158 |
if (gdalWriter.isWrite()) { |
|
159 |
gdalWriter.writeClose(); |
|
160 |
if (outTif != null) { |
|
161 |
GdalDriver driver = null; |
|
162 |
try { |
|
163 |
driver = Gdal.getDriverByName("PNG"); |
|
164 |
GdalWriter.createCopy(driver, outPng, outTif, false, gdalWriter.gdalParamsFromRasterParams(driverParams), null); |
|
165 |
} catch (GdalException exc) { |
|
166 |
throw new IOException("No se ha podido obtener el driver."); |
|
167 |
} |
|
168 |
File file = new File(outTif); |
|
169 |
file.delete(); |
|
170 |
} |
|
171 |
} |
|
172 |
} |
|
173 |
|
|
174 |
/** |
|
175 |
* Cancela el salvado de datos. |
|
176 |
*/ |
|
177 |
public void writeCancel() { |
|
178 |
gdalWriter.setWrite(false); |
|
179 |
} |
|
180 |
|
|
181 |
/* |
|
182 |
* (non-Javadoc) |
|
183 |
* @see org.gvsig.raster.dataset.GeoRasterWriter#setParams(org.gvsig.raster.dataset.Params) |
|
184 |
*/ |
|
185 |
public void setParams(Params params) { |
|
186 |
driverParams = params; |
|
187 |
if (gdalWriter != null) |
|
188 |
gdalWriter.setParams(params); |
|
189 |
} |
|
190 |
|
|
191 |
/** |
|
192 |
* Cierra el compresor ecw. |
|
193 |
* @throws GdalException |
|
194 |
*/ |
|
195 |
public void writeClose() { |
|
196 |
// El close del tif se hizo en dataWrite |
|
197 |
} |
|
198 |
|
|
199 |
public void setWkt(String wkt) {} |
|
200 |
} |
tags/v2_0_0_Build_2020/libraries/libRaster_io/src/org/gvsig/fmap/dal/coverage/dataset/io/DefaultRasterIOLibrary.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2006 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.fmap.dal.coverage.dataset.io; |
|
20 |
|
|
21 |
import org.gvsig.raster.RasterLibrary; |
|
22 |
import org.gvsig.tools.library.AbstractLibrary; |
|
23 |
import org.gvsig.tools.library.Library; |
|
24 |
import org.gvsig.tools.library.LibraryException; |
|
25 |
/** |
|
26 |
* |
|
27 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
28 |
*/ |
|
29 |
public class DefaultRasterIOLibrary extends AbstractLibrary { |
|
30 |
|
|
31 |
public DefaultRasterIOLibrary() { |
|
32 |
super(DefaultRasterIOLibrary.class,Library.TYPE.IMPL); |
|
33 |
} |
|
34 |
|
|
35 |
@Override |
|
36 |
protected void doInitialize() throws LibraryException { |
|
37 |
RasterLibrary.wakeUp(); |
|
38 |
} |
|
39 |
|
|
40 |
@Override |
|
41 |
protected void doPostInitialize() throws LibraryException { |
|
42 |
// Registro de los drivers de lectura |
|
43 |
GdalDriver.register(); |
|
44 |
ErmapperDriver.register(); |
|
45 |
MrSidDriver.register(); |
|
46 |
MemoryRasterDriver.register(); |
|
47 |
|
|
48 |
// Registro de los drivers de escritura |
|
49 |
GdalWriter.register(); |
|
50 |
ErmapperWriter.register(); |
|
51 |
JpegWriter.register(); |
|
52 |
PngWriter.register(); |
|
53 |
} |
|
54 |
} |
|
0 | 55 |
tags/v2_0_0_Build_2020/libraries/libRaster_io/src/org/gvsig/fmap/dal/coverage/dataset/io/JpegWriter.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2008 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.fmap.dal.coverage.dataset.io; |
|
20 |
|
|
21 |
import java.awt.geom.AffineTransform; |
|
22 |
import java.io.File; |
|
23 |
import java.io.IOException; |
|
24 |
|
|
25 |
import org.cresques.cts.IProjection; |
|
26 |
import org.gvsig.fmap.dal.coverage.dataset.io.features.JpegFeatures; |
|
27 |
import org.gvsig.raster.dataset.GeoRasterWriter; |
|
28 |
import org.gvsig.raster.dataset.IDataWriter; |
|
29 |
import org.gvsig.raster.dataset.Params; |
|
30 |
import org.gvsig.raster.dataset.WriteFileFormatFeatures; |
|
31 |
import org.gvsig.raster.util.RasterUtilities; |
|
32 |
import org.gvsig.tools.ToolsLocator; |
|
33 |
import org.gvsig.tools.extensionpoint.ExtensionPoint; |
|
34 |
import org.gvsig.tools.extensionpoint.ExtensionPointManager; |
|
35 |
|
|
36 |
import es.gva.cit.jgdal.Gdal; |
|
37 |
import es.gva.cit.jgdal.GdalDriver; |
|
38 |
import es.gva.cit.jgdal.GdalException; |
|
39 |
/** |
|
40 |
* Driver para la escritura de Jpeg. |
|
41 |
* Este driver utiliza GdalWriter para salvar Jpeg. |
|
42 |
* La escritura de un jpeg no es posible utilizando un servidor de datos |
|
43 |
* como el que usan los drivers comunes por lo que ser? necesario salvar antes |
|
44 |
* a Tif con el driver de Gdal para posteriormente convertir la imagen completa |
|
45 |
* a jpg. |
|
46 |
* |
|
47 |
* @version 22/07/2008 |
|
48 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
49 |
*/ |
|
50 |
public class JpegWriter extends GeoRasterWriter { |
|
51 |
|
|
52 |
// Datos de registro de drivers |
|
53 |
public static void register() { |
|
54 |
ExtensionPointManager extensionPoints =ToolsLocator.getExtensionPointManager(); |
|
55 |
ExtensionPoint point=extensionPoints.get("RasterWriter"); |
|
56 |
point.append("jpg", "", JpegWriter.class); |
|
57 |
fileFeature.put("jpg", new JpegFeatures()); |
|
58 |
} |
|
59 |
|
|
60 |
private GdalWriter gdalWriter = null; |
|
61 |
private String outTif = null; |
|
62 |
private String outJpg = null; |
|
63 |
|
|
64 |
/** |
|
65 |
* Carga los par?metros de este driver. |
|
66 |
*/ |
|
67 |
public void loadParams(String ident) { |
|
68 |
WriteFileFormatFeatures wfff = (WriteFileFormatFeatures) fileFeature.get(ident); |
|
69 |
wfff.loadParams(); |
|
70 |
driverParams = wfff.getParams(); |
|
71 |
} |
|
72 |
|
|
73 |
/** |
|
74 |
* Constructor para la obtenci?n de par?metros del driver |
|
75 |
* @param drvType Tipo de driver |
|
76 |
*/ |
|
77 |
public JpegWriter(String fileName) { |
|
78 |
ident = RasterUtilities.getExtensionFromFileName(fileName); |
|
79 |
driver = ((WriteFileFormatFeatures) fileFeature.get(ident)).getDriverName(); |
|
80 |
gdalWriter = new GdalWriter(fileName); |
|
81 |
|
|
82 |
loadParams(ident); |
|
83 |
} |
|
84 |
|
|
85 |
/** |
|
86 |
* Constructor para salvar datos servidos por el cliente |
|
87 |
* @param dataWriter Objeto servidor de datos para el driver de escritura |
|
88 |
* @param outSizeX N?mero de pixels en X de la imagen de salida |
|
89 |
* @param outSizeY N?mero de pixels en Y de la imagen de salida |
|
90 |
* @param outFilename Fichero de salida |
|
91 |
* @param extentMaxX Posici?n en X m?xima del extent |
|
92 |
* @param extentMinX Posici?n en X m?nima del extent |
|
93 |
* @param extentMaxY Posici?n en Y m?xima del extent |
|
94 |
* @param extentMinY Posici?n en Y m?nima del extent |
|
95 |
* @param nBands N?mero de bandas |
|
96 |
* @param drvType Tipo de driver |
|
97 |
* @throws GdalException |
|
98 |
* @throws IOException |
|
99 |
*/ |
|
100 |
public JpegWriter(IDataWriter dataWriter, |
|
101 |
String outFileName, |
|
102 |
Integer nBands, |
|
103 |
AffineTransform at, |
|
104 |
Integer outSizeX, |
|
105 |
Integer outSizeY, |
|
106 |
Integer dataType, |
|
107 |
Params params, |
|
108 |
IProjection proj, |
|
109 |
Boolean geo)throws GdalException, IOException { |
|
110 |
ident = RasterUtilities.getExtensionFromFileName(outFileName); |
|
111 |
driver = ((WriteFileFormatFeatures) fileFeature.get(ident)).getDriverName(); |
|
112 |
outJpg = outFileName; |
|
113 |
outTif = outFileName.substring(0, outFileName.lastIndexOf(".")); |
|
114 |
outTif += ".tif"; |
|
115 |
|
|
116 |
gdalWriter = new GdalWriter(dataWriter, outTif, nBands, at, outSizeX, outSizeY, dataType, params, proj, geo); |
|
117 |
if (params == null) |
|
118 |
loadParams(ident); |
|
119 |
else |
|
120 |
this.driverParams = params; |
|
121 |
} |
|
122 |
|
|
123 |
/** |
|
124 |
* Asigna el tipo de driver con el que se salvar? la imagen |
|
125 |
* @param drvType Tipo de driver |
|
126 |
*/ |
|
127 |
public void setDriverType(String drvType) { |
|
128 |
gdalWriter.setDriverType(drvType); |
|
129 |
} |
|
130 |
|
|
131 |
/** |
|
132 |
* Realiza la funci?n de compresi?n a partir de un GeoRasterFile. |
|
133 |
* @throws IOException |
|
134 |
*/ |
|
135 |
public void fileWrite() throws IOException, InterruptedException { |
|
136 |
gdalWriter.fileWrite(); |
|
137 |
} |
|
138 |
|
|
139 |
/** |
|
140 |
* Realiza una copia en el formato especificado. |
|
141 |
* @throws IOException |
|
142 |
*/ |
|
143 |
public static void createCopy(GdalDriver driverDst, String dst, String src, boolean bstrict, String[] params, IProjection proj) throws IOException, GdalException { |
|
144 |
GdalWriter.createCopy(driverDst, dst, src, bstrict, params, proj); |
|
145 |
} |
|
146 |
|
|
147 |
/** |
|
148 |
* Realiza la escritura de datos con los datos que le pasa el cliente. |
|
149 |
* @throws IOException |
|
150 |
*/ |
|
151 |
public void dataWrite() throws IOException, InterruptedException { |
|
152 |
if (colorInterp != null) |
|
153 |
gdalWriter.setColorBandsInterpretation(colorInterp.getValues()); |
|
154 |
gdalWriter.dataWrite(); |
|
155 |
if (gdalWriter.isWrite()) { |
|
156 |
gdalWriter.writeClose(); |
|
157 |
if (outTif != null) { |
|
158 |
GdalDriver driver = null; |
|
159 |
try { |
|
160 |
driver = Gdal.getDriverByName("JPEG"); |
|
161 |
GdalWriter.createCopy(driver, outJpg, outTif, false, gdalWriter.gdalParamsFromRasterParams(driverParams), null); |
|
162 |
} catch (GdalException exc) { |
|
163 |
throw new IOException("No se ha podido obtener el driver."); |
|
164 |
} |
|
165 |
File file = new File(outTif); |
|
166 |
file.delete(); |
|
167 |
} |
|
168 |
} |
|
169 |
} |
|
170 |
|
|
171 |
/** |
|
172 |
* Cancela el salvado de datos. |
|
173 |
*/ |
|
174 |
public void writeCancel() { |
|
175 |
gdalWriter.setWrite(false); |
|
176 |
} |
|
177 |
|
|
178 |
/* |
|
179 |
* (non-Javadoc) |
|
180 |
* @see org.gvsig.raster.dataset.GeoRasterWriter#setParams(org.gvsig.raster.dataset.Params) |
|
181 |
*/ |
|
182 |
public void setParams(Params params) { |
|
183 |
driverParams = params; |
|
184 |
if (gdalWriter != null) |
|
185 |
gdalWriter.setParams(params); |
|
186 |
} |
|
187 |
|
|
188 |
/** |
|
189 |
* Cierra el compresor ecw. |
|
190 |
* @throws GdalException |
|
191 |
*/ |
|
192 |
public void writeClose() { |
|
193 |
// El close del tif se hizo en dataWrite |
|
194 |
} |
|
195 |
|
|
196 |
public void setWkt(String wkt) {} |
|
197 |
} |
tags/v2_0_0_Build_2020/libraries/libRaster_io/src/org/gvsig/fmap/dal/coverage/dataset/io/GdalDriver.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2006 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.fmap.dal.coverage.dataset.io; |
|
20 |
|
|
21 |
import java.awt.geom.AffineTransform; |
|
22 |
import java.awt.geom.Point2D; |
|
23 |
import java.awt.geom.Rectangle2D; |
|
24 |
import java.io.BufferedReader; |
|
25 |
import java.io.File; |
|
26 |
import java.io.FileNotFoundException; |
|
27 |
import java.io.FileReader; |
|
28 |
import java.io.IOException; |
|
29 |
|
|
30 |
import org.cresques.cts.ICoordTrans; |
|
31 |
import org.cresques.cts.IProjection; |
|
32 |
import org.gvsig.raster.dataset.BandAccessException; |
|
33 |
import org.gvsig.raster.dataset.BandList; |
|
34 |
import org.gvsig.raster.dataset.FileNotOpenException; |
|
35 |
import org.gvsig.raster.dataset.GeoInfo; |
|
36 |
import org.gvsig.raster.dataset.IBuffer; |
|
37 |
import org.gvsig.raster.dataset.InvalidSetViewException; |
|
38 |
import org.gvsig.raster.dataset.NotSupportedExtensionException; |
|
39 |
import org.gvsig.raster.dataset.RasterDataset; |
|
40 |
import org.gvsig.raster.dataset.RasterDriverException; |
|
41 |
import org.gvsig.raster.dataset.properties.DatasetColorInterpretation; |
|
42 |
import org.gvsig.raster.dataset.properties.DatasetMetadata; |
|
43 |
import org.gvsig.raster.dataset.rmf.ParsingException; |
|
44 |
import org.gvsig.raster.datastruct.Extent; |
|
45 |
import org.gvsig.raster.datastruct.Transparency; |
|
46 |
import org.gvsig.raster.util.RasterUtilities; |
|
47 |
import org.gvsig.tools.ToolsLocator; |
|
48 |
import org.gvsig.tools.extensionpoint.ExtensionPoint; |
|
49 |
import org.gvsig.tools.extensionpoint.ExtensionPointManager; |
|
50 |
|
|
51 |
import es.gva.cit.jgdal.GdalException; |
|
52 |
/** |
|
53 |
* Clase que representa al driver de acceso a datos de gdal. |
|
54 |
* |
|
55 |
* @author Luis W. Sevilla |
|
56 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
57 |
*/ |
|
58 |
public class GdalDriver extends RasterDataset { |
|
59 |
public static final String FORMAT_GTiff = "GTiff"; |
|
60 |
public static final String FORMAT_VRT = "VRT"; |
|
61 |
public static final String FORMAT_NITF = "NITF"; |
|
62 |
public static final String FORMAT_HFA = "HFA"; |
|
63 |
public static final String FORMAT_ELAS = "ELAS"; |
|
64 |
public static final String FORMAT_MEM = "MEM"; |
|
65 |
public static final String FORMAT_BMP = "BMP"; |
|
66 |
public static final String FORMAT_PCIDSK = "PCIDSK"; |
|
67 |
public static final String FORMAT_ILWIS = "ILWIS"; |
|
68 |
public static final String FORMAT_HDF4 = "HDF4Image"; |
|
69 |
public static final String FORMAT_PNM = "PNM"; |
|
70 |
public static final String FORMAT_ENVI = "ENVI"; |
|
71 |
public static final String FORMAT_EHDR = "EHdr"; |
|
72 |
public static final String FORMAT_PAUX = "PAux"; |
|
73 |
public static final String FORMAT_MFF = "MFF"; |
|
74 |
public static final String FORMAT_MFF2 = "MFF2"; |
|
75 |
public static final String FORMAT_BT = "BT"; |
|
76 |
public static final String FORMAT_IDA = "IDA"; |
|
77 |
public static final String FORMAT_RMF = "RMF"; |
|
78 |
public static final String FORMAT_RST = "RST"; |
|
79 |
public static final String FORMAT_LEVELLER = "Leveller"; |
|
80 |
public static final String FORMAT_TERRAGEN = "Terragen"; |
|
81 |
public static final String FORMAT_ERS = "ERS"; |
|
82 |
public static final String FORMAT_INGR = "INGR"; |
|
83 |
public static final String FORMAT_GSAG = "GSAG"; |
|
84 |
public static final String FORMAT_GSBG = "GSBG"; |
|
85 |
public static final String FORMAT_ADRG = "ADRG"; |
|
86 |
public static final int BAND_HEIGHT = 64; |
|
87 |
protected GdalNative file = null; |
|
88 |
|
|
89 |
|
|
90 |
public GdalDriver(){super(null, null);} |
|
91 |
|
|
92 |
private Extent viewRequest = null; |
|
93 |
|
|
94 |
public static void register() { |
|
95 |
ExtensionPointManager extensionPoints = ToolsLocator.getExtensionPointManager(); |
|
96 |
ExtensionPoint point = extensionPoints.get("RasterReader"); |
|
97 |
|
|
98 |
point.append("bmp", "", GdalDriver.class); |
|
99 |
point.append("gif", "", GdalDriver.class); |
|
100 |
point.append("tif", "", GdalDriver.class); |
|
101 |
point.append("tiff", "", GdalDriver.class); |
|
102 |
point.append("jpg", "", GdalDriver.class); |
|
103 |
point.append("jpeg", "", GdalDriver.class); |
|
104 |
point.append("png", "", GdalDriver.class); |
|
105 |
point.append("vrt", "", GdalDriver.class); |
|
106 |
point.append("dat", "", GdalDriver.class); // Envi |
|
107 |
point.append("lan", "", GdalDriver.class); // Erdas |
|
108 |
point.append("gis", "", GdalDriver.class); // Erdas |
|
109 |
point.append("img", "", GdalDriver.class); // Erdas |
|
110 |
point.append("pix", "", GdalDriver.class); // PCI Geomatics |
|
111 |
point.append("aux", "", GdalDriver.class); // PCI Geomatics |
|
112 |
point.append("adf", "", GdalDriver.class); // ESRI Grids |
|
113 |
point.append("mpr", "", GdalDriver.class); // Ilwis |
|
114 |
point.append("mpl", "", GdalDriver.class); // Ilwis |
|
115 |
point.append("map", "", GdalDriver.class); // PC Raster |
|
116 |
point.append("asc", "", GdalDriver.class); |
|
117 |
point.append("pgm", "", GdalDriver.class); //Ficheros PNM en escala de grises |
|
118 |
point.append("ppm", "", GdalDriver.class); //Ficheros PNM en RGB |
|
119 |
point.append("rst", "", GdalDriver.class); //IDRISIS |
|
120 |
point.append("rmf", "", GdalDriver.class); //Raster Matrix Format |
|
121 |
point.append("nos", "", GdalDriver.class); |
|
122 |
point.append("kap", "", GdalDriver.class); |
|
123 |
point.append("hdr", "", GdalDriver.class); |
|
124 |
point.append("raw", "", GdalDriver.class); |
|
125 |
point.append("ers", "", GdalDriver.class); |
|
126 |
|
|
127 |
point = extensionPoints.get("DefaultDriver"); |
|
128 |
point.append("reader", "", GdalDriver.class); |
|
129 |
} |
|
130 |
|
|
131 |
/** |
|
132 |
* Constructor del driver de Gdal. Crea las referencias al fichero y carga |
|
133 |
* las estructuras con la informaci?n y los metadatos. |
|
134 |
* @param proj Proyecci?n |
|
135 |
* @param param Parametros de carga |
|
136 |
* @throws NotSupportedExtensionException |
|
137 |
*/ |
|
138 |
public GdalDriver(IProjection proj, Object param)throws NotSupportedExtensionException { |
|
139 |
super(proj, param); |
|
140 |
try { |
|
141 |
if(param instanceof String) { |
|
142 |
setParam(translateFileName((String)param)); |
|
143 |
validRmf(((String)param)); |
|
144 |
file = new GdalNative(translateFileName((String)param)); |
|
145 |
setColorTable(file.palette); |
|
146 |
noData = file.getNoDataValue(); |
|
147 |
wktProjection = file.getProjectionRef(); |
|
148 |
noDataEnabled = file.existsNoDataValue(); |
|
149 |
ownTransformation = file.getOwnTransformation(); |
|
150 |
externalTransformation = (AffineTransform)ownTransformation.clone(); |
|
151 |
load(); |
|
152 |
} else |
|
153 |
setParam(param); |
|
154 |
//TODO: FUNCIONALIDAD: Formatos gestionados por gdal que no tienen extensi?n. Estos tendr?n un objeto IRegistrableRasterFormat Por ej: Grass |
|
155 |
bandCount = file.getRasterCount(); |
|
156 |
} catch (GdalException e) { |
|
157 |
e.printStackTrace(); |
|
158 |
throw new NotSupportedExtensionException("Extension not supported"); |
|
159 |
} catch(Exception e) { |
|
160 |
System.out.println("Error en GdalOpen"); |
|
161 |
e.printStackTrace(); |
|
162 |
file = null; |
|
163 |
} |
|
164 |
|
|
165 |
//Obtenemos el tipo de dato de gdal y lo convertimos el de RasterBuf |
|
166 |
int[] dt = new int[file.getDataType().length]; |
|
167 |
for (int i = 0; i < dt.length; i++) |
|
168 |
dt[i] = RasterUtilities.getRasterBufTypeFromGdalType(file.getDataType()[i]); |
|
169 |
setDataType(dt); |
|
170 |
|
|
171 |
super.init(); |
|
172 |
|
|
173 |
try { |
|
174 |
loadFromRmf(getRmfBlocksManager()); |
|
175 |
} catch (ParsingException e) { |
|
176 |
//No lee desde rmf |
|
177 |
} |
|
178 |
} |
|
179 |
|
|
180 |
/** |
|
181 |
* Comprueba si el fichero abierto es un RasterMetaFile o una imagen |
|
182 |
* raster. |
|
183 |
* @throws GdalException |
|
184 |
*/ |
|
185 |
private void validRmf(String file) throws GdalException { |
|
186 |
if(file.endsWith(".rmf")) { |
|
187 |
File f = new File(file); |
|
188 |
FileReader fr; |
|
189 |
try { |
|
190 |
fr = new FileReader(f); |
|
191 |
BufferedReader br = new BufferedReader(fr); |
|
192 |
char[] buffer = new char[5]; |
|
193 |
br.read(buffer); |
|
194 |
StringBuffer st = new StringBuffer(new String(buffer)); |
|
195 |
if(st.toString().equals("<?xml")) |
|
196 |
throw new GdalException("RasterMetaFile"); |
|
197 |
} catch (FileNotFoundException e) { |
|
198 |
throw new GdalException("File Not Found"); |
|
199 |
} catch (IOException e) { |
|
200 |
throw new GdalException(""); |
|
201 |
} |
|
202 |
} |
|
203 |
} |
|
204 |
/** |
|
205 |
* Obtenemos o calculamos el extent de la imagen. |
|
206 |
*/ |
|
207 |
public GeoInfo load() { |
|
208 |
return this; |
|
209 |
} |
|
210 |
|
|
211 |
/** |
|
212 |
* Cierra el fichero de imagen |
|
213 |
*/ |
|
214 |
public void close() { |
|
215 |
try { |
|
216 |
if(file != null){ |
|
217 |
file.close(); |
|
218 |
file = null; |
|
219 |
} |
|
220 |
viewRequest = null; |
|
221 |
} catch (GdalException e) { |
|
222 |
e.printStackTrace(); |
|
223 |
} |
|
224 |
} |
|
225 |
|
|
226 |
/* |
|
227 |
* (non-Javadoc) |
|
228 |
* @see org.gvsig.raster.dataset.RasterDataset#translateFileName(java.lang.String) |
|
229 |
*/ |
|
230 |
public String translateFileName(String fileName) { |
|
231 |
if(fileName.endsWith("hdr")) |
|
232 |
return fileName.substring(0, fileName.lastIndexOf(".")); |
|
233 |
return fileName; |
|
234 |
} |
|
235 |
|
|
236 |
/** |
|
237 |
* Asigna el extent de la vista actual. existe un fichero .rmf debemos hacer una transformaci?n |
|
238 |
* de la vista asignada ya que la petici?n viene en coordenadas del fichero .rmf y la vista (v) |
|
239 |
* ha de estar en coordenadas del fichero. |
|
240 |
*/ |
|
241 |
public void setView(Extent e) { |
|
242 |
viewRequest = e; |
|
243 |
} |
|
244 |
|
|
245 |
/** |
|
246 |
* Obtiene extent de la vista actual |
|
247 |
*/ |
|
248 |
public Extent getView() { |
|
249 |
return viewRequest; |
|
250 |
} |
|
251 |
|
|
252 |
/** |
|
253 |
* Obtiene la anchura del fichero |
|
254 |
*/ |
|
255 |
public int getWidth() { |
|
256 |
return file.width; |
|
257 |
} |
|
258 |
|
|
259 |
/** |
|
260 |
* Obtiene la altura del fichero |
|
261 |
*/ |
|
262 |
public int getHeight() { |
|
263 |
return file.height; |
|
264 |
} |
|
265 |
|
|
266 |
/* |
|
267 |
* (non-Javadoc) |
|
268 |
* @see org.gvsig.fmap.driver.GeoRasterFile#readCompletetLine(int, int) |
|
269 |
*/ |
|
270 |
public Object readCompleteLine(int line, int band)throws InvalidSetViewException, FileNotOpenException, RasterDriverException { |
|
271 |
if(line > this.getHeight() || band > this.getBandCount()) |
|
272 |
throw new InvalidSetViewException("Request out of grid"); |
|
273 |
|
|
274 |
try{ |
|
275 |
return file.readCompleteLine(line, band); |
|
276 |
}catch(GdalException e){ |
|
277 |
throw new RasterDriverException("Error reading data from Gdal library"); |
|
278 |
} |
|
279 |
} |
|
280 |
|
|
281 |
/* |
|
282 |
* (non-Javadoc) |
|
283 |
* @see org.gvsig.raster.dataset.RasterDataset#readBlock(int, int) |
|
284 |
*/ |
|
285 |
public Object readBlock(int pos, int blockHeight) |
|
286 |
throws InvalidSetViewException, FileNotOpenException, RasterDriverException, InterruptedException { |
|
287 |
if(pos < 0) |
|
288 |
throw new InvalidSetViewException("Request out of grid"); |
|
289 |
|
|
290 |
if((pos + blockHeight) > getHeight()) |
|
291 |
blockHeight = Math.abs(getHeight() - pos); |
|
292 |
try{ |
|
293 |
return file.readBlock(pos, blockHeight); |
|
294 |
}catch(GdalException e){ |
|
295 |
throw new RasterDriverException("Error reading data from Gdal library"); |
|
296 |
} |
|
297 |
} |
|
298 |
|
|
299 |
/* (non-Javadoc) |
|
300 |
* @see org.cresques.io.GeoRasterFile#getData(int, int, int) |
|
301 |
*/ |
|
302 |
public Object getData(int x, int y, int band)throws InvalidSetViewException, FileNotOpenException, RasterDriverException { |
|
303 |
if(file != null){ |
|
304 |
if(x < 0 || y < 0 || x >= file.width || y >= file.height) |
|
305 |
throw new InvalidSetViewException("Request out of grid"); |
|
306 |
Object[] data = file.getData(x, y); |
|
307 |
return data[band]; |
|
308 |
} |
|
309 |
throw new FileNotOpenException("GdalNative not exist"); |
|
310 |
} |
|
311 |
|
|
312 |
/* |
|
313 |
* (non-Javadoc) |
|
314 |
* @see org.gvsig.raster.dataset.RasterDataset#getWindowRaster(double, double, double, double, org.gvsig.raster.dataset.BandList, org.gvsig.raster.dataset.IBuffer) |
|
315 |
*/ |
|
316 |
public IBuffer getWindowRaster(double ulx, double uly, double lrx, double lry, BandList bandList, IBuffer rasterBuf) throws InterruptedException, RasterDriverException { |
|
317 |
Extent selectedExtent = new Extent(ulx, uly, lrx, lry); |
|
318 |
setView(selectedExtent); |
|
319 |
|
|
320 |
try { |
|
321 |
file.readWindow(rasterBuf, bandList, viewRequest.getULX(), viewRequest.getULY(), viewRequest.getLRX(), viewRequest.getLRY(), rasterBuf.getWidth(), rasterBuf.getHeight(), true); |
|
322 |
} catch (GdalException e) { |
|
323 |
throw new RasterDriverException("Error reading data"); |
|
324 |
} |
|
325 |
|
|
326 |
return rasterBuf; |
|
327 |
} |
|
328 |
|
|
329 |
/* |
|
330 |
* (non-Javadoc) |
|
331 |
* @see org.gvsig.fmap.driver.GeoRasterFile#getWindowRaster(double, double, double, double, org.gvsig.fmap.driver.BandList, org.gvsig.fmap.driver.IBuffer) |
|
332 |
*/ |
|
333 |
public IBuffer getWindowRaster(double ulx, double uly, double w, double h, BandList bandList, IBuffer rasterBuf, boolean adjustToExtent) throws InterruptedException, RasterDriverException { |
|
334 |
//El incremento o decremento de las X e Y depende de los signos de rotaci?n y escala en la matriz de transformaci?n. Por esto |
|
335 |
//tenemos que averiguar si lrx es x + w o x -w, asi como si lry es y + h o y - h |
|
336 |
Extent ext = getExtent(); |
|
337 |
Point2D pInit = rasterToWorld(new Point2D.Double(0, 0)); |
|
338 |
Point2D pEnd = rasterToWorld(new Point2D.Double(getWidth(), getHeight())); |
|
339 |
double wRaster = Math.abs(pEnd.getX() - pInit.getX()); |
|
340 |
double hRaster = Math.abs(pEnd.getY() - pInit.getY()); |
|
341 |
double lrx = (((ext.getULX() - wRaster) > ext.maxX()) || ((ext.getULX() - wRaster) < ext.minX())) ? (ulx + w) : (ulx - w); |
|
342 |
double lry = (((ext.getULY() - hRaster) > ext.maxY()) || ((ext.getULY() - hRaster) < ext.minY())) ? (uly + h) : (uly - h); |
|
343 |
|
|
344 |
Extent selectedExtent = new Extent(ulx, uly, lrx, lry); |
|
345 |
setView(selectedExtent); |
|
346 |
|
|
347 |
try { |
|
348 |
file.readWindow(rasterBuf, bandList, viewRequest.getULX(), viewRequest.getULY(), viewRequest.getLRX(), viewRequest.getLRY(), rasterBuf.getWidth(), rasterBuf.getHeight(), adjustToExtent); |
|
349 |
} catch (GdalException e) { |
|
350 |
throw new RasterDriverException("Error reading data"); |
|
351 |
} |
|
352 |
|
|
353 |
return rasterBuf; |
|
354 |
} |
|
355 |
|
|
356 |
/* |
|
357 |
* (non-Javadoc) |
|
358 |
* @see org.gvsig.fmap.driver.GeoRasterFile#getWindowRaster(double, double, double, double, int, int, org.gvsig.fmap.driver.BandList, org.gvsig.fmap.driver.IBuffer) |
|
359 |
*/ |
|
360 |
public IBuffer getWindowRaster(double minX, double minY, double maxX, double maxY, int bufWidth, int bufHeight, BandList bandList, IBuffer rasterBuf, boolean adjustToExtent) throws InterruptedException, RasterDriverException { |
|
361 |
Extent selectedExtent = new Extent(minX, minY, maxX, maxY); |
|
362 |
setView(selectedExtent); |
|
363 |
|
|
364 |
double width = 0; |
|
365 |
double height = 0; |
|
366 |
|
|
367 |
Point2D ul = new Point2D.Double(viewRequest.getULX(), viewRequest.getULY()); |
|
368 |
Point2D lr = new Point2D.Double(viewRequest.getLRX(), viewRequest.getLRY()); |
|
369 |
ul = worldToRaster(ul); |
|
370 |
lr = worldToRaster(lr); |
|
371 |
width = Math.abs(lr.getX() - ul.getX()); |
|
372 |
height = Math.abs(lr.getY() - ul.getY()); |
|
373 |
|
|
374 |
try { |
|
375 |
file.readWindow(rasterBuf, bandList, viewRequest.getULX(), viewRequest.getULY(), viewRequest.getLRX(), viewRequest.getLRY(), width, height, bufWidth, bufHeight, adjustToExtent); |
|
376 |
} catch (GdalException e) { |
|
377 |
throw new RasterDriverException("Error reading data"); |
|
378 |
} |
|
379 |
|
|
380 |
return rasterBuf; |
|
381 |
} |
|
382 |
|
|
383 |
/* |
|
384 |
* (non-Javadoc) |
|
385 |
* @see org.gvsig.fmap.driver.GeoRasterFile#getWindowRaster(int, int, int, int, org.gvsig.fmap.driver.BandList, org.gvsig.fmap.driver.IBuffer) |
|
386 |
*/ |
|
387 |
public IBuffer getWindowRaster(int x, int y, int w, int h, BandList bandList, IBuffer rasterBuf) throws InterruptedException, RasterDriverException { |
|
388 |
try { |
|
389 |
setView( |
|
390 |
new Extent( RasterUtilities.getMapRectFromPxRect(getExtent().toRectangle2D(), |
|
391 |
getWidth(), |
|
392 |
getHeight(), |
|
393 |
new Rectangle2D.Double(x, y, w, h))) |
|
394 |
); |
|
395 |
file.readWindow(rasterBuf, bandList, x, y, w, h); |
|
396 |
} catch (GdalException e) { |
|
397 |
throw new RasterDriverException("Error reading data"); |
|
398 |
} |
|
399 |
return rasterBuf; |
|
400 |
} |
|
401 |
|
|
402 |
/* |
|
403 |
* (non-Javadoc) |
|
404 |
* @see org.gvsig.fmap.driver.GeoRasterFile#getWindowRaster(int, int, int, int, int, int, org.gvsig.fmap.driver.BandList, org.gvsig.fmap.driver.IBuffer) |
|
405 |
*/ |
|
406 |
public IBuffer getWindowRaster(int x, int y, int w, int h, int bufWidth, int bufHeight, BandList bandList, IBuffer rasterBuf) throws InterruptedException, RasterDriverException { |
|
407 |
try { |
|
408 |
setView( |
|
409 |
new Extent( RasterUtilities.getMapRectFromPxRect(getExtent().toRectangle2D(), |
|
410 |
getWidth(), |
|
411 |
getHeight(), |
|
412 |
new Rectangle2D.Double(x, y, w, h))) |
|
413 |
); |
|
414 |
file.readWindow(rasterBuf, bandList, x, y, w, h, bufWidth, bufHeight); |
|
415 |
} catch (GdalException e) { |
|
416 |
throw new RasterDriverException("Error reading data"); |
|
417 |
} |
|
418 |
return rasterBuf; |
|
419 |
} |
|
420 |
|
|
421 |
/** |
|
422 |
* Devuelve el tama?o de bloque |
|
423 |
* @return Tama?o de bloque |
|
424 |
*/ |
|
425 |
public int getBlockSize(){ |
|
426 |
if(file != null) |
|
427 |
return file.getBlockSize(); |
|
428 |
else |
|
429 |
return 0; |
|
430 |
} |
|
431 |
|
|
432 |
/** |
|
433 |
* Obtiene el objeto que contiene los metadatos |
|
434 |
*/ |
|
435 |
public DatasetMetadata getMetadata() { |
|
436 |
if(file != null) |
|
437 |
return file.metadata; |
|
438 |
else |
|
439 |
return null; |
|
440 |
} |
|
441 |
|
|
442 |
/** |
|
443 |
* Obtiene el objeto que contiene que contiene la interpretaci?n de |
|
444 |
* color por banda |
|
445 |
* @return |
|
446 |
*/ |
|
447 |
public DatasetColorInterpretation getColorInterpretation(){ |
|
448 |
if(file != null) |
|
449 |
return file.colorInterpr; |
|
450 |
return null; |
|
451 |
} |
|
452 |
|
|
453 |
/** |
|
454 |
* Asigna el objeto que contiene que contiene la interpretaci?n de |
|
455 |
* color por banda |
|
456 |
* @param DatasetColorInterpretation |
|
457 |
*/ |
|
458 |
public void setColorInterpretation(DatasetColorInterpretation colorInterpretation){ |
|
459 |
if(file != null) |
|
460 |
file.colorInterpr = colorInterpretation; |
|
461 |
} |
|
462 |
|
|
463 |
/** |
|
464 |
* Obtiene el objeto que contiene el estado de la transparencia |
|
465 |
*/ |
|
466 |
public Transparency getTransparencyDatasetStatus() { |
|
467 |
return file.fileTransparency; |
|
468 |
} |
|
469 |
|
|
470 |
/** |
|
471 |
* Obtiene el flag que dice si la imagen est? o no georreferenciada |
|
472 |
* @return true si est? georreferenciada y false si no lo est?. |
|
473 |
*/ |
|
474 |
public boolean isGeoreferenced() { |
|
475 |
if(file != null) |
|
476 |
return file.georeferenced; |
|
477 |
else |
|
478 |
return false; |
|
479 |
} |
|
480 |
|
|
481 |
/** |
|
482 |
* Informa de si el driver ha supersampleado en el ?ltimo dibujado. Es el driver el que colocar? |
|
483 |
* el valor de esta variable cada vez que dibuja. |
|
484 |
* @return true si se ha supersampleado y false si no se ha hecho. |
|
485 |
*/ |
|
486 |
public boolean isSupersampling() { |
|
487 |
if(file != null) |
|
488 |
return file.isSupersampling; |
|
489 |
else |
|
490 |
return false; |
|
491 |
} |
|
492 |
|
|
493 |
public GdalNative getNative(){ |
|
494 |
return file; |
|
495 |
} |
|
496 |
|
|
497 |
/** |
|
498 |
* Obtiene el nombre del driver |
|
499 |
*/ |
|
500 |
public String getName() { |
|
501 |
return "gvSIG Gdal Raster Driver"; |
|
502 |
} |
|
503 |
|
|
504 |
public void reProject(ICoordTrans rp) { |
|
505 |
} |
|
506 |
|
|
507 |
/* |
|
508 |
* (non-Javadoc) |
|
509 |
* @see org.gvsig.raster.dataset.RasterDataset#setAffineTransform(java.awt.geom.AffineTransform) |
|
510 |
*/ |
|
511 |
public void setAffineTransform(AffineTransform t){ |
|
512 |
super.setAffineTransform(t); |
|
513 |
file.setExternalTransform(t); |
|
514 |
} |
|
515 |
|
|
516 |
/* |
|
517 |
* (non-Javadoc) |
|
518 |
* @see org.gvsig.raster.dataset.RasterDataset#getOverviewCount(int) |
|
519 |
*/ |
|
520 |
public int getOverviewCount(int band) throws BandAccessException, RasterDriverException { |
|
521 |
if(band >= getBandCount()) |
|
522 |
throw new BandAccessException("Wrong band"); |
|
523 |
try { |
|
524 |
return file.getRasterBand(band + 1).getOverviewCount(); |
|
525 |
} catch (GdalException e) { |
|
526 |
throw new RasterDriverException(""); |
|
527 |
} |
|
528 |
} |
|
529 |
|
|
530 |
/* |
|
531 |
* (non-Javadoc) |
|
532 |
* @see org.gvsig.raster.dataset.RasterDataset#getOverviewWidth(int, int) |
|
533 |
*/ |
|
534 |
public int getOverviewWidth(int band, int overview) throws BandAccessException, RasterDriverException { |
|
535 |
if (band >= getBandCount()) |
|
536 |
throw new BandAccessException("Wrong band"); |
|
537 |
try { |
|
538 |
if (overview >= file.getRasterBand(band + 1).getOverviewCount()) |
|
539 |
throw new BandAccessException("Wrong overview count"); |
|
540 |
return file.getRasterBand(band + 1).getOverview(overview).getRasterBandXSize(); |
|
541 |
} catch (GdalException e) { |
|
542 |
throw new RasterDriverException(""); |
|
543 |
} |
|
544 |
} |
|
545 |
|
|
546 |
/* |
|
547 |
* (non-Javadoc) |
|
548 |
* @see org.gvsig.raster.dataset.RasterDataset#getOverviewWidth(int, int) |
|
549 |
*/ |
|
550 |
public int getOverviewHeight(int band, int overview) throws BandAccessException, RasterDriverException { |
|
551 |
if (band >= getBandCount()) |
|
552 |
throw new BandAccessException("Wrong band"); |
|
553 |
try { |
|
554 |
if (overview >= file.getRasterBand(band + 1).getOverviewCount()) |
|
555 |
throw new BandAccessException("Wrong overview count"); |
|
556 |
return file.getRasterBand(band + 1).getOverview(overview).getRasterBandYSize(); |
|
557 |
} catch (GdalException e) { |
|
558 |
throw new RasterDriverException(""); |
|
559 |
} |
|
560 |
} |
|
561 |
|
|
562 |
/* |
|
563 |
* (non-Javadoc) |
|
564 |
* @see org.gvsig.raster.dataset.RasterDataset#overviewsSupport() |
|
565 |
*/ |
|
566 |
public boolean overviewsSupport() { |
|
567 |
return true; |
|
568 |
} |
|
569 |
|
|
570 |
/* |
|
571 |
* (non-Javadoc) |
|
572 |
* @see org.gvsig.raster.dataset.RasterDataset#isReproyectable() |
|
573 |
*/ |
|
574 |
public boolean isReproyectable() { |
|
575 |
return true; |
|
576 |
} |
|
577 |
} |
tags/v2_0_0_Build_2020/libraries/libRaster_io/src/org/gvsig/fmap/dal/coverage/dataset/io/GdalWriter.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2006 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.fmap.dal.coverage.dataset.io; |
|
20 |
|
|
21 |
import java.awt.geom.AffineTransform; |
|
22 |
import java.awt.geom.Point2D; |
|
23 |
import java.io.IOException; |
|
24 |
import java.util.ArrayList; |
|
25 |
|
|
26 |
import org.cresques.cts.IProjection; |
|
27 |
import org.gvsig.fmap.dal.coverage.dataset.io.features.BMPFeatures; |
|
28 |
import org.gvsig.fmap.dal.coverage.dataset.io.features.GTiffFeatures; |
|
29 |
import org.gvsig.fmap.dal.coverage.dataset.io.features.HFAFeatures; |
|
30 |
import org.gvsig.fmap.dal.coverage.dataset.io.features.IDRISIFeatures; |
|
31 |
import org.gvsig.fmap.dal.coverage.dataset.io.features.ILWIS_MprFeatures; |
|
32 |
import org.gvsig.fmap.dal.coverage.dataset.io.features.PNM_PgmFeatures; |
|
33 |
import org.gvsig.fmap.dal.coverage.dataset.io.features.PNM_PpmFeatures; |
|
34 |
import org.gvsig.raster.RasterLibrary; |
|
35 |
import org.gvsig.raster.buffer.RasterBuffer; |
|
36 |
import org.gvsig.raster.dataset.GeoRasterWriter; |
|
37 |
import org.gvsig.raster.dataset.IDataWriter; |
|
38 |
import org.gvsig.raster.dataset.NotSupportedExtensionException; |
|
39 |
import org.gvsig.raster.dataset.Params; |
|
40 |
import org.gvsig.raster.dataset.RasterDataset; |
|
41 |
import org.gvsig.raster.dataset.WriteFileFormatFeatures; |
|
42 |
import org.gvsig.raster.dataset.Params.Param; |
|
43 |
import org.gvsig.raster.dataset.properties.DatasetColorInterpretation; |
|
44 |
import org.gvsig.raster.dataset.serializer.RmfSerializerException; |
|
45 |
import org.gvsig.raster.process.RasterTask; |
|
46 |
import org.gvsig.raster.process.RasterTaskQueue; |
|
47 |
import org.gvsig.raster.util.RasterUtilities; |
|
48 |
import org.gvsig.tools.ToolsLocator; |
|
49 |
import org.gvsig.tools.extensionpoint.ExtensionPoint; |
|
50 |
import org.gvsig.tools.extensionpoint.ExtensionPointManager; |
|
51 |
|
|
52 |
import es.gva.cit.jecwcompress.EcwException; |
|
53 |
import es.gva.cit.jgdal.Gdal; |
|
54 |
import es.gva.cit.jgdal.GdalBuffer; |
|
55 |
import es.gva.cit.jgdal.GdalException; |
|
56 |
import es.gva.cit.jgdal.GdalRasterBand; |
|
57 |
import es.gva.cit.jgdal.GeoTransform; |
|
58 |
|
|
59 |
|
|
60 |
/** |
|
61 |
* Driver para la escritura a trav?s de Gdal. |
|
62 |
* Puede exportar un fichero de un formato a otro desde un GeoRasterFile |
|
63 |
* en cualquier formato soportado por la lectura a un formato que este incluido |
|
64 |
* en la lista supportedDrv. |
|
65 |
* |
|
66 |
* Puede salvar a disco en un formato que este incluido en la lista supportedDrv |
|
67 |
* obteniendo los datos que van siendo servidos desde el cliente. Este cliente |
|
68 |
* debe implementar un IDataWriter o tener un objeto que lo implemente. Inicialmente |
|
69 |
* le pasar? los par?metros de la imagen de salida y cuando el driver comience a |
|
70 |
* escribir le ir? solicitando m?s a trav?s del m?todo readData de IDataWriter. |
|
71 |
* El cliente ser? el que lleve el control de lo que va sirviendo y lo que le queda |
|
72 |
* por servir. |
|
73 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
74 |
*/ |
|
75 |
public class GdalWriter extends GeoRasterWriter { |
|
76 |
|
|
77 |
public static void register() { |
|
78 |
ExtensionPointManager extensionPoints = ToolsLocator.getExtensionPointManager(); |
|
79 |
ExtensionPoint point = extensionPoints.get("RasterWriter"); |
|
80 |
|
|
81 |
point.append("tif", "", GdalWriter.class); |
|
82 |
fileFeature.put("tif", new GTiffFeatures()); |
|
83 |
|
|
84 |
point.append("img", "", GdalWriter.class); |
|
85 |
fileFeature.put("img", new HFAFeatures()); |
|
86 |
|
|
87 |
point.append("bmp", "", GdalWriter.class); |
|
88 |
fileFeature.put("bmp", new BMPFeatures()); |
|
89 |
|
|
90 |
point.append("pgm", "", GdalWriter.class); |
|
91 |
fileFeature.put("pgm", new PNM_PgmFeatures()); |
|
92 |
|
|
93 |
point.append("ppm", "", GdalWriter.class); |
|
94 |
fileFeature.put("ppm", new PNM_PpmFeatures()); |
|
95 |
|
|
96 |
point.append("mpl", "", GdalWriter.class); |
|
97 |
fileFeature.put("mpl", new ILWIS_MprFeatures()); |
|
98 |
|
|
99 |
point.append("rst", "", GdalWriter.class); |
|
100 |
fileFeature.put("rst", new IDRISIFeatures()); |
|
101 |
|
|
102 |
//La exportaci?n no es correcta del todo |
|
103 |
//point.register("rmf", GdalWriter.class); |
|
104 |
//fileFeature.put("rmf", new RMFFeatures()); |
|
105 |
|
|
106 |
//No salva datos. Siempre sale negra la imagen |
|
107 |
//point.register("aux", GdalWriter.class); |
|
108 |
//fileFeature.put("aux", new PAuxFeatures()); |
|
109 |
} |
|
110 |
|
|
111 |
private es.gva.cit.jgdal.GdalDriver drv; |
|
112 |
private Gdal dstDataset = null; |
|
113 |
private GdalRasterBand rband = null; |
|
114 |
private GeoTransform geot = null; //Datos de georeferenciaci?n |
|
115 |
//private OGRSpatialReference oSRS; //Datos de proyecci?n |
|
116 |
private GdalBuffer[] bufBands = null; |
|
117 |
private int nBlocks = 0; //N?mero de bloques en Y en el que se divide la imagen para escribir |
|
118 |
private int anchoResto = 0; //Tama?o del ?ltimo bloque de la imagen. |
|
119 |
private boolean write = true; //Cuando est? a true se puede escribir en la imagen de salida. Si est? a false el proceso es interrumpido |
|
120 |
private int dataType = RasterBuffer.TYPE_UNDEFINED; |
|
121 |
|
|
122 |
/** |
|
123 |
* Carga los par?metros de este driver. |
|
124 |
*/ |
|
125 |
public void loadParams(String ident) { |
|
126 |
WriteFileFormatFeatures wfff = (WriteFileFormatFeatures)fileFeature.get(ident); |
|
127 |
wfff.loadParams(); |
|
128 |
driverParams = wfff.getParams(); |
|
129 |
} |
|
130 |
|
|
131 |
/** |
|
132 |
* Constructor para la obtenci?n de par?metros del driver |
|
133 |
* @param drvType Tipo de driver |
|
134 |
*/ |
|
135 |
public GdalWriter(String fileName) { |
|
136 |
ident = RasterUtilities.getExtensionFromFileName(fileName); |
|
137 |
driver = ((WriteFileFormatFeatures)fileFeature.get(ident)).getDriverName(); |
|
138 |
|
|
139 |
loadParams(ident); |
|
140 |
} |
|
141 |
|
|
142 |
/** |
|
143 |
* Constructor para salvar datos servidos por el cliente |
|
144 |
* @param dataWriter Objeto servidor de datos para el driver de escritura |
|
145 |
* @param outFilename Fichero de salida |
|
146 |
* @param blockSize Tama?o de bloque |
|
147 |
* @param Extent extent |
|
148 |
* @param compresion Compresi?n si la tiene |
|
149 |
* @param outSizeX Tama?o de salida en X |
|
150 |
* @param outSizeY Tama?o de salida en Y |
|
151 |
* @param dataType Tipo de dato |
|
152 |
* @throws GdalException |
|
153 |
* @throws IOException |
|
154 |
*/ |
|
155 |
public GdalWriter( IDataWriter dataWriter, |
|
156 |
String outFileName, |
|
157 |
Integer nBands, |
|
158 |
AffineTransform at, |
|
159 |
Integer outSizeX, |
|
160 |
Integer outSizeY, |
|
161 |
Integer dataType, |
|
162 |
Params params, |
|
163 |
IProjection proj) throws GdalException, IOException { |
|
164 |
this(dataWriter, outFileName, nBands, at, outSizeX, outSizeY, dataType, params, proj, new Boolean(true)); |
|
165 |
} |
|
166 |
|
|
167 |
/** |
|
168 |
* Constructor para salvar datos servidos por el cliente |
|
169 |
* @param dataWriter Objeto servidor de datos para el driver de escritura |
|
170 |
* @param outFilename Fichero de salida |
|
171 |
* @param blockSize Tama?o de bloque |
|
172 |
* @param Extent extent |
|
173 |
* @param compresion Compresi?n si la tiene |
|
174 |
* @param outSizeX Tama?o de salida en X |
|
175 |
* @param outSizeY Tama?o de salida en Y |
|
176 |
* @param dataType Tipo de dato |
|
177 |
* @param geo Flag que dice si se salva con georreferenciaci?n o sin ella |
|
178 |
* @throws GdalException |
|
179 |
* @throws IOException |
|
180 |
*/ |
|
181 |
public GdalWriter( IDataWriter dataWriter, |
|
182 |
String outFileName, |
|
183 |
Integer nBands, |
|
184 |
AffineTransform at, |
|
185 |
Integer outSizeX, |
|
186 |
Integer outSizeY, |
|
187 |
Integer dataType, |
|
188 |
Params params, |
|
189 |
IProjection proj, |
|
190 |
Boolean geo)throws GdalException, IOException { |
|
191 |
|
|
192 |
this.proj = proj; |
|
193 |
ident = outFileName.toLowerCase().substring(outFileName.lastIndexOf(".") + 1); |
|
194 |
driver = ((WriteFileFormatFeatures)fileFeature.get(ident)).getDriverName(); |
|
195 |
this.dataType = dataType.intValue(); |
|
196 |
this.at = at; |
|
197 |
percent = 0; |
|
198 |
|
|
199 |
this.dataWriter = dataWriter; |
|
200 |
this.outFileName = outFileName; |
|
201 |
|
|
202 |
this.sizeWindowX = outSizeX.intValue(); |
|
203 |
this.sizeWindowY = outSizeY.intValue(); |
|
204 |
|
|
205 |
if ((sizeWindowX < 0) || (sizeWindowY < 0)) |
Also available in: Unified diff