gvsig-raster / org.gvsig.raster / trunk / org.gvsig.raster / org.gvsig.raster.io / org.gvsig.raster.io.base / src / main / java / org / gvsig / fmap / dal / coverage / dataset / io / wmts / WMTSConnector.java @ 212
History | View | Annotate | Download (3.44 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 |
package org.gvsig.fmap.dal.coverage.dataset.io.wmts; |
23 |
|
24 |
import java.io.IOException; |
25 |
import java.net.ConnectException; |
26 |
import java.net.URL; |
27 |
import java.util.ArrayList; |
28 |
import java.util.TreeMap; |
29 |
|
30 |
import org.gvsig.compat.net.ICancellable; |
31 |
import org.gvsig.raster.impl.datastruct.WMSLayerNode; |
32 |
import org.gvsig.remoteclient.wmts.WMTSClient; |
33 |
import org.gvsig.remoteclient.wmts.struct.WMTSLayer; |
34 |
import org.gvsig.remoteclient.wmts.struct.WMTSServiceIdentification; |
35 |
import org.gvsig.remoteclient.wmts.struct.WMTSServiceProvider; |
36 |
import org.gvsig.remoteclient.wmts.struct.WMTSThemes; |
37 |
import org.gvsig.remoteclient.wmts.struct.WMTSTileMatrixSet; |
38 |
|
39 |
/**
|
40 |
* This class offers an interface of services for a WMTS
|
41 |
*
|
42 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
43 |
*/
|
44 |
public class WMTSConnector { |
45 |
private WMTSClient client = null; |
46 |
private TreeMap<String, WMSLayerNode> layers = new TreeMap<String, WMSLayerNode>(); |
47 |
|
48 |
public WMTSConnector(URL url) throws ConnectException, IOException { |
49 |
client = new WMTSClient(url.toString());
|
50 |
} |
51 |
|
52 |
/**
|
53 |
* Establishes the connection.
|
54 |
* @param override, if true the previous downloaded data will be overridden
|
55 |
* @return <b>true</b> if the connection was successful, or <b>false</b> if it was no possible
|
56 |
* to establish the connection for any reason such as version negotiation.
|
57 |
*/
|
58 |
public boolean connect(boolean override, ICancellable cancel) { |
59 |
if (override) {
|
60 |
layers.clear(); |
61 |
} |
62 |
return client.connect(override, cancel);
|
63 |
} |
64 |
|
65 |
public boolean connect(ICancellable cancel) { |
66 |
return client.connect(false, cancel); |
67 |
} |
68 |
|
69 |
/**
|
70 |
* Gets the list of themes
|
71 |
* @return
|
72 |
*/
|
73 |
public WMTSThemes getThemes() {
|
74 |
return client.getThemes();
|
75 |
} |
76 |
|
77 |
/**
|
78 |
* Gets a layer
|
79 |
* @param layerName
|
80 |
* @return
|
81 |
*/
|
82 |
public WMTSLayer getLayer(String layerName) { |
83 |
return client.getLayer(layerName);
|
84 |
} |
85 |
|
86 |
/**
|
87 |
* Gets the set of tiles definition
|
88 |
* @return
|
89 |
*/
|
90 |
@SuppressWarnings("unchecked") |
91 |
public ArrayList<WMTSTileMatrixSet> getTileMatrixSet() { |
92 |
return client.getTileMatrixSet();
|
93 |
} |
94 |
|
95 |
/*
|
96 |
* (non-Javadoc)
|
97 |
* @see org.gvsig.fmap.dal.coverage.explorer.WMTSServerExplorer#getServiceIdentification()
|
98 |
*/
|
99 |
public WMTSServiceIdentification getServiceIdentification() {
|
100 |
return client.getServiceIdentification();
|
101 |
} |
102 |
|
103 |
public WMTSServiceProvider getServiceProvider() {
|
104 |
return client.getServiceProvider();
|
105 |
} |
106 |
|
107 |
/**
|
108 |
* Gets the host
|
109 |
* @return
|
110 |
*/
|
111 |
public String getHost(){ |
112 |
return client.getHost();
|
113 |
} |
114 |
|
115 |
} |