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 @ 1961

History | View | Annotate | Download (5.66 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.List;
33

    
34
import org.gvsig.compat.net.ICancellable;
35
import org.gvsig.fmap.dal.DALLocator;
36
import org.gvsig.fmap.dal.DataManager;
37
import org.gvsig.fmap.dal.DataServerExplorer;
38
import org.gvsig.fmap.dal.DataServerExplorerParameters;
39
import org.gvsig.fmap.dal.DataStoreParameters;
40
import org.gvsig.fmap.dal.NewDataStoreParameters;
41
import org.gvsig.fmap.dal.coverage.store.parameter.TileDataParameters;
42
import org.gvsig.fmap.dal.exception.DataException;
43
import org.gvsig.fmap.dal.exception.InitializeException;
44
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException;
45
import org.gvsig.fmap.dal.spi.DataServerExplorerProvider;
46
import org.gvsig.fmap.dal.spi.DataServerExplorerProviderServices;
47
import org.gvsig.raster.wmts.ogc.exception.WMTSException;
48

    
49
/**
50
 * Explorer for a WMTS server
51
 * @author Nacho Brodin (nachobrodin@gmail.com)
52
 */
53
public class WMTSServerExplorer implements DataServerExplorer, DataServerExplorerProvider {
54
        public static final String           NAME                     = "WMTSRemoteServerExplorer";
55
        private WMTSConnector                connector                = null;
56
        private WMTSServerExplorerParameters parameters               = null;
57
        
58
        public WMTSServerExplorer(
59
                        WMTSServerExplorerParameters parameters,
60
                        DataServerExplorerProviderServices services)
61
                        throws InitializeException {
62
                this.parameters = parameters;
63
        }
64
        
65
        public String getDataStoreProviderName() {
66
                return WMTSProvider.NAME;
67
        }
68
        
69
        public String getDescription() {
70
                return WMTSProvider.DESCRIPTION;
71
        }
72
        
73
        public DataStoreParameters getStoreParameters() {
74
                DataManager manager = DALLocator.getDataManager();
75
                WMTSDataParameters wmtsParams = null;
76
                try {
77
                        wmtsParams = (WMTSDataParameters) manager.createStoreParameters(this.getDataStoreProviderName());
78
                        wmtsParams.setURI(parameters.getHost());
79
                        wmtsParams.setConnector(getConnector());
80

    
81
                        if(WMTSProvider.TILED) {
82
                                TileDataParameters tileParams = (TileDataParameters) manager.createStoreParameters("Tile Store");
83
                                tileParams.setDataParameters(wmtsParams);
84
                                return tileParams;
85
                        } 
86
                } catch (InitializeException e) {
87
                        e.printStackTrace();
88
                } catch (ProviderNotRegisteredException e) {
89
                        e.printStackTrace();
90
                }
91
                return wmtsParams;
92
        }
93

    
94
        public boolean add(String provider, NewDataStoreParameters parameters,
95
                        boolean overwrite) throws DataException {
96
                return false;
97
        }
98

    
99
        public boolean canAdd() {
100
                return false;
101
        }
102

    
103
        public boolean canAdd(String storeName) throws DataException {
104
                return false;
105
        }
106

    
107
        public NewDataStoreParameters getAddParameters(String storeName)
108
                        throws DataException {
109
                return null;
110
        }
111

    
112
        @SuppressWarnings("unchecked")
113
        public List getDataStoreProviderNames() {
114
                return null;
115
        }
116

    
117
        /*
118
         * (non-Javadoc)
119
         * @see org.gvsig.fmap.dal.DataServerExplorer#getParameters()
120
         */
121
        public DataServerExplorerParameters getParameters() {
122
                return parameters;
123
        }
124

    
125
        @SuppressWarnings("unchecked")
126
        public List list() throws DataException {
127
                return null;
128
        }
129

    
130
        @SuppressWarnings("unchecked")
131
        public List list(int mode) throws DataException {
132
                return null;
133
        }
134

    
135
        public void remove(DataStoreParameters parameters) throws DataException {
136
                
137
        }
138

    
139
        public void dispose() {
140
                
141
        }
142

    
143
        public String getProviderName() {
144
                return null;
145
        }
146

    
147
        //**********************************************
148
        //Connector
149
        //**********************************************
150
        
151
        public void connect(ICancellable cancellable) throws WMTSException {
152
                URL url = null;
153
                boolean override = false;
154
                
155
                try {
156
                        url = new URL(parameters.getHost());
157
                } catch (Exception e) {
158
                        throw new WMTSException("Malformed URL",e);
159
                }
160
        try {
161
                connector = new WMTSConnector(url);
162
                connector.setForceLongitudeFirstAxisOrder(parameters.isLongitudeFirst());
163
                if (!connector.connect(override, cancellable))
164
                        throw new WMTSException("Error connecting");
165
        } catch (IOException e) {
166
                        throw new WMTSException(e.getMessage(), e);
167
                }
168
        }
169

    
170
        public boolean isConnected() {
171
                if(connector != null)
172
                        return true;
173
                return false;
174
        }
175
        
176
        public WMTSConnector getConnector() {
177
                return connector;
178
        }
179

    
180
        /*public WMTSThemes getThemes() {
181
                return connector.getThemes();
182
        }
183
    
184
    public WMTSLayer getLayer(String layerName) {
185
            return connector.getLayer(layerName);
186
    }
187
    
188
        public List<WMTSTileMatrixSet> getTileMatrixSet() {
189
            return connector.getTileMatrixSet();
190
    }
191
        
192
        public WMTSServiceIdentification getServiceIdentification() {
193
                return connector.getServiceIdentification();
194
        }
195
        
196
        public WMTSServiceProvider getServiceProvider() {
197
                return connector.getServiceProvider();
198
        }*/
199

    
200
        public String getHost() {
201
                return parameters.getHost();
202
        }
203

    
204
        public DataServerExplorerProviderServices getServerExplorerProviderServices() {
205
                return null;
206
        }
207
}