svn-gvsig-desktop / tags / v1_0_2_Build_905 / libraries / libCq CMS for java.old / src / org / cresques / io / GeoFile.java @ 10767
History | View | Annotate | Download (5.2 KB)
1 | 2 | luisw | /*
|
---|---|---|---|
2 | 2809 | nacho | * Cresques Mapping Suite. Graphic Library for constructing mapping applications.
|
3 | 2 | luisw | *
|
4 | 2809 | nacho | * Copyright (C) 2004-5.
|
5 | *
|
||
6 | * This program is free software; you can redistribute it and/or
|
||
7 | * modify it under the terms of the GNU General Public License
|
||
8 | * as published by the Free Software Foundation; either version 2
|
||
9 | * of the License, or (at your option) any later version.
|
||
10 | *
|
||
11 | * This program is distributed in the hope that it will be useful,
|
||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
14 | * GNU General Public License for more details.
|
||
15 | *
|
||
16 | * You should have received a copy of the GNU General Public License
|
||
17 | * along with this program; if not, write to the Free Software
|
||
18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
19 | *
|
||
20 | * For more information, contact:
|
||
21 | *
|
||
22 | * cresques@gmail.com
|
||
23 | 2 | luisw | */
|
24 | package org.cresques.io; |
||
25 | |||
26 | 5185 | nacho | import java.awt.geom.AffineTransform; |
27 | 5155 | nacho | import java.awt.geom.Point2D; |
28 | import java.util.Date; |
||
29 | |||
30 | 94 | luisw | import org.cresques.cts.ICoordTrans; |
31 | import org.cresques.cts.IProjection; |
||
32 | 2 | luisw | import org.cresques.geo.Projected; |
33 | import org.cresques.px.Extent; |
||
34 | 96 | luisw | import org.cresques.px.IObjList; |
35 | 2 | luisw | |
36 | 2809 | nacho | |
37 | 2 | luisw | /**
|
38 | * Ancestro de todos los formatos geogr?ficos
|
||
39 | 2809 | nacho | *
|
40 | 2 | luisw | * @author "Luis W. Sevilla" <sevilla_lui@gva.es>* @author administrador
|
41 | */
|
||
42 | 11 | luisw | public abstract class GeoFile implements Projected, Extent.Has { |
43 | 2809 | nacho | IProjection proj = null;
|
44 | 8765 | jjdelcerro | /**
|
45 | * Extent completo del raster. Este contiene las coordenadas reales tanto
|
||
46 | * para un raster rotado como sin rotar. Este extent coincide con requestExtent
|
||
47 | * cuando el raster no tiene rotaci?n.
|
||
48 | */
|
||
49 | 2809 | nacho | protected Extent extent = null; |
50 | 5155 | nacho | /**
|
51 | 8765 | jjdelcerro | * Este es el extent sobre el que se ajusta una petici?n para que esta no exceda el
|
52 | * extent m?ximo del raster. Para un raster sin rotar ser? igual al extent
|
||
53 | * pero para un raster rotado ser? igual al extent del raster como si no
|
||
54 | * tuviera rotaci?n. Esto ha de ser as? ya que la rotaci?n solo se hace sobre la
|
||
55 | * vista y las peticiones han de hacerse en coordenadas de la imagen sin shearing
|
||
56 | * aplicado.
|
||
57 | */
|
||
58 | protected Extent requestExtent = null; |
||
59 | /**
|
||
60 | 5155 | nacho | * Esto corresponde a la transformaci?n del extent de la imagen. Se calcula a partir del extent
|
61 | 5185 | nacho | * guardado en el fichero .rmf asociado a la imagen. En caso de que no exista este fichero no habr?
|
62 | * transformaci?n
|
||
63 | 5155 | nacho | */
|
64 | 8765 | jjdelcerro | protected AffineTransform transformRMF = null; |
65 | /**
|
||
66 | * Esto corresponde a la transformaci?n del extent de la imagen. Se calcula a partir del extent
|
||
67 | * guardado en el fichero .tfw asociado a la imagen o en la cabecera de la misma.
|
||
68 | */
|
||
69 | protected AffineTransform transformTFW = null; |
||
70 | 5185 | nacho | |
71 | |||
72 | protected boolean rmfExists = false; |
||
73 | 2809 | nacho | long fileSize = 0; |
74 | protected long bytesReaded = 0; |
||
75 | protected long lineCnt = 0; |
||
76 | String name;
|
||
77 | 2 | luisw | |
78 | 2809 | nacho | public GeoFile() {
|
79 | } |
||
80 | 2 | luisw | |
81 | 2809 | nacho | public GeoFile(IProjection p, String n) { |
82 | proj = p; |
||
83 | name = n; |
||
84 | |||
85 | if (name != null) { |
||
86 | name = DataSource.normalize(name);
|
||
87 | } |
||
88 | extent = new Extent();
|
||
89 | 8765 | jjdelcerro | transformRMF = new AffineTransform(); |
90 | transformTFW = new AffineTransform(); |
||
91 | 2809 | nacho | } |
92 | |||
93 | public String getName() { |
||
94 | return name;
|
||
95 | } |
||
96 | |||
97 | public void setName(String n) { |
||
98 | name = n; |
||
99 | } |
||
100 | |||
101 | public long getFileSize() { |
||
102 | return fileSize;
|
||
103 | } |
||
104 | |||
105 | public void setFileSize(long sz) { |
||
106 | fileSize = sz; |
||
107 | } |
||
108 | |||
109 | public IProjection getProjection() {
|
||
110 | return proj;
|
||
111 | } |
||
112 | |||
113 | public void setProjection(IProjection p) { |
||
114 | proj = p; |
||
115 | } |
||
116 | |||
117 | abstract public void reProject(ICoordTrans rp); |
||
118 | |||
119 | 8765 | jjdelcerro | /**
|
120 | * Extent completo del raster. Este contiene las coordenadas reales tanto
|
||
121 | * para un raster rotado como sin rotar. Este extent coincide con requestExtent
|
||
122 | * cuando el raster no tiene rotaci?n.
|
||
123 | * @return Extent
|
||
124 | */
|
||
125 | 2809 | nacho | public Extent getExtent() {
|
126 | return extent;
|
||
127 | } |
||
128 | 5155 | nacho | |
129 | /**
|
||
130 | 8765 | jjdelcerro | * Este es el extent sobre el que se ajusta una petici?n para que esta no exceda el
|
131 | * extent m?ximo del raster. Para un raster sin rotar ser? igual al extent
|
||
132 | * pero para un raster rotado ser? igual al extent del raster como si no
|
||
133 | * tuviera rotaci?n. Esto ha de ser as? ya que la rotaci?n solo se hace sobre la
|
||
134 | * vista y las peticiones han de hacerse en coordenadas de la imagen sin shearing
|
||
135 | * aplicado.
|
||
136 | * @return Extent
|
||
137 | 5155 | nacho | */
|
138 | 8765 | jjdelcerro | public Extent getExtentForRequest() {
|
139 | return requestExtent;
|
||
140 | 5155 | nacho | } |
141 | 8765 | jjdelcerro | |
142 | 2809 | nacho | abstract public GeoFile load(); |
143 | |||
144 | abstract public void close(); |
||
145 | |||
146 | abstract public IObjList getObjects(); |
||
147 | |||
148 | /**
|
||
149 | * Filtra espacios en blanco. Deja solo uno por
|
||
150 | */
|
||
151 | public static String filterWS(String buf) { |
||
152 | boolean lastCharWhite = false; |
||
153 | String str = ""; |
||
154 | buf = buf.trim(); |
||
155 | |||
156 | for (int i = 0; i < buf.length(); i++) { |
||
157 | char c = buf.charAt(i);
|
||
158 | |||
159 | if (Character.isWhitespace(c)) { |
||
160 | if (lastCharWhite) {
|
||
161 | continue;
|
||
162 | } |
||
163 | |||
164 | lastCharWhite = true;
|
||
165 | c = ' ';
|
||
166 | } else {
|
||
167 | lastCharWhite = false;
|
||
168 | } |
||
169 | |||
170 | str += c; |
||
171 | } |
||
172 | |||
173 | return str;
|
||
174 | } |
||
175 | |||
176 | protected long getTime() { |
||
177 | return (new Date()).getTime(); |
||
178 | } |
||
179 | 2 | luisw | } |