Revision 2215

View differences:

org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.impl/src/main/java/org/gvsig/raster/impl/buffer/DefaultRasterQuery.java
95 95
	private BandList         bandList                   = null;
96 96
	private Buffer           buffer                     = null;
97 97
	
98
	/*
99
	 * (non-Javadoc)
100
	 * @see org.gvsig.fmap.dal.coverage.buffer.RasterQuery#setAreaOfInterest(double, double, double, double)
101
	 */
102 98
	public void setAreaOfInterest(double x, double y, double w, double h) {
103 99
		this.x = x;
104 100
		this.y = y;
......
107 103
		this.type = TYPE_COORDS;
108 104
	}
109 105
	
110
	/*
111
	 * (non-Javadoc)
112
	 * @see org.gvsig.fmap.dal.coverage.store.RasterQuery#setAreaOfInterest(org.gvsig.fmap.dal.coverage.datastruct.Extent)
113
	 */
114 106
	public void setAreaOfInterest(Extent bbox) {
115 107
		this.bbox = bbox;
116 108
		this.type = TYPE_COORDS;
117 109
	}
118 110
	
119
	/*
120
	 * (non-Javadoc)
121
	 * @see org.gvsig.fmap.dal.coverage.buffer.RasterQuery#setAreaOfInterest(double, double, double, double, int, int)
122
	 */
123 111
	public void setAreaOfInterest(Extent bbox, int bufWidth, int bufHeight) {
124 112
		this.bbox = bbox;
125 113
		this.bufWidth = bufWidth;
......
127 115
		this.type = TYPE_COORDS_SIZE;
128 116
	}
129 117
	
130
	/*
131
	 * (non-Javadoc)
132
	 * @see org.gvsig.fmap.dal.coverage.store.RasterQuery#setAreaOfInterest(double, double, double, double, int, int, org.gvsig.fmap.dal.coverage.grid.render.TileListener, int)
133
	 */
134 118
	public void setAreaOfInterest(Extent bbox, 
135 119
			int bufWidth, int bufHeight, TileListener listener) {
136 120
		this.bbox = bbox;;
......
140 124
		this.listener = listener;
141 125
	}
142 126
	
143
	/*
144
	 * (non-Javadoc)
145
	 * @see org.gvsig.fmap.dal.coverage.buffer.RasterQuery#setAreaOfInterest(int, int, int, int)
146
	 */
147 127
	public void setAreaOfInterest(int x, int y, int w, int h) {
148 128
		this.pixelX = x;
149 129
		this.pixelY = y;
......
152 132
		this.type = TYPE_PX;
153 133
	}
154 134
	
155
	/*
156
	 * (non-Javadoc)
157
	 * @see org.gvsig.fmap.dal.coverage.buffer.RasterQuery#setAreaOfInterest()
158
	 */
159 135
	public void setAreaOfInterest() {
160 136
		this.type = TYPE_ENTIRE;
161 137
	}
162 138
	
163
	/*
164
	 * (non-Javadoc)
165
	 * @see org.gvsig.fmap.dal.coverage.buffer.RasterQuery#setAreaOfInterest(int, int, int, int, int, int)
166
	 */
167 139
	public void setAreaOfInterest(int x, int y, int w, int h, int bufWidth,
168 140
			int bufHeight) {
169 141
		this.pixelX = x;
......
174 146
		this.bufHeight = bufHeight;
175 147
		this.type = TYPE_PX_SIZE;
176 148
	}
177
	
178
	/*
179
	 * (non-Javadoc)
180
	 * @see org.gvsig.fmap.dal.coverage.store.RasterQuery#setTileParameters(int, int, int, org.gvsig.fmap.dal.coverage.datastruct.Extent, org.gvsig.raster.cache.tile.provider.CacheStruct)
181
	 */
149

  
182 150
	public void setTileParameters(int level, int tileCol, int tileRow, Extent bbox, CacheStruct cacheStruct) {
183 151
		this.type = TYPE_ONE_TILE;
184 152
		this.bbox = bbox;
......
196 164
		this.bufHeight = size[1];
197 165
	}
