Revision 6420
org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.raster.tilecache/org.gvsig.raster.tilecache.provider.legend/src/main/java/org/gvsig/raster/tilecache/provider/legend/TileCacheGetColorInterpretation.java | ||
---|---|---|
1 | 1 |
package org.gvsig.raster.tilecache.provider.legend; |
2 | 2 |
|
3 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
4 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
|
5 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
|
3 |
import org.slf4j.LoggerFactory; |
|
4 |
|
|
6 | 5 |
import org.gvsig.fmap.dal.raster.api.RasterStore; |
7 |
import org.gvsig.raster.lib.buffer.api.Band; |
|
8 | 6 |
import org.gvsig.raster.lib.legend.api.ColorInterpretation; |
9 |
import org.gvsig.raster.lib.legend.api.RasterLegend; |
|
10 |
import org.gvsig.raster.lib.legend.api.RasterLegendLocator; |
|
11 |
import org.gvsig.raster.lib.legend.api.RasterLegendManager; |
|
12 | 7 |
import org.gvsig.raster.tilecache.provider.TileCacheStoreProvider; |
13 | 8 |
import org.gvsig.raster.tilecache.provider.TileStructImage; |
14 | 9 |
import org.gvsig.tools.ToolsLocator; |
... | ... | |
18 | 13 |
import org.gvsig.tools.dynobject.exception.DynMethodException; |
19 | 14 |
import org.gvsig.tools.dynobject.exception.DynMethodNotSupportedException; |
20 | 15 |
|
21 |
import org.slf4j.LoggerFactory; |
|
22 |
|
|
23 | 16 |
/** |
24 | 17 |
* @author dmartinezizquierdo |
25 | 18 |
* |
... | ... | |
62 | 55 |
TileCacheStoreProvider tileCacheStoreProvider = |
63 | 56 |
(TileCacheStoreProvider) self; |
64 | 57 |
|
65 |
RasterLegendManager legendManager = |
|
66 |
RasterLegendLocator.getRasterLegendManager(); |
|
67 |
|
|
68 |
// colorInterpretation = |
|
69 |
// legendManager.createColorInterpretation(ColorInterpretation.ARGB); |
|
70 |
|
|
71 | 58 |
TileStructImage tileStructImage = tileCacheStoreProvider.getTileStructImage(); |
72 | 59 |
|
73 |
RasterStore tileStore = null; |
|
74 |
try { |
|
75 |
tileStore = tileStructImage.getDelegatedRasterStore(); |
|
76 |
colorInterpretation = (ColorInterpretation) tileStore |
|
77 |
.invokeDynMethod(RasterStore.DYNMETHOD_GETCOLORINTERPRETATION_NAME, null); |
|
78 |
} catch (DynMethodNotSupportedException e) { |
|
79 |
logger.debug("This store {} does not provide a color interpretation.", |
|
80 |
tileStore.getName()); |
|
81 |
} catch (DynMethodException e) { |
|
82 |
logger.error( |
|
83 |
"Can't load the specific color interpretation provided for the store {}.", |
|
84 |
tileStore.getName(), e); |
|
85 |
} catch (ValidateDataParametersException | InitializeException | ProviderNotRegisteredException e) { |
|
86 |
logger.error( |
|
87 |
"Can't get delegated store {}.", |
|
88 |
tileStructImage.getProviderName(), e); |
|
89 |
} finally { |
|
90 |
if(tileStore!=null){ |
|
91 |
tileStore.dispose(); |
|
92 |
} |
|
93 |
} |
|
60 |
colorInterpretation = (ColorInterpretation)tileStructImage.getColorInterpretation(); |
|
94 | 61 |
|
95 |
|
|
96 | 62 |
return colorInterpretation; |
97 | 63 |
} |
98 | 64 |
|
org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.raster.tilecache/org.gvsig.raster.tilecache.provider.legend/src/main/java/org/gvsig/raster/tilecache/provider/legend/TileCacheGetColorTable.java | ||
---|---|---|
1 | 1 |
package org.gvsig.raster.tilecache.provider.legend; |
2 | 2 |
|
3 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
4 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
|
5 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
|
3 |
import org.slf4j.LoggerFactory; |
|
4 |
|
|
6 | 5 |
import org.gvsig.fmap.dal.raster.api.RasterStore; |
7 |
import org.gvsig.raster.lib.legend.api.ColorInterpretation; |
|
8 | 6 |
import org.gvsig.raster.lib.legend.api.ColorTable; |
9 |
import org.gvsig.raster.lib.legend.api.RasterLegendLocator; |
|
10 |
import org.gvsig.raster.lib.legend.api.RasterLegendManager; |
|
11 | 7 |
import org.gvsig.raster.tilecache.provider.TileCacheStoreProvider; |
12 | 8 |
import org.gvsig.raster.tilecache.provider.TileStructImage; |
13 | 9 |
import org.gvsig.tools.ToolsLocator; |
... | ... | |
17 | 13 |
import org.gvsig.tools.dynobject.exception.DynMethodException; |
18 | 14 |
import org.gvsig.tools.dynobject.exception.DynMethodNotSupportedException; |
19 | 15 |
|
20 |
import org.slf4j.LoggerFactory; |
|
21 |
|
|
22 | 16 |
/** |
23 | 17 |
* Dynamic method to add a get Color Table funcionality |
24 | 18 |
* @author dmartinezizquierdo |
... | ... | |
61 | 55 |
|
62 | 56 |
TileCacheStoreProvider tileCacheStoreProvider = |
63 | 57 |
(TileCacheStoreProvider) self; |
64 |
|
|
65 |
RasterLegendManager legendManager = |
|
66 |
RasterLegendLocator.getRasterLegendManager(); |
|
67 | 58 |
TileStructImage tileStructImage = tileCacheStoreProvider.getTileStructImage(); |
68 | 59 |
|
69 |
RasterStore tileStore = null; |
|
70 |
try { |
|
71 |
tileStore = tileStructImage.getDelegatedRasterStore(); |
|
72 |
colorTable = (ColorTable) tileStore |
|
73 |
.invokeDynMethod(RasterStore.DYNMETHOD_GETCOLORTABLE_NAME, null); |
|
74 |
} catch (DynMethodNotSupportedException e) { |
|
75 |
logger.debug("This store {} does not provide a color table.", |
|
76 |
tileStore.getName()); |
|
77 |
} catch (DynMethodException e) { |
|
78 |
logger.error( |
|
79 |
"Can't load the specific color table provided for the store {}.", |
|
80 |
tileStore.getName(), e); |
|
81 |
} catch (ValidateDataParametersException | InitializeException | ProviderNotRegisteredException e) { |
|
82 |
logger.error( |
|
83 |
"Can't get delegated store {}.", |
|
84 |
tileStructImage.getProviderName(), e); |
|
85 |
} finally { |
|
86 |
if(tileStore!=null){ |
|
87 |
tileStore.dispose(); |
|
88 |
} |
|
89 |
} |
|
60 |
colorTable = (ColorTable)tileStructImage.getColorTable(); |
|
90 | 61 |
|
91 | 62 |
return colorTable; |
92 | 63 |
|
org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.raster.tilecache/org.gvsig.raster.tilecache.provider.legend/src/main/java/org/gvsig/raster/tilecache/provider/legend/TileCacheGetLegend.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import org.slf4j.LoggerFactory; |
4 | 4 |
|
5 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
6 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
|
7 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
|
8 | 5 |
import org.gvsig.fmap.dal.raster.api.RasterStore; |
9 | 6 |
import org.gvsig.raster.lib.legend.api.RasterLegend; |
10 |
import org.gvsig.raster.lib.legend.api.RasterLegendLocator; |
|
11 |
import org.gvsig.raster.lib.legend.api.RasterLegendManager; |
|
12 | 7 |
import org.gvsig.raster.tilecache.provider.TileCacheStoreProvider; |
13 | 8 |
import org.gvsig.raster.tilecache.provider.TileStructImage; |
14 | 9 |
import org.gvsig.tools.ToolsLocator; |
... | ... | |
55 | 50 |
} |
56 | 51 |
|
57 | 52 |
@Override |
58 |
public Object invoke(DynObject self, Object[] args) |
|
59 |
throws DynMethodException { |
|
53 |
public Object invoke(DynObject self, Object[] args) throws DynMethodException { |
|
60 | 54 |
RasterLegend legend = null; |
61 | 55 |
|
62 |
TileCacheStoreProvider tileCacheStoreProvider = |
|
63 |
(TileCacheStoreProvider) self; |
|
56 |
TileCacheStoreProvider tileCacheStoreProvider = (TileCacheStoreProvider) self; |
|
64 | 57 |
|
65 |
RasterLegendManager legendManager = |
|
66 |
RasterLegendLocator.getRasterLegendManager(); |
|
67 |
|
|
68 |
|
|
69 |
// TileCacheStoreProvider provider=(TileCacheStoreProvider)self; |
|
70 |
// |
|
71 |
// ColorInterpretation colorInterpretation =(ColorInterpretation)provider. |
|
72 |
// invokeDynMethod(RasterStore.DYNMETHOD_GETCOLORINTERPRETATION_NAME, null); |
|
73 |
// |
|
74 |
// legend= legendManager.createLegend(colorInterpretation); |
|
75 |
// if ( !( colorInterpretation.isBGR() || colorInterpretation.isRGB() || colorInterpretation.isRGBA() ) ){ |
|
76 |
// ColorTable colorTable=(ColorTable)provider. |
|
77 |
// invokeDynMethod(RasterStore.DYNMETHOD_GETCOLORTABLE_NAME, null); |
|
78 |
// legend.setColorTable(colorTable); |
|
79 |
// } |
|
80 |
|
|
81 | 58 |
TileStructImage tileStructImage = tileCacheStoreProvider.getTileStructImage(); |
82 |
RasterStore tileStore = null; |
|
83 |
try { |
|
84 |
tileStore = tileStructImage.getDelegatedRasterStore(); |
|
85 |
legend = (RasterLegend) tileStore |
|
86 |
.invokeDynMethod(RasterStore.DYNMETHOD_GETLEGEND_NAME, null); |
|
87 |
} catch (DynMethodNotSupportedException e) { |
|
88 |
logger.debug("This store {} does not provide a legend.", |
|
89 |
tileStore.getName()); |
|
90 |
} catch (DynMethodException e) { |
|
91 |
logger.error( |
|
92 |
"Can't load the specific legend provided for the store {}.", |
|
93 |
tileStore.getName(), e); |
|
94 |
} catch (ValidateDataParametersException | InitializeException | ProviderNotRegisteredException e) { |
|
95 |
logger.error( |
|
96 |
"Can't get delegated store {}.", |
|
97 |
tileStructImage.getProviderName(), e); |
|
98 |
} finally { |
|
99 |
if(tileStore!=null){ |
|
100 |
tileStore.dispose(); |
|
101 |
} |
|
102 |
} |
|
59 |
legend = (RasterLegend) tileStructImage.getLegend(); |
|
103 | 60 |
|
104 | 61 |
return legend; |
105 | 62 |
} |
org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.raster.tilecache/org.gvsig.raster.tilecache.provider/src/main/java/org/gvsig/raster/tilecache/provider/TileStructImage.java | ||
---|---|---|
49 | 49 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
50 | 50 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
51 | 51 |
import org.gvsig.fmap.dal.raster.api.RasterStore; |
52 |
import org.gvsig.fmap.dal.raster.spi.RasterStoreProvider; |
|
52 | 53 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerManager; |
53 | 54 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProviderFactory; |
54 | 55 |
import org.gvsig.fmap.dal.spi.DALSPILocator; |
... | ... | |
64 | 65 |
import org.gvsig.raster.lib.buffer.api.BufferManager; |
65 | 66 |
import org.gvsig.raster.lib.buffer.api.exceptions.BufferException; |
66 | 67 |
import org.gvsig.tools.dynobject.DynObject; |
68 |
import org.gvsig.tools.dynobject.exception.DynMethodException; |
|
69 |
import org.gvsig.tools.dynobject.exception.DynMethodNotSupportedException; |
|
67 | 70 |
import org.gvsig.tools.extensionpoint.ExtensionPoint.Extension; |
68 | 71 |
|
69 | 72 |
/** |
... | ... | |
92 | 95 |
|
93 | 96 |
private IProjection crs; |
94 | 97 |
private Envelope structExtent; |
98 |
private RasterStoreProvider remoteProvider; |
|
99 |
private Object colorInterpretation; |
|
100 |
private Object legend; |
|
95 | 101 |
// Este envelope sirve para calcular el nombre de la fila y columna del tile en la estructura de cach?. |
102 |
private Object colorTable; |
|
96 | 103 |
|
97 | 104 |
/** |
98 | 105 |
* @param folder |
99 | 106 |
* @param crs |
107 |
* @param remoteProvider |
|
100 | 108 |
*/ |
101 |
public TileStructImage(File folder, IProjection crs){ |
|
109 |
public TileStructImage(File folder, IProjection crs, RasterStoreProvider remoteProvider){
|
|
102 | 110 |
GeometryManager geoManager=GeometryLocator.getGeometryManager(); |
103 | 111 |
|
112 |
this.remoteProvider = remoteProvider; |
|
113 |
|
|
104 | 114 |
this.crs=crs; |
105 | 115 |
|
106 | 116 |
envelopePerZoomLevel=new TreeMap<Integer,Envelope>(); |
... | ... | |
313 | 323 |
new File(firstColumnFolder.getAbsolutePath() + File.separatorChar + rowBaseName + "." |
314 | 324 |
+ this.extension); |
315 | 325 |
} |
316 |
if (tileFile.exists()) { |
|
317 |
RasterStore tileStore = null; |
|
318 |
DataManagerProviderServices manager = DALSPILocator.getDataManagerProviderServices(); |
|
319 |
DataStoreProviderFactory providerFactory = manager.getStoreProviderFactory(providerName); |
|
326 |
if (!tileFile.exists()) { |
|
327 |
// TODO pedirselo al proveedor remoto |
|
328 |
} |
|
329 |
RasterStore tileStore = null; |
|
330 |
DataManagerProviderServices manager = DALSPILocator.getDataManagerProviderServices(); |
|
331 |
DataStoreProviderFactory providerFactory = manager.getStoreProviderFactory(providerName); |
|
320 | 332 |
|
321 |
DynObject params = providerFactory.createParameters();
|
|
322 |
if (params.getDynClass().getDynField("file") != null) {
|
|
323 |
params.setDynValue("file", tileFile);
|
|
324 |
}
|
|
325 |
if (params.getDynClass().getDynField("crs") != null) {
|
|
326 |
params.setDynValue("crs", this.crs);
|
|
327 |
}
|
|
333 |
DynObject params = providerFactory.createParameters(); |
|
334 |
if (params.getDynClass().getDynField("file") != null) { |
|
335 |
params.setDynValue("file", tileFile); |
|
336 |
} |
|
337 |
if (params.getDynClass().getDynField("crs") != null) { |
|
338 |
params.setDynValue("crs", this.crs); |
|
339 |
} |
|
328 | 340 |
|
329 |
tileStore = (RasterStore) manager.openStore(providerName, params); |
|
330 |
return tileStore; |
|
331 |
} |
|
341 |
tileStore = (RasterStore) manager.openStore(providerName, params); |
|
342 |
return tileStore; |
|
332 | 343 |
} |
333 | 344 |
} |
334 | 345 |
return null; |
... | ... | |
340 | 351 |
* @throws InitializeException |
341 | 352 |
* @throws ValidateDataParametersException |
342 | 353 |
*/ |
343 |
public RasterStore getDelegatedRasterStore() throws ValidateDataParametersException, InitializeException, ProviderNotRegisteredException{
|
|
354 |
private RasterStore getDelegatedRasterStore() throws ValidateDataParametersException, InitializeException, ProviderNotRegisteredException{
|
|
344 | 355 |
int[] structRowCol = calculateStructRowCol(pixelSizePerZoomLevel.firstKey(), 0, 0); |
345 | 356 |
return createTileStore(0, structRowCol[0], structRowCol[1]); |
346 | 357 |
} |
... | ... | |
460 | 471 |
} |
461 | 472 |
} |
462 | 473 |
|
474 |
/** |
|
475 |
* @return the color interpretation |
|
476 |
* @throws DynMethodException |
|
477 |
*/ |
|
478 |
public Object getColorInterpretation() throws DynMethodException { |
|
479 |
if(this.colorInterpretation == null){ |
|
480 |
RasterStore delegatedRasterStore = null; |
|
481 |
try { |
|
482 |
delegatedRasterStore = getDelegatedRasterStore(); |
|
483 |
} catch (ValidateDataParametersException | InitializeException | ProviderNotRegisteredException e) { |
|
484 |
logger.warn("Can't get raster store", e); |
|
485 |
} |
|
486 |
if (delegatedRasterStore != null) { |
|
487 |
this.colorInterpretation = |
|
488 |
delegatedRasterStore.invokeDynMethod(RasterStore.DYNMETHOD_GETCOLORINTERPRETATION_NAME, null); |
|
489 |
} |
|
490 |
} |
|
491 |
return this.colorInterpretation; |
|
492 |
} |
|
493 |
|
|
494 |
/** |
|
495 |
* @return the color table |
|
496 |
* @throws ValidateDataParametersException |
|
497 |
* @throws DynMethodException |
|
498 |
* @throws InitializeException |
|
499 |
* @throws ProviderNotRegisteredException |
|
500 |
*/ |
|
501 |
public Object getColorTable() throws DynMethodException { |
|
502 |
if (this.colorTable == null) { |
|
503 |
|
|
504 |
RasterStore delegatedRasterStore = null; |
|
505 |
try { |
|
506 |
delegatedRasterStore = getDelegatedRasterStore(); |
|
507 |
} catch (ValidateDataParametersException | InitializeException | ProviderNotRegisteredException e) { |
|
508 |
logger.warn("Can't get raster store {}.", e); |
|
509 |
} |
|
510 |
if (delegatedRasterStore != null) { |
|
511 |
this.colorTable = delegatedRasterStore.invokeDynMethod(RasterStore.DYNMETHOD_GETCOLORTABLE_NAME, null); |
|
512 |
} |
|
513 |
} |
|
514 |
return this.colorTable; |
|
515 |
} |
|
516 |
|
|
517 |
/** |
|
518 |
* @return the legend |
|
519 |
* @throws ValidateDataParametersException |
|
520 |
* @throws DynMethodException |
|
521 |
* @throws InitializeException |
|
522 |
* @throws ProviderNotRegisteredException |
|
523 |
*/ |
|
524 |
public Object getLegend() throws DynMethodException{ |
|
525 |
if(this.legend == null){ |
|
526 |
RasterStore delegatedRasterStore = null; |
|
527 |
try { |
|
528 |
delegatedRasterStore = getDelegatedRasterStore(); |
|
529 |
} catch (ValidateDataParametersException | InitializeException | ProviderNotRegisteredException e) { |
|
530 |
logger.warn("Can't get raster store {}.", e); |
|
531 |
} |
|
532 |
if (delegatedRasterStore != null) { |
|
533 |
this.legend = delegatedRasterStore.invokeDynMethod(RasterStore.DYNMETHOD_GETLEGEND_NAME, null); |
|
534 |
} |
|
535 |
} |
|
536 |
return this.legend; |
|
537 |
} |
|
538 |
|
|
463 | 539 |
private class Tile { |
464 | 540 |
|
465 | 541 |
org.gvsig.raster.lib.buffer.api.Buffer buffer; |
Also available in: Unified diff