Revision 4181 org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.impl/src/main/java/org/gvsig/raster/impl/provider/AbstractRasterProvider.java

View differences:

AbstractRasterProvider.java
27 27
import java.awt.geom.Point2D;
28 28
import java.io.File;
29 29
import java.net.URI;
30
import java.net.URISyntaxException;
31 30
import java.security.NoSuchAlgorithmException;
32 31
import java.util.Collection;
33 32
import java.util.Date;
34 33
import java.util.Iterator;
35 34
import java.util.List;
36
import java.util.logging.Level;
35

  
37 36
import org.apache.commons.io.FilenameUtils;
37
import org.cresques.cts.IProjection;
38
import org.slf4j.Logger;
39
import org.slf4j.LoggerFactory;
38 40

  
39
import org.cresques.cts.IProjection;
40 41
import org.gvsig.compat.net.ICancellable;
41 42
import org.gvsig.fmap.dal.DALLocator;
42 43
import org.gvsig.fmap.dal.DataServerExplorer;
......
110 111
import org.gvsig.timesupport.Time;
111 112
import org.gvsig.tools.dynobject.DynObject;
112 113
import org.gvsig.tools.locator.LocatorException;
113
import org.slf4j.Logger;
114
import org.slf4j.LoggerFactory;
115 114

  
116 115
/**
117
 * Base class for all raster providers. 
116
 * Base class for all raster providers.
118 117
 * @author Nacho Brodin (nachobrodin@gmail.com)
119 118
 */
120 119
public abstract class AbstractRasterProvider extends AbstractCoverageStoreProvider implements RasterProvider {
......
125 124
	public static final int                   GREEN_BAND             = 0x02;
126 125
	public static final int                   BLUE_BAND              = 0x04;
127 126
	public static final int                   ALPHA_BAND             = 0x08;
128
	
127

  
129 128
	protected int                             bandCount              = 1;
130 129
	private int[]                             dataType               = null;
131 130
	protected NoData                          noData                 = null;
......
141 140
	protected Transparency                    transparency           = null;
142 141
	protected TileServer                      tileServer             = null;
143 142
	protected GeoPointList                    geoPointList           = null;
144
	
143

  
145 144
	protected FileUtils                       fileUtil               = RasterLocator.getManager().getFileUtils();
146 145
	protected RasterUtils                     rasterUtil             = RasterLocator.getManager().getRasterUtils();
147
	
146

  
148 147
	protected IProjection                     proj                   = null;
149 148
	protected long                            fileSize               = 0;
150 149
	protected long                            bytesReaded            = 0;
151 150
	protected long                            lineCnt                = 0;
152
	protected String                          uri;
151
	protected URI                          uri;
153 152
	protected String                          selectedSubdatasetID   = null;
154 153
	/**
155 154
	 * Transformaci�n creada a partir de la informaci�n de georreferencia de la
......
163 162
	 */
164 163
	protected AffineTransform                 externalTransformation = null;
165 164
	private static Logger                     logger                 = LoggerFactory.getLogger(AbstractRasterProvider.class.getName());
166
	
165

  
167 166
	public AbstractRasterProvider(AbstractRasterDataParameters params,
168 167
			DataStoreProviderServices storeServices, DynObject metadata) {
169 168
		super(params, storeServices, metadata);
......
172 171
			if(f.exists())
173 172
				setFileSize(f.length());
174 173
		}
175
		
174

  
176 175
		if(params.getURI() != null)
177
			uri = translateFileName(params.getURI());
178
		
176
			uri = params.getURI();
177

  
179 178
		ownTransformation = new AffineTransform();
180 179
		externalTransformation = new AffineTransform();
181 180
	}
182
	
