Statistics
| Revision:

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 @ 1965

History | View | Annotate | Download (9.27 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

    
26
import org.gvsig.fmap.dal.DALFileLocator;
27
import org.gvsig.fmap.dal.DALLocator;
28
import org.gvsig.fmap.dal.DataStore;
29
import org.gvsig.fmap.dal.coverage.RasterLocator;
30
import org.gvsig.fmap.dal.coverage.dataset.Buffer;
31
import org.gvsig.fmap.dal.coverage.datastruct.BandList;
32
import org.gvsig.fmap.dal.coverage.datastruct.Extent;
33
import org.gvsig.fmap.dal.coverage.exception.BandAccessException;
34
import org.gvsig.fmap.dal.coverage.exception.FileNotOpenException;
35
import org.gvsig.fmap.dal.coverage.exception.InvalidSetViewException;
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.TileListener;
48
import org.gvsig.raster.cache.tile.provider.TileServer;
49
import org.gvsig.raster.impl.buffer.DefaultRasterQuery;
50
import org.gvsig.raster.impl.provider.DefaultRasterProvider;
51
import org.gvsig.raster.impl.provider.RasterProvider;
52
import org.gvsig.raster.impl.provider.TiledRasterProvider;
53
import org.gvsig.raster.impl.store.DefaultStoreFactory;
54
import org.gvsig.tools.ToolsLocator;
55
import org.gvsig.tools.extensionpoint.ExtensionPoint;
56
import org.gvsig.tools.extensionpoint.ExtensionPointManager;
57
import org.gvsig.tools.task.TaskStatus;
58
import org.slf4j.Logger;
59
import org.slf4j.LoggerFactory;
60

    
61
/**
62
 * Provider for <code>TileFileFormat</code>
63
 *
64
 * @author Nacho Brodin (nachobrodin@gmail.com)
65
 */
66
public class TileFileFormatProvider extends DefaultRasterProvider implements TiledRasterProvider {
67
        public static String                NAME                     = "TileFileFormat Store";
68
        public static String                DESCRIPTION              = "Tile file format Source";
69
        public static final String          METADATA_DEFINITION_NAME = "TileFileFormatStore";
70
        private static final Logger         logger                   = LoggerFactory.getLogger(TileFileFormatProvider.class);
71
        protected static String[]           formatList               = null;
72
        private boolean                     open                     = false;
73
         
74
        public static void register() {                
75
                ExtensionPointManager extensionPoints = ToolsLocator.getExtensionPointManager();
76
                registerFormats();
77
                
78
                ExtensionPoint point = extensionPoints.get("DefaultRasterProvider");
79
                point.append("reader", TileFileFormatProvider.NAME, TileFileFormatProvider.class);
80
                
81
                DataManagerProviderServices dataman = (DataManagerProviderServices) DALLocator.getDataManager();
82
                if (dataman != null && !dataman.getStoreProviders().contains(NAME)) {
83
                        dataman.registerStoreProvider(NAME,
84
                                        TileFileFormatProvider.class, TileFileFormatDataParameters.class);
85
                }
86
                
87
                if(DALFileLocator.getFilesystemServerExplorerManager() != null)
88
                        DALFileLocator.getFilesystemServerExplorerManager().registerProvider(
89
                                        NAME, DESCRIPTION,
90
                                        TileFileFormatFilesystemServerExplorer.class);
91
                
92
                dataman.registerStoreFactory(NAME, DefaultStoreFactory.class);
93
        }
94
        
95
        private static void registerFormats() {
96
                formatList      = new String[] {"tff"};
97
                for (int i = 0; i < formatList.length; i++) 
98
                        RasterLocator.getManager().getProviderServices().addFormat(formatList[i], TileFileFormatProvider.class);
99
        }
100
        
101
        public String[] getFormatList() {
102
                return formatList;
103
        }
104
        
105
        public boolean isExtensionSupported(String ext) {
106
                if(ext.indexOf(".") != -1)
107
                        ext = ext.substring(ext.lastIndexOf(".") + 1, ext.length());
108
                for (int i = 0; i < formatList.length; i++) {
109
                        if(formatList[i].compareTo(ext) == 0)
110
                                return true;
111
                }
112
                return false;
113
        }
114
        
115
        public TileFileFormatProvider() throws NotSupportedExtensionException {
116
                super();
117
        }
118
        
119
        public TileFileFormatProvider(TileFileFormatDataParameters params,
120
                        DataStoreProviderServices storeServices) throws InitializeException {
121
                super(params, storeServices, ToolsLocator.getDynObjectManager()
122
                                .createDynObject(
123
                                                MetadataLocator.getMetadataManager().getDefinition(
124
                                                                DataStore.METADATA_DEFINITION_NAME)));
125
                try {
126
                        init(params, storeServices);
127
                } catch (OpenException e) {
128
                        throw new InitializeException("Error open the source", e);
129
                } catch (NotSupportedExtensionException e) {
130
                        throw new InitializeException("Not supported extension", e);
131
                }
132
        }
133
        
134
        /**
135
         * Build file references
136
         * @param proj Projection
137
         * @param param Load parameters
138
         * @throws NotSupportedExtensionException
139
         */
140
        public void init(TileFileFormatDataParameters params,
141
                        DataStoreProviderServices storeServices) throws NotSupportedExtensionException, OpenException {
142
                
143
                openFromTff();
144
                
145
                uri = getParameters().getURI();
146
                
147
                super.init();
148
                
149
                try {
150
                        loadFromRmf(getRmfBlocksManager());
151
                } catch (ParsingException e) {
152
                        logger.debug("Problems reading from RMF", e);
153
                }
154

    
155
                open = true;
156
        }
157
        
158
        /**
159
         * Open from a .mff file. 
160
         * This method loads all providers and adds these to the parameters
161
         * @throws OpenException
162
         */
163
        private void openFromTff() throws OpenException {
164
                
165
        }
166
        
167
        public TileFileFormatDataParameters getParameters() {
168
                try {
169
                        return (TileFileFormatDataParameters)parameters;
170
                } catch (ClassCastException e) {
171
                        return null;
172
                }
173
        }
174
        
175
        @Override
176
        public int getBlockSize() {
177
                return 0;
178
        }
179

    
180
        @Override
181
        public Object getData(int x, int y, int band)
182
                        throws InvalidSetViewException, FileNotOpenException,
183
                        RasterDriverException {
184
                return null;
185
        }
186

    
187
        @Override
188
        public double getHeight() {
189
                return 0;
190
        }
191

    
192
        @Override
193
        public int getOverviewHeight(int band, int overview)
194
                        throws BandAccessException, RasterDriverException {
195
                return 0;
196
        }
197

    
198
        @Override
199
        public int getOverviewWidth(int band, int overview)
200
                        throws BandAccessException, RasterDriverException {
201
                return 0;
202
        }
203

    
204
        @Override
205
        public Extent getView() {
206
                return null;
207
        }
208

    
209
        @Override
210
        public double getWidth() {
211
                return 0;
212
        }
213

    
214
        @Override
215
        public Buffer getWindow(Extent extent, BandList bandList,
216
                        Buffer rasterBuf, TaskStatus status)
217
                        throws ProcessInterruptedException, RasterDriverException {
218
                return null;
219
        }
220

    
221
        @Override
222
        public void getWindow(Extent ex, int bufWidth, int bufHeight,
223
                        BandList bandList, TileListener listener, TaskStatus taskStatus)
224
                        throws ProcessInterruptedException, RasterDriverException {
225
                
226
        }
227

    
228
        @Override
229
        public Buffer getWindow(Extent extent, int bufWidth, int bufHeight,
230
                        BandList bandList, Buffer rasterBuf, boolean adjustToExtent,
231
                        TaskStatus status) throws ProcessInterruptedException,
232
                        RasterDriverException {
233
                return null;
234
        }
235

    
236
        @Override
237
        public Buffer getWindow(int x, int y, int w, int h, BandList bandList,
238
                        Buffer rasterBuf, TaskStatus status)
239
                        throws ProcessInterruptedException, RasterDriverException {
240
                return null;
241
        }
242

    
243
        @Override
244
        public Buffer getWindow(double x, double y, double w, double h,
245
                        BandList bandList, Buffer rasterBuf, boolean adjustToExtent,
246
                        TaskStatus status) throws ProcessInterruptedException,
247
                        RasterDriverException {
248
                return null;
249
        }
250

    
251
        @Override
252
        public boolean isOverviewsSupported() {
253
                return false;
254
        }
255

    
256
        @Override
257
        public RasterProvider load() {
258
                return null;
259
        }
260

    
261
        @Override
262
        public void setView(Extent e) {
263
                
264
        }
265

    
266
        public Extent getCoordsInLevel(Point2D viewCenter, int level, int w, int h) {
267
                return null;
268
        }
269

    
270
        public Extent getCoordsInTheNearestLevel(Extent extent, int w, int h) {
271
                return null;
272
        }
273

    
274
        public RasterProvider getInternalProvider() {
275
                return null;
276
        }
277

    
278
        public int getNearestLevel(double pixelSize) {
279
                return 0;
280
        }
281

    
282
        public Tile getTile(DefaultRasterQuery q) throws TileGettingException {
283
                return null;
284
        }
285

    
286
        public int getZoomLevels() {
287
                return 0;
288
        }
289

    
290
        public int getOverviewCount(int band) throws BandAccessException,
291
                        RasterDriverException {
292
                return 0;
293
        }
294

    
295
        public TileServer getTileServer() {
296
                return null;
297
        }
298

    
299
        public boolean isOpen() {
300
                return open;
301
        }
302

    
303
        public Object readBlock(int pos, int blockHeight, double scale)
304
                        throws InvalidSetViewException, FileNotOpenException,
305
                        RasterDriverException, ProcessInterruptedException {
306
                return null;
307
        }
308

    
309
        public void setStatus(RasterProvider provider) {
310
                
311
        }
312

    
313
        public String getName() {
314
                return null;
315
        }
316
        
317
}