Revision 35 1.10/trunk/libraries/lib3DMap/src/org/gvsig/gvsig3d/map3d/MapContext3D.java
MapContext3D.java | ||
---|---|---|
10 | 10 |
import java.awt.image.RenderedImage; |
11 | 11 |
import java.io.File; |
12 | 12 |
import java.io.IOException; |
13 |
import java.net.ConnectException; |
|
14 |
import java.net.URL; |
|
15 |
import java.util.HashMap; |
|
16 | 13 |
import java.util.Hashtable; |
17 | 14 |
import java.util.Vector; |
18 | 15 |
|
... | ... | |
20 | 17 |
|
21 | 18 |
import org.apache.log4j.Logger; |
22 | 19 |
import org.cresques.cts.IProjection; |
23 |
import org.gvsig.cacheservice.CacheServiceException; |
|
24 | 20 |
import org.gvsig.cacheservice.TileNum; |
25 | 21 |
import org.gvsig.gvsig3d.cacheservices.FLayerCacheService; |
26 | 22 |
import org.gvsig.gvsig3d.cacheservices.OSGCacheService; |
... | ... | |
52 | 48 |
import org.gvsig.osgvp.viewer.Camera; |
53 | 49 |
import org.gvsig.osgvp.viewer.IViewerContainer; |
54 | 50 |
import org.gvsig.osgvp.viewer.PrintUtilities; |
55 |
import org.gvsig.remoteClient.utils.Utilities; |
|
56 |
import org.gvsig.remoteClient.wms.ICancellable; |
|
57 |
import org.gvsig.remoteClient.wms.WMSLayer; |
|
58 |
import org.gvsig.remoteClient.wms.WMSStatus; |
|
59 | 51 |
|
60 | 52 |
import com.hardcode.driverManager.Driver; |
61 | 53 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
... | ... | |
64 | 56 |
import com.iver.andami.messages.NotificationManager; |
65 | 57 |
import com.iver.andami.ui.mdiManager.IWindow; |
66 | 58 |
import com.iver.cit.gvsig.exceptions.expansionfile.ExpansionFileReadException; |
67 |
import com.iver.cit.gvsig.exceptions.layers.LoadLayerException; |
|
68 | 59 |
import com.iver.cit.gvsig.fmap.MapContext; |
69 | 60 |
import com.iver.cit.gvsig.fmap.ViewPort; |
70 |
import com.iver.cit.gvsig.fmap.WMSDriverExceptionType; |
|
71 |
import com.iver.cit.gvsig.fmap.drivers.wms.FMapWMSDriver; |
|
72 |
import com.iver.cit.gvsig.fmap.drivers.wms.FMapWMSDriverFactory; |
|
73 |
import com.iver.cit.gvsig.fmap.drivers.wms.WMSException; |
|
74 | 61 |
import com.iver.cit.gvsig.fmap.layers.FBitSet; |
75 | 62 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
76 | 63 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
77 | 64 |
import com.iver.cit.gvsig.fmap.layers.FLyrDefault; |
78 | 65 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
79 | 66 |
import com.iver.cit.gvsig.fmap.layers.FLyrWCS; |
80 |
import com.iver.cit.gvsig.fmap.layers.FLyrWMS; |
|
81 | 67 |
import com.iver.cit.gvsig.fmap.layers.GraphicLayer; |
82 | 68 |
import com.iver.cit.gvsig.fmap.layers.LayerEvent; |
83 | 69 |
import com.iver.cit.gvsig.fmap.layers.LayerListener; |
... | ... | |
91 | 77 |
import com.iver.cit.gvsig.fmap.layers.layerOperations.Classifiable; |
92 | 78 |
import com.iver.cit.gvsig.fmap.rendering.LegendListener; |
93 | 79 |
import com.iver.cit.gvsig.project.documents.view.gui.BaseView; |
94 |
import com.iver.utiles.FileUtils; |
|
95 | 80 |
import com.iver.utiles.XMLEntity; |
96 | 81 |
import com.iver.utiles.swing.threads.Cancellable; |
97 | 82 |
|
... | ... | |
634 | 619 |
|
635 | 620 |
// clear cache |
636 | 621 |
|
637 |
if (bRemoveCache) { |
|
638 |
|
|
639 |
String layerCacheDir = Layer3DProps.m_cacheDir + File.separator |
|
640 |
+ _terrain.getTerrainName() + File.separator + props.getCacheName(); |
|
641 |
|
|
642 |
FLayerCacheService cacheServices = (FLayerCacheService) props.getCacheService(); |
|
643 |
if(cacheServices != null) |
|
644 |
{ |
|
645 |
try { |
|
646 |
cacheServices.free(); |
|
647 |
props.setCacheService(null); |
|
648 |
} catch (Throwable e) { |
|
649 |
// TODO Auto-generated catch block |
|
650 |
e.printStackTrace(); |
|
651 |
} |
|
652 |
} |
|
653 | 622 |
|
654 |
removeCache(new File(layerCacheDir)); |
|
655 |
} |
|
656 | 623 |
|
657 | 624 |
// refresh layer in terrain |
658 | 625 |
int type = props.getType(); |
659 | 626 |
if ((type == Layer3DProps.layer3DImage) |
660 | 627 |
|| (type == Layer3DProps.layer3DElevation) |
661 | 628 |
|| (type == Layer3DProps.layer3DVectorMR)) { |
629 |
|
|
630 |
if (bRemoveCache) { |
|
631 |
|
|
632 |
String layerCacheDir = Layer3DProps.m_cacheDir + File.separator |
|
633 |
+ _terrain.getTerrainName() + File.separator + props.getCacheName(); |
|
634 |
|
|
635 |
FLayerCacheService cacheServices = (FLayerCacheService) props.getCacheService(); |
|
636 |
if(cacheServices != null) |
|
637 |
{ |
|
638 |
try { |
|
639 |
cacheServices.free(); |
|
640 |
props.setCacheService(null); |
|
641 |
} catch (Throwable e) { |
|
642 |
// TODO Auto-generated catch block |
|
643 |
e.printStackTrace(); |
|
644 |
} |
|
645 |
} |
|
646 |
|
|
647 |
removeCache(new File(layerCacheDir)); |
|
648 |
} |
|
662 | 649 |
try { |
663 | 650 |
_terrainLayerManager.invalidateLayer(props.getTerrainLayer()); |
664 | 651 |
} catch (LayerManagementException e) { |
... | ... | |
684 | 671 |
} |
685 | 672 |
|
686 | 673 |
private boolean removeCache(File path) { |
687 |
if( path.exists() ) {
|
|
688 |
File[] files = path.listFiles();
|
|
689 |
for(int i=0; i<files.length; i++) {
|
|
690 |
if(files[i].isDirectory()) {
|
|
691 |
removeCache(files[i]);
|
|
692 |
}
|
|
693 |
else {
|
|
694 |
files[i].delete();
|
|
695 |
}
|
|
696 |
}
|
|
697 |
}
|
|
698 |
return( path.delete() );
|
|
674 |
if( path.exists() ) {
|
|
675 |
File[] files = path.listFiles();
|
|
676 |
for(int i=0; i<files.length; i++) {
|
|
677 |
if(files[i].isDirectory()) {
|
|
678 |
removeCache(files[i]);
|
|
679 |
}
|
|
680 |
else {
|
|
681 |
files[i].delete();
|
|
682 |
}
|
|
683 |
}
|
|
684 |
}
|
|
685 |
return( path.delete() );
|
|
699 | 686 |
} |
700 | 687 |
|
701 | 688 |
protected Layer3DProps getLayer3DProps(FLayer layer) { |
... | ... | |
1199 | 1186 |
|
1200 | 1187 |
} |
1201 | 1188 |
|
1202 |
protected class MyCancel implements Cancellable, ICancellable { |
|
1203 | 1189 |
|
1204 |
public boolean isCanceled() { |
|
1205 |
return false; |
|
1206 |
} |
|
1207 | 1190 |
|
1208 |
public void setCanceled(boolean canceled) { |
|
1209 |
|
|
1210 |
} |
|
1211 |
|
|
1212 |
/* if you don�t put and ID the wms donwload will be fail */ |
|
1213 |
public Object getID() { |
|
1214 |
return this; |
|
1215 |
} |
|
1216 |
|
|
1217 |
} |
|
1218 |
|
|
1219 | 1191 |
public UpdateDataEvent loadData(RequestDataEvent rde) { |
1220 | 1192 |
|
1221 | 1193 |
if (_terrainLayerMap.size() == 0) |
... | ... | |
1243 | 1215 |
Layer3DProps props3D = getLayer3DProps(layer); |
1244 | 1216 |
|
1245 | 1217 |
// get/create cache service |
1246 |
boolean existsCacheService = true; |
|
1247 | 1218 |
FLayerCacheService cacheService = (FLayerCacheService) props3D |
1248 | 1219 |
.getCacheService(); |
1249 | 1220 |
if (cacheService == null) { |
1250 |
existsCacheService = false; |
|
1221 |
|
|
1251 | 1222 |
cacheService = new FLayerCacheService(_terrain, props3D |
1252 | 1223 |
.getCacheName(), layer, _viewProjection); |
1253 | 1224 |
cacheService.setCacheRootDir(Layer3DProps.m_cacheDir); |
... | ... | |
1311 | 1282 |
} |
1312 | 1283 |
} |
1313 | 1284 |
|
1314 |
// if(layer instanceof FLyrWMS && existsCacheService) { |
|
1315 |
// try { |
|
1316 |
// FLyrWMS wmsLayer = (FLyrWMS) layer; |
|
1317 |
// String name = cacheService.getTileAsFName(tileNum, extent); |
|
1318 |
// |
|
1319 |
// if(name != null){ |
|
1320 |
// |
|
1321 |
// File f = new File(name); |
|
1322 |
// wmsLayer.setName(f.getName()); |
|
1323 |
// wmsLayer.setLoadParams(f); |
|
1324 |
// wmsLayer.load(); |
|
1325 |
// } |
|
1326 |
// |
|
1327 |
// } catch (LoadLayerException e) { |
|
1328 |
// // TODO Auto-generated catch block |
|
1329 |
// e.printStackTrace(); |
|
1330 |
// } catch (CacheServiceException e) { |
|
1331 |
// // TODO Auto-generated catch block |
|
1332 |
// e.printStackTrace(); |
|
1333 |
// } |
|
1334 |
// |
|
1335 |
// |
|
1336 |
// } |
|
1337 |
|
|
1338 | 1285 |
return ude; |
1339 | 1286 |
} |
1340 | 1287 |
} |
Also available in: Unified diff