svn-gvsig-desktop / tags / gvSIGv0_6_1RELEASE / applications / appCatalogYNomenclatorClient / src / es / gva / cit / gazetteer / wfsg / parsers / WfsgCapabilitiesParser.java @ 5222
History | View | Annotate | Download (5.54 KB)
1 |
|
---|---|
2 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
3 |
*
|
4 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
19 |
*
|
20 |
* For more information, contact:
|
21 |
*
|
22 |
* Generalitat Valenciana
|
23 |
* Conselleria d'Infraestructures i Transport
|
24 |
* Av. Blasco Ib??ez, 50
|
25 |
* 46010 VALENCIA
|
26 |
* SPAIN
|
27 |
*
|
28 |
* +34 963862235
|
29 |
* gvsig@gva.es
|
30 |
* www.gvsig.gva.es
|
31 |
*
|
32 |
* or
|
33 |
*
|
34 |
* IVER T.I. S.A
|
35 |
* Salamanca 50
|
36 |
* 46005 Valencia
|
37 |
* Spain
|
38 |
*
|
39 |
* +34 963163400
|
40 |
* dac@iver.es
|
41 |
*/
|
42 |
package es.gva.cit.gazetteer.wfsg.parsers; |
43 |
import es.gva.cit.catalogClient.metadataXML.XMLNode; |
44 |
import es.gva.cit.catalogClient.metadataXML.XMLTree; |
45 |
import es.gva.cit.catalogClient.querys.Coordinates; |
46 |
import es.gva.cit.gazetteer.querys.ThesaurusName; |
47 |
import es.gva.cit.gazetteer.wfsg.drivers.WFSGazetteerServiceDriver; |
48 |
import java.util.Vector; |
49 |
|
50 |
/**
|
51 |
* This class parses a WFs-G getCapabilities file
|
52 |
*
|
53 |
*
|
54 |
* @author Jorge Piera Llodra (piera_jor@gva.es)
|
55 |
*/
|
56 |
public class WfsgCapabilitiesParser { |
57 |
/**
|
58 |
*
|
59 |
*
|
60 |
*/
|
61 |
WFSGazetteerServiceDriver driver; |
62 |
/**
|
63 |
*
|
64 |
*
|
65 |
*/
|
66 |
XMLNode rootNode = null;
|
67 |
|
68 |
/**
|
69 |
*
|
70 |
*
|
71 |
*
|
72 |
* @param driver
|
73 |
*/
|
74 |
public WfsgCapabilitiesParser(WFSGazetteerServiceDriver driver) {
|
75 |
this.driver = driver;
|
76 |
} |
77 |
|
78 |
/**
|
79 |
*
|
80 |
*
|
81 |
*
|
82 |
* @return
|
83 |
* @param node
|
84 |
*/
|
85 |
public boolean parse(XMLNode node) { |
86 |
if ((node == null) || !(node.getName().equals("WFS_Capabilities"))){ |
87 |
driver.setServerAnswerReady("El servidor no soporta el protocolo " +
|
88 |
"especificado");
|
89 |
return false; |
90 |
} |
91 |
|
92 |
|
93 |
setRootNode(node); |
94 |
|
95 |
driver.setServerAnswerReady(XMLTree.searchNodeValue(node, |
96 |
"Service->Title") + "\n" + |
97 |
XMLTree.searchNodeValue(node,"Service->Abstract"));
|
98 |
|
99 |
parseGetCapabilities(); |
100 |
parseDescribeFeatureType(); |
101 |
parseGetFeature(); |
102 |
parseFeatures(); |
103 |
parseProjection(); |
104 |
return true; |
105 |
} |
106 |
|
107 |
/**
|
108 |
* Parses the server projection
|
109 |
*/
|
110 |
public void parseProjection(){ |
111 |
driver.setProjection(XMLTree.searchNodeValue(getRootNode(),"FeatureTypeList->FeatureType->SRS"));
|
112 |
} |
113 |
/**
|
114 |
* It parses the getCapabilities operation options
|
115 |
*
|
116 |
*/
|
117 |
public void parseGetCapabilities() { |
118 |
driver.setOperations(new WfsgProtocolsOperations());
|
119 |
driver.getOperations().setGetCapabilities(getOperations("GetCapabilities"));
|
120 |
} |
121 |
|
122 |
/**
|
123 |
* It parses the DescribeFeatureType operation options
|
124 |
*
|
125 |
*/
|
126 |
public void parseDescribeFeatureType() { |
127 |
driver.getOperations().setDescribeFeatureType(getOperations("DescribeFeatureType"));
|
128 |
} |
129 |
|
130 |
/**
|
131 |
* It parses the GetFeature operation options
|
132 |
*
|
133 |
*/
|
134 |
public void parseGetFeature() { |
135 |
driver.getOperations().setGetFeature(getOperations("GetFeature"));
|
136 |
} |
137 |
|
138 |
/**
|
139 |
* It parses the Feature Types
|
140 |
*
|
141 |
*/
|
142 |
public void parseFeatures() { |
143 |
XMLNode[] features = XMLTree.searchMultipleNode(getRootNode(),"FeatureTypeList->FeatureType"); |
144 |
Vector v = new Vector(); |
145 |
for (int i=0 ; i<features.length ; i++){ |
146 |
v.add(parseFeature(features[i])); |
147 |
} |
148 |
driver.setVectorFeatures(v); |
149 |
|
150 |
} |
151 |
|
152 |
/**
|
153 |
* It parses a Feature Node.
|
154 |
*
|
155 |
*
|
156 |
* @return
|
157 |
* @param featureNode
|
158 |
*/
|
159 |
public ThesaurusName parseFeature(XMLNode featureNode) {
|
160 |
ThesaurusName f = new ThesaurusName();
|
161 |
f.setName(XMLTree.searchNodeValue(featureNode,"Name"));
|
162 |
f.setTitle(XMLTree.searchNodeValue(featureNode,"Title"));
|
163 |
if (f.getTitle() == null) |
164 |
f.setTitle(f.getName()); |
165 |
f.setAbstract(XMLTree.searchNodeValue(featureNode,"Abstract"));
|
166 |
f.setKeywords(XMLTree.searchNodeValue(featureNode,"Keywords"));
|
167 |
f.setSrs(XMLTree.searchNodeValue(featureNode,"SRS"));
|
168 |
f.setCoordinates(new Coordinates(XMLTree.searchNodeAtribute(featureNode,"LatLongBoundingBox","minx"), |
169 |
XMLTree.searchNodeAtribute(featureNode,"LatLongBoundingBox","miny"), |
170 |
XMLTree.searchNodeAtribute(featureNode,"LatLongBoundingBox","maxx"), |
171 |
XMLTree.searchNodeAtribute(featureNode,"LatLongBoundingBox","maxy"))); |
172 |
|
173 |
return f;
|
174 |
} |
175 |
|
176 |
/**
|
177 |
* This function parses the protocols of an operation
|
178 |
*
|
179 |
*
|
180 |
* @return
|
181 |
* @param operation Operation to find the supported protocols
|
182 |
*/
|
183 |
public String[] getOperations(String operation) { |
184 |
XMLNode[] protocols = XMLTree.searchMultipleNode(getRootNode(),"Capability->Request->" + operation + "->DCPType"); |
185 |
Vector vProtocols = new Vector(); |
186 |
|
187 |
for (int i=0 ; i<protocols.length ; i++){ |
188 |
if (XMLTree.searchNode(protocols[i],"HTTP->Get") != null){ |
189 |
vProtocols.add("GET");
|
190 |
} |
191 |
if (XMLTree.searchNode(protocols[i],"HTTP->Post") != null){ |
192 |
vProtocols.add("POST");
|
193 |
} |
194 |
|
195 |
} |
196 |
|
197 |
String[] sProtocols = new String[vProtocols.size()]; |
198 |
for (int i=0 ; i<vProtocols.size() ; i++){ |
199 |
sProtocols[i] = (String) vProtocols.get(i);
|
200 |
} |
201 |
|
202 |
return sProtocols;
|
203 |
} |
204 |
|
205 |
/**
|
206 |
*
|
207 |
*
|
208 |
*
|
209 |
* @return Returns the rootNode.
|
210 |
*/
|
211 |
public XMLNode getRootNode() {
|
212 |
return rootNode;
|
213 |
} |
214 |
|
215 |
/**
|
216 |
*
|
217 |
*
|
218 |
*
|
219 |
* @param rootNode The rootNode to set.
|
220 |
*/
|
221 |
public void setRootNode(XMLNode rootNode) { |
222 |
this.rootNode = rootNode;
|
223 |
} |
224 |
} |