Revision 21166

View differences:

org.gvsig.raster.tilecache/tags/org.gvsig.raster.tilecache-2.2.224/org.gvsig.raster.tilecache.io/package.info
1
#
2
#Thu Mar 07 10:25:56 CET 2013
3
owner=gvSIG Association
4
code=org.gvsig.raster.tilecache.io
5
java-version=j1_5
6
official=true
7
type=plugin
8
version=2.0.0-0
9
state=devel
10
operating-system=all
11
dependencies=
12
sources-url=https\://devel.gvsig.org/redmine/projects/gvsig-raster/repository/show/org.gvsig.raster.tilecache/tags/2.0.0/org.gvsig.raster.tilecache.io
13
web-url=http\://www.gvsig.com
14
architecture=all
15
model-version=1.0.1
16
categories=
17
description=cache service for gvSIG
18
buildNumber=0
19
gvSIG-version=2.0.0
20
name=org.gvsig.raster.tilecache.io
org.gvsig.raster.tilecache/tags/org.gvsig.raster.tilecache-2.2.224/org.gvsig.raster.tilecache.io/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.raster.tilecache.io.DefaultCacheIOLibrary
org.gvsig.raster.tilecache/tags/org.gvsig.raster.tilecache-2.2.224/org.gvsig.raster.tilecache.io/src/main/java/org/gvsig/raster/tilecache/io/TileDataParametersImpl.java
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

  
23
package org.gvsig.raster.tilecache.io;
24

  
25
import java.net.URI;
26

  
27
import org.gvsig.fmap.dal.DataParameters;
28
import org.gvsig.fmap.dal.coverage.store.parameter.RasterDataParameters;
29
import org.gvsig.fmap.dal.coverage.store.parameter.TileDataParameters;
30
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters;
31
import org.gvsig.raster.cache.tile.provider.TileServer;
32
import org.gvsig.raster.impl.store.AbstractRasterDataParameters;
33
import org.gvsig.raster.impl.store.AbstractRasterFileDataParameters;
34
import org.gvsig.tools.ToolsLocator;
35
import org.gvsig.tools.dynobject.DelegatedDynObject;
36
import org.gvsig.tools.dynobject.DynStruct;
37
import org.gvsig.tools.persistence.PersistenceManager;
38

  
39
/**
40
 * Parameters for the <code>TileProvider</code>
41
 * @author Nacho Brodin (nachobrodin@gmail.com)
42
 */
