gvsig-raster / org.gvsig.raster / trunk / org.gvsig.raster / org.gvsig.raster.lib / org.gvsig.raster.lib.impl / src / main / java / org / gvsig / raster / impl / DefaultRasterManager.java @ 1967
History | View | Annotate | Download (22.6 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.impl; |
23 |
|
24 |
import java.awt.geom.AffineTransform; |
25 |
import java.awt.geom.Dimension2D; |
26 |
import java.lang.reflect.Constructor; |
27 |
import java.lang.reflect.InvocationTargetException; |
28 |
import java.util.ArrayList; |
29 |
import java.util.HashMap; |
30 |
import java.util.Set; |
31 |
|
32 |
import org.cresques.cts.IProjection; |
33 |
import org.gvsig.fmap.dal.DALLocator; |
34 |
import org.gvsig.fmap.dal.DataStoreParameters; |
35 |
import org.gvsig.fmap.dal.coverage.BufferFactory; |
36 |
import org.gvsig.fmap.dal.coverage.RasterLibrary; |
37 |
import org.gvsig.fmap.dal.coverage.RasterManager; |
38 |
import org.gvsig.fmap.dal.coverage.RasterService; |
39 |
import org.gvsig.fmap.dal.coverage.dataset.Buffer; |
40 |
import org.gvsig.fmap.dal.coverage.datastruct.DataStructFactory; |
41 |
import org.gvsig.fmap.dal.coverage.datastruct.Extent; |
42 |
import org.gvsig.fmap.dal.coverage.datastruct.GridExtent; |
43 |
import org.gvsig.fmap.dal.coverage.datastruct.Params; |
44 |
import org.gvsig.fmap.dal.coverage.datastruct.RasterLegend; |
45 |
import org.gvsig.fmap.dal.coverage.datastruct.ViewPortData; |
46 |
import org.gvsig.fmap.dal.coverage.exception.NotSupportedExtensionException; |
47 |
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException; |
48 |
import org.gvsig.fmap.dal.coverage.exception.RasterBufferInvalidException; |
49 |
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException; |
50 |
import org.gvsig.fmap.dal.coverage.exception.RasterLegendIONotFound; |
51 |
import org.gvsig.fmap.dal.coverage.grid.AbstractROI; |
52 |
import org.gvsig.fmap.dal.coverage.grid.Grid; |
53 |
import org.gvsig.fmap.dal.coverage.grid.RasterFilterList; |
54 |
import org.gvsig.fmap.dal.coverage.grid.render.ImageDrawer; |
55 |
import org.gvsig.fmap.dal.coverage.process.TaskEventManager; |
56 |
import org.gvsig.fmap.dal.coverage.process.overview.OverviewBuilder; |
57 |
import org.gvsig.fmap.dal.coverage.process.vector.Vectorization; |
58 |
import org.gvsig.fmap.dal.coverage.store.DataServerWriter; |
59 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
60 |
import org.gvsig.fmap.dal.coverage.store.RasterQuery; |
61 |
import org.gvsig.fmap.dal.coverage.store.RasterWriter; |
62 |
import org.gvsig.fmap.dal.coverage.store.props.ColorInterpretation; |
63 |
import org.gvsig.fmap.dal.coverage.store.props.Statistics; |
64 |
import org.gvsig.fmap.dal.coverage.util.CRSUtils; |
65 |
import org.gvsig.fmap.dal.coverage.util.ColorConversion; |
66 |
import org.gvsig.fmap.dal.coverage.util.FileUtils; |
67 |
import org.gvsig.fmap.dal.coverage.util.Historical; |
68 |
import org.gvsig.fmap.dal.coverage.util.MathUtils; |
69 |
import org.gvsig.fmap.dal.coverage.util.ProviderServices; |
70 |
import org.gvsig.fmap.dal.coverage.util.RasterUtils; |
71 |
import org.gvsig.fmap.dal.exception.InitializeException; |
72 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
73 |
import org.gvsig.fmap.dal.raster.spi.CoverageStoreProvider; |
74 |
import org.gvsig.fmap.dal.spi.DataManagerProviderServices; |
75 |
import org.gvsig.raster.impl.buffer.DefaultDataServerWriter; |
76 |
import org.gvsig.raster.impl.buffer.DefaultRasterQuery; |
77 |
import org.gvsig.raster.impl.buffer.RasterBuffer; |
78 |
import org.gvsig.raster.impl.buffer.RasterMemoryBuffer; |
79 |
import org.gvsig.raster.impl.buffer.cache.RasterCache; |
80 |
import org.gvsig.raster.impl.buffer.cache.RasterReadOnlyBuffer; |
81 |
import org.gvsig.raster.impl.datastruct.DefaultDataStructFactory; |
82 |
import org.gvsig.raster.impl.datastruct.DefaultViewPortData; |
83 |
import org.gvsig.raster.impl.datastruct.legend.GimpGradients; |
84 |
import org.gvsig.raster.impl.datastruct.legend.GimpPalettes; |
85 |
import org.gvsig.raster.impl.datastruct.legend.LegendgvSIG; |
86 |
import org.gvsig.raster.impl.datastruct.legend.RasterLegendIO; |
87 |
import org.gvsig.raster.impl.grid.GridImpl; |
88 |
import org.gvsig.raster.impl.grid.filter.DefaultRasterFilterList; |
89 |
import org.gvsig.raster.impl.grid.render.ImageDrawerImpl; |
90 |
import org.gvsig.raster.impl.grid.roi.ROIStatistic; |
91 |
import org.gvsig.raster.impl.process.DefaultTaskEventManager; |
92 |
import org.gvsig.raster.impl.process.RasterTask; |
93 |
import org.gvsig.raster.impl.process.RasterTaskQueue; |
94 |
import org.gvsig.raster.impl.process.vector.PotraceVectorization; |
95 |
import org.gvsig.raster.impl.provider.DefaultRasterProvider; |
96 |
import org.gvsig.raster.impl.provider.RasterProvider; |
97 |
import org.gvsig.raster.impl.store.AbstractRasterDataParameters; |
98 |
import org.gvsig.raster.impl.store.DefaultRasterStore; |
99 |
import org.gvsig.raster.impl.store.ParamsImpl; |
100 |
import org.gvsig.raster.impl.store.QueryableRaster; |
101 |
import org.gvsig.raster.impl.store.properties.DataStoreColorInterpretation; |
102 |
import org.gvsig.raster.impl.store.writer.DefaultRasterWriter; |
103 |
import org.gvsig.raster.util.DefaultCRSUtils; |
104 |
import org.gvsig.raster.util.DefaultColorConversion; |
105 |
import org.gvsig.raster.util.DefaultFileUtils; |
106 |
import org.gvsig.raster.util.DefaultHistorical; |
107 |
import org.gvsig.raster.util.DefaultMathUtils; |
108 |
import org.gvsig.raster.util.DefaultProviderServices; |
109 |
import org.gvsig.raster.util.DefaultRasterUtils; |
110 |
import org.gvsig.tools.ToolsLocator; |
111 |
import org.gvsig.tools.extensionpoint.ExtensionPoint; |
112 |
import org.gvsig.tools.extensionpoint.ExtensionPointManager; |
113 |
import org.gvsig.tools.service.ServiceException; |
114 |
import org.slf4j.Logger; |
115 |
import org.slf4j.LoggerFactory; |
116 |
|
117 |
/**
|
118 |
* Default {@link RasterManager} implementation.
|
119 |
*
|
120 |
* @author gvSIG Team
|
121 |
* @version $Id$
|
122 |
*/
|
123 |
public class DefaultRasterManager implements RasterManager { |
124 |
private static DefaultRasterManager internalInstance = new DefaultRasterManager(); |
125 |
private static final Logger logger = LoggerFactory.getLogger(DefaultRasterManager.class); |
126 |
private CRSUtils crs = null; |
127 |
private FileUtils file = null; |
128 |
private MathUtils math = null; |
129 |
private RasterUtils util = null; |
130 |
private ProviderServices pInfo = null; |
131 |
private DefaultColorConversion colorConversion = null; |
132 |
private DataStructFactory dataStructFactory = null; |
133 |
private static Class<?> tileclass = null; |
134 |
private static ArrayList<Class<?>> tiledProviders = new ArrayList<Class<?>>(); |
135 |
private static HashMap<String, ArrayList<Class<?>>> |
136 |
formatsRegistry = new HashMap<String, ArrayList<Class<?>>>(); |
137 |
public static HashMap<String, OverviewBuilder> |
138 |
overviewBuilderRegistry = new HashMap<String, OverviewBuilder>(); |
139 |
|
140 |
/**
|
141 |
* Gets an instance of this object for internal use.
|
142 |
* @return DefaultRasterManager
|
143 |
*/
|
144 |
public static DefaultRasterManager getInstance() { |
145 |
return internalInstance;
|
146 |
} |
147 |
|
148 |
public DataStructFactory getDataStructFactory() {
|
149 |
if(dataStructFactory == null) |
150 |
dataStructFactory = new DefaultDataStructFactory();
|
151 |
return dataStructFactory;
|
152 |
} |
153 |
|
154 |
public ProviderServices getProviderServices() {
|
155 |
if(pInfo == null) |
156 |
pInfo = new DefaultProviderServices();
|
157 |
return pInfo;
|
158 |
} |
159 |
|
160 |
public CRSUtils getCRSUtils() {
|
161 |
if(crs == null) |
162 |
crs = new DefaultCRSUtils();
|
163 |
return crs;
|
164 |
} |
165 |
|
166 |
public FileUtils getFileUtils() {
|
167 |
if(file == null) |
168 |
file = new DefaultFileUtils();
|
169 |
return file;
|
170 |
} |
171 |
|
172 |
public RasterUtils getRasterUtils() {
|
173 |
if(util == null) |
174 |
util = new DefaultRasterUtils();
|
175 |
return util;
|
176 |
} |
177 |
|
178 |
public MathUtils getMathUtils() {
|
179 |
if(math == null) |
180 |
math = new DefaultMathUtils();
|
181 |
return math;
|
182 |
} |
183 |
|
184 |
public RasterService getRasterService()
|
185 |
throws ServiceException {
|
186 |
RasterService fc = new DefaultRasterService(this); |
187 |
return fc;
|
188 |
} |
189 |
|
190 |
public String[] getLegendFormats() { |
191 |
return RasterLegendIO.formats;
|
192 |
} |
193 |
|
194 |
public RasterLegend getRasterLegendIO(String formatName) throws RasterLegendIONotFound { |
195 |
if (formatName.equals(RasterLegendIO.formats[0])) |
196 |
return new LegendgvSIG(); |
197 |
|
198 |
if (formatName.equals(RasterLegendIO.formats[1])) |
199 |
return new GimpGradients(); |
200 |
|
201 |
if (formatName.equals(RasterLegendIO.formats[2])) |
202 |
return new GimpPalettes(); |
203 |
|
204 |
// Incluir mas formatos de la misma manera
|
205 |
throw new RasterLegendIONotFound(); |
206 |
} |
207 |
|
208 |
public DataServerWriter createDataServerWriter() {
|
209 |
return new DefaultDataServerWriter(); |
210 |
} |
211 |
|
212 |
public RasterDataStore open(CoverageStoreProvider prov, DataStoreParameters params) throws NotSupportedExtensionException, RasterDriverException { |
213 |
if(prov instanceof RasterProvider) { |
214 |
DefaultRasterStore store = new DefaultRasterStore();
|
215 |
store.setProvider((RasterProvider)prov); |
216 |
try {
|
217 |
store.intializePhase1(null, params);
|
218 |
} catch (InitializeException e) {
|
219 |
throw new RasterDriverException(e.getMessage()); |
220 |
} |
221 |
return store;
|
222 |
} |
223 |
return null; |
224 |
} |
225 |
|
226 |
public RasterDataStore open(DataStoreParameters params) throws NotSupportedExtensionException, RasterDriverException { |
227 |
if(params == null || !(params instanceof AbstractRasterDataParameters)) |
228 |
return null; |
229 |
DefaultRasterStore dSet = new DefaultRasterStore();
|
230 |
DataManagerProviderServices dataManager = (DataManagerProviderServices)DALLocator.getDataManager(); |
231 |
try {
|
232 |
DefaultRasterProvider provider = (DefaultRasterProvider)dataManager.createProvider(dSet, (AbstractRasterDataParameters)params); |
233 |
dSet.setProvider(provider); |
234 |
} catch (InitializeException e) {
|
235 |
throw new RasterDriverException("Error initializing provider", e); |
236 |
} catch (ProviderNotRegisteredException e) {
|
237 |
throw new RasterDriverException("Provider not register error", e); |
238 |
} |
239 |
return dSet;
|
240 |
} |
241 |
|
242 |
public RasterDataStore open(Object datasetOpenParam) throws NotSupportedExtensionException, RasterDriverException { |
243 |
DefaultRasterStore dSet = new DefaultRasterStore();
|
244 |
|
245 |
if (datasetOpenParam instanceof String) { |
246 |
DefaultRasterProvider provider = DefaultRasterProvider.singleDatasetInstance(dSet, (String)datasetOpenParam);
|
247 |
dSet.setProvider(provider); |
248 |
return dSet;
|
249 |
} |
250 |
|
251 |
/*if (datasetOpenParam instanceof String[]) {
|
252 |
String[] param = (String[]) datasetOpenParam;
|
253 |
try {
|
254 |
for (int dataset = 0; dataset < param.length; dataset++) {
|
255 |
dSet.addDataStore(DefaultRasterProvider.singleDatasetInstance(dSet, param[dataset]) );
|
256 |
}
|
257 |
} catch (OperationNotSupportedException e) {
|
258 |
return open(param[0]);
|
259 |
}
|
260 |
return dSet;
|
261 |
}
|
262 |
|
263 |
if (datasetOpenParam instanceof Buffer[]) {
|
264 |
Buffer[] param = (Buffer[]) datasetOpenParam;
|
265 |
for (int dataset = 0; dataset < param.length; dataset++) {
|
266 |
dSet.addDataStore(DefaultRasterProvider.singleDatasetInstance(param[dataset]));
|
267 |
}
|
268 |
return dSet;
|
269 |
}
|
270 |
|
271 |
if(datasetOpenParam instanceof String[][]) {
|
272 |
String[][] param = (String[][])datasetOpenParam;
|
273 |
DefaultMultiRasterStore[][] mosaic = new DefaultMultiRasterStore[param.length][param[0].length];
|
274 |
for (int i = 0; i < param.length; i++)
|
275 |
for (int j = 0; j < param[i].length; j++)
|
276 |
mosaic[i][j] = (DefaultMultiRasterStore)open(param[i][j]);
|
277 |
DefaultMosaicRasterStore cd;
|
278 |
try {
|
279 |
cd = new DefaultMosaicRasterStore(mosaic);
|
280 |
} catch (MosaicNotValidException e) {
|
281 |
return null;
|
282 |
}
|
283 |
return cd;
|
284 |
}*/
|
285 |
|
286 |
return null; |
287 |
} |
288 |
|
289 |
public RasterQuery createQuery() {
|
290 |
return new DefaultRasterQuery(); |
291 |
} |
292 |
|
293 |
public Buffer createBuffer(int dataType, int width, int height, int bandNr, boolean malloc) { |
294 |
//Opci?n de cachear siempre activada (Solo DEBUG)
|
295 |
if(RasterBuffer.forceToLoadInCache)
|
296 |
return new RasterCache(dataType, width, height, bandNr); |
297 |
if(RasterBuffer.forceToLoadInReadOnlyCache){
|
298 |
return new RasterReadOnlyBuffer(dataType, width, height, bandNr); |
299 |
} |
300 |
|
301 |
if(RasterBuffer.cacheOn){
|
302 |
long size = (long)((long)getRasterUtils().getBytesFromRasterBufType(dataType) * (long)width * (long)height * (long)bandNr) / 1024L; |
303 |
long ms1 = RasterLibrary.cacheSize * 1024L; |
304 |
if(size <= ms1)
|
305 |
return new RasterMemoryBuffer(dataType, width, height, bandNr, malloc); |
306 |
else
|
307 |
return new RasterCache(dataType, width, height, bandNr); |
308 |
}else
|
309 |
return new RasterMemoryBuffer(dataType, width, height, bandNr, malloc); |
310 |
} |
311 |
|
312 |
public Buffer createReadOnlyBuffer(int dataType, int width, int height, int bandNr) { |
313 |
return new RasterReadOnlyBuffer(dataType, width, height, bandNr); |
314 |
} |
315 |
|
316 |
public Buffer createMemoryBuffer(int dataType, int width, int height, int bandNr, boolean malloc) { |
317 |
return new RasterMemoryBuffer(dataType, width, height, bandNr, malloc); |
318 |
} |
319 |
|
320 |
@SuppressWarnings("unchecked") |
321 |
public RasterWriter createWriter(String fName) throws NotSupportedExtensionException, RasterDriverException { |
322 |
String ext = getFileUtils().getExtensionFromFileName(fName);
|
323 |
DefaultRasterWriter grw = null;
|
324 |
ExtensionPointManager extensionPoints = ToolsLocator.getExtensionPointManager(); |
325 |
ExtensionPoint point = extensionPoints.get("RasterWriter");
|
326 |
// ExtensionPoint extensionPoint = ExtensionPoint.getExtensionPoint("RasterWriter");
|
327 |
|
328 |
if (!point.has(ext))
|
329 |
return grw;
|
330 |
|
331 |
Class clase = point.get(ext).getExtension();
|
332 |
Class[] args = { String.class }; |
333 |
try {
|
334 |
Constructor hazNuevo = clase.getConstructor(args);
|
335 |
Object[] args2 = { fName }; |
336 |
grw = (DefaultRasterWriter) hazNuevo.newInstance(args2); |
337 |
} catch (SecurityException e) { |
338 |
throw new RasterDriverException("Error SecurityException in open", e); |
339 |
} catch (NoSuchMethodException e) { |
340 |
throw new RasterDriverException("Error NoSuchMethodException in open", e); |
341 |
} catch (IllegalArgumentException e) { |
342 |
throw new RasterDriverException("Error IllegalArgumentException in open", e); |
343 |
} catch (InstantiationException e) { |
344 |
throw new RasterDriverException("Error InstantiationException in open", e); |
345 |
} catch (IllegalAccessException e) { |
346 |
throw new RasterDriverException("Error IllegalAccessException in open", e); |
347 |
} catch (InvocationTargetException e) { |
348 |
throw new NotSupportedExtensionException("Error in open", e); |
349 |
} |
350 |
return grw;
|
351 |
} |
352 |
|
353 |
public RasterWriter createWriter(DataServerWriter dataWriter,
|
354 |
String outFileName,
|
355 |
int nBands,
|
356 |
AffineTransform at,
|
357 |
int outSizeX,
|
358 |
int outSizeY,
|
359 |
int dataType,
|
360 |
Params params, |
361 |
IProjection proj) throws NotSupportedExtensionException, RasterDriverException {
|
362 |
return createWriter(dataWriter, outFileName, nBands, at, outSizeX, outSizeY, dataType, params, proj, true); |
363 |
} |
364 |
|
365 |
@SuppressWarnings("unchecked") |
366 |
public RasterWriter createWriter(DataServerWriter dataWriter,
|
367 |
String outFileName,
|
368 |
int nBands,
|
369 |
AffineTransform at,
|
370 |
int outSizeX,
|
371 |
int outSizeY,
|
372 |
int dataType,
|
373 |
Params params, |
374 |
IProjection proj, |
375 |
boolean geo) throws NotSupportedExtensionException, RasterDriverException { |
376 |
String ext = outFileName.toLowerCase().substring(outFileName.lastIndexOf('.') + 1); |
377 |
DefaultRasterWriter grw = null;
|
378 |
ExtensionPointManager extensionPoints = ToolsLocator.getExtensionPointManager(); |
379 |
ExtensionPoint point = extensionPoints.get("RasterWriter");
|
380 |
|
381 |
if (!point.has(ext))
|
382 |
return grw;
|
383 |
|
384 |
Class clase = point.get(ext).getExtension();
|
385 |
Class[] args = { DataServerWriter.class, String.class, Integer.class, AffineTransform.class, Integer.class, Integer.class, Integer.class, Params.class, IProjection.class, Boolean.class }; |
386 |
try {
|
387 |
Constructor hazNuevo = clase.getConstructor(args);
|
388 |
Object [] args2 = {dataWriter, outFileName, new Integer(nBands), at, |
389 |
new Integer(outSizeX), new Integer(outSizeY), new Integer(dataType), |
390 |
params, proj, new Boolean(geo)}; |
391 |
grw = (DefaultRasterWriter) hazNuevo.newInstance(args2); |
392 |
} catch (SecurityException e) { |
393 |
throw new RasterDriverException("Error SecurityException in open", e); |
394 |
} catch (NoSuchMethodException e) { |
395 |
throw new RasterDriverException("Error NoSuchMethodException in open", e); |
396 |
} catch (IllegalArgumentException e) { |
397 |
throw new RasterDriverException("Error IllegalArgumentException in open", e); |
398 |
} catch (InstantiationException e) { |
399 |
throw new RasterDriverException("Error InstantiationException in open", e); |
400 |
} catch (IllegalAccessException e) { |
401 |
throw new RasterDriverException("Error IllegalAccessException in open", e); |
402 |
} catch (InvocationTargetException e) { |
403 |
throw new NotSupportedExtensionException("Error in open. Problemas con las librer?as nativas.", e); |
404 |
} |
405 |
return grw;
|
406 |
} |
407 |
|
408 |
public Params createWriterParams(String fileName) { |
409 |
try {
|
410 |
return createWriter(fileName).getParams();
|
411 |
} catch (NotSupportedExtensionException e) {
|
412 |
return null; |
413 |
} catch (RasterDriverException e) {
|
414 |
return null; |
415 |
} |
416 |
} |
417 |
|
418 |
/**
|
419 |
* Gets an object which vectorize a raster
|
420 |
* @param dataStore
|
421 |
* @return
|
422 |
* @throws RasterDriverException
|
423 |
* @throws ProcessInterruptedException
|
424 |
* When the object Vectorization is built the raster data buffer is loaded.
|
425 |
* This operation can be interrupted
|
426 |
*/
|
427 |
public Vectorization getVectorizeObject(QueryableRaster queryable) throws RasterDriverException, ProcessInterruptedException { |
428 |
return new PotraceVectorization(queryable); |
429 |
} |
430 |
|
431 |
public OverviewBuilder getOverviewBuilder(String id) { |
432 |
return overviewBuilderRegistry.get(id);
|
433 |
} |
434 |
|
435 |
public boolean isOverviewBuilderSupported() { |
436 |
return overviewBuilderRegistry.size() > 0; |
437 |
} |
438 |
|
439 |
|
440 |
public Set<String> getOverviewBuilderKeyList() { |
441 |
return overviewBuilderRegistry.keySet();
|
442 |
} |
443 |
|
444 |
public ColorInterpretation createColorInterpretation(String[] colorInterp) { |
445 |
return new DataStoreColorInterpretation(colorInterp); |
446 |
} |
447 |
|
448 |
public Grid createGrid(RasterDataStore datasource, int[] bands, GridExtent windowExtent) throws RasterBufferInvalidException { |
449 |
return new GridImpl(datasource, bands, windowExtent); |
450 |
} |
451 |
|
452 |
public Grid createGrid(RasterDataStore datasource, int[] bands) throws RasterBufferInvalidException { |
453 |
return new GridImpl(datasource, bands); |
454 |
} |
455 |
|
456 |
public Grid createGrid(RasterDataStore datasource) throws RasterBufferInvalidException { |
457 |
return new GridImpl(datasource); |
458 |
} |
459 |
|
460 |
public Grid createGrid(GridExtent layerExtent,
|
461 |
GridExtent windowExtent, |
462 |
int dataType,
|
463 |
int[] bands) throws RasterBufferInvalidException { |
464 |
return new GridImpl(layerExtent, windowExtent, dataType, bands); |
465 |
} |
466 |
|
467 |
public Grid createGrid(Buffer buf, RasterDataStore datasource, boolean notInterp) { |
468 |
return new GridImpl(buf, datasource, notInterp); |
469 |
} |
470 |
|
471 |
public Historical createHistoricalService() {
|
472 |
return new DefaultHistorical(); |
473 |
} |
474 |
|
475 |
public ViewPortData createViewPortData(IProjection proj, Extent extent, Dimension2D size) { |
476 |
return new DefaultViewPortData(proj, extent, size); |
477 |
} |
478 |
|
479 |
public ViewPortData createViewPortData() {
|
480 |
return new DefaultViewPortData(); |
481 |
} |
482 |
|
483 |
public ColorConversion getColorConversion() {
|
484 |
if(colorConversion == null) |
485 |
colorConversion = new DefaultColorConversion();
|
486 |
return colorConversion;
|
487 |
} |
488 |
|
489 |
public Statistics createROIStatistics(AbstractROI roi) {
|
490 |
return new ROIStatistic(roi); |
491 |
} |
492 |
|
493 |
public RasterFilterList createEmptyFilterList(int type) { |
494 |
DefaultRasterFilterList fl = new DefaultRasterFilterList();
|
495 |
fl.setInitDataType(type); |
496 |
return fl;
|
497 |
} |
498 |
|
499 |
public TaskEventManager getRasterTask() {
|
500 |
return DefaultTaskEventManager.get();
|
501 |
} |
502 |
|
503 |
public TaskEventManager createRasterTask(Object process) { |
504 |
RasterTask task = RasterTaskQueue.getRasterTask(Thread.currentThread().getId() + ""); |
505 |
if(task != null) { |
506 |
DefaultTaskEventManager man = new DefaultTaskEventManager();
|
507 |
man.setTask(task); |
508 |
return man;
|
509 |
} |
510 |
DefaultTaskEventManager man = new DefaultTaskEventManager(process);
|
511 |
return man;
|
512 |
} |
513 |
|
514 |
/**
|
515 |
* Builds a new parameter object. These parameters represents the fieds of a filter
|
516 |
* panel.
|
517 |
* @param id
|
518 |
* @param value
|
519 |
* @param type
|
520 |
* @param list
|
521 |
* @return
|
522 |
*/
|
523 |
public Params createParams(String id, Object value, int type, String[] list) { |
524 |
ParamsImpl params = new ParamsImpl();
|
525 |
params.setParam(id, |
526 |
value, |
527 |
type, |
528 |
list); |
529 |
return params;
|
530 |
} |
531 |
|
532 |
public void registerFileProvidersTiled(Class<?> provider) { |
533 |
if(!tiledProviders.contains(provider))
|
534 |
tiledProviders.add(provider); |
535 |
} |
536 |
|
537 |
public void registerTileProviderFormats(Class<?> c) { |
538 |
if(tileclass == null) { |
539 |
if(RasterProvider.class.isAssignableFrom(c)) {
|
540 |
ArrayList<?> pList = getTiledProvidersInstance();
|
541 |
for (int i = 0; i < pList.size(); i++) { |
542 |
String[] fList = ((RasterProvider)pList.get(i)).getFormatList(); |
543 |
for (int j = 0; j < fList.length; j++) { |
544 |
String value = fList[j];
|
545 |
addFormat(value, c); |
546 |
} |
547 |
} |
548 |
} |
549 |
tileclass = c; |
550 |
} |
551 |
} |
552 |
|
553 |
@SuppressWarnings("unchecked") |
554 |
private ArrayList<?> getTiledProvidersInstance() { |
555 |
ArrayList list = new ArrayList(); |
556 |
for (int i = 0; i < tiledProviders.size(); i++) { |
557 |
Class<?> provider = tiledProviders.get(i);
|
558 |
try {
|
559 |
Constructor c = provider.getConstructor();
|
560 |
list.add(c.newInstance()); |
561 |
} catch (SecurityException e) { |
562 |
logger.info("Error SecurityException in open", e);
|
563 |
} catch (NoSuchMethodException e) { |
564 |
logger.info("Error NoSuchMethodException in open", e);
|
565 |
} catch (IllegalArgumentException e) { |
566 |
logger.info("Error IllegalArgumentException in open", e);
|
567 |
} catch (InstantiationException e) { |
568 |
logger.info("Error InstantiationException in open", e);
|
569 |
} catch (IllegalAccessException e) { |
570 |
logger.info("Error IllegalAccessException in open", e);
|
571 |
} catch (InvocationTargetException e) { |
572 |
logger.info("Error in open. Problemas con las librer?as nativas.", e);
|
573 |
} |
574 |
} |
575 |
return list;
|
576 |
} |
577 |
|
578 |
public void addFormat(String ext, Class<?> c) { |
579 |
ArrayList<Class<?>> list = formatsRegistry.get(ext); |
580 |
if(list == null) { |
581 |
list = new ArrayList<Class<?>>(); |
582 |
list.add(c); |
583 |
formatsRegistry.put(ext, list); |
584 |
} else {
|
585 |
if(!list.contains(c))
|
586 |
list.add(c); |
587 |
} |
588 |
} |
589 |
|
590 |
public boolean isExtensionSupported(String ext, Class<?> c) { |
591 |
String extension = getFileUtils().getExtensionFromFileName(ext);
|
592 |
|
593 |
ArrayList<Class<?>> list = formatsRegistry.get(extension); |
594 |
if(list == null) { |
595 |
return false; |
596 |
} else {
|
597 |
for (int i = 0; i < list.size(); i++) { |
598 |
if(c == list.get(i))
|
599 |
return true; |
600 |
} |
601 |
} |
602 |
return false; |
603 |
} |
604 |
|
605 |
public boolean isExtensionSupported(String ext) { |
606 |
String extension = getFileUtils().getExtensionFromFileName(ext);
|
607 |
|
608 |
ArrayList<Class<?>> list = formatsRegistry.get(extension); |
609 |
if(list == null) { |
610 |
return false; |
611 |
} |
612 |
|
613 |
return true; |
614 |
} |
615 |
|
616 |
public String[] getReadOnlyFormatList() { |
617 |
return formatsRegistry.keySet().toArray(new String[0]); |
618 |
} |
619 |
|
620 |
public ImageDrawer createImageDrawerService() {
|
621 |
return new ImageDrawerImpl(); |
622 |
} |
623 |
|
624 |
public BufferFactory getBufferFactory() {
|
625 |
return new BufferFactoryImpl(); |
626 |
} |
627 |
} |