Revision 457 2.1/trunk/org.gvsig.view3d/org.gvsig.view3d.swing/org.gvsig.view3d.swing.impl/src/main/java/org/gvsig/view3d/swing/impl/data/RasterTiledImageLayer.java
RasterTiledImageLayer.java | ||
---|---|---|
24 | 24 |
|
25 | 25 |
package org.gvsig.view3d.swing.impl.data; |
26 | 26 |
|
27 |
import gov.nasa.worldwind.avlist.AVKey; |
|
27 | 28 |
import gov.nasa.worldwind.avlist.AVList; |
29 |
import gov.nasa.worldwind.data.RasterServer; |
|
28 | 30 |
import gov.nasa.worldwind.layers.BasicTiledImageLayer; |
31 |
import gov.nasa.worldwind.retrieve.RetrievalPostProcessor; |
|
32 |
import gov.nasa.worldwind.retrieve.Retriever; |
|
33 |
import gov.nasa.worldwind.retrieve.RetrieverFactory; |
|
34 |
import gov.nasa.worldwind.util.WWUtil; |
|
29 | 35 |
|
36 |
import org.slf4j.Logger; |
|
37 |
import org.slf4j.LoggerFactory; |
|
30 | 38 |
import org.w3c.dom.Element; |
31 | 39 |
|
40 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
41 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
42 |
import org.gvsig.view3d.swing.impl.DefaultMapControl3D; |
|
43 |
|
|
32 | 44 |
/** |
33 | 45 |
* @author <a href="mailto:lmarques@disid.com">Lluis Marques</a> |
34 | 46 |
* |
35 | 47 |
*/ |
36 | 48 |
public class RasterTiledImageLayer extends BasicTiledImageLayer { |
37 | 49 |
|
50 |
private static final Logger LOG = LoggerFactory |
|
51 |
.getLogger(RasterTiledImageLayer.class); |
|
52 |
|
|
38 | 53 |
/** |
39 | 54 |
* @param params |
40 | 55 |
*/ |
41 | 56 |
public RasterTiledImageLayer(AVList params) { |
42 | 57 |
|
43 | 58 |
super(params); |
59 |
|
|
60 |
this.createRasterServer(params); |
|
44 | 61 |
} |
45 | 62 |
|
46 | 63 |
/** |
... | ... | |
49 | 66 |
*/ |
50 | 67 |
public RasterTiledImageLayer(Element domElement, AVList params) { |
51 | 68 |
super(domElement, params); |
69 |
|
|
70 |
this.createRasterServer(params != null ? params : (AVList) this |
|
71 |
.getValue(AVKey.CONSTRUCTION_PARAMETERS)); |
|
52 | 72 |
} |
53 | 73 |
|
74 |
private void createRasterServer(AVList params) { |
|
75 |
|
|
76 |
if (params == null) { |
|
77 |
LOG.error("Can not create raster server, parameters is null"); |
|
78 |
throw new IllegalArgumentException(); |
|
79 |
} |
|
80 |
|
|
81 |
if (this.getDataFileStore() == null) { |
|
82 |
LOG.error("Can not create raster server, file store is null"); |
|
83 |
throw new IllegalArgumentException(); |
|
84 |
} |
|
85 |
|
|
86 |
String datasetName = params.getStringValue(AVKey.DATASET_NAME); |
|
87 |
if (WWUtil.isEmpty(datasetName)) { |
|
88 |
LOG.error( |
|
89 |
"Can not create raster server, missing required parameter: {}", |
|
90 |
AVKey.DATASET_NAME); |
|
91 |
throw new IllegalArgumentException(); |
|
92 |
} |
|
93 |
|
|
94 |
String dataCacheName = params.getStringValue(AVKey.DATA_CACHE_NAME); |
|
95 |
if (WWUtil.isEmpty(dataCacheName)) { |
|
96 |
LOG.error( |
|
97 |
"Can not create raster server, missing required parameter: {}", |
|
98 |
AVKey.DATA_CACHE_NAME); |
|
99 |
throw new IllegalArgumentException(); |
|
100 |
} |
|
101 |
|
|
102 |
MapContext mapContext = |
|
103 |
(MapContext) params.getValue(DefaultMapControl3D.GVSIG_MAPCONTEXT); |
|
104 |
|
|
105 |
if (mapContext == null) { |
|
106 |
LOG.error( |
|
107 |
"Can not create raster server, missing required parameter: {}", |
|
108 |
DefaultMapControl3D.GVSIG_MAPCONTEXT); |
|
109 |
throw new IllegalArgumentException(); |
|
110 |
} |
|
111 |
|
|
112 |
FLayer layer = (FLayer) params.getValue(DefaultMapControl3D.GVSIG_LAYER); |
|
113 |
|
|
114 |
if (layer == null) { |
|
115 |
LOG.error( |
|
116 |
"Can not create raster server, missing required parameter: {}", |
|
117 |
"GVSIG_LAYER"); |
|
118 |
throw new IllegalArgumentException(); |
|
119 |
} |
|
120 |
|
|
121 |
final AVList rasterServerParams = params.copy(); |
|
122 |
|
|
123 |
rasterServerParams.setValue(AVKey.FILE_STORE, this.getDataFileStore()); |
|
124 |
|
|
125 |
RetrieverFactory retrieverFactory = new RetrieverFactory() { |
|
126 |
|
|
127 |
final protected RasterServer rasterServer = |
|
128 |
new DefaultRasterServer(rasterServerParams); |
|
129 |
|
|
130 |
public Retriever createRetriever(AVList tileParams, |
|
131 |
RetrievalPostProcessor postProcessor) { |
|
132 |
|
|
133 |
DefaultRasterServerRetriever retriever = |
|
134 |
new DefaultRasterServerRetriever(tileParams, |
|
135 |
this.rasterServer, postProcessor); |
|
136 |
|
|
137 |
// copy only values that do not exist in destination AVList |
|
138 |
// from rasterServerParams (source) to retriever (destination) |
|
139 |
|
|
140 |
String[] keysToCopy = |
|
141 |
new String[] { AVKey.DATASET_NAME, AVKey.DISPLAY_NAME, |
|
142 |
AVKey.FILE_STORE, AVKey.IMAGE_FORMAT, |
|
143 |
AVKey.FORMAT_SUFFIX }; |
|
144 |
|
|
145 |
WWUtil.copyValues(rasterServerParams, retriever, keysToCopy, |
|
146 |
false); |
|
147 |
|
|
148 |
return retriever; |
|
149 |
} |
|
150 |
}; |
|
151 |
|
|
152 |
params.setValue(AVKey.RETRIEVER_FACTORY_LOCAL, retrieverFactory); |
|
153 |
this.setValue(AVKey.RETRIEVER_FACTORY_LOCAL, retrieverFactory); |
|
154 |
|
|
155 |
} |
|
54 | 156 |
} |
Also available in: Unified diff