svn-gvsig-desktop / branches / org.gvsig.desktop-2018a / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.tilecache / org.gvsig.fmap.dal.tilecache.raster / src / main / java / org / gvsig / raster / tilecache / provider / MemoryTileCacheStoreProvider.java @ 43876
History | View | Annotate | Download (5.47 KB)
1 |
/* gvSIG. Desktop Geographic Information System.
|
---|---|
2 |
*
|
3 |
* Copyright ? 2007-2016 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.provider; |
24 |
|
25 |
import org.cresques.cts.IProjection; |
26 |
import org.slf4j.Logger; |
27 |
import org.slf4j.LoggerFactory; |
28 |
|
29 |
import org.gvsig.fmap.dal.DataStoreNotification; |
30 |
import org.gvsig.fmap.dal.FileHelper; |
31 |
import org.gvsig.fmap.dal.exception.DataException; |
32 |
import org.gvsig.fmap.dal.exception.InitializeException; |
33 |
import org.gvsig.fmap.dal.raster.RasterQuery; |
34 |
import org.gvsig.fmap.dal.raster.RasterStore; |
35 |
import org.gvsig.fmap.dal.raster.spi.RasterStoreProvider; |
36 |
import org.gvsig.fmap.dal.resource.spi.ResourceConsumer; |
37 |
import org.gvsig.fmap.dal.resource.spi.ResourceProvider; |
38 |
import org.gvsig.fmap.dal.spi.DataStoreProviderServices; |
39 |
import org.gvsig.metadata.MetadataLocator; |
40 |
import org.gvsig.metadata.MetadataManager; |
41 |
import org.gvsig.metadata.exceptions.MetadataException; |
42 |
import org.gvsig.raster.lib.buffer.api.TileStruct; |
43 |
import org.gvsig.tools.ToolsLocator; |
44 |
import org.gvsig.tools.dynobject.DynObject; |
45 |
import org.gvsig.tools.task.SimpleTaskStatus; |
46 |
import org.gvsig.tools.task.TaskStatusManager; |
47 |
|
48 |
/**
|
49 |
* Provider for Tile Cache
|
50 |
*
|
51 |
* @author dmartinezizquierdo
|
52 |
*
|
53 |
*/
|
54 |
public class MemoryTileCacheStoreProvider extends AbstractTileCacheStoreProvider implements //RasterCacheStoreProvider, |
55 |
ResourceConsumer { |
56 |
|
57 |
private static final Logger logger = LoggerFactory.getLogger(MemoryTileCacheStoreProvider.class); |
58 |
|
59 |
public static String NAME = "MemoryTileCache"; |
60 |
public static String DESCRIPTION = "Memory Tile cache provider"; |
61 |
public static final String METADATA_DEFINITION_NAME = NAME; |
62 |
|
63 |
private final SimpleTaskStatus taskStatus; |
64 |
|
65 |
protected static void registerMetadataDefinition() throws MetadataException { |
66 |
MetadataManager manager = MetadataLocator.getMetadataManager(); |
67 |
if (manager.getDefinition(METADATA_DEFINITION_NAME) == null) { |
68 |
manager.addDefinition(METADATA_DEFINITION_NAME, |
69 |
MemoryTileCacheStoreProviderParameters.class.getResourceAsStream("TileCacheMetadata.xml"),
|
70 |
MemoryTileCacheStoreProviderParameters.class.getClassLoader()); |
71 |
} |
72 |
} |
73 |
|
74 |
/**
|
75 |
* @param params
|
76 |
* @param storeServices
|
77 |
* @throws InitializeException
|
78 |
*/
|
79 |
public MemoryTileCacheStoreProvider(MemoryTileCacheStoreProviderParameters params, DataStoreProviderServices storeServices)
|
80 |
throws InitializeException {
|
81 |
super(params, storeServices, FileHelper.newMetadataContainer(METADATA_DEFINITION_NAME));
|
82 |
TaskStatusManager manager = ToolsLocator.getTaskStatusManager(); |
83 |
this.taskStatus = manager.createDefaultSimpleTaskStatus("MemoryTileCache"); |
84 |
this.init(params, storeServices);
|
85 |
} |
86 |
|
87 |
protected MemoryTileCacheStoreProvider(MemoryTileCacheStoreProviderParameters params, DataStoreProviderServices storeServices,
|
88 |
DynObject metadata) throws InitializeException {
|
89 |
super(params, storeServices, metadata);
|
90 |
TaskStatusManager manager = ToolsLocator.getTaskStatusManager(); |
91 |
this.taskStatus = manager.createDefaultSimpleTaskStatus("MemoryTileCache"); |
92 |
this.init(params, storeServices);
|
93 |
} |
94 |
|
95 |
protected void init(MemoryTileCacheStoreProviderParameters params, |
96 |
DataStoreProviderServices storeServices) throws InitializeException {
|
97 |
bandsNumber = ((RasterStore)storeServices).getBands(); |
98 |
|
99 |
if (params == null) { |
100 |
throw new InitializeException( |
101 |
new NullPointerException("params is null")); |
102 |
} |
103 |
} |
104 |
|
105 |
@Override
|
106 |
public MemoryTileCacheStoreProviderParameters getParameters() {
|
107 |
return (MemoryTileCacheStoreProviderParameters) super.getParameters(); |
108 |
} |
109 |
|
110 |
@Override
|
111 |
public ResourceProvider getResource() {
|
112 |
return null; |
113 |
} |
114 |
|
115 |
@Override
|
116 |
public Object getSourceId() { |
117 |
return this.innerProvider.getSourceId()+"_MemoryTileCache"; |
118 |
} |
119 |
|
120 |
@Override
|
121 |
public String getProviderName() { |
122 |
return NAME;
|
123 |
} |
124 |
|
125 |
@Override
|
126 |
public boolean closeResourceRequested(ResourceProvider resource) { |
127 |
return true; |
128 |
} |
129 |
|
130 |
@Override
|
131 |
public void resourceChanged(ResourceProvider resource) { |
132 |
this.getStoreServices().notifyChange(DataStoreNotification.RESOURCE_CHANGED, resource);
|
133 |
} |
134 |
|
135 |
@Override
|
136 |
public void apply(RasterStoreProvider provider, IProjection crs, RasterQuery query) throws DataException { |
137 |
super.apply(provider, crs, query);
|
138 |
|
139 |
setTileStructImage(new MemoryTileStructImage(provider, query));
|
140 |
} |
141 |
|
142 |
@Override
|
143 |
public RasterStoreProvider getInnerProvider() {
|
144 |
return innerProvider;
|
145 |
} |
146 |
|
147 |
@Override
|
148 |
public TileStruct getTileStruct() {
|
149 |
return innerProvider.getTileStruct();
|
150 |
} |
151 |
|
152 |
} |