gvsig-raster / org.gvsig.raster.wcs / trunk / org.gvsig.raster.wcs / org.gvsig.raster.wcs.io / src / main / java / org / gvsig / raster / wcs / io / WCSServerExplorerImpl.java @ 418
History | View | Annotate | Download (7.61 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.wcs.io; |
29 |
|
30 |
import java.awt.geom.Point2D; |
31 |
import java.io.IOException; |
32 |
import java.net.URL; |
33 |
import java.util.Hashtable; |
34 |
import java.util.List; |
35 |
|
36 |
import org.gvsig.compat.net.ICancellable; |
37 |
import org.gvsig.fmap.dal.DALLocator; |
38 |
import org.gvsig.fmap.dal.DataManager; |
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.exception.RemoteServiceException; |
43 |
import org.gvsig.fmap.dal.coverage.explorer.WCSServerExplorer; |
44 |
import org.gvsig.fmap.dal.coverage.explorer.WCSServerExplorerParameters; |
45 |
import org.gvsig.fmap.dal.coverage.store.parameter.WCSDataParameters; |
46 |
import org.gvsig.fmap.dal.coverage.store.remote.RemoteWCSLayerNode; |
47 |
import org.gvsig.fmap.dal.exception.DataException; |
48 |
import org.gvsig.fmap.dal.exception.InitializeException; |
49 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
50 |
import org.gvsig.fmap.dal.spi.DataServerExplorerProvider; |
51 |
import org.gvsig.fmap.dal.spi.DataServerExplorerProviderServices; |
52 |
|
53 |
/**
|
54 |
* Explorer for a WCS server
|
55 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
56 |
*/
|
57 |
public class WCSServerExplorerImpl implements WCSServerExplorer, DataServerExplorerProvider { |
58 |
private WCSConnector connector = null; |
59 |
private WCSServerExplorerParameters parameters = null; |
60 |
|
61 |
public WCSServerExplorerImpl(
|
62 |
WCSServerExplorerParameters parameters, |
63 |
DataServerExplorerProviderServices services) |
64 |
throws InitializeException {
|
65 |
this.parameters = parameters;
|
66 |
} |
67 |
|
68 |
/*
|
69 |
* (non-Javadoc)
|
70 |
* @see org.gvsig.fmap.dal.coverage.store.remote.RemoteServerExplorerProvider#getDataStoreProviderName()
|
71 |
*/
|
72 |
public String getDataStoreProviderName() { |
73 |
return WCSProvider.NAME;
|
74 |
} |
75 |
|
76 |
/*
|
77 |
* (non-Javadoc)
|
78 |
* @see org.gvsig.fmap.dal.coverage.store.remote.RemoteServerExplorerProvider#getDescription()
|
79 |
*/
|
80 |
public String getDescription() { |
81 |
return WCSProvider.DESCRIPTION;
|
82 |
} |
83 |
|
84 |
/*
|
85 |
* (non-Javadoc)
|
86 |
* @see org.gvsig.fmap.dal.coverage.explorer.WMSServerExplorer#getParameters(java.lang.String, int)
|
87 |
*/
|
88 |
public DataStoreParameters getStoreParameters() {
|
89 |
DataManager manager = DALLocator.getDataManager(); |
90 |
WCSDataParameters params = null;
|
91 |
try {
|
92 |
params = (WCSDataParameters) manager |
93 |
.createStoreParameters(this.getDataStoreProviderName());
|
94 |
} catch (InitializeException e) {
|
95 |
e.printStackTrace(); |
96 |
} catch (ProviderNotRegisteredException e) {
|
97 |
e.printStackTrace(); |
98 |
} |
99 |
params.setHost(parameters.getHost()); |
100 |
return params;
|
101 |
} |
102 |
|
103 |
public boolean add(String provider, NewDataStoreParameters parameters, |
104 |
boolean overwrite) throws DataException { |
105 |
return false; |
106 |
} |
107 |
|
108 |
public boolean canAdd() { |
109 |
return false; |
110 |
} |
111 |
|
112 |
public boolean canAdd(String storeName) throws DataException { |
113 |
return false; |
114 |
} |
115 |
|
116 |
public NewDataStoreParameters getAddParameters(String storeName) |
117 |
throws DataException {
|
118 |
return null; |
119 |
} |
120 |
|
121 |
@SuppressWarnings("unchecked") |
122 |
public List getDataStoreProviderNames() { |
123 |
return null; |
124 |
} |
125 |
|
126 |
|
127 |
/*
|
128 |
* (non-Javadoc)
|
129 |
* @see org.gvsig.fmap.dal.DataServerExplorer#getParameters()
|
130 |
*/
|
131 |
public DataServerExplorerParameters getParameters() {
|
132 |
return parameters;
|
133 |
} |
134 |
|
135 |
@SuppressWarnings("unchecked") |
136 |
public List list() throws DataException { |
137 |
return null; |
138 |
} |
139 |
|
140 |
@SuppressWarnings("unchecked") |
141 |
public List list(int mode) throws DataException { |
142 |
return null; |
143 |
} |
144 |
|
145 |
public void remove(DataStoreParameters parameters) throws DataException { |
146 |
|
147 |
} |
148 |
|
149 |
public void dispose() { |
150 |
|
151 |
} |
152 |
|
153 |
public String getProviderName() { |
154 |
return null; |
155 |
} |
156 |
|
157 |
/*
|
158 |
* (non-Javadoc)
|
159 |
* @see org.gvsig.fmap.dal.coverage.explorer.WCSServerExplorer#getOnlineResources()
|
160 |
*/
|
161 |
@SuppressWarnings("unchecked") |
162 |
public Hashtable getOnlineResources() { |
163 |
/*if(connector != null) {
|
164 |
return connector.getOnlineResources();
|
165 |
}*/
|
166 |
return null; |
167 |
} |
168 |
|
169 |
//**********************************************
|
170 |
//Connector
|
171 |
//**********************************************
|
172 |
|
173 |
/*
|
174 |
* (non-Javadoc)
|
175 |
* @see org.gvsig.fmap.dal.coverage.store.remote.RemoteRasterServiceStore#connect(org.gvsig.tools.task.Cancellable)
|
176 |
*/
|
177 |
public void connect(ICancellable cancellable) throws RemoteServiceException { |
178 |
URL url = null; |
179 |
boolean override = false; |
180 |
|
181 |
try {
|
182 |
url = new URL(parameters.getHost()); |
183 |
} catch (Exception e) { |
184 |
throw new RemoteServiceException("Malformed URL",e); |
185 |
} |
186 |
try {
|
187 |
connector = WCSProvider.getConnectorFromURL(url); |
188 |
if (!connector.connect(override, cancellable))
|
189 |
throw new RemoteServiceException("Error connecting"); |
190 |
} catch (IOException e) { |
191 |
throw new RemoteServiceException("Error connecting",e); |
192 |
} |
193 |
|
194 |
} |
195 |
|
196 |
/*
|
197 |
* (non-Javadoc)
|
198 |
* @see org.gvsig.fmap.dal.coverage.explorer.WMSServerExplorer#isConnected()
|
199 |
*/
|
200 |
public boolean isConnected() { |
201 |
if(connector != null) |
202 |
return true; |
203 |
return false; |
204 |
} |
205 |
|
206 |
/*
|
207 |
* (non-Javadoc)
|
208 |
* @see org.gvsig.fmap.dal.coverage.explorer.WMSServerExplorer#getAbstract()
|
209 |
*/
|
210 |
public String getAbstract() { |
211 |
if(connector != null) |
212 |
return connector.getDescription();
|
213 |
return null; |
214 |
} |
215 |
|
216 |
/*
|
217 |
* (non-Javadoc)
|
218 |
* @see org.gvsig.fmap.dal.coverage.explorer.WMSServerExplorer#getServerType()
|
219 |
*/
|
220 |
public String getServerType() { |
221 |
if (getVersion() == null) |
222 |
return "WCS"; |
223 |
return "WCS "+ getVersion(); |
224 |
} |
225 |
|
226 |
/*
|
227 |
* (non-Javadoc)
|
228 |
* @see org.gvsig.fmap.dal.coverage.explorer.WMSServerExplorer#getVersion()
|
229 |
*/
|
230 |
public String getVersion() { |
231 |
if(connector != null) { |
232 |
return (connector.getVersion() == null) ? "" : connector.getVersion(); |
233 |
} |
234 |
return null; |
235 |
} |
236 |
|
237 |
/*
|
238 |
* (non-Javadoc)
|
239 |
* @see org.gvsig.fmap.dal.coverage.explorer.WMSServerExplorer#getHost()
|
240 |
*/
|
241 |
public String getHost() { |
242 |
return parameters.getHost();
|
243 |
} |
244 |
|
245 |
/*
|
246 |
* (non-Javadoc)
|
247 |
* @see org.gvsig.fmap.dal.coverage.explorer.WMSServerExplorer#getTitle()
|
248 |
*/
|
249 |
public String getTitle() { |
250 |
return null; |
251 |
} |
252 |
|
253 |
public DataServerExplorerProviderServices getServerExplorerProviderServices() {
|
254 |
// TODO Auto-generated method stub
|
255 |
return null; |
256 |
} |
257 |
|
258 |
/*
|
259 |
* (non-Javadoc)
|
260 |
* @see org.gvsig.fmap.dal.coverage.explorer.WCSServerExplorer#getMaxResolution(java.lang.String)
|
261 |
*/
|
262 |
public Point2D getMaxResolution(String layerName) { |
263 |
return connector.getMaxResolution(layerName);
|
264 |
} |
265 |
|
266 |
/*
|
267 |
* (non-Javadoc)
|
268 |
* @see org.gvsig.fmap.dal.coverage.explorer.WCSServerExplorer#getCoverageList()
|
269 |
*/
|
270 |
public RemoteWCSLayerNode[] getCoverageList() { |
271 |
return connector.getLayerList();
|
272 |
} |
273 |
|
274 |
/*
|
275 |
* (non-Javadoc)
|
276 |
* @see org.gvsig.fmap.dal.coverage.explorer.WCSServerExplorer#getCoverageByName(java.lang.String)
|
277 |
*/
|
278 |
public RemoteWCSLayerNode getCoverageByName(String name) { |
279 |
RemoteWCSLayerNode[] list = getCoverageList();
|
280 |
for (int i = 0; i < list.length; i++) { |
281 |
if(list[i].getName().compareTo(name) == 0) |
282 |
return list[i];
|
283 |
} |
284 |
return null; |
285 |
} |
286 |
} |