gvsig-raster / org.gvsig.raster.wmts / trunk / org.gvsig.raster.wmts / org.gvsig.raster.wmts.ogc / org.gvsig.raster.wmts.ogc.impl / src / main / java / org / gvsig / raster / wmts / ogc / impl / base / WMTSServiceInformation.java @ 1811
History | View | Annotate | Download (6.77 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.ogc.impl.base; |
29 |
|
30 |
import java.util.HashMap; |
31 |
import java.util.Hashtable; |
32 |
import java.util.Iterator; |
33 |
import java.util.Vector; |
34 |
|
35 |
import org.gvsig.raster.wmts.ogc.impl.Tags; |
36 |
|
37 |
/**
|
38 |
* Class that represents the description of the WMS metadata.
|
39 |
* The first part of the capabilities will return the service information
|
40 |
* from the WMS, this class will hold this information.
|
41 |
*
|
42 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
43 |
*/
|
44 |
public class WMTSServiceInformation { |
45 |
public String online_resource = null; |
46 |
protected HashMap<String, WMTSOperation> |
47 |
operationsGet = new HashMap<String, WMTSOperation>(); |
48 |
protected HashMap<String, WMTSOperation> |
49 |
operationsPost = new HashMap<String, WMTSOperation>(); |
50 |
public String version; |
51 |
public String name; |
52 |
public String scope; |
53 |
public String title; |
54 |
public String abstr; |
55 |
public String keywords; |
56 |
public String fees; |
57 |
public String operationsInfo; |
58 |
public String personname; |
59 |
public String organization; |
60 |
public String function; |
61 |
public String addresstype; |
62 |
public String address; |
63 |
public String place; |
64 |
public String province; |
65 |
public String postcode; |
66 |
public String country; |
67 |
public String phone; |
68 |
public String fax; |
69 |
public String email; |
70 |
public Vector<String> |
71 |
formats; |
72 |
|
73 |
public WMTSServiceInformation() {
|
74 |
version = new String(); |
75 |
name = new String(); |
76 |
scope = new String(); |
77 |
title = new String(); |
78 |
abstr = new String(); |
79 |
keywords = new String(); |
80 |
fees = new String(); |
81 |
operationsInfo = new String(); |
82 |
personname = new String(); |
83 |
organization = new String(); |
84 |
function = new String(); |
85 |
addresstype = new String(); |
86 |
address = new String(); |
87 |
place = new String(); |
88 |
province = new String(); |
89 |
postcode = new String(); |
90 |
country = new String(); |
91 |
phone = new String(); |
92 |
fax = new String(); |
93 |
email = new String(); |
94 |
formats = new Vector<String>(); |
95 |
} |
96 |
|
97 |
/**
|
98 |
* @return Returns the online_resource.
|
99 |
*/
|
100 |
public String getOnline_resource() { |
101 |
return online_resource;
|
102 |
} |
103 |
|
104 |
/**
|
105 |
* Add a new supported operation
|
106 |
* @param operation
|
107 |
* The operation to support
|
108 |
* @param protocol
|
109 |
* The HTTP protocol (Get or Post)
|
110 |
*/
|
111 |
public void addOperation(String operation, int protocol){ |
112 |
if (protocol == Tags.PROTOCOL_GET){
|
113 |
operationsGet.put(operation, createOperation(operation)); |
114 |
}else if (protocol == Tags.PROTOCOL_POST){ |
115 |
operationsPost.put(operation, createOperation(operation)); |
116 |
} |
117 |
} |
118 |
|
119 |
/**
|
120 |
* Add a new supported operation
|
121 |
* @param operation
|
122 |
* The operation to support
|
123 |
* @param protocol
|
124 |
* The HTTP protocol (Get or Post)
|
125 |
* @param onlineResource
|
126 |
* The online resource
|
127 |
*/
|
128 |
public void addOperation(String operation, int protocol, String onlineResource){ |
129 |
if (protocol == Tags.PROTOCOL_GET){
|
130 |
operationsGet.put(operation, createOperation(operation, onlineResource)); |
131 |
}else if (protocol == Tags.PROTOCOL_POST){ |
132 |
operationsPost.put(operation, createOperation(operation, onlineResource)); |
133 |
} |
134 |
} |
135 |
|
136 |
/**
|
137 |
* Gest the online resource for a concrete operation
|
138 |
* @param operation
|
139 |
* The operation
|
140 |
* @param protocol
|
141 |
* The HTTP protocol (Get or Post)
|
142 |
* @return
|
143 |
* The online resource
|
144 |
*/
|
145 |
public String getOnlineResource(String operation, int protocol){ |
146 |
WMTSOperation op = null;
|
147 |
if (protocol == Tags.PROTOCOL_GET){
|
148 |
op = (WMTSOperation)operationsGet.get(operation); |
149 |
}else if (protocol == Tags.PROTOCOL_POST){ |
150 |
op = (WMTSOperation)operationsPost.get(operation); |
151 |
} |
152 |
if ((op == null) || |
153 |
(op.getOnlineResource() == null) ||
|
154 |
(op.getOnlineResource().equals(""))){
|
155 |
return null; |
156 |
} |
157 |
return op.getOnlineResource();
|
158 |
} |
159 |
|
160 |
/**
|
161 |
* Gets the online resource for a concrete operation.
|
162 |
* The default protocol is GET
|
163 |
* @param operation
|
164 |
* The operation
|
165 |
* @return
|
166 |
* The online resource
|
167 |
*/
|
168 |
public String getOnlineResource(String operation){ |
169 |
return getOnlineResource(operation, Tags.PROTOCOL_GET);
|
170 |
} |
171 |
|
172 |
/**
|
173 |
* Get a hash map with the supported operations
|
174 |
* @return
|
175 |
*/
|
176 |
public Hashtable<String, String> getSupportedOperationsByName(){ |
177 |
Hashtable<String, String> operations = new Hashtable<String, String>(); |
178 |
Iterator<String> getIt = operationsGet.keySet().iterator(); |
179 |
while (getIt.hasNext()){
|
180 |
String id = (String)getIt.next(); |
181 |
WMTSOperation operation = (WMTSOperation)operationsGet.get(id); |
182 |
operations.put(operation.getOperationName(), |
183 |
operation.getOnlineResource()); |
184 |
} |
185 |
return operations;
|
186 |
} |
187 |
|
188 |
public boolean isOperationSupported(String operationName){ |
189 |
if (operationsGet.containsKey(operationName)){
|
190 |
return true; |
191 |
} |
192 |
if (operationsPost.containsKey(operationName)){
|
193 |
return true; |
194 |
} |
195 |
return false; |
196 |
} |
197 |
|
198 |
public boolean isQueryable() { |
199 |
if (getOnlineResource(Tags.GETFEATUREINFO) != null) |
200 |
return true; |
201 |
else
|
202 |
return false; |
203 |
} |
204 |
|
205 |
public boolean hasLegendGraphic() { |
206 |
if (getOnlineResource(Tags.GETLEGENDGRAPHIC) != null) |
207 |
return true; |
208 |
else
|
209 |
return false; |
210 |
} |
211 |
|
212 |
public void clear() { |
213 |
version = new String(); |
214 |
name = new String(); |
215 |
scope = new String(); |
216 |
title = new String(); |
217 |
abstr = new String(); |
218 |
keywords = new String(); |
219 |
fees = new String(); |
220 |
operationsInfo = new String(); |
221 |
personname = new String(); |
222 |
organization = new String(); |
223 |
function = new String(); |
224 |
addresstype = new String(); |
225 |
address = new String(); |
226 |
place = new String(); |
227 |
province = new String(); |
228 |
postcode = new String(); |
229 |
country = new String(); |
230 |
phone = new String(); |
231 |
fax = new String(); |
232 |
email = new String(); |
233 |
formats = new Vector<String>(); |
234 |
} |
235 |
|
236 |
public WMTSOperation createOperation(String name) { |
237 |
return new WMTSOperation(name); |
238 |
} |
239 |
|
240 |
public WMTSOperation createOperation(String name, String onlineResource) { |
241 |
return new WMTSOperation(name, onlineResource); |
242 |
} |
243 |
|
244 |
} |
245 |
|