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