181

  
183 182
	public AbstractRasterProvider(DataStoreParameters params,
184 183
			DataStoreProviderServices storeServices, DynObject metadata) {
185 184
		super(params, storeServices, metadata);
186
		if(((RasterDataParameters)params).getURI() != null) {
187
			File f = new File(((RasterDataParameters)params).getURI());
188
			if(f.exists())
189
				setFileSize(f.length());
185
		URI uriParam = ((RasterDataParameters)params).getURI();
186
        if(uriParam != null) {
187
            if ("FILE".equalsIgnoreCase(uriParam.getScheme())) {
188
                File f = new File(uriParam);
189
                if (f.exists())
190
                    setFileSize(f.length());
191
            }
190 192
			if(params instanceof RemoteStoreParameters)
191
				uri = translateFileName(((RasterDataParameters)params).getURI());
193
				uri = translateURI(uriParam);
192 194
		}
193
		
195

  
194 196
		ownTransformation = new AffineTransform();
195 197
		externalTransformation = new AffineTransform();
196 198
	}
197
	
199

  
198 200
	public AbstractRasterProvider(String params) {
199 201
		super();
200 202
	}
201
	
203

  
204
	public AbstractRasterProvider(URI uri) {
205
        super();
206
    }
207

  
202 208
	public AbstractRasterProvider() {
203 209
		super(null, null, null);
204 210
	}
205
	
211

  
206 212
	public String[] getFormatList() {
207 213
		return null;
208 214
	}
209
	
215

  
210 216
	/**
211 217
	 * Acciones de inicilizaci?n comunes a todos los drivers.
212 218
	 * Este m?todo debe ser llamado explicitamente por el constructor de cada driver.
......
215 221
	 */
216 222
	protected void init() {
217 223
	}
218
	
224

  
219 225
	public boolean isRGB() {
220 226
		if(getDataType()[0] == Buffer.TYPE_BYTE) {
221 227
			ColorInterpretation ci = getColorInterpretation();
......
223 229
		}
224 230
		return false;
225 231
	}
226
	
232

  
227 233
	public boolean isARGB() {
228 234
		if(getDataType()[0] == Buffer.TYPE_BYTE) {
229 235
			ColorInterpretation ci = getColorInterpretation();
......
231 237
		}
232 238
		return false;
233 239
	}
234
	
240

  
235 241
	public boolean isTiled() {
236 242
		return false;
237 243
	}
238
	
244

  
239 245
	public boolean isTimeSupported() {
240 246
		return false;
241 247
	}
242
	
248

  
243 249
	public RasterProvider cloneProvider() throws CloneException {
244 250
		try {
245 251
			DataManagerProviderServices dataManager = (DataManagerProviderServices)DALLocator.getDataManager();
......
256 262
		}
257 263
		return null;
258 264
	}
259
	
265

  
260 266
	/**
261 267
	 * Factoria para abrir distintos tipos de raster.
262 268
	 * @param fName Nombre del fichero.
......
268 274
		DataManagerProviderServices dataManager = (DataManagerProviderServices)DALLocator.getDataManager();
269 275
		//We have to locate a provider's name which manages the selected file
270 276
		//A FilesystemServerExplorer will give a getProviderNames service
271
		
277

  
272 278
		FilesystemServerExplorer serverExplorer = null;
273 279
		try {
274 280
			FilesystemServerExplorerParameters paramsExplorer = (FilesystemServerExplorerParameters)dataManager.createServerExplorerParameters(FilesystemServerExplorer.NAME);
......
281 287
		} catch (ProviderNotRegisteredException e) {
282 288
			throw new RasterDriverException("Provider not registered", e);
283 289
		}
284
		
290

  
285 291
		//Gets the list of provider's name to manage the file
286 292
		File file = new File(param);
287 293
		List<String> provName = serverExplorer.getProviderNameList(file);
......
292 298
					DataStoreParameters newparams;
293 299
					try {
294 300
						newparams = dataManager.createStoreParameters(provName.get(i));
295
						((FilesystemStoreParameters)newparams).setFile(file); 
301
						((FilesystemStoreParameters)newparams).setFile(file);
296 302
						if(storeServices == null)
297 303
							storeServices = new DefaultRasterStore();
298 304
						return (AbstractRasterProvider)dataManager.createProvider(storeServices, newparams);
......
351 357
	 * Gets the set of data selected in the {@link RasterQuery}
352 358
	 * @param q
353 359
	 * @return
354
	 * @throws RasterDriverException 
355
	 * @throws ProcessInterruptedException 
360
	 * @throws RasterDriverException
361
	 * @throws ProcessInterruptedException
356 362
	 */
357 363
	public Buffer getDataSet(SpiRasterQuery query) throws ProcessInterruptedException, RasterDriverException {
358 364
		SpiRasterQuery q = (SpiRasterQuery)query;
359 365
		loadBuffer(q);
360 366
		return q.getBufferForProviders();
361 367
	}
362
	
368

  
363 369
	/**
364
	 * Load a buffer with the parameters. The buffer should already have been created 
370
	 * Load a buffer with the parameters. The buffer should already have been created
365 371
	 * inside the query structure <code>SpiRasterQuery</code> by the <code>RasterDataStore</code>. The other
366
	 * parameters have been calculated too, all of them adjusted to the raster limits. The provider only 
372
	 * parameters have been calculated too, all of them adjusted to the raster limits. The provider only
367 373
	 * have to read the parameters and load the buffer.
368
	 * 
374
	 *
369 375
	 * @param query
370 376
	 * @throws ProcessInterruptedException
371 377
	 * @throws RasterDriverException
......
373 379
	abstract public void loadBuffer(SpiRasterQuery query) throws ProcessInterruptedException, RasterDriverException;
374 380

  
375 381
	abstract public int getBlockSize();
376
	
382

  
377 383
	abstract public int getOverviewHeight(int band, int overview) throws BandAccessException, RasterDriverException;
378 384

  
379 385
	/**
......
381 387
	 * @return true si soporta overviews y false si no las soporta.
382 388
	 */
383 389
	abstract public boolean isOverviewsSupported();
384
	
390

  
385 391
	public void reload() {
386 392
		try {
387 393
			loadFromRmf(getRmfBlocksManager());
......
389 395
			logger.debug("No se ha podido leer el RMF", e);
390 396
		}
391 397
	}
392
	
398

  
393 399
	/**
394 400
	 * Carga metadatos desde el fichero Rmf si estos existen
395 401
	 * @param fName Nombre del fichero
......
401 407

  
402 408
		if (!new File(manager.getPath()).exists())
403 409
			return;
404
		
410

  
405 411
		GeoInfoRmfSerializer geoInfoSerializer = new GeoInfoRmfSerializer(this);
406 412
		ColorTableRmfSerializer colorTableSerializer = new ColorTableRmfSerializer();
407 413
		GeoPointListRmfSerializer gcpSerializer = new GeoPointListRmfSerializer();
408 414
		NoDataRmfSerializer noDataSerializer = null;
409 415
		if(noData == null)
410 416
			noData = new DefaultNoData(null, null, manager.getPath(), getBandCount());
411
		noDataSerializer = new NoDataRmfSerializer((DefaultNoData)noData);			
417
		noDataSerializer = new NoDataRmfSerializer((DefaultNoData)noData);
412 418
		ColorInterpretationRmfSerializer colorInterpSerializer = new ColorInterpretationRmfSerializer();
413 419
		ProjectionRmfSerializer projectionRmfSerializer = new ProjectionRmfSerializer();
414 420
		StatisticsRmfSerializer statsRmfSerializer = new StatisticsRmfSerializer(getStatistics());
......
438 444
		if (projectionRmfSerializer.getResult() != null) {
439 445
			proj = (IProjection) projectionRmfSerializer.getResult();
440 446
		}
441
		
442
		if( gcpSerializer.getResult() != null && 
443
			gcpSerializer.getResult() instanceof GeoPointList && 
447

  
448
		if( gcpSerializer.getResult() != null &&
449
			gcpSerializer.getResult() instanceof GeoPointList &&
444 450
			((GeoPointList)gcpSerializer.getResult()).size() > 0) {
445 451
			setGeoPointList((GeoPointList)gcpSerializer.getResult());
446 452
		}
......
480 486
		if(noData == null) {
481 487
			noData = RasterLocator.getManager().getDataStructFactory().createDefaultNoData(getBandCount(), getDataType()[0]);
482 488
			noData.setNoDataTransparent(false);
483
			noData.setFileName(getRMFFile());
489
			noData.setFileName(getRMFFile().getName());
484 490
		}
485 491
		return noData;
486 492
	}
487
	
493

  
488 494
	public void setNoDataValue(NoData value) {
489 495
		this.noData = value;
490 496
	}
......
560 566
	}
561 567

  
562 568
	abstract public int getOverviewWidth(int band, int overview) throws BandAccessException, RasterDriverException;
563
	
569

  
564 570
	public void selectSubdataset() {}
565
	
571

  
566 572
	/**
567 573
	 * Selects the subdataset. This method will select
568
	 * the rmf file. 
574
	 * the rmf file.
569 575
	 */
570 576
	protected void selectSubdataset(String subdataset) {
571 577
		selectedSubdatasetID = subdataset;
572
		getRmfBlocksManager().setPath(getRMFFile());
578
		getRmfBlocksManager().setPath(getRMFFile().getPath());
573 579
	}
574 580

  
575 581
	/**
......
577 583
	 * @return RmfBloksManager
578 584
	 */
579 585
	public RmfBlocksManager getRmfBlocksManager() {
580
		String fileRMF = getRMFFile();
586
		File fileRMF = getRMFFile();
581 587
		if(fileRMF != null) {
582
			if (rmfBlocksManager == null || fileRMF.compareTo(rmfBlocksManager.getPath()) != 0) {
583
				rmfBlocksManager = new RmfBlocksManager(fileRMF);
588
			if (rmfBlocksManager == null || !fileRMF.equals(rmfBlocksManager)) {
589
				rmfBlocksManager = new RmfBlocksManager(fileRMF.getPath());
584 590
			}
585 591
		}
586 592
		return rmfBlocksManager;
587 593
	}
588
	
589
	public String getRMFFile() {
590
		String tail = selectedSubdatasetID == null ? ".rmf" : "-sd" + selectedSubdatasetID + ".rmf";
591
		File rmfFolder = (getDataParameters() != null && getDataParameters() instanceof RasterDataParameters) ? 
592
						((RasterDataParameters)getDataParameters()).getRMFFolder() : 
593
						null;
594
			
595
		String fileName = getURI();
596
		if(fileName.contains(File.separator)) {
597
			if(!fileName.endsWith(File.separator)) {
598
				fileName = fileName.substring(fileName.lastIndexOf(File.separator) + 1);
599
				fileName = fileUtil.getNameWithoutExtension(fileName);
600
			}
601
		}
602
		
603
		if(rmfFolder == null) {
604
			if(getURI().contains(File.separator)) {
605
				if(!getURI().endsWith(File.separator)) {
606
					String folder = getURI().substring(0, getURI().lastIndexOf(fileName));
607
					if((getDataParameters() != null && getDataParameters() instanceof RasterDataParameters))
608
						((RasterDataParameters)getDataParameters()).setRMFFolder(new File(folder));
609
				}
610
			}
611
			return fileUtil.getNameWithoutExtension(getURI()) + tail;
612
		} else {
613
			return rmfFolder.getAbsolutePath() + File.separator + fileName + tail;
614
		}
615
		
616
	}
617
	
594

  
595
    public File getRMFFile() {
596
        String tail = selectedSubdatasetID == null ? ".rmf" : "-sd" + selectedSubdatasetID + ".rmf";
597
        File rmfFolder =
598
            (getDataParameters() != null && getDataParameters() instanceof RasterDataParameters)
599
                ? ((RasterDataParameters) getDataParameters()).getRMFFolder() : null;
600

  
601
        String fileName;
602

  
603
        URI objUri = getURI();
604
        File file = new File(objUri);
605
        fileName = FilenameUtils.getBaseName(objUri.getPath());
606
        if (rmfFolder == null) {
607
            rmfFolder = file.getParentFile();
608
            if ((getDataParameters() != null && getDataParameters() instanceof RasterDataParameters)) {
609
                ((RasterDataParameters) getDataParameters()).setRMFFolder(rmfFolder);
610
            }
611
            return new File(fileName + tail);
612
        } else {
613
            return new File(rmfFolder.getAbsolutePath() + File.separator + fileName + tail);
614
        }
615
    }
616

  
618 617
	protected String getRMFFileForRemoteServices(String layerName) {
619 618
		String md5 = "";
620 619
		try {
621
			md5 = RasterLocator.getManager().getFileUtils().convertPathToMD5(uri);
620
			md5 = RasterLocator.getManager().getFileUtils().convertPathToMD5(uri.getPath());
622 621
		} catch (LocatorException e) {
623 622
			logger.debug("Error getting the Locator", e);
624 623
		} catch (NoSuchAlgorithmException e) {
......
657 656
			return true;
658 657
		return false;
659 658
	}
660
	
659

  
661 660
	public boolean isMultiFile() {
662 661
		return false;
663 662
	}
664
	
663

  
665 664
	public boolean isMosaic() {
666 665
		return false;
667 666
	}
......
681 680
	}
682 681

  
683 682
	public void saveObjectToRmf(Class<?> class1, Object value) throws RmfSerializerException {
684
		((DefaultProviderServices)RasterLocator.getManager().getProviderServices()).saveObjectToRmfFile(getRmfBlocksManager(), class1, value);
683
        if (getRmfBlocksManager() != null) {
684
            ((DefaultProviderServices) RasterLocator.getManager().getProviderServices()).saveObjectToRmfFile(
685
                getRmfBlocksManager(), class1, value);
686
        }
685 687
	}
686 688

  
687 689
	/**
......
750 752
	public Object loadObjectFromRmf(Object value) throws RmfSerializerException {
751 753
		return loadObjectFromRmf(value.getClass(), value);
752 754
	}
753
	
754 755

  
756

  
755 757
	public double getCellSize() {
756 758
		try {
757 759
			Extent e = getExtent();
......
761 763
			return 1;
762 764
		}
763 765
	}
764
	
765
	
766

  
767

  
766 768
	public RasterProvider newProvider() {
767 769
		return null;
768 770
	}
769
	
771

  
770 772
	public ColorTable getColorTable() {
771 773
		return colorTable;
772 774
	}
773
	
775

  
774 776
	public Image getImageLegend() {
775 777
		return null;
776 778
	}
777
	
779

  
778 780
	public void setColorTable(ColorTable value) {
779 781
		colorTable = value;
780 782
	}
......
782 784
	public Transparency getTransparency() {
783 785
		return transparency;
784 786
	}
785
	
787

  
786 788
	public Metadata getMetadata() {
787 789
		return null;
788 790
	}
789
	
791

  
790 792
	public ColorInterpretation getColorInterpretation() {
791 793
		return this.colorInterpretation;
792 794
	}
......
799 801
	public void setColorInterpretation(ColorInterpretation colorInterpretation) {
800 802
		this.colorInterpretation = colorInterpretation;
801 803
	}
802
	
804

  
803 805
	public Statistics getStatistics() {
804 806
		if(stats == null) {
805 807
			stats = new SimpleProviderStatistics(this);
806 808
		}
807 809
		return stats;
808 810
	}
809
	
811

  
810 812
	public void setStatistics(Statistics stats) throws RmfSerializerException {
811 813
		this.stats = stats;
812 814
		saveObjectToRmf(Statistics.class, stats);
813 815
	}
814
	
816

  
815 817
	public HistogramComputer getHistogramComputer() {
816 818
		if (histogram == null)
817 819
			histogram = new SimpleProviderHistogramComputer(this);
818 820
		return histogram;
819 821
	}
820
	
822

  
821 823
    //****************************************************
822 824
	//*********Implementing Disposable methods************
823 825
	//****************************************************
824
    
826

  
825 827
    public void doDispose() {
826
    	
828

  
827 829
    }
828
    
830

  
829 831
    //****************************************************
830 832
	//*****Implementing DataStoreProvider methods*********
831 833
	//****************************************************
832
    
834

  
833 835
	@Override
834 836
	public DataServerExplorer getExplorer() throws ReadException,
835 837
			ValidateDataParametersException {
......
845 847
		}*/
846 848
    	return null;
847 849
	}
848
  
849
	
850

  
851

  
850 852
	/**
851 853
	 * Returs the DataParameters
852 854
	 * @return
......
874 876

  
875 877
	public void open() throws OpenException {
876 878
	}
877
	
879

  
878 880
	/**
879 881
	 * Traduce el nombre del fichero por un alias asignado por el propio driver.
880 882
	 * Cuando es traducido por un alias el driver intentar� abrir el alias y no el
......
883 885
	 * @param fileName
884 886
	 * @return
885 887
	 */
886
	public String translateFileName(String fileName) {
888
	public URI translateURI(URI uri) {
889
	    return uri;
890
	}
891

  
892
	/*
893
	 * Si alguna subclase necesita sobreescribir este m?todo, deber? hacerlo con el translateURI en lugar de este.
894
	 */
895
	public final String translateFileName(String fileName) {
887 896
		return fileName;
888 897
	}
889
	
898

  
899

  
890 900
	public String getFileSuffix() {
891
		return getURIOfFirstProvider().substring(getURIOfFirstProvider().lastIndexOf(".") + 1, getURIOfFirstProvider().length());
901
	    //FIXME: ?Sirve para algo?
902
		String path = getURIOfFirstProvider().getPath();
903
        return path.substring(path.lastIndexOf(".") + 1, path.length());
892 904
	}
893 905

  
894
	public String getURIOfFirstProvider() {
895
		return RasterLocator.getManager().getFileUtils().getFormatedRasterFileName(uri);
906
	public URI getURIOfFirstProvider() {
907
	    //FIXME: Esto que lo sobreescriban los proveedores que no son de archivo
908
//		return RasterLocator.getManager().getFileUtils().getFormatedRasterFileName(uri);
909
	    return getURI();
896 910
	}
897 911

  
898
	public String getURI() {
912
	public URI getURI() {
899 913
		return uri;
900 914
	}
901
	
915

  
902 916
	public void setFName(String n) {
903
		uri = n;
917
	    File file = new File(n);
918
	    uri = file.toURI();
904 919
	}
905 920

  
906
        public String getName() {
907
            String pathName = null;
921
    public String getName() {
922
        String pathName = null;
923
        try {
924
            URI x = this.getURI();
925
            pathName = x.getPath();
926
            return FilenameUtils.getBaseName(pathName);
927
        } catch (Throwable th1) {
908 928
            try {
909
                URI x = new URI(this.uri);
910
                pathName = x.getPath();
911
                return FilenameUtils.getBaseName(pathName);
912
            } catch (Throwable th1) {
913
                try {
914
                    return FilenameUtils.getBaseName(this.uri);
915
                } catch(Throwable th2) {
916
                    return this.uri;
917
                }
929
                return FilenameUtils.getBaseName(this.uri.getPath());
930
            } catch (Throwable th2) {
931
                return this.uri.getPath();
918 932
            }
919
	}
920
	
933
        }
934
    }
935

  
921 936
	public String getFullName() {
922
		return uri;
937
		return uri.getPath();
923 938
	}
924
        
939

  
925 940
	/**
926 941
	 * Gets the size of the file if exists in Bytes
927 942
	 * @return
......
974 989
	public String getInfoByPoint(double x, double y, ICancellable cancellable) throws InfoByPointException {
975 990
		return null;
976 991
	}
977
	
992

  
978 993
	public String getInfoByPoint(int x, int y, Extent bbox, int w, int h, ICancellable cancellable) throws InfoByPointException {
979 994
		return null;
980 995
	}
981
	
996

  
982 997
	public void setTileServer(Class<?> tileServer) throws InitializeException {
983
		
998

  
984 999
	}
985
	
1000

  
986 1001
	public int[] getTileSize(int level) {
987 1002
		return new int[]{0, 0};
988 1003
	}
989
	
1004

  
990 1005
	public boolean isRasterEnclosed() {
991 1006
		return false;
992 1007
	}
993
	
1008

  
994 1009
	public int getSourceType() {
995
		if(getURI().startsWith("PG:host"))
996
			return RasterDataStore.POSTGIS;
997
		if(getURI().startsWith("http:") || getURI().startsWith("https:"))
998
			return RasterDataStore.REMOTE;
1010
	    String scheme = getURI().getScheme();
1011
        if("PG".equalsIgnoreCase(scheme)){
1012
	           return RasterDataStore.POSTGIS;
1013
	    } else if ("http".equalsIgnoreCase(scheme) || "https".equalsIgnoreCase(scheme)) {
1014
            return RasterDataStore.REMOTE;
1015
	    }
1016
        //"file".equalsIgnoreCase(scheme)
999 1017
		return RasterDataStore.FILE;
1000 1018
	}
1001
	
1019

  
1002 1020
	/**
1003 1021
	 * Most of providers don't need tiles. It those cases this method
1004 1022
	 * won't execute anything. Only providers that use tile cache will need
1005 1023
	 * implement this function, for instance TileProvider and MosaicProvider.
1006 1024
	 */
1007 1025
	public void deleteLayerFromCache() {
1008
		
1026

  
1009 1027
	}
1010
	
1028

  
1011 1029
	public TimeSeries getTimeSerials() throws RmfSerializerException {
1012 1030
		if(serialInfo == null) {
1013 1031
			serialInfo =  new DefaultTimeSerials();
......
1017 1035
		}
1018 1036
		return serialInfo;
1019 1037
	}
1020
	
1038

  
1021 1039
	public void setTimeSerials(TimeSeries serialInfo) throws RmfSerializerException {
1022 1040
		this.serialInfo = serialInfo;
1023 1041
		saveObjectToRmf(TimeSeries.class, serialInfo);
1024 1042
	}
1025
	
1043

  
1026 1044
	public long[] getFileSizeByProvider() {
1027 1045
		return new long[]{getFileSize()};
1028 1046
	}
1029
	
1030
	public String[] getURIByProvider() {
1047

  
1048
	public URI[] getURIByProvider() {
1031 1049
		//For providers with one file
1032
		return new String[]{getURIOfFirstProvider()};
1050
		return new URI[]{getURIOfFirstProvider()};
1033 1051
	}
1034
	
1052

  
1035 1053
	public int[] getBandCountByProvider() {
1036 1054
		return new int[]{getBandCount()};
1037 1055
	}
1038
	
1056

  
1039 1057
	public int getInternalProviderCount() {
1040 1058
		return 1;
1041 1059
	}
1042
	
1060

  
1043 1061
	public RasterProvider getInternalProvider(int i) {
1044 1062
		return this;
1045 1063
	}
1046
	
1047
	public String getURIByBand(int band) {
1064

  
1065
	public URI getURIByBand(int band) {
1048 1066
		//No matter which band be selected. In providers with one file is always the first URI
1049 1067
		return getURIOfFirstProvider();
1050 1068
	}
1051
	
1069

  
1052 1070
	public int getBandPositionByProvider(int band) {
1053 1071
		return band;
1054 1072
	}
1055
	
1073

  
1056 1074
	public int getSubdatasetCount() {
1057 1075
		return 0;
1058 1076
	}
1059
	
1060
	public void addFile(String file) throws InvalidSourceException {
1061
		//Do nothing
1062
	}
1063
	
1064
	public void removeFile(String file) {
1065
		//Do nothing		
1066
	}
1067
	
1077

  
1078
//	public void addFile(File file) throws InvalidSourceException {
1079
//		//Do nothing
1080
//	}
1081
//
1082
//	public void removeFile(File file) {
1083
//		//Do nothing
1084
//	}
1085

  
1068 1086
	public boolean needEnhanced() {
1069 1087
		return false;
1070 1088
	}
1071
	
1089

  
1072 1090
	/**
1073 1091
	 * Gets the {@link Interval} of the store, that means the temporal
1074 1092
	 * interval where the store has valid data.
1075
	 * In raster this method has sense in a mosaic. Therefore this has to be implemented 
1093
	 * In raster this method has sense in a mosaic. Therefore this has to be implemented
1076 1094
	 * by the provider.
1077 1095
	 * @return
1078 1096
	 *         a time interval or null if there is not time support
......
1080 1098
	public Interval getInterval() {
1081 1099
		return null;
1082 1100
	}
1083
	
1101

  
1084 1102
	/**
1085
	 * Gets all the possible values of time for which the store has data.  
1086
	 * In raster this method has sense in a mosaic. Therefore this has to be implemented 
1103
	 * Gets all the possible values of time for which the store has data.
1104
	 * In raster this method has sense in a mosaic. Therefore this has to be implemented
1087 1105
	 * by the provider.
1088 1106
	 * @return
1089 1107
	 *         a collection of {@link Time} objects.
......
1091 1109
	public Collection<?> getTimes() {
1092 1110
		return null;
1093 1111
	}
1094
	
1112

  
1095 1113
	/**
1096 1114
	 * Gets all the possible values of time for which the store has data
1097 1115
	 * and intersects with an interval.
1098
	 * In raster this method has sense in a mosaic. Therefore this has to be implemented 
1116
	 * In raster this method has sense in a mosaic. Therefore this has to be implemented
1099 1117
	 * by the provider.
1100 1118
	 * @param interval
1101 1119
	 *         the interval of time
......
1105 1123
	public Collection<?> getTimes(Interval interval) {
1106 1124
		return null;
1107 1125
	}
1108
	
1126

  
1109 1127
	/**
1110 1128
	 * Gets the list of geo points associated to this provider
1111 1129
	 * @return
......
1113 1131
	public GeoPointList getGeoPointList() {
1114 1132
		return geoPointList;
1115 1133
	}
1116
	
1134

  
1117 1135
	/**
1118 1136
	 * Sets the list of geo points associated to this provider
1119 1137
	 */
1120 1138
	public void setGeoPointList(GeoPointList geoPointList) {
1121 1139
		this.geoPointList = geoPointList;
1122 1140
	}
1123
	
1141

  
1124 1142
	/**
1125 1143
	 * @deprecated This method should not be used. The store have a getDefaultBandList
1126 1144
	 * @return
1127 1145
	 */
1128 1146
	public BandList getDefaultBandList() {
1129 1147
		BandList bandList = new BandListImpl();
1130
		String[] uriByProvider = getURIByProvider();
1148
		URI[] uriByProvider = getURIByProvider();
1131 1149
		int[] nBandsByProvider = getBandCountByProvider();
1132
		
1150

  
1133 1151
		for (int iProvider = 0; iProvider < uriByProvider.length; iProvider++) {
1134 1152
			for (int iBand = 0; iBand < nBandsByProvider[iProvider]; iBand++) {
1135 1153
				try {
1136
					bandList.addBand(new DatasetBandImpl(uriByProvider[iProvider], iBand, getDataType()[0], nBandsByProvider[iProvider]));
1154
					bandList.addBand(new DatasetBandImpl(uriByProvider[iProvider].getPath(), iBand, getDataType()[0], nBandsByProvider[iProvider]));
1137 1155
				} catch (BandNotFoundInListException e1) {
1138 1156
				}
1139 1157
			}
1140 1158
		}
1141
		
1159

  
1142 1160
		int[] drawableBands = new int[bandList.getBandCount()];
1143 1161
		for (int i = 0; i < bandList.getBandCount(); i++) {
1144 1162
			drawableBands[i] = i;
1145 1163
		}
1146
		
1164

  
1147 1165
		bandList.setDrawableBands(drawableBands);
1148 1166
		return bandList;
1149 1167
	}
1150
	
1168

  
1151 1169
	public void close() {
1152 1170
		if(transparency != null)
1153 1171
			transparency.dispose();
......
1156 1174
		} catch (Throwable e) {
1157 1175
		}
1158 1176
	}
1159
	
1177

  
1160 1178
	protected void finalize() throws Throwable {
1161 1179
		dataType               = null;
1162 1180
		noData                 = null;

Also available in: Unified diff