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

History | View | Annotate | Download (8.15 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.datastruct.Extent;
31
import org.gvsig.fmap.dal.coverage.exception.BandAccessException;
32
import org.gvsig.fmap.dal.coverage.exception.FileNotOpenException;
33
import org.gvsig.fmap.dal.coverage.exception.InvalidSetViewException;
34
import org.gvsig.fmap.dal.coverage.exception.NotSupportedExtensionException;
35
import org.gvsig.fmap.dal.coverage.exception.ParsingException;
36
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException;
37
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException;
38
import org.gvsig.fmap.dal.exception.InitializeException;
39
import org.gvsig.fmap.dal.exception.OpenException;
40
import org.gvsig.fmap.dal.spi.DataManagerProviderServices;
41
import org.gvsig.fmap.dal.spi.DataStoreProviderServices;
42
import org.gvsig.metadata.MetadataLocator;
43
import org.gvsig.raster.cache.tile.Tile;
44
import org.gvsig.raster.cache.tile.exception.TileGettingException;
45
import org.gvsig.raster.cache.tile.provider.TileServer;
46
import org.gvsig.raster.impl.buffer.SpiRasterQuery;
47
import org.gvsig.raster.impl.provider.AbstractRasterProvider;
48
import org.gvsig.raster.impl.provider.RasterProvider;
49
import org.gvsig.raster.impl.provider.TiledRasterProvider;
50
import org.gvsig.raster.impl.store.DefaultStoreFactory;
51
import org.gvsig.tools.ToolsLocator;
52
import org.gvsig.tools.extensionpoint.ExtensionPoint;
53
import org.gvsig.tools.extensionpoint.ExtensionPointManager;
54
import org.slf4j.Logger;
55
import org.slf4j.LoggerFactory;
56

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

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

    
176
        @Override
177
        public Object getData(int x, int y, int band)
178
                        throws InvalidSetViewException, FileNotOpenException,
179
                        RasterDriverException {
180
                return null;
181
        }
182

    
183
        @Override
184
        public double getHeight() {
185
                return 0;
186
        }
187

    
188
        @Override
189
        public int getOverviewHeight(int band, int overview)
190
                        throws BandAccessException, RasterDriverException {
191
                return 0;
192
        }
193

    
194
        @Override
195
        public int getOverviewWidth(int band, int overview)
196
                        throws BandAccessException, RasterDriverException {
197
                return 0;
198
        }
199

    
200
        @Override
201
        public Extent getView() {
202
                return null;
203
        }
204

    
205
        @Override
206
        public double getWidth() {
207
                return 0;
208
        }
209

    
210
        @Override
211
        public boolean isOverviewsSupported() {
212
                return false;
213
        }
214

    
215
        @Override
216
        public RasterProvider load() {
217
                return null;
218
        }
219

    
220
        @Override
221
        public void setView(Extent e) {
222
                
223
        }
224

    
225
        public Extent getCoordsInLevel(Point2D viewCenter, int level, int w, int h) {
226
                return null;
227
        }
228

    
229
        public Extent getCoordsInTheNearestLevel(Extent extent, int w, int h) {
230
                return null;
231
        }
232

    
233
        public RasterProvider getInternalProvider() {
234
                return null;
235
        }
236

    
237
        public int getNearestLevel(double pixelSize) {
238
                return 0;
239
        }
240

    
241
        public Tile getTile(SpiRasterQuery q) throws TileGettingException {
242
                return null;
243
        }
244

    
245
        public int getZoomLevels() {
246
                return 0;
247
        }
248

    
249
        public int getOverviewCount(int band) throws BandAccessException,
250
                        RasterDriverException {
251
                return 0;
252
        }
253

    
254
        public TileServer getTileServer() {
255
                return null;
256
        }
257

    
258
        public boolean isOpen() {
259
                return open;
260
        }
261

    
262
        public Object readBlock(int pos, int blockHeight, double scale)
263
                        throws InvalidSetViewException, FileNotOpenException,
264
                        RasterDriverException, ProcessInterruptedException {
265
                return null;
266
        }
267

    
268
        public void setStatus(RasterProvider provider) {
269
                
270
        }
271

    
272
        public String getName() {
273
                return null;
274
        }
275

    
276
        @Override
277
        public void loadBuffer(SpiRasterQuery query)
278
                        throws ProcessInterruptedException, RasterDriverException {
279
                // TODO Auto-generated method stub
280
                
281
        }
282
        
283
}