gvsig-raster / org.gvsig.raster.tilecache / trunk / org.gvsig.raster.tilecache / org.gvsig.raster.tilecache.io / src / main / java / org / gvsig / raster / tilecache / io / tff / TileFileFormatProvider.java @ 5981
History | View | Annotate | Download (8.89 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
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., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
package org.gvsig.raster.tilecache.io.tff; |
23 |
|
24 |
import java.awt.geom.Point2D; |
25 |
import java.io.File; |
26 |
|
27 |
import org.gvsig.fmap.dal.DALFileLocator; |
28 |
import org.gvsig.fmap.dal.DALLocator; |
29 |
import org.gvsig.fmap.dal.DataStore; |
30 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
31 |
import org.gvsig.fmap.dal.coverage.datastruct.Extent; |
32 |
import org.gvsig.fmap.dal.coverage.exception.BandAccessException; |
33 |
import org.gvsig.fmap.dal.coverage.exception.FileNotOpenException; |
34 |
import org.gvsig.fmap.dal.coverage.exception.InvalidSetViewException; |
35 |
import org.gvsig.fmap.dal.coverage.exception.InvalidSourceException; |
36 |
import org.gvsig.fmap.dal.coverage.exception.NotSupportedExtensionException; |
37 |
import org.gvsig.fmap.dal.coverage.exception.ParsingException; |
38 |
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException; |
39 |
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException; |
40 |
import org.gvsig.fmap.dal.exception.InitializeException; |
41 |
import org.gvsig.fmap.dal.exception.OpenException; |
42 |
import org.gvsig.fmap.dal.spi.DataManagerProviderServices; |
43 |
import org.gvsig.fmap.dal.spi.DataStoreProviderServices; |
44 |
import org.gvsig.metadata.MetadataLocator; |
45 |
import org.gvsig.raster.cache.tile.Tile; |
46 |
import org.gvsig.raster.cache.tile.exception.TileGettingException; |
47 |
import org.gvsig.raster.cache.tile.provider.TileServer; |
48 |
import org.gvsig.raster.impl.buffer.SpiRasterQuery; |
49 |
import org.gvsig.raster.impl.provider.AbstractRasterProvider; |
50 |
import org.gvsig.raster.impl.provider.RasterProvider; |
51 |
import org.gvsig.raster.impl.provider.TiledRasterProvider; |
52 |
import org.gvsig.raster.impl.store.DefaultStoreFactory; |
53 |
import org.gvsig.tools.ToolsLocator; |
54 |
import org.gvsig.tools.extensionpoint.ExtensionPoint; |
55 |
import org.gvsig.tools.extensionpoint.ExtensionPointManager; |
56 |
|
57 |
import org.slf4j.Logger; |
58 |
import org.slf4j.LoggerFactory; |
59 |
|
60 |
/**
|
61 |
* Provider for <code>TileFileFormat</code>
|
62 |
*
|
63 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
64 |
*/
|
65 |
public class TileFileFormatProvider extends AbstractRasterProvider implements TiledRasterProvider { |
66 |
public static String NAME = "TileFileFormat Store"; |
67 |
public static String DESCRIPTION = "Tile file format Source"; |
68 |
public static final String METADATA_DEFINITION_NAME = "TileFileFormatStore"; |
69 |
private static final Logger logger = LoggerFactory.getLogger(TileFileFormatProvider.class); |
70 |
protected static String[] formatList = null; |
71 |
private boolean open = false; |
72 |
|
73 |
/**
|
74 |
*
|
75 |
*/
|
76 |
public static void register() { |
77 |
ExtensionPointManager extensionPoints = ToolsLocator.getExtensionPointManager(); |
78 |
registerFormats(); |
79 |
|
80 |
ExtensionPoint point = extensionPoints.get("DefaultRasterProvider");
|
81 |
point.append("reader", TileFileFormatProvider.NAME, TileFileFormatProvider.class);
|
82 |
|
83 |
DataManagerProviderServices dataman = (DataManagerProviderServices) DALLocator.getDataManager(); |
84 |
if (dataman != null && !dataman.getStoreProviders().contains(NAME)) { |
85 |
dataman.registerStoreProvider(NAME, |
86 |
TileFileFormatProvider.class, TileFileFormatDataParameters.class); |
87 |
} |
88 |
|
89 |
if(DALFileLocator.getFilesystemServerExplorerManager() != null) |
90 |
DALFileLocator.getFilesystemServerExplorerManager().registerProvider( |
91 |
NAME, DESCRIPTION, |
92 |
TileFileFormatFilesystemServerExplorer.class); |
93 |
|
94 |
dataman.registerStoreFactory(NAME, DefaultStoreFactory.class); |
95 |
} |
96 |
|
97 |
private static void registerFormats() { |
98 |
formatList = new String[] {"tff"}; |
99 |
for (int i = 0; i < formatList.length; i++) |
100 |
RasterLocator.getManager().getProviderServices().addFormat(formatList[i], TileFileFormatProvider.class); |
101 |
} |
102 |
|
103 |
public String[] getFormatList() { |
104 |
return formatList;
|
105 |
} |
106 |
|
107 |
/**
|
108 |
* @param ext
|
109 |
* @return true if the extension is supported
|
110 |
*/
|
111 |
public boolean isExtensionSupported(String ext) { |
112 |
if(ext.indexOf(".") != -1) |
113 |
ext = ext.substring(ext.lastIndexOf(".") + 1, ext.length()); |
114 |
for (int i = 0; i < formatList.length; i++) { |
115 |
if(formatList[i].compareTo(ext) == 0) |
116 |
return true; |
117 |
} |
118 |
return false; |
119 |
} |
120 |
|
121 |
/**
|
122 |
* @throws NotSupportedExtensionException
|
123 |
*/
|
124 |
public TileFileFormatProvider() throws NotSupportedExtensionException { |
125 |
super();
|
126 |
} |
127 |
|
128 |
/**
|
129 |
* @param params
|
130 |
* @param storeServices
|
131 |
* @throws InitializeException
|
132 |
*/
|
133 |
public TileFileFormatProvider(TileFileFormatDataParameters params,
|
134 |
DataStoreProviderServices storeServices) throws InitializeException {
|
135 |
super(params, storeServices, ToolsLocator.getDynObjectManager()
|
136 |
.createDynObject( |
137 |
MetadataLocator.getMetadataManager().getDefinition( |
138 |
DataStore.METADATA_DEFINITION_NAME))); |
139 |
try {
|
140 |
init(params, storeServices); |
141 |
} catch (OpenException e) {
|
142 |
throw new InitializeException("Error open the source", e); |
143 |
} catch (NotSupportedExtensionException e) {
|
144 |
throw new InitializeException("Not supported extension", e); |
145 |
} |
146 |
} |
147 |
|
148 |
/**
|
149 |
* Build file references
|
150 |
* @param params
|
151 |
* @param storeServices
|
152 |
* @throws NotSupportedExtensionException
|
153 |
* @throws OpenException
|
154 |
*/
|
155 |
public void init(TileFileFormatDataParameters params, |
156 |
DataStoreProviderServices storeServices) throws NotSupportedExtensionException, OpenException {
|
157 |
|
158 |
openFromTff(); |
159 |
|
160 |
uri = getParameters().getURI(); |
161 |
|
162 |
super.init();
|
163 |
|
164 |
try {
|
165 |
loadFromRmf(getRmfBlocksManager()); |
166 |
} catch (ParsingException e) {
|
167 |
logger.debug("Problems reading from RMF", e);
|
168 |
} |
169 |
|
170 |
open = true;
|
171 |
} |
172 |
|
173 |
/**
|
174 |
* Open from a .mff file.
|
175 |
* This method loads all providers and adds these to the parameters
|
176 |
* @throws OpenException
|
177 |
*/
|
178 |
private void openFromTff() throws OpenException { |
179 |
|
180 |
} |
181 |
|
182 |
/**
|
183 |
* @return the TileFileFormatDataParameters
|
184 |
*/
|
185 |
public TileFileFormatDataParameters getParameters() {
|
186 |
try {
|
187 |
return (TileFileFormatDataParameters)parameters;
|
188 |
} catch (ClassCastException e) { |
189 |
return null; |
190 |
} |
191 |
} |
192 |
|
193 |
@Override
|
194 |
public int getBlockSize() { |
195 |
return 0; |
196 |
} |
197 |
|
198 |
@Override
|
199 |
public Object getData(int x, int y, int band) |
200 |
throws InvalidSetViewException, FileNotOpenException,
|
201 |
RasterDriverException { |
202 |
return null; |
203 |
} |
204 |
|
205 |
@Override
|
206 |
public double getHeight() { |
207 |
return 0; |
208 |
} |
209 |
|
210 |
@Override
|
211 |
public int getOverviewHeight(int band, int overview) |
212 |
throws BandAccessException, RasterDriverException {
|
213 |
return 0; |
214 |
} |
215 |
|
216 |
@Override
|
217 |
public int getOverviewWidth(int band, int overview) |
218 |
throws BandAccessException, RasterDriverException {
|
219 |
return 0; |
220 |
} |
221 |
|
222 |
@Override
|
223 |
public Extent getView() {
|
224 |
return null; |
225 |
} |
226 |
|
227 |
@Override
|
228 |
public double getWidth() { |
229 |
return 0; |
230 |
} |
231 |
|
232 |
@Override
|
233 |
public boolean isOverviewsSupported() { |
234 |
return false; |
235 |
} |
236 |
|
237 |
@Override
|
238 |
public RasterProvider load() {
|
239 |
return null; |
240 |
} |
241 |
|
242 |
@Override
|
243 |
public void setView(Extent e) { |
244 |
|
245 |
} |
246 |
|
247 |
public Extent getCoordsInLevel(Point2D viewCenter, int level, int w, int h) { |
248 |
return null; |
249 |
} |
250 |
|
251 |
public Extent getCoordsInTheNearestLevel(Extent extent, int w, int h) { |
252 |
return null; |
253 |
} |
254 |
|
255 |
public RasterProvider getInternalProvider() {
|
256 |
return null; |
257 |
} |
258 |
|
259 |
public int getNearestLevel(double pixelSize) { |
260 |
return 0; |
261 |
} |
262 |
|
263 |
public Tile getTile(SpiRasterQuery q) throws TileGettingException { |
264 |
return null; |
265 |
} |
266 |
|
267 |
public int getZoomLevels() { |
268 |
return 0; |
269 |
} |
270 |
|
271 |
public int getOverviewCount(int band) throws BandAccessException, |
272 |
RasterDriverException { |
273 |
return 0; |
274 |
} |
275 |
|
276 |
public TileServer getTileServer() {
|
277 |
return null; |
278 |
} |
279 |
|
280 |
public boolean isOpen() { |
281 |
return open;
|
282 |
} |
283 |
|
284 |
public Object readBlock(int pos, int blockHeight, double scale) |
285 |
throws InvalidSetViewException, FileNotOpenException,
|
286 |
RasterDriverException, ProcessInterruptedException { |
287 |
return null; |
288 |
} |
289 |
|
290 |
public void setStatus(RasterProvider provider) { |
291 |
|
292 |
} |
293 |
|
294 |
public String getProviderName() { |
295 |
return NAME;
|
296 |
} |
297 |
|
298 |
@Override
|
299 |
public void loadBuffer(SpiRasterQuery query) |
300 |
throws ProcessInterruptedException, RasterDriverException {
|
301 |
// TODO Auto-generated method stub
|
302 |
|
303 |
} |
304 |
|
305 |
/* (non-Javadoc)
|
306 |
* @see org.gvsig.raster.impl.provider.RasterProvider#addFile(java.io.File)
|
307 |
*/
|
308 |
@Override
|
309 |
public void addFile(File file) throws InvalidSourceException { |
310 |
//Do nothing
|
311 |
} |
312 |
|
313 |
/* (non-Javadoc)
|
314 |
* @see org.gvsig.raster.impl.provider.RasterProvider#removeFile(java.io.File)
|
315 |
*/
|
316 |
@Override
|
317 |
public void removeFile(File file) { |
318 |
//Do nothing
|
319 |
} |
320 |
|
321 |
} |