Revision 34305 branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wmts/WMTSClient.java

View differences:

WMTSClient.java
21 21
*/
22 22
package org.gvsig.remoteclient.wmts;
23 23

  
24
import java.io.File;
24 25
import java.io.IOException;
25 26
import java.net.ConnectException;
26 27
import java.util.ArrayList;
27 28

  
28 29
import org.gvsig.compat.net.ICancellable;
30
import org.gvsig.remoteclient.exceptions.ServerErrorException;
31
import org.gvsig.remoteclient.wmts.exception.WMTSException;
29 32
import org.gvsig.remoteclient.wmts.struct.WMTSLayer;
30 33
import org.gvsig.remoteclient.wmts.struct.WMTSServiceIdentification;
31 34
import org.gvsig.remoteclient.wmts.struct.WMTSServiceProvider;
......
38 41
 */
39 42
@SuppressWarnings("unchecked")
40 43
public class WMTSClient extends org.gvsig.remoteclient.RasterClient {
41
	private org.gvsig.remoteclient.wmts.WMTSProtocolHandler handler   = null;
42
	private WMTSStatus                                      status    = null;
44
	private org.gvsig.remoteclient.wmts.WMTSProtocolHandler handler           = null;
45
	private WMTSServerDescription                           serverDescription = null;
43 46

  
44 47
	/**
45 48
	 * Constructor.
......
70 73
     * @return a TreeMap with the available layers in the WMS 
71 74
     */
72 75
	public ArrayList getLayers() {        
73
    	if(status != null)
74
			return status.getLayerList();
76
    	if(serverDescription != null)
77
			return serverDescription.getLayerList();
75 78
		return null;
76 79
    } 
77 80
    
......
80 83
     * @return, number of layers available
81 84
     */
82 85
    public int getNumberOfLayers() {        
83
    	if(status != null)
84
			return status.getLayerList().size();
86
    	if(serverDescription != null)
87
			return serverDescription.getLayerList().size();
85 88
		return 0;
86 89
    }
87 90

  
88 91
	@Override
89 92
	public void close() {
90
		status = null;
93
		serverDescription = null;
91 94
		handler = null;
92 95
	}
93 96
	
97
	 /**
98
     * <p>One of the three interfaces that OGC WMS defines. Request a map.</p> 
99
     * @throws ServerErrorException 
100
     */
101
    public File getTile(WMTSStatus status, ICancellable cancel) throws WMTSException, ServerErrorException {   
102
        return handler.getTile(status, cancel);
103
    } 
104
	
94 105
	/**
95 106
     * <p>One of the three interfaces defined by OGC WMS, it gets the service capabilities</p>
96 107
     * @param override, if true the previous downloaded data will be overridden
97 108
     */
98
    public void getCapabilities(WMTSStatus status, boolean override, ICancellable cancel) {        
99
        handler.getCapabilities(status, override, cancel);
109
    public void getCapabilities(WMTSServerDescription serverDescription, boolean override, ICancellable cancel) {        
110
        handler.getCapabilities(serverDescription, override, cancel);
100 111
    } 
101 112

  
102 113
	/*
......
114 125
                    return false;
115 126
                }                
116 127
            }
117
            if(status == null)
118
            	status = new WMTSStatus(handler.getVersion());
119
            getCapabilities(status, override, cancel);
128
            if(serverDescription == null)
129
            	serverDescription = new WMTSServerDescription(handler.getVersion());
130
            getCapabilities(serverDescription, override, cancel);
120 131
            return true;
121 132
            
122 133
        } catch (Exception e) {
......
135 146
	 * @return
136 147
	 */
137 148
	public ArrayList getFormats(String layerTitle) {
138
		if(status != null)
139
			return status.getLayerByTitle(layerTitle).getFormat();
149
		if(serverDescription != null)
150
			return serverDescription.getLayerByTitle(layerTitle).getFormat();
140 151
		return null;
141 152
    }
142 153
	
......
145 156
	 * @return
146 157
	 */
147 158
	public WMTSServiceIdentification getServiceIdentification() {
148
		if(status != null)
149
			return status.getServiceIdentification();
159
		if(serverDescription != null)
160
			return serverDescription.getServiceIdentification();
150 161
		return null;
151 162
	}
152 163
	
......
155 166
	 * @return
156 167
	 */
157 168
	public WMTSServiceProvider getServiceProvider() {
158
		if(status != null)
159
			return status.getServiceProvider();
169
		if(serverDescription != null)
170
			return serverDescription.getServiceProvider();
160 171
		return null;
161 172
	}
162 173

  
......
165 176
	 * @return
166 177
	 */
167 178
	public WMTSThemes getThemes() {
168
		if(status != null)
169
			return status.getThemes();
179
		if(serverDescription != null)
180
			return serverDescription.getThemes();
170 181
		return null;
171 182
	}
172 183
	
......
175 186
     * @return
176 187
     */
177 188
    public ArrayList getTileMatrixSet() {
178
    	if(status != null)
179
    		return status.getTileMatrixSet();
189
    	if(serverDescription != null)
190
    		return serverDescription.getTileMatrixSet();
180 191
    	return null;
181 192
    }
182 193
    
......
186 197
     * @return
187 198
     */
188 199
    public WMTSLayer getLayer(String layerName) {
189
    	if(status != null) {
190
			ArrayList list = status.getLayerList();
200
    	if(serverDescription != null) {
201
			ArrayList list = serverDescription.getLayerList();
191 202
			for (int i = 0; i < list.size(); i++) {
192 203
				WMTSLayer layer = (WMTSLayer)list.get(i);
193 204
				if(layer.getTitle().compareTo(layerName) == 0) {

Also available in: Unified diff