198 166
	
199
	/*
200
	 * (non-Javadoc)
201
	 * @see org.gvsig.fmap.dal.coverage.buffer.RasterQuery#storeLastBuffer(boolean)
202
	 */
203 167
	public void storeLastBuffer(boolean store) {
204 168
		this.storeLastBuffer = store;
205 169
	}
......
212 176
		return storeLastBuffer;
213 177
	}
214 178

  
215
	/*
216
	 * (non-Javadoc)
217
	 * @see org.gvsig.fmap.dal.coverage.buffer.RasterQuery#setAdjustToExtent(boolean)
218
	 */
219 179
	public void setAdjustToExtent(boolean adjustToExtent) {
220 180
		this.adjustToExtent = adjustToExtent;
221 181
	}
222 182
	
223
	/*
224
	 * (non-Javadoc)
225
	 * @see org.gvsig.fmap.dal.coverage.buffer.RasterQuery#isAdjustToExtent()
226
	 */
227 183
	public boolean isAdjustToExtent() {
228 184
		return adjustToExtent;
229 185
	}
230 186
	
231
	/*
232
	 * (non-Javadoc)
233
	 * @see org.gvsig.fmap.dal.coverage.buffer.RasterQuery#getDrawableBands()
234
	 */
235 187
	public int[] getDrawableBands() {
236 188
		return drawableBands;
237 189
	}
238 190

  
239
	/*
240
	 * (non-Javadoc)
241
	 * @see org.gvsig.fmap.dal.coverage.buffer.RasterQuery#setAllDrawableBands()
242
	 */
243 191
	public void setAllDrawableBands() {
244 192
		this.drawableBands = null;
245 193
	}
246 194

  
247
	/*
248
	 * (non-Javadoc)
249
	 * @see org.gvsig.fmap.dal.coverage.buffer.RasterQuery#setDrawableBands(int[])
250
	 */
251 195
	public void setDrawableBands(int[] drawableBands) {
252 196
		this.drawableBands = drawableBands;
253 197
	}
254 198

  
255
	/*
256
	 * (non-Javadoc)
257
	 * @see org.gvsig.fmap.dal.coverage.buffer.RasterQuery#setReadOnly(boolean)
258
	 */
259 199
	public void setReadOnly(boolean readOnly) {
260 200
		this.readOnly = readOnly;
261 201
	}
262 202
	
263
	/*
264
	 * (non-Javadoc)
265
	 * @see org.gvsig.fmap.dal.coverage.buffer.RasterQuery#isSupersamplingLoadingBuffer()
266
	 */
267 203
	public boolean isSupersamplingLoadingBuffer() {
268 204
		return supersamplingLoadingBuffer;
269 205
	}
270 206

  
271
	/*
272
	 * (non-Javadoc)
273
	 * @see org.gvsig.fmap.dal.coverage.buffer.RasterQuery#setSupersamplingLoadingBuffer(boolean)
274
	 */
275 207
	public void setSupersamplingLoadingBuffer(boolean supersamplingLoadingBuffer) {
276 208
		this.supersamplingLoadingBuffer = supersamplingLoadingBuffer;
277 209
	}
278 210
	
279
	/*
280
	 * (non-Javadoc)
281
	 * @see org.gvsig.fmap.dal.coverage.buffer.RasterQuery#setMemoryBuffer(boolean)
282
	 */
283 211
	public void setMemoryBuffer(boolean memoryBuffer) {
284 212
		this.memoryBuffer = memoryBuffer;
285 213
	}
......
293 221
		return memoryBuffer;
294 222
	}
295 223
	
296
	/*
297
	 * (non-Javadoc)
298
	 * @see org.gvsig.fmap.dal.coverage.buffer.RasterQuery#setNoDataToFill(double)
299
	 */
300 224
	public void setNoDataToFill(NoData noData) {
301 225
		this.noDataValueToFill = noData;
302 226
	}
