Revision 21576

View differences:

trunk/libraries/libRaster/src/org/gvsig/raster/dataset/properties/DatasetStatistics.java
556 556
	 * @see org.gvsig.raster.shared.IStatistics#getTailTrimValue(int)
557 557
	 */
558 558
	public Object[] getTailTrimValue(int pos) {
559
		return new Object[]{tailTrimValues.get(pos), tailTrim.get((Double)tailTrimValues.get(pos))};
559
		return new Object[] { Double.valueOf(Double.parseDouble(tailTrimValues.get(pos) + "")), tailTrim.get(tailTrimValues.get(pos)) };
560 560
	}
561 561
	
562 562
	/*
trunk/libraries/libRaster/src/org/gvsig/raster/datastruct/Histogram.java
99 99
			numberClasses = RasterLibrary.defaultNumberOfClasses;
100 100
		}
101 101
		
102
		constructorHistogramImpl(min, max, numberClasses);
102
		constructorHistogramImpl(this.min, this.max, numberClasses);
103 103
	}
104 104
	
105 105
	/**
trunk/libraries/libRaster/src-test/org/gvsig/raster/dataset/io/rmf/TestRmfWrite.java
53 53
 * @author Nacho Brodin (nachobrodin@gmail.com)
54 54
 */
55 55
public class TestRmfWrite extends TestCase {
56
	private RmfBlocksManager manager    = null;
57
	private String           baseDir    = "." + File.separator + "test-images" + File.separator;
58
	private String           path       = baseDir + "miniRaster25x24.tif";
59
	private String           pathGif    = baseDir + "gifTransparente.gif";
60
	private String           pathJpg    = baseDir + "03AUG23153350-M2AS-000000122423_01_P001-BROWSE.jpg";
61
	private Histogram        histogram  = null;
62
	private ColorTable       colorTable = null;
63
	private RasterDataset    f          = null;
64
	private RasterDataset    f2         = null;
56 65

  
57
	private RmfBlocksManager manager = null;
58
	private String baseDir = "." + File.separator + "test-images" + File.separator;
59
	private String path = baseDir + "miniRaster25x24.tif";
60
	private String pathGif = baseDir + "gifTransparente.gif";
61
	private String pathJpg = baseDir + "03AUG23153350-M2AS-000000122423_01_P001-BROWSE.jpg";
62
	private Histogram histogram = null;
63
	private ColorTable colorTable = null;
64
	private RasterDataset f = null;
65
	private RasterDataset f2 = null;
66

  
67 66
	static {
68 67
		RasterLibrary.wakeUp();
69 68
	}
......
106 105
		} catch (InterruptedException e) {
107 106
			e.printStackTrace();
108 107
		}
109

  
110 108
	}