43
public class TileDataParametersImpl extends AbstractRasterFileDataParameters implements TileDataParameters {
44
	public static final String       FIELD_PARAMETERS      = "parameters";
45
	public static final String       FIELD_SECONDLEVEL     = "secondlevel";
46
	public static final String       FIELD_NAME            = "name";
47
	private static final String      FIELD_DELETECACHE     = "deletecache";
48

  
49
	private DelegatedDynObject       delegatedDynObject    = null;
50
	private TileServer               tileServer            = null;
51

  
52
	/**
53
	 *
54
	 */
55
	public TileDataParametersImpl() {
56
		super();
57
		initialize();
58
	}
59

  
60
	protected void initialize() {
61
		this.delegatedDynObject = (DelegatedDynObject) ToolsLocator
62
				.getDynObjectManager().createDynObject(
63
						registerDynClass());
64
	}
65

  
66
	/**
67
	 * @return The DynStruct
68
	 */
69
	public static DynStruct registerDynClass() {
70
		PersistenceManager manager = ToolsLocator.getPersistenceManager();
71
		DynStruct definition = manager.getDefinition("TileDataParameters_Persistent");
72
		if( definition == null ) {
73
			definition = manager.addDefinition(
74
					TileDataParametersImpl.class,
75
					"TileDataParameters_Persistent",
76
					"TileDataParameters Persistency",
77
					null,
78
					null
79
					);
80
		}
81

  
82
		AbstractRasterDataParameters.registerDynClass(definition);
83

  
84
		definition.addDynFieldObject(FIELD_PARAMETERS)
85
		.setDescription("Provider")
86
		.setClassOfValue(RasterDataParameters.class)
87
		.setMandatory(true);
88

  
89
		definition.addDynFieldBoolean(FIELD_SECONDLEVEL)
90
		.setDescription("SecondLevelProvider")
91
		.setMandatory(false);
92

  
93
		definition.addDynFieldString(FIELD_NAME)
94
		.setDescription("Name")
95
		.setMandatory(false);
96

  
97
		definition.addDynFieldBoolean(FIELD_DELETECACHE)
98
		.setDescription("Flag to delete cache the next request")
99
		.setMandatory(false);
100
		return definition;
101
	}
102

  
103
	/**
104
	 * Sets the <code>DataParameters</code>
105
	 * @param params DataParameters
106
	 */
107
	public void setDataParameters(DataParameters params) {
108
		this.setDynValue(FIELD_PARAMETERS, params);
109
	}
110

  
111
	public DataParameters getDataParameters() {
112
		return (DataParameters) this.getDynValue(FIELD_PARAMETERS);
113
	}
114

  
115
	/**
116
	 * Sets the <code>TileServer</code>
117
	 * @param tileServer TileServer
118
	 */
119
	public void setTileServer(TileServer tileServer) {
120
		this.tileServer = tileServer;
121
	}
122

  
123
	/**
124
	 * Gets the <code>TileServer</code>
125
	 * @return the TileServer
126
	 */
127
	public TileServer getTileServer() {
128
		return tileServer;
129
	}
130

  
131
	/**
132
	 * @return true if this provider is for the second level of cach?
133
	 */
134
	public boolean isSecondLevelCache() {
135
		Object obj = this.getDynValue(FIELD_SECONDLEVEL);
136
		if(obj != null && obj instanceof Boolean)
137
			return ((Boolean)obj).booleanValue();
138
		return false;
139
	}
140

  
141
	/**
142
	 * Sets the flag to inform to the provider that is a second level provider
143
	 * @param secondLevel boolean
144
	 */
145
	public void setSecondLevelCache(boolean secondLevel) {
146
		this.setDynValue(FIELD_SECONDLEVEL, new Boolean(secondLevel));
147
	}
148

  
149
	/**
150
	 * @return the name
151
	 */
152
	public String getName() {
153
		DataParameters p = getDataParameters();
154
		if(p != null) {
155
			if(p instanceof FilesystemStoreParameters) {
156
				return ((FilesystemStoreParameters)p).getFile().getAbsolutePath();
157
            } else {
158
                return ((RasterDataParameters) p).getURI().getPath();
159
            }
160
		}
161
		return null;
162
	}
163

  
164
	@Override
165
	public URI getURI() {
166
		if(this.getDynValue(FIELD_URI) == null) {
167
			DataParameters p = getDataParameters();
168
			if(p != null) {
169
				if(p instanceof FilesystemStoreParameters) {
170
					return ((FilesystemStoreParameters)p).getFile().toURI();
171
				} else {
172
                    return ((RasterDataParameters)p).getURI();
173
				}
174
			}
175
		}
176
		return (URI) this.getDynValue(FIELD_URI);
177
	}
178

  
179

  
180
	//**********************************************
181

  
182
	public String getDataStoreName() {
183
		return TileProvider.NAME;
184
	}
185

  
186
	public String getDescription() {
187
		return TileProvider.DESCRIPTION;
188
	}
189

  
190
	/**
191
	 * @return the explorer name
192
	 */
193
	public String getExplorerName() {
194
		return TileServerExplorer.NAME;
195
	}
196

  
197
	public boolean isValid() {
198
		return (this.getDataParameters() != null);
199
	}
200

  
201
	protected DelegatedDynObject getDelegatedDynObject() {
202
		return delegatedDynObject;
203
	}
204

  
205
	/**
206
	 * Sets the flag to delete the cache
207
	 * @param deleteCache boolean
208
	 */
209
	public void deleteCache(boolean deleteCache) {
210
		this.setDynValue(FIELD_DELETECACHE, new Boolean(deleteCache));
211
	}
212

  
213
	/**
214
	 * @return true if the cache is going to be deleted
215
	 */
216
	public boolean isDeletingCache() {
217
		Boolean b = (Boolean)getDynValue(FIELD_DELETECACHE);
218
		if(b != null)
219
			return ((Boolean)getDynValue(FIELD_DELETECACHE)).booleanValue();
220
		else
221
			return false;
222
	}
223

  
224
	public boolean isSourceTiled() {
225
		return true;
226
	}
227
}
0 228

  
org.gvsig.raster.tilecache/tags/org.gvsig.raster.tilecache-2.2.224/org.gvsig.raster.tilecache.io/src/main/java/org/gvsig/raster/tilecache/io/tff/TileFileFormatProvider.java
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
}
0 322

  
org.gvsig.raster.tilecache/tags/org.gvsig.raster.tilecache-2.2.224/org.gvsig.raster.tilecache.io/src/main/java/org/gvsig/raster/tilecache/io/tff/TileFileFormatNewRasterStoreParameters.java
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 org.gvsig.raster.impl.store.AbstractNewRasterStoreParameters;
25

  
26
/**
27
 * Parameters for creating a <code>TileFileFormat</code> store
28
 * @author Nacho Brodin (nachobrodin@gmail.com)
29
 */