303 227
	
304
	/*
305
	 * (non-Javadoc)
306
	 * @see org.gvsig.fmap.dal.coverage.store.RasterQuery#setAlphaBand(int)
307
	 */
308 228
	public void setAlphaBand(int bandNumber) {
309 229
		this.alphaBandNumber = bandNumber;
310 230
	}
311 231
	
312
	/*
313
	 * (non-Javadoc)
314
	 * @see org.gvsig.fmap.dal.coverage.store.RasterQuery#setFrameWidth(int)
315
	 */
316 232
	public void setFrameWidth(int n) {
317 233
		this.frameWidth = n;
318 234
	}
......
421 337
		this.listener = listener;
422 338
	}
423 339
	
424
	/*
425
	 * (non-Javadoc)
426
	 * @see org.gvsig.fmap.dal.coverage.store.RasterQuery#getTime()
427
	 */
428 340
	public Time getTime() {
429 341
		return time;
430 342
	}
431 343

  
432
	/*
433
	 * (non-Javadoc)
434
	 * @see org.gvsig.fmap.dal.coverage.store.RasterQuery#setTime(org.gvsig.timesupport.Time)
435
	 */
436 344
	public void setTime(Time time) {
437 345
		this.time = time;
438 346
	}
......
457 365
		return resolutionLevel;
458 366
	}
459 367
	
460
	/*
461
	 * (non-Javadoc)
462
	 * @see org.gvsig.fmap.dal.coverage.store.RasterQuery#setTaskStatus(org.gvsig.tools.task.TaskStatus)
463
	 */
464 368
	public void setTaskStatus(TaskStatus taskStatus) {
465 369
		this.taskStatus = taskStatus;
466 370
	}
......
496 400
	//*********Implementing DataQuery methods*************
497 401
	//****************************************************
498 402
	
499
	/*
500
	 * (non-Javadoc)
501
	 * @see org.gvsig.fmap.dal.DataQuery#getQueryParameter(java.lang.String)
502
	 */
503 403
	public Object getQueryParameter(String name) {
504 404
		// TODO Auto-generated method stub
505 405
		return null;
506 406
	}
507 407

  
508
	/*
509
	 * (non-Javadoc)
510
	 * @see org.gvsig.fmap.dal.DataQuery#getScale()
511
	 */
512 408
	public double getScale() {
513 409
		// TODO Auto-generated method stub
514 410
		return 0;
515 411
	}
516 412

  
517
	/*
518
	 * (non-Javadoc)
519
	 * @see org.gvsig.fmap.dal.DataQuery#setQueryParameter(java.lang.String, java.lang.Object)
520
	 */
521 413
	public void setQueryParameter(String name, Object value) {
522 414
		// TODO Auto-generated method stub
523 415
		
524 416
	}
525 417

  
526
	/*
527
	 * (non-Javadoc)
528
	 * @see org.gvsig.fmap.dal.DataQuery#setScale(double)
529
	 */