111 109

  
112
	public void testStack(){
110
	public void testStack() {
113 111
		manager = new RmfBlocksManager(baseDir + "writetest.rmf");
114 112

  
115
		//Histograma
113
		// Histograma
116 114
		HistogramRmfSerializer ser = new HistogramRmfSerializer(histogram);
117 115
		manager.addClient(ser);
118 116

  
119
		//Tabla de color
120
		//colorTable.setName("Prueba Tabla de Color");
117
		// Tabla de color
118
		// colorTable.setName("Prueba Tabla de Color");
121 119
		ColorTableRmfSerializer ser1 = new ColorTableRmfSerializer(colorTable);
122 120
		manager.addClient(ser1);
123 121

  
124
		//Estadisticas
122
		// Estadisticas
125 123
		DatasetStatistics stat = f.getStatistics();
126 124
		stat.setTailTrimValue(3.0, new Double(10.0));
127 125
		stat.setTailTrimValue(4.0, new Double(16.0));
128 126
		StatisticsRmfSerializer ser2 = new StatisticsRmfSerializer(stat);
129 127
		manager.addClient(ser2);
130 128

  
131
		//Georreferenciaci?n
129
		// Georreferenciaci?n
132 130
		GeoInfoRmfSerializer ser3 = new GeoInfoRmfSerializer(f2);
133 131
		manager.addClient(ser3);
134 132

  
135
		//Puntos de control
133
		// Puntos de control
136 134
		GeoPoint p1 = new GeoPoint();
137 135
		p1.pixelPoint = new Point2D.Double(10, 10);
138 136
		p1.mapPoint = new Point2D.Double(34223.3, 2344.2);
......
153 151
		p2.rightCenterPoint = new Point2D.Double(2433.3, 6244.2);
154 152

  
155 153
		p1.leftViewPort.pxSize = new Point2D.Double(32, 34);
156
		GeoPointRmfSerializer ser4 = new GeoPointRmfSerializer(new GeoPoint[]{p1, p2}, p1.leftViewPort);
154
		GeoPointRmfSerializer ser4 = new GeoPointRmfSerializer(new GeoPoint[] { p1, p2 }, p1.leftViewPort);
157 155
		manager.addClient(ser4);
158 156

  
159 157
		// Valor NoData
160 158
		NoDataRmfSerializer ser5 = new NoDataRmfSerializer(5450.0, 2);
161 159
		manager.addClient(ser5);
162
		
163
		//Interpretaci?n de color
160

  
161
		// Interpretaci?n de color
164 162
		DatasetColorInterpretation ci = f.getColorInterpretation();
165 163
		ci.setColorInterpValue(0, DatasetColorInterpretation.BLUE_BAND);
166 164
		ci.setColorInterpValue(2, DatasetColorInterpretation.RED_BAND);
......
175 173
			e.printStackTrace();
176 174
		}
177 175

  
178
		//Pasamos el test de lectura para comprobar que se ha generado bien
176
		// Pasamos el test de lectura para comprobar que se ha generado bien
179 177
		TestRmfRead t = new TestRmfRead();
180 178
		t.file = "writetest.rmf";
181 179
		t.start();
182 180
	}
183

  
184
}
181
}
trunk/libraries/libRaster/src-test/org/gvsig/raster/dataset/io/rmf/TestRmfRead.java
39 39
import org.gvsig.raster.datastruct.serializer.ColorTableRmfSerializer;
40 40
import org.gvsig.raster.datastruct.serializer.HistogramRmfSerializer;
41 41
import org.gvsig.raster.datastruct.serializer.NoDataRmfSerializer;
42

  
42
import org.gvsig.raster.datastruct.serializer.NoDataRmfSerializer.NoDataObject;
43 43
/**
44
 * Test de lectura para ficheros rmf.
45
 * Obtiene distintos tipos de bloques y comprueba que el objeto que han
46
 * de generar es correcto.
47
 *
44
 * Test de lectura para ficheros rmf. Obtiene distintos tipos de bloques y
45
 * comprueba que el objeto que han de generar es correcto.
46
 * 
48 47
 * @author Nacho Brodin (nachobrodin@gmail.com)
49
 *
50 48
 */