30
public class TileFileFormatNewRasterStoreParameters extends AbstractNewRasterStoreParameters {
31

  
32
	public String getDataStoreName() {
33
		return TileFileFormatProvider.NAME;
34
	}
35

  
36
	public String getDescription() {
37
		return TileFileFormatProvider.DESCRIPTION;
38
	}
39

  
40
}
0 41

  
org.gvsig.raster.tilecache/tags/org.gvsig.raster.tilecache-2.2.224/org.gvsig.raster.tilecache.io/src/main/java/org/gvsig/raster/tilecache/io/tff/TileFileFormatFilesystemServerExplorer.java
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

  
23
package org.gvsig.raster.tilecache.io.tff;
24

  
25
import java.io.File;
26
import java.util.List;
27

  
28
import org.gvsig.fmap.dal.DALLocator;
29
import org.gvsig.fmap.dal.DataManager;
30
import org.gvsig.fmap.dal.DataServerExplorer;
31
import org.gvsig.fmap.dal.DataServerExplorerParameters;
32
import org.gvsig.fmap.dal.DataStoreParameters;
33
import org.gvsig.fmap.dal.NewDataStoreParameters;
34
import org.gvsig.fmap.dal.coverage.RasterLocator;
35
import org.gvsig.fmap.dal.exception.CreateException;
36
import org.gvsig.fmap.dal.exception.DataException;
37
import org.gvsig.fmap.dal.exception.InitializeException;
38
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException;
39
import org.gvsig.fmap.dal.exception.RemoveException;
40
import org.gvsig.fmap.dal.serverexplorer.filesystem.impl.AbstractFilesystemServerExplorerProvider;
41
import org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProviderServices;
42
import org.gvsig.fmap.dal.spi.DataServerExplorerProviderServices;
43
import org.gvsig.raster.impl.store.AbstractRasterFileDataParameters;
44

  
45
public class TileFileFormatFilesystemServerExplorer extends AbstractFilesystemServerExplorerProvider {
46
	
47
	public TileFileFormatFilesystemServerExplorer() {
48
		
49
	}
50
	
51
	public TileFileFormatFilesystemServerExplorer(
52
			TileFileFormatExplorerParameters parameters,
53
			DataServerExplorerProviderServices services)
54
			throws InitializeException {
55
		System.out.println();
56
	}
57
	
58
	public String getDataStoreProviderName() {
59
		return TileFileFormatProvider.NAME;
60
	}
61
	
62
	public String getDescription() {
63
		return TileFileFormatProvider.DESCRIPTION;
64
	}
65
	
66
	public DataStoreParameters getStoreParameters() {
67
		DataManager manager = DALLocator.getDataManager();
68
		try {
69
			return  manager.createStoreParameters(this.getDataStoreProviderName());
70
		} catch (InitializeException e) {
71
			e.printStackTrace();
72
		} catch (ProviderNotRegisteredException e) {
73
			e.printStackTrace();
74
		}
75
		return null;
76
	}
77

  
78
	@SuppressWarnings("unchecked")
79
	public List getDataStoreProviderNames() {
80
		return null;
81
	}
82

  
83
	public String getProviderName() {
84
		return TileFileFormatProvider.NAME;
85
	}
86

  
87
	public DataServerExplorerProviderServices getServerExplorerProviderServices() {
88
		return null;
89
	}
90

  
91
	public boolean canCreate() {
92
		return false;
93
	}
94

  
95
	public boolean canCreate(NewDataStoreParameters parameters) {
96
		return false;
97
	}
98

  
99
	public void create(NewDataStoreParameters parameters, boolean overwrite)
100
			throws CreateException {
101
		throw new UnsupportedOperationException();
102
	}
103

  
104
	public NewDataStoreParameters getCreateParameters() throws DataException {
105
		return null;
106
	}
107

  
108
	public void initialize(
109
			FilesystemServerExplorerProviderServices serverExplorer) {
110
	}
111

  
112
	public boolean accept(File pathname) {
113
		return RasterLocator.getManager().getProviderServices().isExtensionSupported(
114
				pathname.getAbsolutePath(), 
115
				TileFileFormatProvider.class);
116
	}
117

  
118
	public void remove(DataStoreParameters parameters) throws RemoveException {
119
		throw new UnsupportedOperationException();
120
	}
121

  
122
	public boolean add(String provider, NewDataStoreParameters parameters,
123
			boolean overwrite) throws DataException {
124
		return false;
125
	}
126

  
127
	public boolean canAdd() {
128
		return false;
129
	}
130

  
131
	public boolean canAdd(String storeName) throws DataException {
132
		return false;
133
	}
134

  
135
	public NewDataStoreParameters getAddParameters(String storeName)
136
			throws DataException {
137
		return null;
138
	}
139
	
140
	public DataStoreParameters getParameters(File file) throws DataException {
141
		DataManager manager = DALLocator.getDataManager();
142
		AbstractRasterFileDataParameters params = (AbstractRasterFileDataParameters) manager
143
				.createStoreParameters(this.getDataStoreProviderName());
144
		params.setFile(file);
145
		return params;
146
	}
147

  
148
	public DataServerExplorerParameters getParameters() {
149
		return null;
150
	}
151

  
152
	@SuppressWarnings("unchecked")
153
	public List list() throws DataException {
154
		return null;
155
	}
156

  
157
	@SuppressWarnings("unchecked")
158
	public List list(int mode) throws DataException {
159
		return null;
160
	}
161

  
162
	public void dispose() {
163
	}
164
	
165
	public int getMode() {
166
		return DataServerExplorer.MODE_RASTER;
167
	}
168

  
169
}
0 170

  
org.gvsig.raster.tilecache/tags/org.gvsig.raster.tilecache-2.2.224/org.gvsig.raster.tilecache.io/src/main/java/org/gvsig/raster/tilecache/io/tff/TileFileFormatDataParameters.java
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

  
23
package org.gvsig.raster.tilecache.io.tff;
24

  
25
import org.gvsig.raster.impl.store.AbstractRasterDataParameters;
26
import org.gvsig.raster.impl.store.AbstractRasterFileDataParameters;
27
import org.gvsig.tools.ToolsLocator;
28
import org.gvsig.tools.dynobject.DynStruct;
29
import org.gvsig.tools.persistence.PersistenceManager;
30
import org.gvsig.tools.persistence.PersistentState;
31
import org.gvsig.tools.persistence.exception.PersistenceException;
32

  
33
/**
34
 * Parameters for the <code>TileFileFormatProvider</code>
35
 * @author Nacho Brodin (nachobrodin@gmail.com)
36
 */
