Revision 4181 org.gvsig.raster.gdal/trunk/org.gvsig.raster.gdal/org.gvsig.raster.gdal.io/src/main/java/org/gvsig/raster/memory/io/MemoryRasterProvider.java

View differences:

MemoryRasterProvider.java
24 24
import java.awt.geom.AffineTransform;
25 25
import java.awt.geom.Point2D;
26 26
import java.awt.geom.Rectangle2D;
27
import java.io.File;
27 28

  
28 29
import org.cresques.cts.ICoordTrans;
30

  
29 31
import org.gvsig.fmap.dal.coverage.dataset.Buffer;
30 32
import org.gvsig.fmap.dal.coverage.datastruct.BandList;
31 33
import org.gvsig.fmap.dal.coverage.datastruct.Extent;
32 34
import org.gvsig.fmap.dal.coverage.exception.BandAccessException;
33 35
import org.gvsig.fmap.dal.coverage.exception.FileNotOpenException;
34 36
import org.gvsig.fmap.dal.coverage.exception.InvalidSetViewException;
37
import org.gvsig.fmap.dal.coverage.exception.InvalidSourceException;
35 38
import org.gvsig.fmap.dal.coverage.exception.NotSupportedExtensionException;
36 39
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException;
37 40
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException;
......
57 60
	public static String        NAME                     = "Gdal Store";
58 61
	public static String        DESCRIPTION              = "Gdal Raster file";
59 62
	public static final String  METADATA_DEFINITION_NAME = "GdalStore";
60
	
63

  
61 64
	private Extent              v                        = null;
62 65
	protected Buffer            buffer                   = null;
63 66
	private Extent 		        extent                   = null;
64 67
	private boolean             open                     = false;
65
	
68

  
66 69
	public static void register() {
67 70
	}
68
	
71

  
69 72
	public void registerTileProviderFormats(Class<RasterProvider> c) {
70
		
73

  
71 74
	}
72
	
75

  
73 76
	/**
74 77
	 * Mandatory constructor to instantiate an empty provider
75 78
	 */
......
118 121
	public RasterProvider load() {
119 122
		return this;
120 123
	}
121
	
124

  
122 125
	public boolean isOpen() {
123 126
		return open;
124 127
	}
......
246 249
		if(end.getX() > buffer.getWidth())
247 250
			begin.setLocation(buffer.getWidth(), begin.getY());
248 251
	}
249
	
250
	public void loadBuffer(SpiRasterQuery q) 
252

  
253
	public void loadBuffer(SpiRasterQuery q)
251 254
			throws ProcessInterruptedException, RasterDriverException {
252 255
		getWindow(q.getAdjustedRequestBoundingBox(), q.getBandList(), q.getBufferForProviders(), q.getTaskStatus());
253 256
	}
......
269 272
		return rasterBuf;
270 273
	}