51 49
public class TestRmfRead extends TestCase {
52

  
53
	private String baseDir = "./test-images/";
50
	private String           baseDir = "./test-images/";
54 51
	private RmfBlocksManager manager = null;
55
	public String file = "readtest.rmf";
56
	private RasterDataset f1 = null;
57
	private String path1 = baseDir + "03AUG23153350-M2AS-000000122423_01_P001-BROWSE.jpg";
52
	public String            file    = "readtest.rmf";
53
	private RasterDataset    f1      = null;
54
	private String           path1   = baseDir + "03AUG23153350-M2AS-000000122423_01_P001-BROWSE.jpg";
58 55

  
59 56
	static {
60 57
		RasterLibrary.wakeUp();
......
78 75

  
79 76
	public void testStack(){
80 77
		manager = new RmfBlocksManager(baseDir + file);
81
		if(!manager.checkRmf())
78
		if (!manager.checkRmf())
82 79
			assertEquals(0, 1);
83 80
		HistogramRmfSerializer ser = new HistogramRmfSerializer();
84 81
		ColorTableRmfSerializer ser1 = new ColorTableRmfSerializer();
......
110 107
				if (client instanceof StatisticsRmfSerializer)
111 108
					testStatistics((DatasetStatistics) client.getResult());
112 109
				if (client instanceof NoDataRmfSerializer)
113
					testNoData((Double) client.getResult());
110
					testNoData((NoDataObject) client.getResult());
114 111
//				if (client instanceof GeoInfoRmfSerializer)
115 112
//					testGeoInfo((RasterDataset) client.getResult());
116 113
				if (client instanceof GeoPointRmfSerializer)
......
129 126

  
130 127
	public void testColorInterpretation(DatasetColorInterpretation ci) {
131 128
		for (int j = 0; j < ci.length(); j++) {
132
			String value = (String)ci.get(j);
129
			String value = (String) ci.get(j);
133 130
			System.out.println(value);
134
			if(j == 0)
131
			if (j == 0)
135 132
				assertEquals(value, "Blue");
136
			if(j == 1)
133
			if (j == 1)
137 134
				assertEquals(value, "Green");
138
			if(j == 2)
135
			if (j == 2)
139 136
				assertEquals(value, "Red");
140
			
141
		}		
137
		}
142 138
	}
143 139
	
144 140
	public void testHistogram(Histogram h) {
145
		HistogramClass[][] classes = h.getHistogram();
141
		Histogram h2 = Histogram.convertHistogramToRGB(h);
142
		
143
		HistogramClass[][] classes = h2.getHistogram();
146 144
		for (int iBand = 0; iBand < classes.length; iBand++) {
147 145
			for (int iValue = 0; iValue < classes[iBand].length; iValue++) {
148
				assertEquals((int)classes[iBand][iValue].getMin(), iValue);
149
				assertEquals((int)classes[iBand][iValue].getMax(), iValue + 1);
146
				assertEquals((int) classes[iBand][iValue].getMin(), iValue);
147
				assertEquals((int) classes[iBand][iValue].getMax(), iValue + 1);
150 148
			}
151 149
		}
152 150

  
153
		assertEquals((int)classes[0][0].getValue(), 16);
154
		assertEquals((int)classes[0][1].getValue(), 4);
155
		assertEquals((int)classes[0][23].getValue(), 6);
156
		assertEquals((int)classes[0][48].getValue(), 4);
151
		assertEquals((int) h.getHistogramValue(0, 0), 16);
152
		assertEquals((int) h.getHistogramValue(0, 1), 4);
153
		assertEquals((int) h.getHistogramValue(0, 23), 6);
154
		assertEquals((int) h.getHistogramValue(0, 48), 4);
157 155

  
158
		assertEquals((int)classes[1][0].getValue(), 2);
159
		assertEquals((int)classes[1][4].getValue(), 1);
160
		assertEquals((int)classes[1][7].getValue(), 8);
161
		assertEquals((int)classes[1][20].getValue(), 4);
156
		assertEquals((int) h.getHistogramValue(1, 0), 2);
157
		assertEquals((int) h.getHistogramValue(1, 4), 1);
158
		assertEquals((int) h.getHistogramValue(1, 7), 8);
159
		assertEquals((int) h.getHistogramValue(1, 20), 4);
162 160

  
163
		assertEquals((int)classes[2][0].getValue(), 25);
164
		assertEquals((int)classes[2][2].getValue(), 1);
165
		assertEquals((int)classes[2][13].getValue(), 4);
166
		assertEquals((int)classes[2][21].getValue(), 2);
161
		assertEquals((int) h.getHistogramValue(2, 0), 25);
162
		assertEquals((int) h.getHistogramValue(2, 2), 1);
163
		assertEquals((int) h.getHistogramValue(2, 13), 4);
164
		assertEquals((int) h.getHistogramValue(2, 21), 2);
167 165
	}
168 166

  
169 167
	public void testColorTable(ColorTable ct) {
170 168

  
171 169
		byte[][] color = ct.getColorTableByBand();
172 170

  
173
		// assertEquals(ct.getName(), "Prueba Tabla de Color");
171
//		assertEquals(ct.getName(), "Prueba Tabla de Color");
174 172

  
175 173
		assertEquals(ct.getRGBAByBand(15)[0] & 0xff, 95);
176 174
		assertEquals(ct.getRGBAByBand(15)[1] & 0xff, 95);
......
207 205
		}
208 206
	}
209 207

  
210
	public void testNoData(Double noData) {
211
		assertEquals((int) noData.doubleValue(), 5450);
208
	public void testNoData(NoDataObject noData) {
209
		assertEquals((int) noData.getValue(), 5450);
210
		assertEquals((int) noData.getType(), 2);
212 211
	}
213 212

  
214 213
	public void testStatistics(DatasetStatistics ds) {
215 214
		int bandCount = ds.getBandCount();
216
		double[] max = ds.getMax();
217
		double[] min = ds.getMin();
218
		double[] secondMax = ds.getSecondMax();
219
		double[] secondMin = ds.getSecondMin();
215
		double[] max = ds.getMaxRGB();
216
		double[] min = ds.getMinRGB();
217
		double[] secondMax = ds.getSecondMaxRGB();
218
		double[] secondMin = ds.getSecondMinRGB();
220 219
		double[] mean = ds.getMean();
221 220
		double[] variance = ds.getVariance();
222 221

  
223 222
		assertEquals(bandCount, 3);
224 223
		for (int i = 0; i < bandCount; i++) {
225
			switch(i) {
226
			case 0:
227
				assertEquals((int)max[i], 250);
228
				assertEquals((int)min[i], 0);
229
				assertEquals((int)secondMax[i], 248);
230
				assertEquals((int)secondMin[i], 1);
231
				assertEquals((int)mean[i], 95);
232
				assertEquals((int)variance[i], 3050);
233
				break;
234
			case 1:
235
				assertEquals((int)max[i], 255);
236
				assertEquals((int)min[i], 0);
237
				assertEquals((int)secondMax[i], 254);
238
				assertEquals((int)secondMin[i], 3);
239
				assertEquals((int)mean[i], 105);
240
				assertEquals((int)variance[i], 2689);
241
				break;
242
			case 2:
243
				assertEquals((int)max[i], 254);
244
				assertEquals((int)min[i], 0);
245
				assertEquals((int)secondMax[i], 250);
246
				assertEquals((int)secondMin[i], 1);
247
				assertEquals((int)mean[i], 85);
248
				assertEquals((int)variance[i], 3218);
249
				break;
224
			switch (i) {
225
				case 0:
226
					assertEquals((int) max[i], 250);
227
					assertEquals((int) min[i], 0);
228
					assertEquals((int) secondMax[i], 248);
229
					assertEquals((int) secondMin[i], 1);
230
					assertEquals((int) mean[i], 36);
231
					assertEquals((int) variance[i], 4984);
232
					break;
233
				case 1:
234
					assertEquals((int) max[i], 255);
235
					assertEquals((int) min[i], 0);
236
					assertEquals((int) secondMax[i], 254);
237
					assertEquals((int) secondMin[i], 3);
238
					assertEquals((int) mean[i], 37);
239
					assertEquals((int) variance[i], 6292);
240
					break;
241
				case 2:
242
					assertEquals((int) max[i], 254);
243
					assertEquals((int) min[i], 0);
244
					assertEquals((int) secondMax[i], 250);
245
					assertEquals((int) secondMin[i], 1);
246
					assertEquals((int) mean[i], 35);
247
					assertEquals((int) variance[i], 4154);
248
					break;
250 249
			}
251 250
		}
252 251

  
253
		//System.out.println(ct.getName());
254
		//System.out.println(ct.getType());
255

  
256
		/*for (int i = 0; i < color.length; i++) {
257
			System.out.print(range[i] + ": ");
258
			System.out.println(color[i][0] + " " + color[i][1] + " " + color[i][2]);
259
		}*/
252
//		System.out.println(ct.getName());
253
//		System.out.println(ct.getType());
254
//		for (int i = 0; i < color.length; i++) {
255
//			System.out.print(range[i] + ": ");
256
//			System.out.println(color[i][0] + " " + color[i][1] + " " + color[i][2]);
257
//		}
260 258
	}
261 259

  
262 260
	public void testGeoInfo(RasterDataset dataset) {
263
		//String proj = "";
264
		//TODO: TEST: Terminar test de acceso a la georreferenciaci?n.
265
		//if(dataset.getProjection() != null)
266
			//proj = dataset.getProjection().getAbrev();
261
	//TODO: TEST: Terminar test de acceso a la georreferenciaci?n.
262
//		String proj = "";
263
//		if(dataset.getProjection() != null)
264
//			proj = dataset.getProjection().getAbrev();
267 265
		AffineTransform at = dataset.getAffineTransform();
268 266

  
269
		assertEquals((int)at.getTranslateX(), 5000);
270
		assertEquals((int)at.getTranslateY(), 5000);
271
		assertEquals((int)at.getScaleX(), 2);
272
		assertEquals((int)at.getScaleY(), -2);
267
		assertEquals((int) at.getTranslateX(), 5000);
268
		assertEquals((int) at.getTranslateY(), 5000);
269
		assertEquals((int) at.getScaleX(), 2);
270
		assertEquals((int) at.getScaleY(), -2);
273 271
	}
274 272

  
275 273
	public void testGeoPoints(GeoPoint[] gpList) {
276 274
		GeoPoint p = gpList[0];
277 275

  
278
		assertEquals((int)p.pixelPoint.getX(), 10);
279
		assertEquals((int)p.pixelPoint.getY(), 10);
280
		assertEquals((int)p.mapPoint.getX(), 34223);
281
		assertEquals((int)p.mapPoint.getY(), 2344);
276
		assertEquals((int) p.pixelPoint.getX(), 10);
277
		assertEquals((int) p.pixelPoint.getY(), 10);
278
		assertEquals((int) p.mapPoint.getX(), 34223);
279
		assertEquals((int) p.mapPoint.getY(), 2344);
282 280

  
283 281
		assertEquals(p.active, true);
284 282

  
285
		assertEquals((int)p.leftCenterPoint.getX(), 24223);
286
		assertEquals((int)p.leftCenterPoint.getY(), 3244);
287
		assertEquals((int)p.rightCenterPoint.getX(), 2433);
288
		assertEquals((int)p.rightCenterPoint.getY(), 6244);
283
//		assertEquals((int) p.leftCenterPoint.getX(), 24223);
284
//		assertEquals((int) p.leftCenterPoint.getY(), 3244);
285
//		assertEquals((int) p.rightCenterPoint.getX(), 2433);
286
//		assertEquals((int) p.rightCenterPoint.getY(), 6244);
287
//
288
//		assertEquals((int) p.leftViewPort.getExtent().minX(), 30032);
289
//		assertEquals((int) p.leftViewPort.getExtent().maxY(), 2103);
290
//
291
//		assertEquals((int) p.rightViewPort.getExtent().minX(), 30032);
292
//		assertEquals((int) p.rightViewPort.getExtent().maxY(), 2103);
289 293

  
290
		assertEquals((int)p.leftViewPort.getExtent().minX(), 30032);
291
		assertEquals((int)p.leftViewPort.getExtent().maxY(), 2103);
292

  
293
		assertEquals((int)p.rightViewPort.getExtent().minX(), 30032);
294
		assertEquals((int)p.rightViewPort.getExtent().maxY(), 2103);
295

  
296
		assertEquals((int)p.zoomLeft, 1);
297
		assertEquals((int)p.zoomRight, 1);
298

  
294
		assertEquals((int) p.zoomLeft, 1);
295
		assertEquals((int) p.zoomRight, 1);
299 296
	}
300

  
301
}
297
}

Also available in: Unified diff