37
public class TileFileFormatDataParameters extends AbstractRasterFileDataParameters {
38
	 
39
	public String getDataStoreName() {
40
		return TileFileFormatProvider.NAME;
41
	}
42
	
43
	public String getDescription() {
44
		return TileFileFormatProvider.DESCRIPTION;
45
	}
46
	
47
	public void loadFromState(PersistentState state)
48
			throws PersistenceException {
49
		super.loadFromState(state);
50
	}
51

  
52
	public void saveToState(PersistentState state) throws PersistenceException {
53
		super.saveToState(state);
54
	}	
55
	
56
	public static void registerPersistence() {
57
		PersistenceManager manager = ToolsLocator.getPersistenceManager();
58
		DynStruct definition = manager.getDefinition("TileFileFormatDataParameters_Persistent");
59
		if( definition == null ) {
60
			definition = manager.addDefinition(
61
					TileFileFormatDataParameters.class,
62
					"TileFileFormatDataParameters_Persistent",
63
					"TileFileFormatDataParameters Persistent",
64
					null, 
65
					null
66
			);
67
			AbstractRasterDataParameters.registerDynClass(definition);
68
		}
69
	}
70
}
0 71

  
org.gvsig.raster.tilecache/tags/org.gvsig.raster.tilecache-2.2.224/org.gvsig.raster.tilecache.io/src/main/java/org/gvsig/raster/tilecache/io/tff/TileFileFormatExplorerParameters.java
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

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2009 IVER T.I   {{Task}}
26
*/
27

  
28
package org.gvsig.raster.tilecache.io.tff;
29

  
30
import java.util.Objects;
31
import org.gvsig.fmap.dal.DataServerExplorerParameters;
32
import org.gvsig.fmap.dal.spi.AbstractDataParameters;
33
import org.gvsig.tools.ToolsLocator;
34
import org.gvsig.tools.dynobject.DelegatedDynObject;
35
import org.gvsig.tools.dynobject.DynClass;
36
import org.gvsig.tools.dynobject.DynObjectManager;
37

  
38
/**
39
 * Parameters for the TileFileFormat explorer provider
40
 * @author Nacho Brodin (nachobrodin@gmail.com)
41
 */
