Revision 474 2.1/trunk/org.gvsig.view3d/org.gvsig.view3d.swing/org.gvsig.view3d.swing.impl/src/main/java/org/gvsig/view3d/swing/impl/data/DefaultTiledImageLayer.java
DefaultTiledImageLayer.java | ||
---|---|---|
47 | 47 |
import org.w3c.dom.Element; |
48 | 48 |
|
49 | 49 |
/** |
50 |
* Default implementation of {@link BasicTiledImageLayer}. This class represents |
|
51 |
* a tiled raster layer. Manages creation of tiles, visibility of tiles, levels |
|
52 |
* of details, resolution... |
|
53 |
* |
|
50 | 54 |
* @author <a href="mailto:lmarques@disid.com">Lluis Marques</a> |
51 |
* |
|
52 | 55 |
*/ |
53 | 56 |
public class DefaultTiledImageLayer extends BasicTiledImageLayer { |
54 | 57 |
|
... | ... | |
56 | 59 |
.getLogger(DefaultTiledImageLayer.class); |
57 | 60 |
|
58 | 61 |
/** |
62 |
* Default constructor from parameters. |
|
63 |
* |
|
59 | 64 |
* @param params |
65 |
* parameters of {@link DefaultTiledImageLayer} |
|
60 | 66 |
*/ |
61 | 67 |
public DefaultTiledImageLayer(AVList params) { |
62 | 68 |
|
... | ... | |
66 | 72 |
} |
67 | 73 |
|
68 | 74 |
/** |
75 |
* Default constructor form {@link Element}. Requerided parameters: |
|
76 |
* |
|
77 |
* <ul> |
|
78 |
* <li>AVKey.DATASET_NAME</li> |
|
79 |
* <li>AVKey.DATA_CACHE_NAME</li> |
|
80 |
* <li>DefaultMapControl3D.GVSIG_MAPCONTROL3D</li> |
|
81 |
* <li>DefaultMapControl3D.GVSIG_LAYER</li> |
|
82 |
* </ul> |
|
83 |
* |
|
69 | 84 |
* @param domElement |
85 |
* element that contains parameters values. |
|
70 | 86 |
* @param params |
87 |
* Additional parameters. If there are some parameter not defined |
|
88 |
* at {@link Element}, it is getted from additional parameters. |
|
71 | 89 |
*/ |
72 | 90 |
public DefaultTiledImageLayer(Element domElement, AVList params) { |
73 | 91 |
super(domElement, params); |
... | ... | |
77 | 95 |
} |
78 | 96 |
|
79 | 97 |
private void createRasterServer(AVList params) { |
80 |
|
|
98 |
|
|
81 | 99 |
if (params == null) { |
82 | 100 |
LOG.error("Can not create raster server, parameters is null"); |
83 | 101 |
throw new IllegalArgumentException(); |
... | ... | |
105 | 123 |
} |
106 | 124 |
|
107 | 125 |
MapControl3D mapControl3D = |
108 |
(MapControl3D) params.getValue(DefaultMapControl3D.GVSIG_MAPCONTROL3D); |
|
126 |
(MapControl3D) params |
|
127 |
.getValue(DefaultMapControl3D.GVSIG_MAPCONTROL3D); |
|
109 | 128 |
|
110 | 129 |
if (mapControl3D == null) { |
111 | 130 |
LOG.error( |
... | ... | |
114 | 133 |
throw new IllegalArgumentException(); |
115 | 134 |
} |
116 | 135 |
|
117 |
FLayer layer = (FLayer) params.getValue(DefaultMapControl3D.GVSIG_LAYER); |
|
136 |
FLayer layer = |
|
137 |
(FLayer) params.getValue(DefaultMapControl3D.GVSIG_LAYER); |
|
118 | 138 |
|
119 | 139 |
if (layer == null) { |
120 | 140 |
LOG.error( |
... | ... | |
158 | 178 |
this.setValue(AVKey.RETRIEVER_FACTORY_LOCAL, retrieverFactory); |
159 | 179 |
|
160 | 180 |
} |
161 |
|
|
181 |
|
|
162 | 182 |
protected boolean isTileVisible(DrawContext dc, TextureTile tile) { |
163 |
|
|
164 |
if(tile.getSector().isWithinLatLonLimits()){
|
|
183 |
|
|
184 |
if (tile.getSector().isWithinLatLonLimits()) {
|
|
165 | 185 |
return tile.getExtent(dc).intersects( |
166 | 186 |
dc.getView().getFrustumInModelCoordinates()) |
167 | 187 |
&& (dc.getVisibleSector() == null || dc.getVisibleSector() |
168 |
.intersects(tile.getSector())); |
|
188 |
.intersects(tile.getSector()));
|
|
169 | 189 |
} else { |
170 |
|
|
190 |
|
|
171 | 191 |
// Try to fix extend. This is necessary to avoid problems getting if |
172 | 192 |
// some tile is visible or not when the tile has corrupt sector like |
173 | 193 |
// 180.0000001 or -90.000000004561 |
... | ... | |
180 | 200 |
} |
181 | 201 |
|
182 | 202 |
private Extent fixExtend(TextureTile tile, DrawContext dc) { |
183 |
|
|
203 |
|
|
184 | 204 |
if (dc == null) { |
185 | 205 |
String msg = Logging.getMessage("nullValue.DrawContextIsNull"); |
186 | 206 |
Logging.logger().severe(msg); |
187 | 207 |
throw new IllegalArgumentException(msg); |
188 | 208 |
} |
189 |
|
|
190 |
if ( tile.getSector().isWithinLatLonLimits()){
|
|
209 |
|
|
210 |
if (tile.getSector().isWithinLatLonLimits()) {
|
|
191 | 211 |
return Sector.computeBoundingBox(dc.getGlobe(), |
192 | 212 |
dc.getVerticalExaggeration(), tile.getSector()); |
193 | 213 |
} else { |
194 |
|
|
214 |
|
|
195 | 215 |
double[] degreesArray = tile.getSector().asDegreesArray(); |
196 |
|
|
216 |
|
|
197 | 217 |
double minLatitude = |
198 | 218 |
degreesArray[0] < Angle.NEG90.degrees ? Angle.NEG90.degrees |
199 | 219 |
: degreesArray[0]; |
... | ... | |
206 | 226 |
double maxLongitude = |
207 | 227 |
degreesArray[3] > Angle.POS180.degrees ? Angle.POS180.degrees |
208 | 228 |
: degreesArray[3]; |
209 |
|
|
229 |
|
|
210 | 230 |
Sector adjustedSector = |
211 | 231 |
new Sector(Angle.fromDegrees(minLatitude), |
212 | 232 |
Angle.fromDegrees(maxLatitude), |
213 | 233 |
Angle.fromDegrees(minLongitude), |
214 | 234 |
Angle.fromDegrees(maxLongitude)); |
215 |
|
|
235 |
|
|
216 | 236 |
return Sector.computeBoundingBox(dc.getGlobe(), |
217 | 237 |
dc.getVerticalExaggeration(), adjustedSector); |
218 | 238 |
} |
Also available in: Unified diff