Statistics
| Revision:

root / trunk / libraries / libRaster / src / org / gvsig / raster / dataset / GeoInfo.java @ 11067

History | View | Annotate | Download (5.08 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2006 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 */
19
package org.gvsig.raster.dataset;
20

    
21
import java.awt.geom.AffineTransform;
22
import java.util.Date;
23

    
24
import org.cresques.cts.IProjection;
25
import org.cresques.geo.Projected;
26
import org.gvsig.raster.shared.Extent;
27

    
28

    
29
/**
30
 * Ancestro de todos los formatos geogr?ficos
31
 *
32
 * @author "Luis W. Sevilla" <sevilla_lui@gva.es>* @author administrador
33
 */
34
public abstract class GeoInfo implements Projected{
35
    IProjection proj = null;
36
    /**
37
     * Extent completo del raster. Este contiene las coordenadas reales tanto
38
     * para un raster rotado como sin rotar. Este extent coincide con requestExtent
39
     * cuando el raster no tiene rotaci?n. 
40
     */
41
    protected Extent extent = null;
42
    /**
43
     * Este es el extent sobre el que se ajusta una petici?n para que esta no exceda el 
44
     * extent m?ximo del raster. Para un raster sin rotar ser? igual al extent
45
     * pero para un raster rotado ser? igual al extent del raster como si no 
46
     * tuviera rotaci?n. Esto ha de ser as? ya que la rotaci?n solo se hace sobre la
47
     * vista y las peticiones han de hacerse en coordenadas de la imagen sin shearing
48
     * aplicado.
49
     */
50
    protected Extent requestExtent = null;
51
    /**
52
     * Esto corresponde a la transformaci?n del extent de la imagen. Se calcula a partir del extent
53
     * guardado en el fichero .rmf asociado a la imagen.  En caso de que no exista este fichero no habr?
54
     * transformaci?n
55
     */
56
    protected AffineTransform        transformRMF = null;
57
    /**
58
     * Esto corresponde a la transformaci?n del extent de la imagen. Se calcula a partir del extent
59
     * guardado en el fichero .tfw asociado a la imagen o en la cabecera de la misma.
60
     */
61
    protected AffineTransform        transformTFW = null;
62
    
63
    protected boolean                        rmfExists = false;
64
    long fileSize = 0;
65
    protected long bytesReaded = 0;
66
    protected long lineCnt = 0;
67
    String name;
68

    
69
    public GeoInfo() {
70
    }
71

    
72
    public GeoInfo(IProjection p, String n) {
73
        proj = p;
74
        name = n;
75
        extent = new Extent();
76
              transformRMF = new AffineTransform();
77
            transformTFW = new AffineTransform();
78
    }
79

    
80
    public String getFName() {
81
        return name;
82
    }
83

    
84
    public void setFName(String n) {
85
        name = n;
86
    }
87

    
88
    public long getFileSize() {
89
        return fileSize;
90
    }
91

    
92
    public void setFileSize(long sz) {
93
        fileSize = sz;
94
    }
95

    
96
    public IProjection getProjection() {
97
        return proj;
98
    }
99

    
100
    public void setProjection(IProjection p) {
101
        proj = p;
102
    }
103

    
104
    /**
105
     * Extent completo del raster. Este contiene las coordenadas reales tanto
106
     * para un raster rotado como sin rotar. Este extent coincide con requestExtent
107
     * cuando el raster no tiene rotaci?n.
108
     * @return Extent 
109
     */
110
    public Extent getExtent() {
111
        return extent;
112
    }
113
    
114
    /**
115
     * Este es el extent sobre el que se ajusta una petici?n para que esta no exceda el 
116
     * extent m?ximo del raster. Para un raster sin rotar ser? igual al extent
117
     * pero para un raster rotado ser? igual al extent del raster como si no 
118
     * tuviera rotaci?n. Esto ha de ser as? ya que la rotaci?n solo se hace sobre la
119
     * vista y las peticiones han de hacerse en coordenadas de la imagen sin shearing
120
     * aplicado.
121
     * @return Extent
122
     */
123
    public Extent getExtentForRequest() {
124
        return requestExtent;
125
    }
126

    
127
    abstract public GeoInfo load();
128

    
129
    abstract public void close();
130

    
131
    /**
132
     * Filtra espacios en blanco. Deja solo uno por
133
     */
134
    public static String filterWS(String buf) {
135
        boolean lastCharWhite = false;
136
        String str = "";
137
        buf = buf.trim();
138

    
139
        for (int i = 0; i < buf.length(); i++) {
140
            char c = buf.charAt(i);
141

    
142
            if (Character.isWhitespace(c)) {
143
                if (lastCharWhite) {
144
                    continue;
145
                }
146

    
147
                lastCharWhite = true;
148
                c = ' ';
149
            } else {
150
                lastCharWhite = false;
151
            }
152

    
153
            str += c;
154
        }
155

    
156
        return str;
157
    }
158

    
159
    protected long getTime() {
160
        return (new Date()).getTime();
161
    }
162
    
163
        /**
164
         * Obtiene la proyecci?n asociada al dataset en formato de cadena de texto
165
         * @return Proyecci?n
166
         */
167
        public String getStringProjection() throws RasterDriverException{
168
                return null;
169
        }
170
    
171
}