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