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 @ 1812
History | View | Annotate | Download (5.83 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 |
import org.gvsig.raster.wmts.ogc.struct.WMTSLayer; |
49 |
import org.gvsig.raster.wmts.ogc.struct.WMTSServiceIdentification; |
50 |
import org.gvsig.raster.wmts.ogc.struct.WMTSServiceProvider; |
51 |
import org.gvsig.raster.wmts.ogc.struct.WMTSThemes; |
52 |
import org.gvsig.raster.wmts.ogc.struct.WMTSTileMatrixSet; |
53 |
|
54 |
/**
|
55 |
* Explorer for a WMTS server
|
56 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
57 |
*/
|
58 |
public class WMTSServerExplorer implements DataServerExplorer, DataServerExplorerProvider { |
59 |
public static final String NAME = "WMTSRemoteServerExplorer"; |
60 |
private WMTSConnector connector = null; |
61 |
private WMTSServerExplorerParameters parameters = null; |
62 |
|
63 |
public WMTSServerExplorer(
|
64 |
WMTSServerExplorerParameters parameters, |
65 |
DataServerExplorerProviderServices services) |
66 |
throws InitializeException {
|
67 |
this.parameters = parameters;
|
68 |
} |
69 |
|
70 |
public String getDataStoreProviderName() { |
71 |
return WMTSProvider.NAME;
|
72 |
} |
73 |
|
74 |
public String getDescription() { |
75 |
return WMTSProvider.DESCRIPTION;
|
76 |
} |
77 |
|
78 |
public DataStoreParameters getStoreParameters() {
|
79 |
DataManager manager = DALLocator.getDataManager(); |
80 |
WMTSDataParameters wmtsParams = null;
|
81 |
try {
|
82 |
wmtsParams = (WMTSDataParameters) manager.createStoreParameters(this.getDataStoreProviderName());
|
83 |
wmtsParams.setURI(parameters.getHost()); |
84 |
|
85 |
if(WMTSProvider.TILED) {
|
86 |
TileDataParameters tileParams = (TileDataParameters) manager.createStoreParameters("Tile Store");
|
87 |
tileParams.setDataParameters(wmtsParams); |
88 |
return tileParams;
|
89 |
} |
90 |
} catch (InitializeException e) {
|
91 |
e.printStackTrace(); |
92 |
} catch (ProviderNotRegisteredException e) {
|
93 |
e.printStackTrace(); |
94 |
} |
95 |
return wmtsParams;
|
96 |
} |
97 |
|
98 |
public boolean add(String provider, NewDataStoreParameters parameters, |
99 |
boolean overwrite) throws DataException { |
100 |
return false; |
101 |
} |
102 |
|
103 |
public boolean canAdd() { |
104 |
return false; |
105 |
} |
106 |
|
107 |
public boolean canAdd(String storeName) throws DataException { |
108 |
return false; |
109 |
} |
110 |
|
111 |
public NewDataStoreParameters getAddParameters(String storeName) |
112 |
throws DataException {
|
113 |
return null; |
114 |
} |
115 |
|
116 |
@SuppressWarnings("unchecked") |
117 |
public List getDataStoreProviderNames() { |
118 |
return null; |
119 |
} |
120 |
|
121 |
/*
|
122 |
* (non-Javadoc)
|
123 |
* @see org.gvsig.fmap.dal.DataServerExplorer#getParameters()
|
124 |
*/
|
125 |
public DataServerExplorerParameters getParameters() {
|
126 |
return parameters;
|
127 |
} |
128 |
|
129 |
@SuppressWarnings("unchecked") |
130 |
public List list() throws DataException { |
131 |
return null; |
132 |
} |
133 |
|
134 |
@SuppressWarnings("unchecked") |
135 |
public List list(int mode) throws DataException { |
136 |
return null; |
137 |
} |
138 |
|
139 |
public void remove(DataStoreParameters parameters) throws DataException { |
140 |
|
141 |
} |
142 |
|
143 |
public void dispose() { |
144 |
|
145 |
} |
146 |
|
147 |
public String getProviderName() { |
148 |
return null; |
149 |
} |
150 |
|
151 |
//**********************************************
|
152 |
//Connector
|
153 |
//**********************************************
|
154 |
|
155 |
public void connect(ICancellable cancellable) throws WMTSException { |
156 |
URL url = null; |
157 |
boolean override = false; |
158 |
|
159 |
try {
|
160 |
url = new URL(parameters.getHost()); |
161 |
} catch (Exception e) { |
162 |
throw new WMTSException("Malformed URL",e); |
163 |
} |
164 |
try {
|
165 |
connector = new WMTSConnector(url);
|
166 |
connector.setForceLongitudeFirstAxisOrder(parameters.isLongitudeFirst()); |
167 |
if (!connector.connect(override, cancellable))
|
168 |
throw new WMTSException("Error connecting"); |
169 |
} catch (IOException e) { |
170 |
throw new WMTSException(e.getMessage(), e); |
171 |
} |
172 |
} |
173 |
|
174 |
public boolean isConnected() { |
175 |
if(connector != null) |
176 |
return true; |
177 |
return false; |
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 |
} |