Revision 487 2.1/trunk/org.gvsig.view3d/org.gvsig.view3d.swing/org.gvsig.view3d.swing.impl/src/main/java/org/gvsig/view3d/swing/impl/data/DefaultLayerConverter.java
DefaultLayerConverter.java | ||
---|---|---|
47 | 47 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
48 | 48 |
import org.gvsig.fmap.mapcontext.layers.operations.SingleLayer; |
49 | 49 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
50 |
import org.gvsig.view3d.lib.api.View3DLocator; |
|
51 |
import org.gvsig.view3d.lib.api.View3DManager; |
|
52 |
import org.gvsig.view3d.lib.api.properties.LayerProperties3D; |
|
50 | 53 |
import org.gvsig.view3d.swing.api.MapControl3D; |
51 | 54 |
import org.gvsig.view3d.swing.impl.DefaultMapControl3D; |
52 | 55 |
import org.slf4j.Logger; |
... | ... | |
62 | 65 |
|
63 | 66 |
private static final Logger LOG = LoggerFactory |
64 | 67 |
.getLogger(DefaultLayerConverter.class); |
68 |
|
|
69 |
private final int DEFAULT_RASTERIZED_LEVEL_ZERO = 20; |
|
70 |
private final int DEFAULT_TILE_WIDTH = 512; |
|
71 |
private final int DEFAULT_TILE_HEIGHT = 512; |
|
65 | 72 |
|
66 | 73 |
public Layer convertToLayer(MapControl3D mapControl, FLayer layer) |
67 | 74 |
throws DataException { |
... | ... | |
163 | 170 |
|
164 | 171 |
private void createRasterTiledImageLayerParams(FLayer layer, AVList params) { |
165 | 172 |
|
166 |
// TODO Get 3D propeties of layer with View3DManager.getProperties3D(layer) |
|
167 |
// and fill parameters with properties |
|
168 |
|
|
169 | 173 |
if (params == null) { |
170 | 174 |
params = new AVListImpl(); |
171 | 175 |
} |
... | ... | |
190 | 194 |
params.setValue(AVKey.SECTOR, sector); |
191 | 195 |
|
192 | 196 |
// Set resolution of layer |
193 |
// TODO Make configurable by user |
|
194 | 197 |
params.setValue(AVKey.WIDTH, Integer.MAX_VALUE); |
195 | 198 |
params.setValue(AVKey.HEIGHT,Integer.MAX_VALUE); |
196 | 199 |
|
... | ... | |
202 | 205 |
.getValue(AVKey.IMAGE_FORMAT).toString() }); |
203 | 206 |
params.setValue(AVKey.TILE_ORIGIN, new LatLon(sector.getMinLatitude(), |
204 | 207 |
sector.getMinLongitude())); |
205 |
params.setValue(AVKey.TILE_WIDTH, 512); |
|
206 |
params.setValue(AVKey.TILE_HEIGHT, 512); |
|
207 |
|
|
208 |
LatLon rasterTileDelta = this.computeRasterTileDelta(params); |
|
209 |
LatLon desiredLevelZeroDelta = this.computeDesiredTileDelta(sector); |
|
210 |
int numLevels = computeNumLevels(desiredLevelZeroDelta, rasterTileDelta); |
|
211 |
|
|
208 |
|
|
209 |
View3DManager manager = View3DLocator.getManager(); |
|
210 |
LayerProperties3D layerProperties = manager.getLayerProperties(layer); |
|
211 |
|
|
212 |
// If tile sizes are 0, set defautlt values |
|
213 |
params.setValue(AVKey.TILE_WIDTH, layerProperties.getTileWidth() == 0 |
|
214 |
? DEFAULT_TILE_WIDTH : layerProperties.getTileWidth()); |
|
215 |
params.setValue(AVKey.TILE_HEIGHT, layerProperties.getTileHeight() == 0 |
|
216 |
? DEFAULT_TILE_HEIGHT : layerProperties.getTileHeight()); |
|
217 |
|
|
218 |
int numLevels; |
|
219 |
// If deatail levels are 0, compute best level of detail number |
|
220 |
if(layerProperties.getMinLevel() == 0 && layerProperties.getMaxLevel() == 0){ |
|
221 |
|
|
222 |
LatLon rasterTileDelta = this.computeRasterTileDelta(params); |
|
223 |
LatLon desiredLevelZeroDelta = this.computeDesiredTileDelta(sector); |
|
224 |
numLevels = computeNumLevels(desiredLevelZeroDelta, rasterTileDelta); |
|
225 |
|
|
226 |
} else { |
|
227 |
numLevels = |
|
228 |
layerProperties.getMaxLevel() - layerProperties.getMinLevel(); |
|
229 |
params.setValue(AVKey.NUM_EMPTY_LEVELS, |
|
230 |
layerProperties.getMinLevel()); |
|
231 |
|
|
232 |
} |
|
212 | 233 |
params.setValue(AVKey.NUM_LEVELS, numLevels); |
213 | 234 |
|
214 | 235 |
if(layer instanceof FLyrVect){ |
215 | 236 |
|
216 |
// Only rasterized vectorial layers TODO Make configurable |
|
217 |
params.setValue(AVKey.LEVEL_ZERO_TILE_DELTA, new |
|
218 |
LatLon(Angle.fromDegrees(20), Angle.fromDegrees(20))); |
|
237 |
// Only rasterized vectorial layers |
|
238 |
double degrees = |
|
239 |
DEFAULT_RASTERIZED_LEVEL_ZERO |
|
240 |
* layerProperties.getLevelZeroResolutionMultiplier(); |
|
241 |
params.setValue( |
|
242 |
AVKey.LEVEL_ZERO_TILE_DELTA, |
|
243 |
new LatLon(Angle.fromDegrees(degrees), Angle |
|
244 |
.fromDegrees(degrees))); |
|
219 | 245 |
|
220 | 246 |
} else { |
221 | 247 |
|
248 |
LatLon rasterTileDelta = this.computeRasterTileDelta(params); |
|
222 | 249 |
double scale = Math.pow(2d, numLevels - 1); |
223 |
LatLon levelZeroTileDelta = LatLon.fromDegrees( |
|
224 |
scale * rasterTileDelta.getLatitude().degrees, |
|
225 |
scale * rasterTileDelta.getLongitude().degrees); |
|
250 |
LatLon levelZeroTileDelta = |
|
251 |
LatLon.fromDegrees( |
|
252 |
scale * layerProperties.getLevelZeroResolutionMultiplier() |
|
253 |
* rasterTileDelta.getLatitude().degrees, scale |
|
254 |
* layerProperties.getLevelZeroResolutionMultiplier() |
|
255 |
* rasterTileDelta.getLongitude().degrees); |
|
226 | 256 |
params.setValue(AVKey.LEVEL_ZERO_TILE_DELTA, levelZeroTileDelta); |
227 | 257 |
} |
228 |
|
|
258 |
|
|
259 |
params.setValue(AVKey.NUM_LEVELS, numLevels); |
|
229 | 260 |
params.setValue(AVKey.NETWORK_RETRIEVAL_ENABLED, false); |
230 | 261 |
params.setValue(AVKey.USE_MIP_MAPS, true); |
231 | 262 |
params.setValue(AVKey.USE_TRANSPARENT_TEXTURES, true); |
232 |
|
|
233 | 263 |
} |
234 | 264 |
|
235 | 265 |
private Sector getSector(FLayer layer, IProjection projection) |
Also available in: Unified diff