Revision 77 trunk/libraries/libCq CMS for java.old/src/org/cresques/io/GeoRasterFile.java

View differences:

GeoRasterFile.java
11 11
import org.cresques.geo.ReProjection;
12 12
import org.cresques.px.Extent;
13 13
import org.cresques.px.PxContour;
14
import java.io.File;
14 15

  
15 16
/**
16 17
 * 
......
26 27
	public static GeoRasterFile openFile(Projection proj, String fName) {
27 28
		String ext = fName.toLowerCase().substring(fName.lastIndexOf('.')+1);
28 29
		
30
		// Copiado de WorldFile
31
		int lengthExtension = fName.length() - fName.lastIndexOf('.');
32
		int l = fName.length(), le = lengthExtension-1;
33
		String wfExt = "."+fName.substring(l-le,l-(le-1))+fName.substring(l-1)+"w"; // ".tfw"
34
		String wfName = fName.substring(0, fName.length()-lengthExtension) + wfExt;
35
		File file = new File(wfName);
36
		
29 37
		if (ext.compareTo("ecw") == 0) {
30 38
			return new EcwFile(proj, fName);
31
		} else if (ext.compareTo("tif") == 0 || ext.compareTo("tiff") == 0 || ext.compareTo("jpg") == 0 ) {
32
			return new TifGeoRefFile(proj, fName);
39
		} else if (ext.compareTo("tif") == 0 || ext.compareTo("tiff") == 0 || ext.compareTo("jpg") == 0 || ext.compareTo("png") == 0) {
40
			// Si la imagen TIFF no lleva un fichero TFW asociado, el programa
41
			// entiende que se trata de una imagen en formato GeoTiff. La
42
			// aproximacion es correcta siempre que manejemos informacion
43
			// georeferenciada, puesto que cualquier TIFF Georeferenciado llevara
44
			// su correspondiente fichero TFW y si no lo lleva no sera una imagen
45
			// georeferenciada valida.
46
			// Para no meter la pata al contemplar TIFFs sin georeferenciar
47
			// debemos contemplar esta alternativa dentro de la categoria de los
48
			// GeoTiffs.
49
			if (!file.exists()) {
50
				return new GeoTiffFile(proj, fName);
51
			} else {
52
				return new TifGeoRefFile(proj, fName);				
53
			}
33 54
		}
34 55

  
35 56
		return (GeoRasterFile) null;

Also available in: Unified diff