Revision 4180

View differences:

org.gvsig.raster.wcs/trunk/org.gvsig.raster.wcs/org.gvsig.raster.wcs.io/src/main/java/org/gvsig/raster/wcs/io/WCSServerExplorer.java
31 31
import java.io.IOException;
32 32
import java.io.InputStream;
33 33
import java.net.MalformedURLException;
34
import java.net.URI;
35
import java.net.URISyntaxException;
34 36
import java.net.URL;
35 37
import java.net.URLConnection;
36 38
import java.util.Hashtable;
37 39
import java.util.List;
38 40

  
41
import org.slf4j.Logger;
42
import org.slf4j.LoggerFactory;
43

  
39 44
import org.gvsig.compat.net.ICancellable;
40 45
import org.gvsig.fmap.dal.DALLocator;
41 46
import org.gvsig.fmap.dal.DataManager;
......
59 64
public class WCSServerExplorer implements RasterDataServerExplorer, DataServerExplorerProvider {
60 65
	private WCSConnector                connector                = null;
61 66
	private WCSServerExplorerParameters parameters               = null;
62
	
67
	private static final Logger         logger                    = LoggerFactory.getLogger(WCSServerExplorer.class);
68

  
69

  
63 70
	public WCSServerExplorer(
64 71
			WCSServerExplorerParameters parameters,
65 72
			DataServerExplorerProviderServices services)
66 73
			throws InitializeException {
67 74
		this.parameters = parameters;
68 75
	}
69
	
76

  
70 77
	/**
71 78
	 * Gets the provider's name
72 79
	 * @return
......
74 81
	public String getDataStoreProviderName() {
75 82
		return WCSProvider.NAME;
76 83
	}
77
	
84

  
78 85
	public String getDescription() {
79 86
		return WCSProvider.DESCRIPTION;
80 87
	}
81
	
88

  
82 89
	public boolean add(String provider, NewDataStoreParameters parameters,
83 90
			boolean overwrite) throws DataException {
84 91
		return false;
......
114 121
	}
115 122

  
116 123
	public void remove(DataStoreParameters parameters) throws DataException {
117
		
124

  
118 125
	}
119 126

  
120 127
	public void dispose() {
121
		
128

  
122 129
	}
123 130

  
124 131
	public String getProviderName() {
125 132
		return null;
126 133
	}
127
	
134

  
128 135
	/**
129 136
	 * Gets the online resources
130 137
	 * @return
131 138
	 */
132 139
	public Hashtable getOnlineResources() {
133
		/*if(connector != null) {
134
			return connector.getOnlineResources();
135
		}*/
136 140
		return null;
137 141
	}
138
	
142

  
139 143
	//**********************************************
140 144
	//Connector
141 145
	//**********************************************
142
	
146

  
143 147
	public DataStoreParameters getStoredParameters() {
144 148
		DataManager manager = DALLocator.getDataManager();
145 149
		WCSDataParametersImpl params = null;
146 150
		try {
147 151
			params = (WCSDataParametersImpl) manager.createStoreParameters(this.getDataStoreProviderName());
148 152

  
149
			/*if(WCSProvider.TILED) {
150
				TileDataParameters tileParams = (TileDataParameters) manager.createStoreParameters("Tile Store");
151
				tileParams.setDataParameters(params);
152
				return tileParams;
153
			} */
154
			
155 153
		} catch (InitializeException e) {
156
			e.printStackTrace();
154
            logger.warn("Can't get DataStoreParameters from WCSServerExplorer", e);
157 155
		} catch (ProviderNotRegisteredException e) {
158
			e.printStackTrace();
156
            logger.warn("Can't get DataStoreParameters from WCSServerExplorer", e);
159 157
		}
160
		params.setURI(parameters.getHost());
158
		String host = parameters.getHost();
159
		URI hostURI;
160
        try {
161
            hostURI = new URI(host);
162
            params.setURI(hostURI);
163
        } catch (URISyntaxException e) {
164
            logger.warn("Can't create URI from"+host, e);
165
        }
161 166
		return params;
162 167
	}
163 168

  
164 169
	/**
165
	 * Connects to the server and throws a getCapabilities. This loads 
170
	 * Connects to the server and throws a getCapabilities. This loads
166 171
	 * the basic information to make requests.
167
	 * @throws RemoteServiceException 
172
	 * @throws RemoteServiceException
168 173
	 */
169 174
	public void connect(ICancellable cancellable) throws ConnectException {
170 175
		URL url = null;
171 176
		boolean override = false;
172
		
177

  
173 178
		try {
174 179
			url = new URL(parameters.getHost());
175 180
		} catch (Exception e) {
......
182 187
        } catch (IOException e) {
183 188
			throw new ConnectException(Messages.getText("error_connecting"), e);
184 189
		}
185
		
190

  
186 191
	}
187
	
192

  
188 193
	/**
189 194
	 * Checks if the network and host are reachable
190 195
	 * @param timeout for the host
......
206 211
		} catch (IOException e) {
207 212
			return false;
208 213
		}
209
		
214

  
210 215
		return true;
211 216
	}
212 217

  
......
244 249
	 * @return
245 250
	 */
246 251
	public String getServerType() {
247
		if (getVersion() == null) 
252
		if (getVersion() == null)
248 253
			return "WCS";
249 254
        return "WCS "+ getVersion();
250 255
	}
......
267 272
	public String getHost() {
268 273
		return parameters.getHost();
269 274
	}
270
	
275

  
271 276
	/**
272 277
	 * Gets the title
273 278
	 * @return
......
291 296
	public WCSLayerNode[] getCoverageList() {
292 297
		return connector.getLayerList();
293 298
	}
294
	
299

  
295 300
	/**
296
	 * Gets a layer searching by its name 
301
	 * Gets a layer searching by its name
297 302
	 * @return
298 303
	 */
299 304
	public WCSLayerNode getCoverageByName(String name) {
org.gvsig.raster.wcs/trunk/org.gvsig.raster.wcs/org.gvsig.raster.wcs.io/src/main/java/org/gvsig/raster/wcs/io/WCSProvider.java
7 7
import java.awt.geom.Rectangle2D;
8 8
import java.io.File;
9 9
import java.io.IOException;
10
import java.net.URI;
11
import java.net.URISyntaxException;
10 12
import java.net.URL;
11 13
import java.util.ArrayList;
12 14
import java.util.Hashtable;
13 15

  
16
import org.apache.commons.io.FilenameUtils;
14 17
import org.apache.commons.lang3.StringUtils;
15
import org.cresques.cts.IProjection;
18
import org.slf4j.Logger;
19
import org.slf4j.LoggerFactory;
20

  
16 21
import org.gvsig.fmap.dal.DALLocator;
17 22
import org.gvsig.fmap.dal.DataStore;
18 23
import org.gvsig.fmap.dal.DataStoreParameters;
......
24 29
import org.gvsig.fmap.dal.coverage.exception.BandNotFoundInListException;
25 30
import org.gvsig.fmap.dal.coverage.exception.FileNotOpenException;
26 31
import org.gvsig.fmap.dal.coverage.exception.InvalidSetViewException;
32
import org.gvsig.fmap.dal.coverage.exception.InvalidSourceException;
27 33
import org.gvsig.fmap.dal.coverage.exception.NotSupportedExtensionException;
28 34
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException;
29 35
import org.gvsig.fmap.dal.coverage.exception.QueryException;
......
34 40
import org.gvsig.fmap.dal.coverage.store.props.HistogramComputer;
35 41
import org.gvsig.fmap.dal.coverage.store.props.Transparency;
36 42
import org.gvsig.fmap.dal.exception.InitializeException;
43
import org.gvsig.fmap.dal.exception.OpenException;
37 44
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException;
38 45
import org.gvsig.fmap.dal.spi.DataManagerProviderServices;
39 46
import org.gvsig.fmap.dal.spi.DataStoreProviderServices;
40 47
import org.gvsig.metadata.MetadataLocator;
41 48
import org.gvsig.raster.cache.tile.provider.TileServer;
42
import org.gvsig.raster.impl.buffer.DefaultRasterQuery;
43 49
import org.gvsig.raster.impl.buffer.SpiRasterQuery;
44 50
import org.gvsig.raster.impl.datastruct.BandListImpl;
45 51
import org.gvsig.raster.impl.datastruct.DatasetBandImpl;
......
68 74
	public static final String          METADATA_DEFINITION_NAME = "WcsStore";
69 75

  
70 76
	private Extent                      viewRequest              = null;
71
	private static Hashtable<URL, WCSConnector>    
77
	private static Hashtable<URL, WCSConnector>
72 78
	drivers                  = new Hashtable<URL, WCSConnector> ();
73 79
	private boolean                     open                     = false;
74 80
	private DataStoreTransparency       fileTransparency         = null;
75 81
	private File                        lastRequest              = null;
76
	private AbstractRasterProvider      lastRequestProvider      = null; 
82
	private AbstractRasterProvider      lastRequestProvider      = null;
83
	private static final Logger         logger                    = LoggerFactory.getLogger(WCSProvider.class);
77 84

  
85

  
78 86
	public static void register() {
79 87
		DataManagerProviderServices dataman = (DataManagerProviderServices) DALLocator.getDataManager();
80 88
		if (dataman != null && !dataman.getStoreProviders().contains(NAME)) {
......
96 104
	 * Constructor. Abre el dataset.
97 105
	 * @param proj Proyecci?n
98 106
	 * @param fName Nombre del fichero
107
	 * @throws OpenException
99 108
	 * @throws NotSupportedExtensionException
109
     * @deprecated use {@link #WCSProvider(URI)}, this constructor will be removed in gvSIG 2.5
100 110
	 */
101
	public WCSProvider(String params) throws InitializeException {
111
	public WCSProvider(String params) throws InitializeException, OpenException {
102 112
		super(params);
113
        logger.info("Deprecated use of WCSProvider constructor");
103 114
		if(params instanceof String) {
104 115
			WCSDataParametersImpl p = new WCSDataParametersImpl();
105
			p.setURI((String)params);
116
            try {
117
                p.setURI(new URI((String) params));
118
            } catch (URISyntaxException e) {
119
                throw new OpenException("Can't create URI from" + (String) params, e);
120
            }
106 121
			super.init(p, null, ToolsLocator.getDynObjectManager()
107 122
					.createDynObject(
108 123
							MetadataLocator.getMetadataManager().getDefinition(
......
111 126
		}
112 127
	}
113 128

  
129

  
130
    /**
131
     * Constructor. Abre el dataset.
132
     * @param proj Proyecci?n
133
     * @param fName Nombre del fichero
134
     * @throws NotSupportedExtensionException
135
     */
136
    public WCSProvider(URI uri) throws InitializeException {
137
        super(uri);
138
        WCSDataParametersImpl p = new WCSDataParametersImpl();
139
        p.setURI(uri);
140
        super.init(
141
            p,
142
            null,
143
            ToolsLocator.getDynObjectManager().createDynObject(
144
                MetadataLocator.getMetadataManager().getDefinition(DataStore.METADATA_DEFINITION_NAME)));
145
        init(p, null);
146
    }
147

  
114 148
	public WCSProvider(WCSDataParametersImpl params,
115 149
			DataStoreProviderServices storeServices) throws InitializeException {
116 150
		super(params, storeServices, ToolsLocator.getDynObjectManager()
......
129 163
		WCSDataParametersImpl p = (WCSDataParametersImpl)parameters;
130 164
		URL url = null;
131 165
		try {
132
			url = new URL(p.getURI());
166
			url = p.getURI().toURL();
133 167
		} catch (Exception e) {
134 168
			throw new RemoteServiceException("Malformed URL",e);
135 169
		}
......
146 180
	 * @param proj Proyecci?n
147 181
	 * @param param Parametros de carga
148 182
	 * @throws NotSupportedExtensionException
149
	 * @throws RasterDriverException 
183
	 * @throws RasterDriverException
150 184
	 */
151 185
	public void init (DataStoreParameters params,
152 186
			DataStoreProviderServices storeServices) throws InitializeException {
......
204 238
		double resolutionX = e.width() / getWidth();
205 239
		double resolutionY = e.height() / getHeight();
206 240
		ownTransformation = new AffineTransform(
207
				resolutionX, 
208
				0, 
209
				0, 
210
				-resolutionY, 
241
				resolutionX,
242
				0,
243
				0,
244
				-resolutionY,
211 245
				e.getULX() - (resolutionX / 2),
212 246
				e.getULY() - (resolutionY / 2));
213 247
		externalTransformation = (AffineTransform) ownTransformation.clone();
......
223 257
		try {
224 258
			p.setFormat("image/tiff");
225 259
			if(p.getSRSCode() == null){
226
				WCSConnector connector = WCSProvider.getConnectorFromURL(new URL(p.getURI()));
260
				WCSConnector connector = WCSProvider.getConnectorFromURL(p.getURI().toURL());
227 261
				ArrayList srs = connector.getSRSs(p.getCoverageName());
228 262
				if(!srs.isEmpty() && !StringUtils.isBlank((String)srs.get(0))){
229 263
					p.setSRSID((String) srs.get(0));
......
265 299
		return fileTransparency;
266 300
	}
267 301

  
268
	public String translateFileName(String fileName) {
269
		return fileName;
302
	public URI translateURI(URI uri) {
303
		return uri;
270 304
	}
271 305

  
272 306
	public void setView(Extent e) {
......
303 337
	}
304 338

  
305 339
	/**
306
	 * When the remote layer has fixed size this method downloads the file and return its reference. 
340
	 * When the remote layer has fixed size this method downloads the file and return its reference.
307 341
	 * File layer has in the long side FIXED_SIZE pixels and the bounding box is complete. This file could be
308 342
	 * useful to build an histogram or calculate statistics. This represents a sample of data.
309 343
	 * @return
......
321 355
	 * Reads a complete block of data and returns an tridimensional array of the right type. This function is useful
322 356
	 * to read a file very fast without setting a view. In a WCS service when the size is fixed then it will read the
323 357
	 * entire image but when the source hasn't pixel size it will read a sample of data. This set of data will have
324
	 * the size defined in FIXED_SIZE. 
325
	 * 
358
	 * the size defined in FIXED_SIZE.
359
	 *
326 360
	 * @param pos Posici?n donde se empieza  a leer
327 361
	 * @param blockHeight Altura m?xima del bloque leido
328 362
	 * @return Object que es un array tridimendional del tipo de datos del raster. (Bandas X Filas X Columnas)
......
330 364
	 * @throws FileNotOpenException
331 365
	 * @throws RasterDriverException
332 366
	 */
333
	public Object readBlock(int pos, int blockHeight, double scale) 
367
	public Object readBlock(int pos, int blockHeight, double scale)
334 368
			throws InvalidSetViewException, FileNotOpenException, RasterDriverException, ProcessInterruptedException {
335 369
		File lastFile = getFileLayer();
336 370
		BandList bandList = new BandListImpl();
......
396 430
			bandList.setDrawableBands(new int[]{0, 1, 2});*/
397 431

  
398 432
			RasterQuery q = RasterLocator.getManager().createQuery();
399
			q.setAreaOfInterest(lastRequestProvider.getExtent(), 
400
					(int)lastRequestProvider.getWidth(), 
433
			q.setAreaOfInterest(lastRequestProvider.getExtent(),
434
					(int)lastRequestProvider.getWidth(),
401 435
					(int)lastRequestProvider.getHeight());
402 436
			q.setAllDrawableBands();
403 437
			q.setAdjustToExtent(true);
......
510 544
	 * @return
511 545
	 * a georeferencing file
512 546
	 */
513
	private String getWorldFile(String file){		
547
	private String getWorldFile(String file){
514 548
		String worldFile = file;
515 549
		int index = file.lastIndexOf(".");
516
		if (index > 0) {			
550
		if (index > 0) {
517 551
			worldFile = file.substring(0, index) + getExtensionWorldFile();
518 552
		} else {
519 553
			worldFile = file + getExtensionWorldFile();
......
552 586
	}
553 587

  
554 588
	public boolean needEnhanced() {
555
		return (getDataType()[0] != Buffer.TYPE_BYTE || 
589
		return (getDataType()[0] != Buffer.TYPE_BYTE ||
556 590
				(getBandCount() == 1 && getDataType()[0] == Buffer.TYPE_BYTE));
557 591
	}
558 592

  
......
615 649
	 * @throws RasterDriverException
616 650
	 * @throws ProcessInterruptedException
617 651
	 */
618
	public Buffer getBuffer(BandList bandList, File lastFile, 
652
	public Buffer getBuffer(BandList bandList, File lastFile,
619 653
			double ulx, double uly, double lrx, double lry) throws RasterDriverException, ProcessInterruptedException {
620 654
		try {
621 655
			//El nombre de fichero que ha puesto en el bandList es el del servidor y no el del fichero en disco
......
654 688
		WCSStatus wcsStatus = loadWCSStatus(ex.toRectangle2D());
655 689

  
656 690
		lastRequest = downloadFile(
657
				wcsStatus, 
658
				ex, 
659
				query.getAdjustedBufWidth(), 
691
				wcsStatus,
692
				ex,
693
				query.getAdjustedBufWidth(),
660 694
				query.getAdjustedBufHeight());
661 695

  
662 696
		if (lastRequest == null) {
......
686 720
	 * @param buf
687 721
	 * @param bandList
688 722
	 * @return
689
	 * @throws RasterDriverException 
723
	 * @throws RasterDriverException
690 724
	 */
691 725
	private void loadInitialInfo() throws RasterDriverException {
692 726
		WCSDataParametersImpl p = (WCSDataParametersImpl)parameters;
......
733 767
	/*private Buffer changeBufferDataType(int newDataType, Buffer buf, BandList bandList) {
734 768
		Buffer newBuffer = null;
735 769
		if(buf.getDataType() != newDataType) {
736
			newBuffer = DefaultRasterManager.getInstance().createReadOnlyBuffer(newDataType, buf.getWidth(), buf.getHeight(), buf.getBandCount()); 
770
			newBuffer = DefaultRasterManager.getInstance().createReadOnlyBuffer(newDataType, buf.getWidth(), buf.getHeight(), buf.getBandCount());
737 771
			buf.free();
738
		} else 
772
		} else
739 773
			return buf;
740 774

  
741 775
		bandList.clear();
......
750 784
		return newBuffer;
751 785
	}*/
752 786

  
753
	/*public Buffer getWindow(int x, int y, int w, int h, 
787
	/*public Buffer getWindow(int x, int y, int w, int h,
754 788
			BandList bandList, Buffer rasterBuf, TaskStatus status) throws ProcessInterruptedException, RasterDriverException {
755 789
		Point2D p1 = rasterToWorld(new Point2D.Double(x, y));
756 790
		Point2D p2 = rasterToWorld(new Point2D.Double(x + w, y + h));
......
879 913
		}
880 914
		if (format.indexOf("png") >= 0){
881 915
			return "png";
882
		}	
916
		}
883 917
		if (format.indexOf("xml") >= 0){
884 918
			return "xml";
885
		}	
919
		}
886 920
		if (format.indexOf("gif") >= 0){
887 921
			return "gif";
888 922
		}
......
894 928
		}
895 929
		if (format.indexOf("jpg") >= 0
896 930
				|| format.indexOf("jpeg") >= 0){
897
			return "jpg";			 
931
			return "jpg";
898 932
		}
899 933
		return "xml";
900 934
	}
......
912 946
		return true;
913 947
	}
914 948

  
915
	public String getRMFFile() {
916
		if(lastRequest != null)
917
			return fileUtil.getNameWithoutExtension(lastRequest.getAbsolutePath()) + ".rmf";
949
	public File getRMFFile() {
950
		if(lastRequest != null) {
951
		    return new File(FilenameUtils.removeExtension(lastRequest.getAbsolutePath()) + ".rmf");
952
		}
918 953
		return null;
919 954
	}
920 955

  
......
924 959
		return histogram;
925 960
	}
926 961

  
962
    /* (non-Javadoc)
963
     * @see org.gvsig.raster.impl.provider.RasterProvider#addFile(java.io.File)
964
     */
965
    @Override
966
    public void addFile(File file) throws InvalidSourceException {
967
        // Do nothing
968

  
969
    }
970

  
971
    /* (non-Javadoc)
972
     * @see org.gvsig.raster.impl.provider.RasterProvider#removeFile(java.io.File)
973
     */
974
    @Override
975
    public void removeFile(File file) {
976
        // Do nothing
977

  
978
    }
979

  
927 980
}
org.gvsig.raster.wcs/trunk/org.gvsig.raster.wcs/org.gvsig.raster.wcs.io/src/main/java/org/gvsig/raster/wcs/io/WCSDataParameters.java
24 24

  
25 25
import java.awt.geom.Point2D;
26 26
import java.awt.geom.Rectangle2D;
27
import java.net.URI;
27 28
import java.util.Hashtable;
28 29
import java.util.Map;
29 30

  
......
40 41
	 * @return
41 42
	 */
42 43
	public Object getTime();
43
	
44

  
44 45
	/**
45 46
	 * Sets the time information for the request
46 47
	 * @param time
......
52 53
	 * @return Formato.
53 54
	 */
54 55
	public Object getFormat();
55
	
56

  
56 57
	/**
57 58
	 * Sets the format
58 59
	 * @param format Formato.
......
64 65
	public Object getURI();
65 66

  
66 67
	public String getCoverageName();
67
	
68

  
68 69
	public Point2D getMaxResolution();
69
	
70

  
70 71
	public String getParameter();
71
	
72

  
72 73
	/**
73 74
	 * Gets the bounding box
74 75
	 * @return
75 76
	 */
76 77
	public Rectangle2D getExtent();
77
	
78

  
78 79
	public int getWidth();
79
	
80

  
80 81
	public int getHeight();
81
	
82

  
82 83
	public boolean isOverridingHost();
83
	
84

  
84 85
	/**
85 86
	 * Gets the online resource map
86 87
	 * @param onlineResources
87 88
	 */
88 89
	public Map<String,String> getOnlineResource();
89
	
90

  
90 91
	public String getDepth();
91 92

  
92 93
	public void setCancellable(ICancellable cancel);
93
	
94

  
94 95
	public void setOverrideHost(boolean over);
95 96

  
96 97
	/**
97
	 * Assigns the extent. 
98
	 * Assigns the extent.
98 99
	 * When a provider is initialized this will need to know what is the extent before the request.
99
	 * 
100
	 *
100 101
	 * @param bBox
101 102
	 */
102 103
	public void setExtent(Rectangle2D bBox);
103 104

  
104
	public void setURI(String string);
105
	public void setURI(URI uri);
105 106

  
106 107
	public void setSRS(String srs);
107 108

  
......
118 119
	 * @param onlineResources
119 120
	 */
120 121
	public void setOnlineResources(Hashtable<String, String> onlineResources);
121
	
122

  
122 123
	public void setDepth(String depth);
123 124

  
124 125
}
org.gvsig.raster.wcs/trunk/org.gvsig.raster.wcs/org.gvsig.raster.wcs.io/src/main/java/org/gvsig/raster/wcs/io/downloader/WCSTileServer.java
16 16
import org.slf4j.Logger;
17 17
import org.slf4j.LoggerFactory;
18 18

  
19
/** 
20
* Data server for the tile cache in a WMSProvider 
19
/**
20
* Data server for the tile cache in a WMSProvider
21 21
* @author Nacho Brodin (nachobrodin@gmail.com)
22 22
*/
23 23
public class WCSTileServer implements TileServer {
......
26 26
	private Downloader                 downloader           = null;
27 27
	private RasterDataStore            store                = null;
28 28
	private String                     suffix               = ".tif";
29
	
29

  
30 30
	public WCSTileServer(RasterDataStore store) {
31 31
		this.store = store;
32 32
		this.suffix = ((RasterProvider)store.getProvider()).getFileSuffix();
33 33
	}
34
	
34

  
35 35
	public Downloader getDownloader() {
36 36
		if(downloader == null ||
37 37
		   ((TileDownloaderForWCS)downloader).getTileSize()[0] != TileCacheLibrary.ALTERNATIVE_TILESIZE ||
38 38
		   ((TileDownloaderForWCS)downloader).getTileSize()[1] != TileCacheLibrary.ALTERNATIVE_TILESIZE) {
39
							
39

  
40 40
			try {
41 41
				downloader = new TileDownloaderForWCS(
42
						store, 
43
						TileCacheLibrary.ALTERNATIVE_TILESIZE, 
44
						TileCacheLibrary.ALTERNATIVE_TILESIZE, 
42
						store,
43
						TileCacheLibrary.ALTERNATIVE_TILESIZE,
44
						TileCacheLibrary.ALTERNATIVE_TILESIZE,
45 45
						((WCSProvider)store.getProvider()).getConnector());
46 46
			} catch (RemoteServiceException e) {
47 47
				return null;
......
53 53
	public CacheStruct getStruct() {
54 54
		if(struct == null) {
55 55
			TileCacheManager  manager = TileCacheLocator.getManager();
56
			
56

  
57 57
			int coordinates = CacheStruct.FLAT;
58 58
			if(store.getProjection() != null)
59 59
				coordinates = (store.getProjection() != null && store.getProjection().isProjected()) ? CacheStruct.FLAT : CacheStruct.GEOGRAFIC;
60 60
			else {
61 61
				Extent e = store.getExtent();
62
				if(e.getULX() >= -180 && e.getULX() <= 180 && e.getLRX() >= -180 && e.getLRX() <= 180 && 
62
				if(e.getULX() >= -180 && e.getULX() <= 180 && e.getLRX() >= -180 && e.getLRX() <= 180 &&
63 63
					e.getULY() >= -90 && e.getULY() <= 90 && e.getLRY() >= -90 && e.getLRY() <= 90) {
64 64
					coordinates = CacheStruct.GEOGRAFIC;
65 65
				}
66 66
			}
67
			
67

  
68 68
			String epsg = null;
69 69
			IProjection proj = store.getProjection();
70 70
			if(proj != null)
71 71
				epsg = proj.getAbrev();
72
			
73
			struct = manager.createCacheStructure(coordinates, 
74
					TileCacheLibrary.DEFAULT_LEVELS, 
75
					store.getExtent().toRectangle2D(), 
76
					store.getCellSize(), 
77
					TileCacheLibrary.ALTERNATIVE_TILESIZE, 
72

  
73
			struct = manager.createCacheStructure(coordinates,
74
					TileCacheLibrary.DEFAULT_LEVELS,
75
					store.getExtent().toRectangle2D(),
76
					store.getCellSize(),
78 77
					TileCacheLibrary.ALTERNATIVE_TILESIZE,
79
					((WCSProvider)store.getProvider()).getURIOfFirstProvider(),
78
					TileCacheLibrary.ALTERNATIVE_TILESIZE,
79
					((WCSProvider)store.getProvider()).getURIOfFirstProvider().getPath(),
80 80
					((WCSProvider)store.getProvider()).getParameters().getCoverageName(),
81 81
					TileCacheLibrary.DEFAULT_STRUCTURE,
82 82
					RasterLibrary.pathTileCache,
......
86 86
		}
87 87
		return struct;
88 88
	}
89
	
89

  
90 90
	public void setStruct(CacheStruct struct) {
91 91
		if(struct != null) {
92 92
			this.struct = struct;
93 93
			if(struct.getTileSizeByLevel(0) != null) {
94 94
				try {
95
					downloader = new TileDownloaderForWCS(store, 
96
							struct.getTileSizeByLevel(0)[0], 
95
					downloader = new TileDownloaderForWCS(store,
96
							struct.getTileSizeByLevel(0)[0],
97 97
							struct.getTileSizeByLevel(0)[1],
98 98
							((WCSProvider)store.getProvider()).getConnector());
99 99
				} catch (RemoteServiceException ex) {
......
102 102
			}
103 103
		}
104 104
	}
105
	
105

  
106 106
	public String getFileSuffix() {
107 107
		return suffix;
108 108
	}
109
	
109

  
110 110
	public void setFileSuffix(String extension) {
111 111
		this.suffix = extension;
112 112
	}
org.gvsig.raster.wcs/trunk/org.gvsig.raster.wcs/org.gvsig.raster.wcs.app.wcsclient/src/main/java/org/gvsig/raster/wcs/app/wcsclient/layer/FLyrWCS.java
50 50
import java.awt.geom.Rectangle2D;
51 51
import java.awt.image.BufferedImage;
52 52
import java.io.IOException;
53
import java.net.URI;
54
import java.net.URISyntaxException;
53 55
import java.util.HashMap;
54 56
import java.util.List;
55 57

  
56 58
import javax.print.attribute.PrintRequestAttributeSet;
57 59

  
58 60
import org.cresques.cts.IProjection;
61

  
59 62
import org.gvsig.compat.net.ICancellable;
60 63
import org.gvsig.fmap.dal.DALLocator;
61 64
import org.gvsig.fmap.dal.DataManager;
......
107 110
import org.gvsig.tools.task.Cancellable;
108 111
import org.gvsig.tools.task.SimpleTaskStatus;
109 112
import org.gvsig.tools.task.TaskStatusManager;
113

  
110 114
import org.slf4j.Logger;
111 115
import org.slf4j.LoggerFactory;
112 116

  
......
188 192
        this();
189 193
        //Create the explorer and connect
190 194
        DataManager dataManager = DALLocator.getDataManager();
191
        WCSServerExplorerParameters explorerParams = (WCSServerExplorerParameters) 
195
        WCSServerExplorerParameters explorerParams = (WCSServerExplorerParameters)
192 196
        dataManager.createServerExplorerParameters(WCSProvider.NAME);
193 197
        explorerParams.setHost((String)dataStoreParameters.getDynValue("uri"));
194
        WCSServerExplorer wmsServerExplorer = 
198
        WCSServerExplorer wmsServerExplorer =
195 199
            (WCSServerExplorer) dataManager.openServerExplorer(WCSProvider.NAME, explorerParams);
196 200
        wmsServerExplorer.connect(null);
197 201
        wmsServerExplorer.getCoverageList();
198
        
202

  
199 203
        //Set the parameters
200 204
        setParameters((WCSDataParameters)dataStoreParameters);
201 205
        setExplorer(wmsServerExplorer);
......
211 215
        } catch (ProviderNotRegisteredException e) {
212 216
            return null;
213 217
        }
214
        params.setURI(host);
218
        URI uriHost;
219
        try {
220
            uriHost = new URI(host);
221
        } catch (URISyntaxException e1) {
222
            throw new InitializeException(e1);
223
        }
224
        params.setURI(uriHost);
215 225
        params.setSRS(srs);
216 226

  
217 227
        try {
......
255 265
            firstLoad = true;
256 266
        }
257 267

  
258
        callCount = 0;  
268
        callCount = 0;
259 269

  
260 270
        enableStopped();
261
        
271

  
262 272
        if(recalcLevel) {
263 273
			double pixelSize = viewPort.getEnvelope().getLength(0) / (double)viewPort.getImageWidth();
264 274
			zoomLevel = dataStore.getNearestLevel(pixelSize);
......
343 353
            //Rectangle2D.intersect(vpExtent, bBox, extent);
344 354

  
345 355
            Extent ex = rManager.getDataStructFactory().createExtent(
346
                vp.getAdjustedEnvelope().getMinimum(0), 
347
                vp.getAdjustedEnvelope().getMaximum(1), 
348
                vp.getAdjustedEnvelope().getMaximum(0), 
356
                vp.getAdjustedEnvelope().getMinimum(0),
357
                vp.getAdjustedEnvelope().getMaximum(1),
358
                vp.getAdjustedEnvelope().getMaximum(0),
349 359
                vp.getAdjustedEnvelope().getMinimum(1));
350 360
            ViewPortData vpData = rManager.getDataStructFactory().createViewPortData(vp.getProjection(), ex, sz );
351 361
            vpData.setMat(vp.getAffineTransform());
352 362
            vpData.setDPI((int)vp.getDPI());
353
    		
363

  
354 364
            try {
355 365
                getParameters().setExtent(bBox);
356 366
                getParameters().setWidth(wImg);
......
376 386
            } catch (QueryException e) {
377 387
            	throw new RemoteServiceException("Problems drawing this layer: " + e.getMessage(), e);
378 388
			} finally {
379
            	taskStatus.terminate();            	
389
            	taskStatus.terminate();
380 390
            }
381 391

  
382 392
        } catch (RemoteServiceException e) {
......
430 440
            .getLength(0), env.getLength(1));
431 441
    }
432 442

  
433
    
443

  
434 444
    /**
435 445
     * Gets the explorer
436 446
     * @return
......
445 455
		}
446 456
    	return null;
447 457
    }
448
    
458

  
449 459
    /**
450 460
     * Calcula el contenido del fichero de georreferenciaci?n de una imagen.
451 461
     * @param bBox Tama?o y posici?n de la imagen (en coordenadas de usuario)
......
575 585
    public boolean isTiled() {
576 586
        return mustTileDraw;
577 587
    }
578
    
588

  
579 589
	public boolean isRemote() {
580 590
		return true;
581 591
	}
......
619 629
        }
620 630
        return new DynObjectSetWCSInfo(fInfo, DynObjectSetWCSInfo.TYPE_TEXT);
621 631
    }
622
    
632

  
623 633
	@Override
624 634
	public String getFileFormat() {
625 635
		return "WCS";
......
679 689
        }*/
680 690
        return getWCSParameters(getDataStore().getParameters());
681 691
    }
682
    
692

  
683 693
    /**
684 694
     * Gets <code>WCSDataParameters</code>
685 695
     * @param parameters
......
690 700
    	if(parameters instanceof WCSDataParameters) {
691 701
			params = (WCSDataParameters) parameters;
692 702
		}
693
		
703

  
694 704
		if(parameters instanceof TileDataParameters) {
695 705
			DataParameters p = ((TileDataParameters) parameters).getDataParameters();
696 706
			if(p instanceof WCSDataParameters) {
......
708 718
    	if(getDataStore() != null)
709 719
    		getDataStore().setExplorer(explorer);
710 720
    }
711
    
721

  
712 722
    /**
713 723
	 * Assigns the flag to delete this layer from the cache
714 724
	 * @param selected
......
726 736
        if(params instanceof TileDataParameters) {
727 737
			((TileDataParameters)params).deleteCache(deleteCache);
728 738
		}
729
        
739

  
730 740
        DataManagerProviderServices dataman = (DataManagerProviderServices) DALLocator.getDataManager();
731 741
        try {
732 742
            DataStore dStore = dataman.openStore(params.getDataStoreName(), params);
......
735 745
			if(params instanceof WCSDataParameters) {
736 746
				this.setName((String)((WCSDataParameters)params).getURI());
737 747
			}
738
			
748

  
739 749
			if(params instanceof TileDataParameters) {
740 750
				DataParameters p = ((TileDataParameters) params).getDataParameters();
741 751
				if(p instanceof WCSDataParameters) {
......
750 760
            throw new InitializeException(e);
751 761
        }
752 762
    }
753
    
763

  
754 764
	/*@Override
755 765
	public void loadFromState(PersistentState state)
756 766
	throws PersistenceException {
757 767
		String host = state.getString("host");
758
		
768

  
759 769
		getParameters();
760 770
		((WCSServerExplorerParameters)explorer.getParameters()).setHost(host);
761
		
771

  
762 772
		if(!explorer.isHostReachable()) {
763 773
			loadDataStore = false;
764 774
			super.loadFromState(state);
765 775
			return;
766 776
		}
767
		
777

  
768 778
		try {
769 779
			explorer.connect(new CancelTaskImpl());
770 780
			explorer.getCoverageList();
......
773 783
			super.loadFromState(state);
774 784
			return;
775 785
		}
776
		
786

  
777 787
		loadDataStore = true;
778 788

  
779 789
		super.loadFromState(state);
......
795 805
		state.set("host", getParameters().getURI());
796 806
		state.set("name", getName());
797 807
	}*/
798
    
808

  
799 809
	/*public static void registerPersistent() {
800 810
		PersistenceManager manager = ToolsLocator.getPersistenceManager();
801 811
		DynStruct definition = manager.getDefinition(PERSISTENT_NAME);
......
808 818
					FLyrWCS.class,
809 819
					PERSISTENT_NAME,
810 820
					PERSISTENT_DESCRIPTION,
811
					null, 
821
					null,
812 822
					null
813 823
			);
814
			
824

  
815 825
			definition.extend(PersistenceManager.PERSISTENCE_NAMESPACE, "FLyrDefault");
816 826
		}
817 827

  
......
820 830
		definition.addDynFieldString("host").setMandatory(false);
821 831
		definition.addDynFieldString("name").setMandatory(false);
822 832
	}*/
823
	
833

  
824 834
	public static void registerPersistent() {
825 835
		PersistenceManager manager = ToolsLocator.getPersistenceManager();
826 836
		DynStruct definition = manager.getDefinition("FLyrWCS_Persistent");
......
833 843
					FLyrWCS.class,
834 844
					"FLyrWCS_Persistent",
835 845
					"FLyrWCS Persistent Definition",
836
					null, 
846
					null,
837 847
					null
838 848
			);
839
			
849

  
840 850
			definition.extend(PersistenceManager.PERSISTENCE_NAMESPACE, DefaultFLyrRaster.PERSISTENT_NAME);
841 851
		}
842 852

  
org.gvsig.raster.wcs/trunk/org.gvsig.raster.wcs/org.gvsig.raster.wcs.app.wcsclient/src/main/java/org/gvsig/raster/wcs/app/wcsclient/gui/panel/WCSParamsPanel.java
2 2
*
3 3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4 4
* of the Valencian Government (CIT)
5
* 
5
*
6 6
* This program is free software; you can redistribute it and/or
7 7
* modify it under the terms of the GNU General Public License
8 8
* as published by the Free Software Foundation; either version 2
9 9
* of the License, or (at your option) any later version.
10
* 
10
*
11 11
* This program is distributed in the hope that it will be useful,
12 12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13 13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 14
* GNU General Public License for more details.
15
* 
15
*
16 16
* You should have received a copy of the GNU General Public License
17 17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 19
* MA  02110-1301, USA.
20
* 
20
*
21 21
*/
22
 
22

  
23 23
package org.gvsig.raster.wcs.app.wcsclient.gui.panel;
24 24

  
25 25
import java.awt.event.FocusEvent;
26 26
import java.awt.event.FocusListener;
27 27
import java.awt.geom.Rectangle2D;
28 28
import java.lang.reflect.InvocationTargetException;
29
import java.net.URI;
30
import java.net.URISyntaxException;
29 31
import java.util.ArrayList;
30 32
import java.util.prefs.Preferences;
31 33

  
......
80 82
	private WizardListenerSupport  listenerSupport;
81 83
	private JTabbedPane            jTabbedPane        = null;
82 84
	private boolean                lastCached         = false;
83
	
85

  
84 86
	public WCSParamsPanel() {
85 87
		super();
86 88
		initialize();
......
108 110
		listenerSupport.callStateChanged(b);
109 111
		callStateChanged(b);
110 112
	}
111
	
113

  
112 114
	/**
113 115
	 * WCSWizard doesn't have a JCheckBox for selecting with or without cache.
114
	 * 
116
	 *
115 117
	 * @return
116 118
	 * @throws LoadLayerException
117 119
	 */
118 120
	public FLayer getLayer() throws InitializeException {
119 121
		return getLayer(lastCached);
120 122
	}
121
	
123

  
122 124
	@SuppressWarnings("unchecked")
123
	public FLayer getLayer(boolean cached) throws InitializeException { 
125
	public FLayer getLayer(boolean cached) throws InitializeException {
124 126
		lastCached = cached;
125 127
		FLyrWCS layer = new FLyrWCS();
126 128
		WCSDataParameters par = (WCSDataParameters)explorer.getStoredParameters();
127 129
		DataStoreParameters parameters = par;
128
		
130

  
129 131
		if(cached) {
130 132
			DataManager manager = DALLocator.getDataManager();
131 133
			TileDataParameters tileParams = null;
......
137 139
			tileParams.setDataParameters(par);
138 140
			parameters = tileParams;
139 141
		}
140
				
141
		par.setURI(explorer.getHost().toString());
142

  
143
		String host = explorer.getHost();
144
		URI hostURI;
145
        try {
146
            hostURI = new URI(host);
147
        } catch (URISyntaxException e1) {
148
            throw new InitializeException(e1);
149
        }
150
		par.setURI(hostURI);
142 151
		par.setSRS(getSRS());
143 152
		par.setFormat(getFormat());
144 153
		par.setCoverageName(getLayerPanel().getSelectedCoverageName());
......
149 158
		WCSLayerNode lNode = explorer.getCoverageByName(cName);
150 159
		par.setMaxResolution(lNode.getMaxRes());
151 160
		par.setOnlineResources(explorer.getOnlineResources());
152
		
161

  
153 162
		try {
154 163
			layer.setParameters(parameters);
155 164
			layer.setExplorer(explorer);
......
165 174
		}
166 175
		return layer;
167 176
	}
168
	
177

  
169 178
	/**
170
	 * Gets the <code>RasterDriverException</code> message. The message 
179
	 * Gets the <code>RasterDriverException</code> message. The message
171 180
	 * of this exception is returned by the server
172 181
	 * @param e
173 182
	 * @return
......
184 193
				t = ex.getCause();
185 194
			} else if(ex instanceof InvocationTargetException) {
186 195
				t = ((InvocationTargetException)ex).getTargetException();
187
			} 
196
			}
188 197
			if(t == null)
189 198
				return null;
190 199
			else
......
254 263
			fireWizardComplete(isCorrectlyConfigured());
255 264
		}
256 265
	}
257
	
266

  
258 267
	/**
259 268
	 * Cleans up the wizard's components but the server's layers list.
260 269
	 *
......
297 306
				pString);
298 307
	}
299 308

  
300
	
309

  
301 310
	public void setListenerSupport(WizardListenerSupport support) {
302 311
		listenerSupport = support;
303 312
	}
......
351 360
		}
352 361
		return jTabbedPane;
353 362
	}
354
	
355 363

  
364

  
356 365
	/**
357 366
	 * This method initializes InfoPanel
358 367
	 *
......
365 374
		}
366 375
		return infoPanel;
367 376
	}
368
	
377

  
369 378
	/**
370 379
	 * This method initializes TimePanel
371 380
	 *
......
377 386
		}
378 387
		return timesPanel;
379 388
	}
380
	
389

  
381 390
	/**
382 391
	 * This method initializes FormatPanel
383 392
	 *
......
389 398
		}
390 399
		return formatsPanel;
391 400
	}
392
	
401

  
393 402
	/**
394 403
	 * This method initializes ParameterPanel
395 404
	 * @return javax.swing.JPanel
......
400 409
		}
401 410
		return parameterPanel;
402 411
	}
403
	
412

  
404 413
	/**
405 414
	 * This method initializes LayerPanel
406 415
	 * @return javax.swing.JPanel
......
508 517
	public void close() {
509 518
		// Nothing to do
510 519
	}
511
	
520

  
512 521
	public WCSServerExplorer getExplorer() {
513 522
		return explorer;
514 523
	}
515
	
524

  
516 525
	/**
517 526
	 * Returns the extent of the currently selected coverage for the currently
518 527
	 * selected SRS.
......
526 535
		}
527 536
		return null;
528 537
	}
529
	
538

  
530 539
	/**
531 540
	 * Returns the name of the selected coverage.
532 541
	 *
......
535 544
	public String getLayerName() {
536 545
		return getLayerPanel().getTxtName().getText();
537 546
	}
538
	
547

  
539 548
	/**
540 549
	 * Returns the selected CRS.
541 550
	 *
......
582 591
		if (getTimePanel().timeRequired() && getTimePanel().getTime()==null) {
583 592
			return false;
584 593
		}
585
		
594

  
586 595
		/*if (getParameterPanel().getCmbParam().getSelectedItem()!=null){
587 596
			if (parameterType == SINGLE_VALUE && getParameterPanel().getParameterString()==null) {
588 597
				return false;
......
590 599
			if (parameterType == INTERVAL) {
591 600
			}
592 601
		}*/
593
		
602

  
594 603
		if (getSRS() == null) {
595 604
			return false;
596 605
		}
597
		
606

  
598 607
		if (getFormat() == null) {
599 608
			return false;
600 609
		}
org.gvsig.raster.wcs/trunk/org.gvsig.raster.wcs/pom.xml
7 7
    <name>${project.artifactId}</name>
8 8
    <description>WCS client</description>
9 9
    <inceptionYear>2011</inceptionYear>
10
	
10

  
11 11
    <parent>
12 12
        <groupId>org.gvsig</groupId>
13 13
        <artifactId>org.gvsig.desktop</artifactId>
14
        <version>2.0.111</version>
14
        <version>2.0.112</version>
15 15
    </parent>
16 16

  
17 17
        <properties>
18 18
            <!-- El plugin versions:use-latest-versions falla con scope import -->
19 19
            <!-- asi que toca usar el versions:update-properties que si que funciona -->
20
            <org.gvsig.raster.version>2.2.21</org.gvsig.raster.version>
20
            <org.gvsig.raster.version>2.2.22</org.gvsig.raster.version>
21 21
        </properties>
22
    
22

  
23 23
    <repositories>
24 24
        <repository>
25 25
            <id>gvsig-public-http-repository</id>
......
37 37
            </snapshots>
38 38
        </repository>
39 39
    </repositories>
40
    
41
    
40

  
41

  
42 42
    <scm>
43 43
        <connection>scm:svn:https://devel.gvsig.org/svn/gvsig-raster/org.gvsig.raster.wcs/trunk/org.gvsig.raster.wcs</connection>
44 44
        <developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-raster/org.gvsig.raster.wcs/trunk/org.gvsig.raster.wcs</developerConnection>
45 45
        <url>https://devel.gvsig.org/redmine/projects/gvsig-raster/repository/show/org.gvsig.raster.wcs/trunk/org.gvsig.raster.wcs</url>
46 46
    </scm>
47
    
47

  
48 48
    <build>
49 49
        <plugins>
50 50
            <plugin>
......
57 57
            </plugin>
58 58
        </plugins>
59 59
    </build>
60
    		
60

  
61 61
    <dependencyManagement>
62 62
        <dependencies>
63 63
                        <dependency>
......
86 86

  
87 87
        </dependencies>
88 88
    </dependencyManagement>
89
	
89

  
90 90
    <modules>
91 91
        <module>org.gvsig.raster.wcs.remoteclient</module>
92 92
        <module>org.gvsig.raster.wcs.io</module>
93 93
        <module>org.gvsig.raster.wcs.app.wcsclient</module>
94 94
    </modules>
95
	
95

  
96 96
</project>

Also available in: Unified diff