42
public class TileFileFormatExplorerParameters extends AbstractDataParameters implements DataServerExplorerParameters {
43
	public static final String     DYNCLASS_NAME       = "TileFileFormatExplorerParameters";
44
	protected static DynClass      DYNCLASS            = null;
45
	private DelegatedDynObject     delegatedDynObject  = null;
46
	
47
	
48
	public TileFileFormatExplorerParameters() {
49
		super();
50
		initialize();
51
	}
52

  
53
	protected void initialize() {
54
		this.delegatedDynObject = (DelegatedDynObject) ToolsLocator
55
				.getDynObjectManager().createDynObject(
56
						DYNCLASS);
57
	}
58
	
59
	public static void registerDynClass() {
60
		DynObjectManager dynman = ToolsLocator.getDynObjectManager();
61
		DynClass dynClass;
62
		
63
		if(dynman == null)
64
			return;
65
		
66
		if (DYNCLASS == null) {
67
			dynClass = dynman.add(DYNCLASS_NAME);
68

  
69
			DYNCLASS = dynClass;
70
		}
71

  
72
	}
73
	
74
	protected DelegatedDynObject getDelegatedDynObject() {
75
		return delegatedDynObject;
76
	}
77

  
78
	public String getDataStoreName() {
79
		return TileFileFormatProvider.NAME;
80
	}
81
	
82
	public String getDescription() {
83
		return TileFileFormatProvider.DESCRIPTION;
84
	}
85
	
86
	public String getExplorerName() {
87
		return TileFileFormatProvider.NAME;
88
	}
89

  
90
    @Override
91
    public boolean isTheSameServerExplorer(DataServerExplorerParameters params) {
92
        if(!(params instanceof TileFileFormatExplorerParameters)){
93
            return false;
94
        }
95
        return Objects.equals(this, (TileFileFormatExplorerParameters)params);
96
    }
97
}
0 98

  
org.gvsig.raster.tilecache/tags/org.gvsig.raster.tilecache-2.2.224/org.gvsig.raster.tilecache.io/src/main/java/org/gvsig/raster/tilecache/io/TileProviderFactory.java
1
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2017 gvSIG Association
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., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA  02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us
21
 * at info AT gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.raster.tilecache.io;
24

  
25
import org.gvsig.fmap.dal.DataParameters;
26
import org.gvsig.fmap.dal.DataStoreProvider;
27
import org.gvsig.fmap.dal.DataStoreProviderFactory;
28
import org.gvsig.fmap.dal.exception.InitializeException;
29
import org.gvsig.fmap.dal.spi.AbstractDataStoreProviderFactory;
30
import org.gvsig.fmap.dal.spi.DataStoreProviderServices;
31
import org.gvsig.tools.dynobject.DynObject;
32

  
33

  
34
/**
35
 * @author fdiaz
36
 *
37
 */
38
public class TileProviderFactory extends AbstractDataStoreProviderFactory implements DataStoreProviderFactory {
39

  
40
    /**
41
     * @param name
42
     * @param description
43
     */
44
    protected TileProviderFactory(String name, String description) {
45
        super(name, description);
46
    }
47

  
48
    /* (non-Javadoc)
49
     * @see org.gvsig.fmap.dal.DataFactory#createParameters()
50
     */
51
    @Override
52
    public DynObject createParameters() {
53
        return new TileDataParametersImpl();
54
    }
55

  
56
    /* (non-Javadoc)
57
     * @see org.gvsig.fmap.dal.DataStoreProviderFactory#createProvider(org.gvsig.fmap.dal.DataParameters, org.gvsig.fmap.dal.spi.DataStoreProviderServices)
58
     */
59
    @Override
60
    public DataStoreProvider createProvider(DataParameters arg0, DataStoreProviderServices arg1)
61
        throws InitializeException {
62
        return new TileProvider((TileDataParametersImpl) arg0, arg1);
63
    }
64

  
65
    @Override
66
    public int isTiledSupported() {
67
        return YES;
68
    }
69

  
70
}
org.gvsig.raster.tilecache/tags/org.gvsig.raster.tilecache-2.2.224/org.gvsig.raster.tilecache.io/src/main/java/org/gvsig/raster/tilecache/io/DefaultCacheIOLibrary.java
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;
23

  
24
import org.gvsig.raster.cache.tile.impl.TileCacheDefaultImplLibrary;
25
import org.gvsig.tools.library.AbstractLibrary;
26
import org.gvsig.tools.library.LibraryException;
27

  
28
/**
29
 *
30
 * @author Nacho Brodin (nachobrodin@gmail.com)
31
 */
