Statistics
| Revision:

root / trunk / libraries / libRaster / src / org / gvsig / raster / driver / GeoData.java @ 10740

History | View | Annotate | Download (5.16 KB)

1 10740 nacho
/* 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.driver;
20
21
import java.awt.geom.AffineTransform;
22
import java.util.Date;
23
24
import org.cresques.cts.ICoordTrans;
25
import org.cresques.cts.IProjection;
26
import org.cresques.geo.Projected;
27
import org.gvsig.raster.shared.Extent;
28
29
import com.hardcode.driverManager.Driver;
30
31
32
/**
33
 * Ancestro de todos los formatos geogr?ficos
34
 *
35
 * @author "Luis W. Sevilla" <sevilla_lui@gva.es>* @author administrador
36
 */
37
public abstract class GeoData implements Projected{
38
    IProjection proj = null;
39
    /**
40
     * Extent completo del raster. Este contiene las coordenadas reales tanto
41
     * para un raster rotado como sin rotar. Este extent coincide con requestExtent
42
     * cuando el raster no tiene rotaci?n.
43
     */
44
    protected Extent extent = null;
45
    /**
46
     * Este es el extent sobre el que se ajusta una petici?n para que esta no exceda el
47
     * extent m?ximo del raster. Para un raster sin rotar ser? igual al extent
48
     * pero para un raster rotado ser? igual al extent del raster como si no
49
     * tuviera rotaci?n. Esto ha de ser as? ya que la rotaci?n solo se hace sobre la
50
     * vista y las peticiones han de hacerse en coordenadas de la imagen sin shearing
51
     * aplicado.
52
     */
53
    protected Extent requestExtent = null;
54
    /**
55
     * Esto corresponde a la transformaci?n del extent de la imagen. Se calcula a partir del extent
56
     * guardado en el fichero .rmf asociado a la imagen.  En caso de que no exista este fichero no habr?
57
     * transformaci?n
58
     */
59
    protected AffineTransform        transformRMF = null;
60
    /**
61
     * Esto corresponde a la transformaci?n del extent de la imagen. Se calcula a partir del extent
62
     * guardado en el fichero .tfw asociado a la imagen o en la cabecera de la misma.
63
     */
64
    protected AffineTransform        transformTFW = null;
65
66
    protected boolean                        rmfExists = false;
67
    long fileSize = 0;
68
    protected long bytesReaded = 0;
69
    protected long lineCnt = 0;
70
    String name;
71
72
    public GeoData() {
73
    }
74
75
    public GeoData(IProjection p, String n) {
76
        proj = p;
77
        name = n;
78
        extent = new Extent();
79
              transformRMF = new AffineTransform();
80
            transformTFW = new AffineTransform();
81
    }
82
83
    public String getFName() {
84
        return name;
85
    }
86
87
    public void setFName(String n) {
88
        name = n;
89
    }
90
91
    public long getFileSize() {
92
        return fileSize;
93
    }
94
95
    public void setFileSize(long sz) {
96
        fileSize = sz;
97
    }
98
99
    public IProjection getProjection() {
100
        return proj;
101
    }
102
103
    public void setProjection(IProjection p) {
104
        proj = p;
105
    }
106
107
    /**
108
     * Extent completo del raster. Este contiene las coordenadas reales tanto
109
     * para un raster rotado como sin rotar. Este extent coincide con requestExtent
110
     * cuando el raster no tiene rotaci?n.
111
     * @return Extent
112
     */
113
    public Extent getExtent() {
114
        return extent;
115
    }
116
117
    /**
118
     * Este es el extent sobre el que se ajusta una petici?n para que esta no exceda el
119
     * extent m?ximo del raster. Para un raster sin rotar ser? igual al extent
120
     * pero para un raster rotado ser? igual al extent del raster como si no
121
     * tuviera rotaci?n. Esto ha de ser as? ya que la rotaci?n solo se hace sobre la
122
     * vista y las peticiones han de hacerse en coordenadas de la imagen sin shearing
123
     * aplicado.
124
     * @return Extent
125
     */
126
    public Extent getExtentForRequest() {
127
        return requestExtent;
128
    }
129
130
    abstract public GeoData load();
131
132
    abstract public void close();
133
134
    /**
135
     * Filtra espacios en blanco. Deja solo uno por
136
     */
137
    public static String filterWS(String buf) {
138
        boolean lastCharWhite = false;
139
        String str = "";
140
        buf = buf.trim();
141
142
        for (int i = 0; i < buf.length(); i++) {
143
            char c = buf.charAt(i);
144
145
            if (Character.isWhitespace(c)) {
146
                if (lastCharWhite) {
147
                    continue;
148
                }
149
150
                lastCharWhite = true;
151
                c = ' ';
152
            } else {
153
                lastCharWhite = false;
154
            }
155
156
            str += c;
157
        }
158
159
        return str;
160
    }
161
162
    protected long getTime() {
163
        return (new Date()).getTime();
164
    }
165
166
        /**
167
         * Obtiene la proyecci?n asociada al dataset en formato de cadena de texto
168
         * @return Proyecci?n
169
         */
170
        public String getStringProjection() throws RasterDriverException{
171
                return null;
172
        }
173
174
}