Index: src/org/gvsig/gvsig3d/cacheservices/FLayerCacheService.java
===================================================================
--- src/org/gvsig/gvsig3d/cacheservices/FLayerCacheService.java	(revision 349)
+++ src/org/gvsig/gvsig3d/cacheservices/FLayerCacheService.java	(working copy)
@@ -32,6 +32,7 @@
 import org.gvsig.raster.dataset.InvalidSetViewException;
 import org.gvsig.raster.dataset.NotSupportedExtensionException;
 import org.gvsig.raster.dataset.Params;
+import org.gvsig.raster.dataset.Params.Param;
 import org.gvsig.raster.dataset.io.RasterDriverException;
 import org.gvsig.remoteClient.utils.Utilities;
 import org.gvsig.remoteClient.wcs.WCSStatus;
@@ -41,6 +42,7 @@
 import com.hardcode.gdbms.driver.exceptions.ReadDriverException;
 import com.iver.ai2.gvsig3d.map3d.layers.Layer3DProps;
 import com.iver.cit.gvsig.exceptions.expansionfile.ExpansionFileReadException;
+import com.iver.cit.gvsig.exceptions.layers.LoadLayerException;
 import com.iver.cit.gvsig.fmap.ViewPort;
 import com.iver.cit.gvsig.fmap.drivers.wcs.FMapWCSDriver;
 import com.iver.cit.gvsig.fmap.drivers.wcs.FMapWCSDriverFactory;
@@ -293,10 +295,12 @@
 						_downloadMonitor.monitorThis(cancelDownload, System.currentTimeMillis());
 						File f = _wmsDriver.getMap(_wmsStatus, cancelDownload);
 						_downloadMonitor.endMonitor();
+						
 						if (f == null)
 							return;
 						synchronized (cacheMutex) {
 							FileUtils.copy(f, new File(fName));
+							
 						}
 
 					} catch (Exception e) {
@@ -480,6 +484,16 @@
 
 						FLyrRasterSE rasterLayer = (FLyrRasterSE) _layer;
 						BufferFactory bufferFactory = rasterLayer.getBufferFactory();
+						try {
+							if (bufferFactory == null) {
+								rasterLayer.init();
+								bufferFactory = rasterLayer.getBufferFactory();
+							}
+						} catch (LoadLayerException e1) {
+							// TODO Auto-generated catch block
+							e1.printStackTrace();
+						}
+						
 
 						//int bands[] = { 0 };
 						bufferFactory.setAllDrawableBands();
@@ -510,33 +524,41 @@
 						raster.setNoDataValue(0.0);
 						raster.setNotValidValue(0.0);
 						try {
-							WriterBufferServer bufferServer = new WriterBufferServer(
-									raster);
-							Params p = GeoRasterWriter.getWriter(fName).getParams();
-							AffineTransform at = new AffineTransform(tileExtent
-									.getWidth() / 32, 0, 0,
-									-(tileExtent.getHeight() / 32), tileExtent
-									.getMinX(), tileExtent.getMaxY());
-							GeoRasterWriter grw = GeoRasterWriter.getWriter(
-									bufferServer, fName, 1, at, raster.getWidth(),
-									raster.getHeight(), raster.getDataType(), p, null);
 							synchronized (cacheMutex) {
 								try {
+									WriterBufferServer bufferServer = new WriterBufferServer(
+											raster);
+									Params p = GeoRasterWriter.getWriter(fName).getParams();
+//									if (raster.getBandCount() == 1) {
+//										Param phot = (Param) p.getParamById("photometric");
+//										if (phot != null)
+//											phot.defaultValue = new Integer(1);
+//									}
+									AffineTransform at = new AffineTransform(tileExtent
+											.getWidth() / 32, 0, 0,
+											-(tileExtent.getHeight() / 32), tileExtent
+											.getMinX(), tileExtent.getMaxY());
+									
+									GeoRasterWriter grw = GeoRasterWriter.getWriter(
+											bufferServer, fName, 1, at, raster.getWidth(),
+											raster.getHeight(), raster.getDataType(), p, null);
+									
 									grw.dataWrite();
+									grw.writeClose();
 								} catch (InterruptedException e) {
 									e.printStackTrace();
 								}
-								grw.writeClose();
+								
 							}
 
 						} catch (NotSupportedExtensionException e) {
-							// e.printStackTrace();
+							e.printStackTrace();
 							return;
 						} catch (RasterDriverException e) {
-							// e.printStackTrace();
+							e.printStackTrace();
 							return;
 						} catch (IOException e) {
-							// e.printStackTrace();
+							e.printStackTrace();
 							return;
 						}
 
Index: src/org/gvsig/gvsig3d/map3d/MapContext3D.java
===================================================================
--- src/org/gvsig/gvsig3d/map3d/MapContext3D.java	(revision 349)
+++ src/org/gvsig/gvsig3d/map3d/MapContext3D.java	(working copy)
@@ -543,7 +543,7 @@
 			IWindow f = PluginServices.getMDIManager().getActiveWindow();
 			if (f instanceof BaseView) {
 				BaseView view3D = (BaseView) f;
-				view3D.getTOC().refresh();
+				view3D.getTOC().getComponent().invalidate();
 			}
 		}
 		visibilityChange = false;
