Statistics
| Revision:

gvsig-raster / org.gvsig.raster.wmts / trunk / org.gvsig.raster.wmts / org.gvsig.raster.wmts.io / src / main / java / org / gvsig / raster / wmts / io / WMTSServerExplorer.java @ 483

History | View | Annotate | Download (7.22 KB)

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

    
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2009 IVER T.I   {{Task}}
26
*/
27

    
28
package org.gvsig.raster.wmts.io;
29

    
30
import java.io.IOException;
31
import java.net.URL;
32
import java.util.ArrayList;
33
import java.util.List;
34

    
35
import org.gvsig.compat.net.ICancellable;
36
import org.gvsig.fmap.dal.DALLocator;
37
import org.gvsig.fmap.dal.DataManager;
38
import org.gvsig.fmap.dal.DataServerExplorer;
39
import org.gvsig.fmap.dal.DataServerExplorerParameters;
40
import org.gvsig.fmap.dal.DataStoreParameters;
41
import org.gvsig.fmap.dal.NewDataStoreParameters;
42
import org.gvsig.fmap.dal.coverage.store.parameter.TileDataParameters;
43
import org.gvsig.fmap.dal.exception.DataException;
44
import org.gvsig.fmap.dal.exception.InitializeException;
45
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException;
46
import org.gvsig.fmap.dal.spi.DataServerExplorerProvider;
47
import org.gvsig.fmap.dal.spi.DataServerExplorerProviderServices;
48
import org.gvsig.remoteclient.wmts.exception.WMTSException;
49
import org.gvsig.remoteclient.wmts.struct.WMTSLayer;
50
import org.gvsig.remoteclient.wmts.struct.WMTSServiceIdentification;
51
import org.gvsig.remoteclient.wmts.struct.WMTSServiceProvider;
52
import org.gvsig.remoteclient.wmts.struct.WMTSThemes;
53
import org.gvsig.remoteclient.wmts.struct.WMTSTileMatrixSet;
54

    
55
/**
56
 * Explorer for a WMTS server
57
 * @author Nacho Brodin (nachobrodin@gmail.com)
58
 */