32
public class DefaultCacheIOLibrary extends AbstractLibrary {	
33

  
34
	public DefaultCacheIOLibrary() {
35
		registerAsServiceOf(TileCacheDefaultImplLibrary.class);
36
	}
37
	
38
	@Override
39
	protected void doInitialize() throws LibraryException {
40
		//RasterLibrary.wakeUp();
41
	}
42

  
43
	@Override
44
	protected void doPostInitialize() throws LibraryException {
45
		TileDataParametersImpl.registerDynClass();
46
		TileProvider.register();
47
	}
48
}
0 49

  
org.gvsig.raster.tilecache/tags/org.gvsig.raster.tilecache-2.2.224/org.gvsig.raster.tilecache.io/src/main/java/org/gvsig/raster/tilecache/io/TileServerExplorer.java
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

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2009 IVER T.I   {{Task}}
26
*/
27

  
28
package org.gvsig.raster.tilecache.io;
29

  
30
import java.io.File;
31
import java.io.FileInputStream;
32
import java.util.List;
33

  
34
import org.apache.commons.io.FilenameUtils;
35

  
36
import org.gvsig.fmap.dal.DALLocator;
37
import org.gvsig.fmap.dal.DataManager;
38
import org.gvsig.fmap.dal.DataServerExplorer;
39
import org.gvsig.fmap.dal.DataServerExplorerParameters;
40
import org.gvsig.fmap.dal.DataStore;
41
import org.gvsig.fmap.dal.DataStoreParameters;
42
import org.gvsig.fmap.dal.NewDataStoreParameters;
43
import org.gvsig.fmap.dal.coverage.RasterLocator;
44
import org.gvsig.fmap.dal.exception.CreateException;
45
import org.gvsig.fmap.dal.exception.DataException;
46
import org.gvsig.fmap.dal.exception.InitializeException;
47
import org.gvsig.fmap.dal.exception.RemoveException;
48
import org.gvsig.fmap.dal.serverexplorer.filesystem.impl.AbstractFilesystemServerExplorerProvider;
49
import org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProviderServices;
50
import org.gvsig.fmap.dal.spi.AbstractDataServerExplorer;
51
import org.gvsig.fmap.dal.spi.DataServerExplorerProvider;
52
import org.gvsig.fmap.dal.spi.DataServerExplorerProviderServices;
53
import org.gvsig.raster.impl.store.AbstractRasterFileDataParameters;
54

  
55
public class TileServerExplorer extends AbstractDataServerExplorer implements DataServerExplorerProvider {
56
	public static final String               NAME                     = "TileServerExplorer";
57

  
58
	public TileServerExplorer() {
59
            super(null,null);
60
	}
61

  
62
	public TileServerExplorer(
63
			TileServerExplorerParameters parameters,
64
			DataServerExplorerProviderServices services)
65
			throws InitializeException {
66
            super(parameters, services);
67
	}
68

  
69
	public void remove(DataStoreParameters parameters) throws RemoveException {
70
		throw new UnsupportedOperationException();
71
	}
72

  
73
	public DataServerExplorerParameters getParameters() {
74
		return null;
75
	}
76

  
77
	public DataServerExplorerProviderServices getServerExplorerProviderServices() {
78
		return null;
79
	}
80

  
81
	public boolean add(String provider, NewDataStoreParameters parameters,
82
			boolean overwrite) throws DataException {
83
		return false;
84
	}
85

  
86
	public boolean canAdd() {
87
		return false;
88
	}
89

  
90
	public boolean canAdd(String storeName) throws DataException {
91
		return false;
92
	}
93

  
94
	public NewDataStoreParameters getAddParameters(String storeName)
95
			throws DataException {
96
		return null;
97
	}
98

  
99
	@SuppressWarnings("unchecked")
100
	public List getDataStoreProviderNames() {
101
		return null;
102
	}
103

  
104
	public String getProviderName() {
105
		return null;
106
	}
107

  
108
	@SuppressWarnings("unchecked")
109
	public List list() throws DataException {
110
		return null;
111
	}
112

  
113
	@SuppressWarnings("unchecked")
114
	public List list(int mode) throws DataException {
115
		return null;
116
	}
117

  
118
    @Override
119
    public DataStoreParameters get(String name) throws DataException {
120
        return null;
121
    }
122

  
123
}
0 124

  
org.gvsig.raster.tilecache/tags/org.gvsig.raster.tilecache-2.2.224/org.gvsig.raster.tilecache.io/src/main/java/org/gvsig/raster/tilecache/io/TileProvider.java
1
package org.gvsig.raster.tilecache.io;
2

  
3
import java.awt.Image;
4
import java.awt.geom.AffineTransform;
5
import java.awt.geom.NoninvertibleTransformException;
6
import java.awt.geom.Point2D;
7
import java.io.File;
8
import java.io.FileNotFoundException;
9
import java.io.IOException;
10
import java.lang.reflect.Constructor;
11
import java.lang.reflect.InvocationTargetException;
12
import java.net.URI;
13
import java.util.List;
14

  
15
import org.gvsig.compat.net.ICancellable;
16
import org.gvsig.fmap.dal.DALLocator;
17
import org.gvsig.fmap.dal.DataStore;
18
import org.gvsig.fmap.dal.DataStoreParameters;
19
import org.gvsig.fmap.dal.coverage.RasterLibrary;
20
import org.gvsig.fmap.dal.coverage.RasterLocator;
21
import org.gvsig.fmap.dal.coverage.dataset.Buffer;
22
import org.gvsig.fmap.dal.coverage.datastruct.BandList;
23
import org.gvsig.fmap.dal.coverage.datastruct.DatasetBand;
24
import org.gvsig.fmap.dal.coverage.datastruct.Extent;
25
import org.gvsig.fmap.dal.coverage.exception.BandAccessException;
26
import org.gvsig.fmap.dal.coverage.exception.BandNotFoundInListException;
27
import org.gvsig.fmap.dal.coverage.exception.FileNotOpenException;
28
import org.gvsig.fmap.dal.coverage.exception.FileNotSupportedException;
29
import org.gvsig.fmap.dal.coverage.exception.InfoByPointException;
30
import org.gvsig.fmap.dal.coverage.exception.InvalidSetViewException;
31
import org.gvsig.fmap.dal.coverage.exception.InvalidSourceException;
32
import org.gvsig.fmap.dal.coverage.exception.NotSupportedExtensionException;
33
import org.gvsig.fmap.dal.coverage.exception.ParsingException;
34
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException;
35
import org.gvsig.fmap.dal.coverage.exception.QueryException;
36
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException;
37
import org.gvsig.fmap.dal.coverage.exception.RmfSerializerException;
38
import org.gvsig.fmap.dal.coverage.store.RasterQuery;
39
import org.gvsig.fmap.dal.coverage.store.parameter.MultiDimensionalStoreParameters;
40
import org.gvsig.fmap.dal.coverage.store.parameter.RasterDataParameters;
41
import org.gvsig.fmap.dal.coverage.store.parameter.RemoteStoreParameters;
42
import org.gvsig.fmap.dal.coverage.store.parameter.TileDataParameters;
43
import org.gvsig.fmap.dal.coverage.store.props.ColorInterpretation;
44
import org.gvsig.fmap.dal.coverage.store.props.ColorTable;
45
import org.gvsig.fmap.dal.coverage.util.MathUtils;
46
import org.gvsig.fmap.dal.exception.InitializeException;
47
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException;
48
import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
49
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer;
50
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorerParameters;
51
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters;
52
import org.gvsig.fmap.dal.spi.DataManagerProviderServices;
53
import org.gvsig.fmap.dal.spi.DataStoreProvider;
54
import org.gvsig.fmap.dal.spi.DataStoreProviderServices;
55
import org.gvsig.metadata.MetadataLocator;
56
import org.gvsig.raster.cache.tile.Tile;
57
import org.gvsig.raster.cache.tile.TileCache;
58
import org.gvsig.raster.cache.tile.TileCacheLibrary;
59
import org.gvsig.raster.cache.tile.TileCacheLocator;
60
import org.gvsig.raster.cache.tile.TileCacheManager;
61
import org.gvsig.raster.cache.tile.exception.TileBuildException;
62
import org.gvsig.raster.cache.tile.exception.TileGettingException;
63
import org.gvsig.raster.cache.tile.layer.TiledLayer;
64
import org.gvsig.raster.cache.tile.provider.CacheStruct;
65
import org.gvsig.raster.cache.tile.provider.TileServer;
66
import org.gvsig.raster.impl.buffer.SpiRasterQuery;
67
import org.gvsig.raster.impl.datastruct.BandListImpl;
68
import org.gvsig.raster.impl.datastruct.DatasetBandImpl;
69
import org.gvsig.raster.impl.datastruct.ExtentImpl;
70
import org.gvsig.raster.impl.provider.AbstractRasterProvider;
71
import org.gvsig.raster.impl.provider.MemoryTileMatrixBuffer;
72
import org.gvsig.raster.impl.provider.RasterProvider;
73
import org.gvsig.raster.impl.provider.RemoteRasterProvider;
74
import org.gvsig.raster.impl.provider.TiledRasterProvider;
75
import org.gvsig.raster.impl.store.DefaultRasterStore;
76
import org.gvsig.raster.impl.store.DefaultStoreFactory;
77
import org.gvsig.raster.impl.store.properties.DataStoreColorInterpretation;
78
import org.gvsig.raster.impl.store.properties.DataStoreTransparency;
79
import org.gvsig.raster.impl.store.properties.RemoteDataStoreStatistics;
80
import org.gvsig.tools.ToolsLocator;
81
import org.gvsig.tools.locator.LocatorException;
82

  
83
import org.slf4j.Logger;
84
import org.slf4j.LoggerFactory;
85

  
86
/**
87
 * Provider for WMTS service
88
 *
89
 * @author Nacho Brodin (nachobrodin@gmail.com)
90
 */