271 274

  
272
	public Buffer getWindow(double x, double y, double w, double h, 
275
	public Buffer getWindow(double x, double y, double w, double h,
273 276
			BandList bandList, Buffer rasterBuf, boolean adjustToExtent, TaskStatus status) {
274 277
		Point2D begin = worldToRaster(new Point2D.Double(x, y));
275 278
		Point2D end = worldToRaster(new Point2D.Double(x + w, y - h));
......
287 290
		return rasterBuf;
288 291
	}
289 292

  
290
	public Buffer getWindow(Extent extent, int bufWidth, int bufHeight, 
293
	public Buffer getWindow(Extent extent, int bufWidth, int bufHeight,
291 294
			BandList bandList, Buffer rasterBuf, boolean adjustToExtent, TaskStatus status) {
292 295
		Point2D begin = worldToRaster(new Point2D.Double(extent.getMin().getX(), extent.getMax().getY()));
293 296
		Point2D end = worldToRaster(new Point2D.Double(extent.getMax().getX(), extent.getMin().getY()));
......
348 351
	private void writeByteBuffer(Buffer rasterBuf, double stepX, double stepY, Point2D begin, BandList bandList) {
349 352
		int xPx = 0, yPx = 0;
350 353
		for (int iBand = 0; iBand < buffer.getBandCount(); iBand++) {
351
			int[] drawableBands = bandList.getBufferBandToDraw(this.getURIOfFirstProvider(), iBand);
354
			int[] drawableBands = bandList.getBufferBandToDraw(this.getURIOfFirstProvider().getPath(), iBand);
352 355
			if(drawableBands == null || (drawableBands.length == 1 && drawableBands[0] == -1))
353 356
				continue;
354 357
			for(int drawBands = 0; drawBands < drawableBands.length; drawBands++) {
......
380 383
	private void writeShortBuffer(Buffer rasterBuf, double stepX, double stepY, Point2D begin, BandList bandList) {
381 384
		int xPx = 0, yPx = 0;
382 385
		for (int iBand = 0; iBand < buffer.getBandCount(); iBand++) {
383
			int[] drawableBands = bandList.getBufferBandToDraw(this.getURIOfFirstProvider(), iBand);
386
			int[] drawableBands = bandList.getBufferBandToDraw(this.getURIOfFirstProvider().getPath(), iBand);
384 387
			if(drawableBands == null || (drawableBands.length == 1 && drawableBands[0] == -1))
385 388
				continue;
386 389
			for(int drawBands = 0; drawBands < drawableBands.length; drawBands++) {
......
412 415
	private void writeIntBuffer(Buffer rasterBuf, double stepX, double stepY, Point2D begin, BandList bandList) {
413 416
		int xPx = 0, yPx = 0;
414 417
		for (int iBand = 0; iBand < buffer.getBandCount(); iBand++) {
415
			int[] drawableBands = bandList.getBufferBandToDraw(this.getURIOfFirstProvider(), iBand);
418
			int[] drawableBands = bandList.getBufferBandToDraw(this.getURIOfFirstProvider().getPath(), iBand);
416 419
			if(drawableBands == null || (drawableBands.length == 1 && drawableBands[0] == -1))
417 420
				continue;
418 421
			for(int drawBands = 0; drawBands < drawableBands.length; drawBands++) {
......
444 447
	private void writeFloatBuffer(Buffer rasterBuf, double stepX, double stepY, Point2D begin, BandList bandList) {
445 448
		int xPx = 0, yPx = 0;
446 449
		for (int iBand = 0; iBand < buffer.getBandCount(); iBand++) {
447
			int[] drawableBands = bandList.getBufferBandToDraw(this.getURIOfFirstProvider(), iBand);
450
			int[] drawableBands = bandList.getBufferBandToDraw(this.getURIOfFirstProvider().getPath(), iBand);
448 451
			if(drawableBands == null || (drawableBands.length == 1 && drawableBands[0] == -1))
449 452
				continue;
450 453
			for(int drawBands = 0; drawBands < drawableBands.length; drawBands++) {
......
476 479
	private void writeDoubleBuffer(Buffer rasterBuf, double stepX, double stepY, Point2D begin, BandList bandList) {
477 480
		int xPx = 0, yPx = 0;
478 481
		for (int iBand = 0; iBand < buffer.getBandCount(); iBand++) {
479
			int[] drawableBands = bandList.getBufferBandToDraw(this.getURIOfFirstProvider(), iBand);
482
			int[] drawableBands = bandList.getBufferBandToDraw(this.getURIOfFirstProvider().getPath(), iBand);
480 483
			if(drawableBands == null || (drawableBands.length == 1 && drawableBands[0] == -1))
481 484
				continue;
482 485
			for(int drawBands = 0; drawBands < drawableBands.length; drawBands++) {
......
546 549
//		return rasterBuf;
547 550
//	}
548 551

  
549
	public Buffer getWindow(int x, int y, int w, int h, 
552
	public Buffer getWindow(int x, int y, int w, int h,
550 553
			BandList bandList, Buffer rasterBuf, TaskStatus status) {
551 554
		setView(
552 555
				new ExtentImpl( rasterUtil.getMapRectFromPxRect(getExtent().toRectangle2D(),
......
661 664
	public boolean isOverviewsSupported() {
662 665
		return false;
663 666
	}
664
	
667

  
665 668
	public String getProviderName() {
666 669
		return NAME;
667 670
	}
......
669 672
        public String getName() {
670 673
		return "buffer"+this.hashCode();
671 674
	}
672
	
675

  
673 676
        public String getFullName() {
674 677
		return this.getName();
675 678
	}
676
        
679

  
677 680
	public void setStatus(RasterProvider provider) {
678 681
		if(provider instanceof MemoryRasterProvider) {
679 682
			//Not implemented yet
680 683
		}
681 684
	}
682
	
685

  
683 686
	public TileServer getTileServer() {
684 687
		return null;
685 688
	}
686 689

  
690
    public void addFile(File file) throws InvalidSourceException {
691
        // Do nothing
692
    }
693

  
694
    public void removeFile(File file) {
695
        // Do nothing
696
    }
697

  
687 698
}

Also available in: Unified diff