59
public class WMTSServerExplorer implements DataServerExplorer, DataServerExplorerProvider {
60
        public static final String           NAME                     = "WMTSRemoteServerExplorer";
61
        private WMTSConnector                connector                = null;
62
        private WMTSServerExplorerParameters parameters               = null;
63
        
64
        public WMTSServerExplorer(
65
                        WMTSServerExplorerParameters parameters,
66
                        DataServerExplorerProviderServices services)
67
                        throws InitializeException {
68
                this.parameters = parameters;
69
        }
70
        
71
        /*
72
         * (non-Javadoc)
73
         * @see org.gvsig.fmap.dal.coverage.store.remote.RemoteServerExplorerProvider#getDataStoreProviderName()
74
         */
75
        public String getDataStoreProviderName() {
76
                return WMTSProvider.NAME;
77
        }
78
        
79
        /*
80
         * (non-Javadoc)
81
         * @see org.gvsig.fmap.dal.coverage.store.remote.RemoteServerExplorerProvider#getDescription()
82
         */
83
        public String getDescription() {
84
                return WMTSProvider.DESCRIPTION;
85
        }
86
        
87
        /*
88
         * (non-Javadoc)
89
         * @see org.gvsig.fmap.dal.coverage.explorer.WMTSServerExplorer#getStoreParameters()
90
         */
91
        public DataStoreParameters getStoreParameters() {
92
                DataManager manager = DALLocator.getDataManager();
93
                WMTSDataParameters wmtsParams = null;
94
                try {
95
                        wmtsParams = (WMTSDataParameters) manager
96
                        .createStoreParameters(this.getDataStoreProviderName());
97

    
98
                        wmtsParams.setURI(parameters.getHost());
99

    
100
                        if(WMTSProvider.TILED) {
101
                                TileDataParameters tileParams = (TileDataParameters) manager
102
                                .createStoreParameters("Tile Store");
103

    
104
                                tileParams.setDataParameters(wmtsParams);
105
                                return tileParams;
106
                        } 
107
                } catch (InitializeException e) {
108
                        e.printStackTrace();
109
                } catch (ProviderNotRegisteredException e) {
110
                        e.printStackTrace();
111
                }
112
                return wmtsParams;
113
        }
114

    
115
        public boolean add(String provider, NewDataStoreParameters parameters,
116
                        boolean overwrite) throws DataException {
117
                return false;
118
        }
119

    
120
        public boolean canAdd() {
121
                return false;
122
        }
123

    
124
        public boolean canAdd(String storeName) throws DataException {
125
                return false;
126
        }
127

    
128
        public NewDataStoreParameters getAddParameters(String storeName)
129
                        throws DataException {
130
                return null;
131
        }
132

    
133
        @SuppressWarnings("unchecked")
134
        public List getDataStoreProviderNames() {
135
                return null;
136
        }
137

    
138
        /*
139
         * (non-Javadoc)
140
         * @see org.gvsig.fmap.dal.DataServerExplorer#getParameters()
141
         */
142
        public DataServerExplorerParameters getParameters() {
143
                return parameters;
144
        }
145

    
146
        @SuppressWarnings("unchecked")
147
        public List list() throws DataException {
148
                return null;
149
        }
150

    
151
        @SuppressWarnings("unchecked")
152
        public List list(int mode) throws DataException {
153
                return null;
154
        }
155

    
156
        public void remove(DataStoreParameters parameters) throws DataException {
157
                
158
        }
159

    
160
        public void dispose() {
161
                
162
        }
163

    
164
        public String getProviderName() {
165
                return null;
166
        }
167

    
168
        //**********************************************
169
        //Connector
170
        //**********************************************
171
        
172
        /*
173
         * (non-Javadoc)
174
         * @see org.gvsig.fmap.dal.coverage.explorer.WMTSServerExplorer#connect(org.gvsig.compat.net.ICancellable)
175
         */
176
        public void connect(ICancellable cancellable) throws WMTSException {
177
                URL url = null;
178
                boolean override = false;
179
                
180
                try {
181
                        url = new URL(parameters.getHost());
182
                } catch (Exception e) {
183
                        throw new WMTSException("Malformed URL",e);
184
                }
185
        try {
186
                connector = WMTSProvider.getConnectorFromURL(url);
187
                if (!connector.connect(override, cancellable))
188
                        throw new WMTSException("Error connecting");
189
        } catch (IOException e) {
190
                        throw new WMTSException(e.getMessage(), e);
191
                }
192
        }
193

    
194
        /*
195
         * (non-Javadoc)
196
         * @see org.gvsig.fmap.dal.coverage.explorer.WMTSServerExplorer#isConnected()
197
         */
198
        public boolean isConnected() {
199
                if(connector != null)
200
                        return true;
201
                return false;
202
        }
203

    
204
        /*
205
         * (non-Javadoc)
206
         * @see org.gvsig.fmap.dal.coverage.explorer.WMTSServerExplorer#getThemes()
207
         */
208
        public WMTSThemes getThemes() {
209
                return connector.getThemes();
210
        }
211
    
212
    /*
213
     * (non-Javadoc)
214
     * @see org.gvsig.fmap.dal.coverage.explorer.WMTSServerExplorer#getLayer(java.lang.String)
215
     */
216
    public WMTSLayer getLayer(String layerName) {
217
            return connector.getLayer(layerName);
218
    }
219
    
220
    /*
221
     * (non-Javadoc)
222
     * @see org.gvsig.fmap.dal.coverage.explorer.WMTSServerExplorer#getTileMatrixSet()
223
     */
224
        public ArrayList<WMTSTileMatrixSet> getTileMatrixSet() {
225
            return connector.getTileMatrixSet();
226
    }
227
        
228
        /*
229
         * (non-Javadoc)
230
         * @see org.gvsig.fmap.dal.coverage.explorer.WMTSServerExplorer#getServiceIdentification()
231
         */
232
        public WMTSServiceIdentification getServiceIdentification() {
233
                return connector.getServiceIdentification();
234
        }
235
        
236
        /*
237
         * (non-Javadoc)
238
         * @see org.gvsig.fmap.dal.coverage.explorer.WMTSServerExplorer#getServiceProvider()
239
         */
240
        public WMTSServiceProvider getServiceProvider() {
241
                return connector.getServiceProvider();
242
        }
243

    
244
    /*
245
     * (non-Javadoc)
246
     * @see org.gvsig.fmap.dal.coverage.explorer.WMTSServerExplorer#getHost()
247
     */
248
        public String getHost() {
249
                return parameters.getHost();
250
        }
251

    
252
        /*
253
         * (non-Javadoc)
254
         * @see org.gvsig.fmap.dal.spi.DataServerExplorerProvider#getServerExplorerProviderServices()
255
         */
256
        public DataServerExplorerProviderServices getServerExplorerProviderServices() {
257
                return null;
258
        }
259
}