svn-gvsig-desktop / tags / Root_v06 / applications / appCatalogYNomenclatorClient / src / es / gva / cit / gazetteer / wfsg / parsers / WfsgCapabilitiesParser.java @ 4811
History | View | Annotate | Download (5.54 KB)
1 | 3566 | jorpiell | |
---|---|---|---|
2 | 3214 | jorpiell | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
3 | 4488 | jorpiell | *
|
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 | 3214 | jorpiell | 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 | 3613 | jorpiell | import java.util.Vector; |
49 | 3214 | jorpiell | |
50 | /**
|
||
51 | * This class parses a WFs-G getCapabilities file
|
||
52 | *
|
||
53 | 3566 | jorpiell | *
|
54 | 3214 | jorpiell | * @author Jorge Piera Llodra (piera_jor@gva.es)
|
55 | */
|
||
56 | public class WfsgCapabilitiesParser { |
||
57 | 4488 | jorpiell | /**
|
58 | *
|
||
59 | *
|
||
60 | */
|
||
61 | WFSGazetteerServiceDriver driver; |
||
62 | /**
|
||
63 | *
|
||
64 | *
|
||
65 | */
|
||
66 | XMLNode rootNode = null;
|
||
67 | 3566 | jorpiell | |
68 | 4488 | jorpiell | /**
|
69 | *
|
||
70 | *
|
||
71 | *
|
||
72 | * @param driver
|
||
73 | */
|
||
74 | public WfsgCapabilitiesParser(WFSGazetteerServiceDriver driver) {
|
||
75 | this.driver = driver;
|
||
76 | } |
||
77 | 3566 | jorpiell | |
78 | 4488 | jorpiell | /**
|
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 | 3566 | jorpiell | |
92 | |||
93 | 4488 | jorpiell | setRootNode(node); |
94 | 3566 | jorpiell | |
95 | 4488 | jorpiell | driver.setServerAnswerReady(XMLTree.searchNodeValue(node, |
96 | "Service->Title") + "\n" + |
||
97 | XMLTree.searchNodeValue(node,"Service->Abstract"));
|
||
98 | 3566 | jorpiell | |
99 | 4488 | jorpiell | parseGetCapabilities(); |
100 | parseDescribeFeatureType(); |
||
101 | parseGetFeature(); |
||
102 | parseFeatures(); |
||
103 | parseProjection(); |
||
104 | return true; |
||
105 | } |
||
106 | 3566 | jorpiell | |
107 | 4488 | jorpiell | /**
|
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 | 3566 | jorpiell | |
122 | 4488 | jorpiell | /**
|
123 | * It parses the DescribeFeatureType operation options
|
||
124 | *
|
||
125 | */
|
||
126 | public void parseDescribeFeatureType() { |
||
127 | driver.getOperations().setDescribeFeatureType(getOperations("DescribeFeatureType"));
|
||
128 | } |
||
129 | 3566 | jorpiell | |
130 | 4488 | jorpiell | /**
|
131 | * It parses the GetFeature operation options
|
||
132 | *
|
||
133 | */
|
||
134 | public void parseGetFeature() { |
||
135 | driver.getOperations().setGetFeature(getOperations("GetFeature"));
|
||
136 | } |
||
137 | 3566 | jorpiell | |
138 | 4488 | jorpiell | /**
|
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 | } |