91
public class TileProvider extends AbstractRasterProvider implements TiledRasterProvider {
92
	public static String                NAME                     = "Tile Store";
93
	public static String                DESCRIPTION              = "Raster Tiled Source";
94
	public static final String          METADATA_DEFINITION_NAME = "TileStore";
95
	private static final Logger         logger                   = LoggerFactory.getLogger(TileProvider.class);
96
	private RasterProvider              provider                 = null;
97
	private boolean                     open                     = false;
98
	private Extent                      viewRequest              = null;
99
	private TiledLayer                  tiledLayer               = null;
100
	private MathUtils                   math                     = RasterLocator.getManager().getMathUtils();
101
	private TileServer                  secondLevelTileServer    = null;
102

  
103
	/**
104
	 * Register in data manager
105
	 */
106
	public static void register() {
107
		DataManagerProviderServices dataman = (DataManagerProviderServices) DALLocator.getDataManager();
108
		if (dataman != null && !dataman.getStoreProviders().contains(NAME)) {
109
		    dataman.registerStoreProviderFactory(new TileProviderFactory(NAME, DESCRIPTION));
110
		}
111

  
112
		/*if(DALFileLocator.getFilesystemServerExplorerManager() != null)
113
			DALFileLocator.getFilesystemServerExplorerManager().registerProvider(
114
					NAME, DESCRIPTION,
115
					TileServerExplorer.class);*/
116

  
117
		if (!dataman.getExplorerProviders().contains(TileServerExplorer.NAME)) {
118
			dataman.registerExplorerProvider(TileServerExplorer.NAME, TileServerExplorer.class, TileServerExplorerParameters.class);
119
		}
120
		dataman.registerStoreFactory(NAME, DefaultStoreFactory.class);
121
	}
122

  
123
	/**
124
	 * Loads the specific provider to download data
125
	 * @param file
126
	 * @return
127
	 * @throws NotSupportedExtensionException
128
	 * @throws FileNotSupportedException
129
	 */
130
	@SuppressWarnings("unchecked")
131
	private RasterProvider loadProvider(TileDataParametersImpl params, DataStoreProviderServices storeServices) throws ProviderNotRegisteredException, InitializeException {
132
		Object obj = params.getDataParameters();
133
		DataManagerProviderServices dataManager = (DataManagerProviderServices)DALLocator.getDataManager();
134
		DataStoreProvider prov = null;
135

  
136
		if(obj != null && obj instanceof DataStoreParameters) //Remote
137
			prov = dataManager.createProvider(storeServices, (DataStoreParameters)obj);
138
		else { //File
139
			if(params.getFile() != null) {
140
				//We have to locate a provider's name which manages the selected file
141
				//A FilesystemServerExplorer will give a getProviderNames service
142
				FilesystemServerExplorerParameters paramsExplorer = (FilesystemServerExplorerParameters)dataManager.createServerExplorerParameters(FilesystemServerExplorer.NAME);
143
				FilesystemServerExplorer serverExplorer = null;
144
				try {
145
					paramsExplorer.setRoot(File.separator);
146
					serverExplorer = (FilesystemServerExplorer)dataManager.openServerExplorer(FilesystemServerExplorer.NAME, paramsExplorer);
147
				} catch (ValidateDataParametersException e) {
148
					throw new InitializeException(e);
149
				}
150

  
151
				//Gets the list of provider's name to manage the file
152
				List<String> provName = serverExplorer.getProviderNameList(params.getFile());
153
				if(provName.size() > 0) {
154
					for (int i = 0; i < provName.size(); i++) {
155
						//Gets the first provider what is not a TileProvider
156
						if(provName.get(i).compareTo(NAME) != 0) {
157
							DataStoreParameters newparams = dataManager.createStoreParameters(provName.get(i));
158
							((FilesystemStoreParameters)newparams).setFile(params.getFile());
159
							prov = dataManager.createProvider(storeServices, newparams);
160
						}
161
					}
162
				}
163
			}
164
		}
165

  
166
		if(prov != null && prov instanceof RasterProvider) {
167
			if(((RasterProvider)prov).isRotated())
168
				throw new InitializeException("Rotation not supported tiling files", new Throwable());
169

  
170
			return (RasterProvider)prov;
171
		}
172

  
173
		return null;
174
	}
175

  
176
	/**
177
	 * @return the internal provider used to feed the TileProvider
178
	 */
179
	public RasterProvider getInternalProvider() {
180
		return provider;
181
	}
182

  
183
	public Image getImageLegend() {
184
		return provider.getImageLegend();
185
	}
186

  
187
	public ColorInterpretation getColorInterpretation() {
188
		return provider.getColorInterpretation();
189
	}
190

  
191
	public String getFileSuffix() {
192
		try {
193
            return provider.getFileSuffix();
194
		} catch(Throwable e) {
195
			return "tif";
196
		}
197
	}
198

  
199
	public File getRMFFile() {
200
		TileCacheManager  manager = TileCacheLocator.getManager();
201
		TileCache tileCache = manager.getTileCache(RasterLibrary.pathTileCache);
202

  
203
		String metadataDir = tiledLayer.getBaseLayerDirectory().substring(0, tiledLayer.getBaseLayerDirectory().lastIndexOf(File.separator) + 1) +
204
				  			tileCache.getConfigurationDirectory();
205

  
206
		File metadaDirFile = new File(metadataDir);
207
		if(!metadaDirFile.exists())
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff