Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libCq CMS for java.old / src / org / cresques / io / GeoRasterFile.java @ 77

History | View | Annotate | Download (2.34 KB)

1
/*
2
 * Created on 26-abr-2004
3
 *
4
 * @author "Luis W. Sevilla" <sevilla_lui@gva.es>
5
 */
6
package org.cresques.io;
7

    
8
import java.awt.Image;
9

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

    
16
/**
17
 * 
18
 * @author "Luis W. Sevilla" <sevilla_lui@gva.es>*
19
 */
20

    
21
public abstract class GeoRasterFile extends GeoFile {
22
        /**
23
         * Factoria para abrir distintos tipos de raster
24
         * @param fName
25
         * @return
26
         */
27
        public static GeoRasterFile openFile(Projection proj, String fName) {
28
                String ext = fName.toLowerCase().substring(fName.lastIndexOf('.')+1);
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
                
37
                if (ext.compareTo("ecw") == 0) {
38
                        return new EcwFile(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
                        }
54
                }
55

    
56
                return (GeoRasterFile) null;
57
        }
58
        public GeoRasterFile(Projection proj, String name) {
59
                super(proj, name);
60
        }
61
        public static PxContour getContour(String fName, String name, Projection proj) {
62
                PxContour contour = null;
63
                return contour;
64
        }
65

    
66
        abstract public void reProject(ReProjection rp);
67

    
68
        abstract public GeoFile load();
69
        
70
        abstract public void setView(Extent e);
71
        abstract public Extent getView();
72
        
73
        abstract public void setTransparency(boolean t);
74
        
75
        abstract public Image updateImage(int width, int height, ReProjection rp);
76
}