530 418
	public void setScale(double scale) {
531 419
		// TODO Auto-generated method stub
532 420
		
......
536 424
	//*********Implementing Persistent methods************
537 425
	//****************************************************
538 426

  
539
	/*
540
	 * (non-Javadoc)
541
	 * @see org.gvsig.tools.persistence.Persistent#loadFromState(org.gvsig.tools.persistence.PersistentState)
542
	 */
543 427
	public void loadFromState(PersistentState state)
544 428
			throws PersistenceException {
545 429
		// TODO Auto-generated method stub
546 430
		
547 431
	}
548 432

  
549
	/*
550
	 * (non-Javadoc)
551
	 * @see org.gvsig.tools.persistence.Persistent#saveToState(org.gvsig.tools.persistence.PersistentState)
552
	 */
553 433
	public void saveToState(PersistentState state) throws PersistenceException {
554 434
		// TODO Auto-generated method stub
555 435
		
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.impl/src/main/java/org/gvsig/raster/impl/provider/fusion/AbstractFusionMethod.java
1 1
package org.gvsig.raster.impl.provider.fusion;
2 2

  
3
import java.awt.geom.Rectangle2D;
4

  
5
import org.gvsig.fmap.dal.coverage.dataset.Buffer;
6
import org.gvsig.fmap.dal.coverage.datastruct.Extent;
7
import org.gvsig.raster.impl.provider.fusion.BufferListFusion.PixelSquareStructure;
8

  
3 9
public abstract class AbstractFusionMethod {
10
	protected PixelSquareStructure     pxSquare  = null;
4 11
	
5
	public abstract byte getByteValue(int row, int col, int band);
12
	public class SubSquare {
13
		private int    ulxPxDistance = 0;
14
		private int    ulyPxDistance = 0;
15
		private int    lrxPxDistance = 0;
16
		private int    lryPxDistance = 0;
17
		private Buffer buffer        = null;
18
		
19
		public SubSquare(
20
				Extent parentExtent,
21
				Rectangle2D parentSize,
22
				Extent squareExtent,
23
				Rectangle2D squareSize,
24
				Buffer buf) {
25
			this.buffer = buf;
26
			double xDistWc = Math.abs(squareExtent.getULX() - parentExtent.getULX());
27
			double yDistWc = Math.abs(squareExtent.getULY() - parentExtent.getULY());
28
			double pixelSize = parentExtent.width() / parentSize.getWidth();
29
			ulxPxDistance = (int)Math.floor(xDistWc * pixelSize);
30
			ulyPxDistance = (int)Math.ceil(yDistWc * pixelSize);
31
			lrxPxDistance = (int)(ulxPxDistance + squareSize.getWidth() - 1);
32
			lryPxDistance = (int)(ulyPxDistance + squareSize.getHeight() - 1);
33
		}
34
		
35
		/**
36
		 * Returns true if the pixel coordinates relative to the parent buffer is inside of this square
37
		 * @param row
38
		 * @param col
39
		 * @return
40
		 */
41
		public boolean isInside(int row, int col) {
42
			return (col >= ulxPxDistance && col <= lrxPxDistance && row >= ulyPxDistance && row <= lryPxDistance);
43
		}
44
		
45
		public void loadLocalCoords(int row, int col, int[] coords) {
46
			coords[0] = row - ulyPxDistance;
47
			coords[1] = col - ulxPxDistance;
48
		}
49
		
50
		public Buffer getBuffer() {
51
			return buffer;
52
		}
53
	}
6 54
	
7
	public abstract float getFloatValue(int row, int col, int band);
55
	public AbstractFusionMethod(PixelSquareStructure pxSquare) {
56
		this.pxSquare = pxSquare;
57
	}
58
	
59
	public abstract byte[] getByteValue(int row, int col);
60
	
61
	public abstract float[] getFloatValue(int row, int col);
8 62

  
9 63
}
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.impl/src/main/java/org/gvsig/raster/impl/provider/fusion/BufferListFusion.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22 1
package org.gvsig.raster.impl.provider.fusion;
23 2

  
24 3
import java.awt.geom.Rectangle2D;
25 4
import java.util.List;
26 5

  
6
import org.gvsig.fmap.dal.coverage.RasterLocator;
27 7
import org.gvsig.fmap.dal.coverage.dataset.Buffer;
28 8
import org.gvsig.fmap.dal.coverage.datastruct.Extent;
9
import org.gvsig.fmap.dal.coverage.datastruct.NoData;
29 10
import org.gvsig.raster.impl.DefaultRasterManager;
30 11
import org.gvsig.raster.impl.datastruct.ExtentImpl;
31 12

  
......
50 31
	
51 32
	private List<Buffer>         bufferList                = null;
52 33
	private List<Extent>         bboxList                  = null;
53
	private double               outputPixelSize           = 0;
54
	private int                  dataType                  = Buffer.TYPE_UNDEFINED;
55
	private int                  bandCount                 = 0;
56
	private Extent               bbox                      = null;
57
	private AbstractFusionMethod         fusion                    = null;
34
	private PixelSquareStructure pxSquare                  = null;
35
	private AbstractFusionMethod fusion                    = null;
58 36
	
37
	public class PixelSquareStructure {
38
		public double               pixelSize                 = 0;
39
		public int                  dataType                  = Buffer.TYPE_UNDEFINED;
40
		public int                  bandCount                 = 0;
41
		public int                  width                     = 0;
42
		public int                  height                    = 0;
43
		public Extent               bbox                      = null;
44
		public NoData               nodata                    = null;
45
		public Buffer               buffer                    = null;
46
		
47
		public PixelSquareStructure(
48
				Buffer buf,
49
				Extent bbox,
50
				double pixelSize) {
51
			this.pixelSize = pixelSize;
52
			this.dataType = buf.getDataType();
53
			this.bandCount = buf.getBandCount();
54
			this.width = buf.getWidth();
55
			this.height = buf.getHeight();
56
			nodata = buf.getNoDataValue() != null ? 
57
					buf.getNoDataValue() : 
58
					RasterLocator.getManager().getDataStructFactory().createDefaultNoData(bandCount, dataType);
59
			this.bbox = bbox;
60
			this.buffer = buf;
61
		}
62
		
63
		public PixelSquareStructure(
64
				double pixelSize,
65
				int bandCount,
66
				int datatype) {
67
			this.pixelSize = pixelSize;
68
			this.dataType = datatype;
69
			this.bandCount = bandCount;
70
			this.width = (int)Math.ceil(bbox.width() * pixelSize);
71
			this.height = (int)Math.ceil(bbox.height() * pixelSize);
72
			nodata = RasterLocator.getManager().getDataStructFactory().createDefaultNoData(bandCount, datatype);
73
		}
74
	}
75
	
76
	public static PixelSquareStructure buildPixelSquareStructure(
77
			Buffer buf,
78
			Extent bbox,
79
			double pixelSize) {
80
		return  new BufferListFusion().new PixelSquareStructure(buf, bbox, pixelSize);
81
	}
82
	
83
	public static PixelSquareStructure buildPixelSquareStructure(
84
			double pixelSize,
85
			int bandCount,
86
			int datatype) {
87
		return  new BufferListFusion().new PixelSquareStructure(pixelSize, bandCount, datatype);
88
	}
89
	
90
	public BufferListFusion() {}
91
	
59 92
	public BufferListFusion(
60 93
			List<Buffer> bufferList,
61
			int pixelSize,
62
			int ouputBandCount,
63
			int outputDatatype,
94
			PixelSquareStructure pxSquare,
64 95
			int fusionMethod) {
65
		this.outputPixelSize = pixelSize;
66
		this.dataType = outputDatatype;
67
		this.bandCount = ouputBandCount;
68 96
		this.bufferList = bufferList;
69
		bbox = getBoundingBox();
97
		if(pxSquare.bbox == null) {
98
			Extent bbox = getBoundingBox();
99
			pxSquare.bbox = bbox;
100
		}
101
		this.pxSquare = pxSquare;
70 102
		
71 103
		if(fusionMethod == FIRST) {
72
			fusion = new FirstFusionMethod();
104
			fusion = new FirstFusionMethod(bufferList, pxSquare);
73 105
		}
74 106
	}
75 107
	
......
80 112
	 * @return
81 113
	 */
82 114
	public Buffer getWindow() {
83
		int width = (int)Math.ceil(bbox.width() * outputPixelSize);
84
		int height = (int)Math.ceil(bbox.height() * outputPixelSize);
85
		Buffer buffer = DefaultRasterManager.getInstance().createBuffer(dataType, width, height, bandCount, true);
115
		if(pxSquare.buffer == null) {
116
			pxSquare.buffer = DefaultRasterManager.getInstance().createBuffer(
117
					pxSquare.dataType, pxSquare.width, pxSquare.height, pxSquare.bandCount, true);
118
		}
86 119
		
87
		if(dataType == Buffer.TYPE_BYTE) {
88
			for (int iBand = 0; iBand < buffer.getBandCount(); iBand++) {
89
				for (int row = 0; row < buffer.getHeight(); row++) {
90
					for (int col = 0; col < buffer.getWidth(); col++) {
91
						buffer.setElem(row, col, iBand, fusion.getByteValue(row, col, iBand));
92
					}	
93
				}
120
		if(pxSquare.dataType == Buffer.TYPE_BYTE) {
121
			for (int row = 0; row < pxSquare.buffer.getHeight(); row++) {
122
				for (int col = 0; col < pxSquare.buffer.getWidth(); col++) {
123
					pxSquare.buffer.setElemByte(row, col, fusion.getByteValue(row, col));
124
				}	
94 125
			}
95 126
		}
96
		
97
		if(dataType == Buffer.TYPE_FLOAT) {
98
			for (int iBand = 0; iBand < buffer.getBandCount(); iBand++) {
99
				for (int row = 0; row < buffer.getHeight(); row++) {
100
					for (int col = 0; col < buffer.getWidth(); col++) {
101
						buffer.setElem(row, col, iBand, fusion.getFloatValue(row, col, iBand));
102
					}	
103
				}
127

  
128
		if(pxSquare.dataType == Buffer.TYPE_FLOAT) {
129
			for (int row = 0; row < pxSquare.buffer.getHeight(); row++) {
130
				for (int col = 0; col < pxSquare.buffer.getWidth(); col++) {
131
					pxSquare.buffer.setElemFloat(row, col, fusion.getFloatValue(row, col));
132
				}	
104 133
			}
105 134
		}
106
		return buffer;
135
		return pxSquare.buffer;
107 136
	}
108 137
	
109
	/*private Extent getIntersectionBoundingBox(Extent bbox) {
110
		Extent intersection = bbox;
111
		if(bboxList != null) {
112
			for (int i = 0; i < bboxList.size(); i++) {
113
				Extent e = bboxList.get(i);
114
				intersection = intersection.intersection(e);
138
	/**
139
	 * Sets a band to NODATA value 
140
	 * @param bufResult
141
	 * @param tileExtent
142
	 * @param buf
143
	 * @param ex
144
	 * @param pixelSize
145
	 */
146
	protected void clearMaskBuffer(Buffer buf) {
147
		if(buf.getDataType() == Buffer.TYPE_BYTE) {
148
			for (int i = 0; i < buf.getHeight(); i++) {
149
				for (int j = 0; j < buf.getWidth(); j++) {
150
					for (int iBand = 0; iBand < buf.getBandCount(); iBand++) {
151
						buf.setElem(i, j, iBand, pxSquare.nodata.getValue().byteValue());						
152
					}
153
				}
115 154
			}
116
		} else {
117
			for (int i = 0; i < bufferList.size(); i++) {
118
				Rectangle2D r = bufferList.get(i).getDataExtent();
119
				Extent e = new ExtentImpl(r.getMinX(), r.getMinY(), r.getMaxX(), r.getMaxY());
120
				intersection = intersection.intersection(e);
155
			return;
156
		}
157
		if(buf.getDataType() == Buffer.TYPE_SHORT) {
158
			for (int i = 0; i < buf.getHeight(); i++) {
159
				for (int j = 0; j < buf.getWidth(); j++) {
160
					for (int iBand = 0; iBand < buf.getBandCount(); iBand++) {
161
						buf.setElem(i, j, iBand, pxSquare.nodata.getValue().shortValue());						
162
					}
163
				}
121 164
			}
165
			return;
122 166
		}
123
		return intersection;
124
	}*/
167
		if(buf.getDataType() == Buffer.TYPE_INT) {
168
			for (int i = 0; i < buf.getHeight(); i++) {
169
				for (int j = 0; j < buf.getWidth(); j++) {
170
					for (int iBand = 0; iBand < buf.getBandCount(); iBand++) {
171
						buf.setElem(i, j, iBand, pxSquare.nodata.getValue().intValue());						
172
					}
173
				}
174
			}
175
			return;
176
		}
177
		if(buf.getDataType() == Buffer.TYPE_FLOAT) {
178
			for (int i = 0; i < buf.getHeight(); i++) {
179
				for (int j = 0; j < buf.getWidth(); j++) {
180
					for (int iBand = 0; iBand < buf.getBandCount(); iBand++) {
181
						buf.setElem(i, j, iBand, pxSquare.nodata.getValue().floatValue());						
182
					}
183
				}
184
			}
185
			return;
186
		}
187
		if(buf.getDataType() == Buffer.TYPE_DOUBLE) {
188
			for (int i = 0; i < buf.getHeight(); i++) {
189
				for (int j = 0; j < buf.getWidth(); j++) {
190
					for (int iBand = 0; iBand < buf.getBandCount(); iBand++) {
191
						buf.setElem(i, j, iBand, pxSquare.nodata.getValue().doubleValue());						
192
					}
193
				}
194
			}
195
			return;
196
		}
197
	}
125 198
	
126 199
	private Extent getBoundingBox() {
127 200
		double minX = Double.MAX_VALUE;
......
156 229
		return new ExtentImpl(minX, minY, maxX, maxY);
157 230
	}
158 231
	
232
	public void dispose() {
233
		for (int i = 0; i < bufferList.size(); i++) {
234
			bufferList.get(i).dispose();
235
		}
236
		bufferList.clear();
237
	}
238
	
239
	/*public void setNoDataValue(int datatype) {
240
		NoData noData = RasterLocator.getManager().getDataStructFactory().createDefaultNoData(bandCount, datatype);
241
		switch (datatype) {
242
		case Buffer.TYPE_BYTE:
243
			byteNoData = noData.getValue().byteValue();
244
			break;
245
		case Buffer.TYPE_SHORT:
246
			shortNoData = noData.getValue().shortValue();
247
			break;
248
		case Buffer.TYPE_INT:
249
			intNoData = noData.getValue().intValue();
250
			break;
251
		case Buffer.TYPE_FLOAT:
252
			floatNoData = noData.getValue().floatValue();
253
			break;
254
		case Buffer.TYPE_DOUBLE:
255
			doubleNoData = ((NoData)noData).getValue().doubleValue();
256
			break;
257
		}
258
	}
259
	
260
	private Extent getIntersectionBoundingBox(Extent bbox) {
261
		Extent intersection = bbox;
262
		if(bboxList != null) {
263
			for (int i = 0; i < bboxList.size(); i++) {
264
				Extent e = bboxList.get(i);
265
				intersection = intersection.intersection(e);
266
			}
267
		} else {
268
			for (int i = 0; i < bufferList.size(); i++) {
269
				Rectangle2D r = bufferList.get(i).getDataExtent();
270
				Extent e = new ExtentImpl(r.getMinX(), r.getMinY(), r.getMaxX(), r.getMaxY());
271
				intersection = intersection.intersection(e);
272
			}
273
		}
274
		return intersection;
275
	}*/
276
	
277
	
159 278
}
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.impl/src/main/java/org/gvsig/raster/impl/provider/fusion/FirstFusionMethod.java
1 1
package org.gvsig.raster.impl.provider.fusion;
2 2

  
3
import java.awt.geom.Rectangle2D;
4
import java.util.ArrayList;
5
import java.util.List;
6

  
7
import org.gvsig.fmap.dal.coverage.dataset.Buffer;
8
import org.gvsig.raster.impl.datastruct.ExtentImpl;
9
import org.gvsig.raster.impl.provider.fusion.BufferListFusion.PixelSquareStructure;
10

  
3 11
public class FirstFusionMethod extends AbstractFusionMethod {
12
	protected SubSquareList     subSquareList = null;
13
	protected byte[]            dataByte      = null;
14
	protected short[]           dataShort     = null;
15
	protected int[]             dataInt       = null;
16
	protected float[]           dataFloat     = null;
17
	protected double[]          dataDouble    = null;
4 18
	
5
	public FirstFusionMethod() {
19
	public class SubSquareList extends ArrayList<SubSquare> {
20
		private static final long serialVersionUID = 1L;
21
		private int[]             coords           = new int[2];
6 22
		
23
		public void getByteValue(int row, int col, byte[] data) {
24
			for (int i = 0; i < size(); i++) {
25
				if(get(i).isInside(row, col)) {
26
					get(i).loadLocalCoords(row, col, coords);
27
					get(i).getBuffer().getElemByte(coords[0], coords[1], data);
28
					return;
29
				}
30
			}
31
		}
32
		
33
		public void getFloatValue(int row, int col, float[] data) {
34
			for (int i = 0; i < size(); i++) {
35
				if(get(i).isInside(row, col)) {
36
					get(i).loadLocalCoords(row, col, coords);
37
					get(i).getBuffer().getElemFloat(coords[0], coords[1], data);
38
					return;
39
				}
40
			}
41
		}
7 42
	}
8

  
9
	public byte getByteValue(int row, int col, int band) {
10
		// TODO Auto-generated method stub
11
		return 0;
43
	
44
	public FirstFusionMethod(
45
			List<Buffer> bufferList, 
46
			PixelSquareStructure pxSquare) {
47
		super(pxSquare);
48
		switch (pxSquare.dataType) {
49
		case Buffer.TYPE_BYTE:
50
			dataByte = new byte[pxSquare.bandCount];
51
			break;
52
		case Buffer.TYPE_SHORT:
53
			dataShort = new short[pxSquare.bandCount];
54
			break;
55
		case Buffer.TYPE_INT:
56
			dataInt = new int[pxSquare.bandCount];
57
			break;
58
		case Buffer.TYPE_FLOAT:
59
			dataFloat = new float[pxSquare.bandCount];
60
			break;
61
		case Buffer.TYPE_DOUBLE:
62
			dataDouble = new double[pxSquare.bandCount];
63
			break;
64
		}
65
		
66
		subSquareList = new SubSquareList();
67
		for (int i = 0; i < bufferList.size(); i++) {
68
			SubSquare square = new SubSquare(
69
					pxSquare.bbox, 
70
					new Rectangle2D.Double(0, 0, pxSquare.width, pxSquare.height),
71
					new ExtentImpl(bufferList.get(i).getDataExtent()),
72
					new Rectangle2D.Double(0, 0, bufferList.get(i).getWidth(), bufferList.get(i).getHeight()),
73
					bufferList.get(i));
74
			subSquareList.add(square);
75
		}
12 76
	}
77
	
78
	public byte[] getByteValue(int row, int col) {
79
		for (int i = 0; i < dataByte.length; i++) {
80
			dataByte[i] = pxSquare.nodata.getValue().byteValue();
81
		}
82
		subSquareList.getByteValue(row, col, dataByte);
83
		return dataByte;
84
	}
13 85

  
14
	public float getFloatValue(int row, int col, int band) {
15
		// TODO Auto-generated method stub
16
		return 0;
86
	public float[] getFloatValue(int row, int col) {
87
		for (int i = 0; i < dataFloat.length; i++) {
88
			dataFloat[i] = pxSquare.nodata.getValue().byteValue();
89
		}
90
		subSquareList.getFloatValue(row, col, dataFloat);
91
		return dataFloat;
17 92
	}
18 93

  
19 94
}
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.impl/src/main/java/org/gvsig/raster/impl/store/DefaultRasterStore.java
57 57
import org.gvsig.fmap.dal.coverage.exception.InvalidSourceException;
58 58
import org.gvsig.fmap.dal.coverage.exception.NotSupportedExtensionException;
59 59
import org.gvsig.fmap.dal.coverage.exception.OperationNotSupportedException;
60
import org.gvsig.fmap.dal.coverage.exception.ParsingException;
61 60
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException;
62 61
import org.gvsig.fmap.dal.coverage.exception.ROIException;
63 62
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException;

Also available in: Unified diff