svn-gvsig-desktop / trunk / applications / appCatalogYNomenclatorClient / src / es / gva / cit / gazetteer / parsers / wfsg / WfsgCapabilitiesParser.java @ 3081
History | View | Annotate | Download (5.75 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ib??ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
package es.gva.cit.gazetteer.parsers.wfsg; |
42 |
|
43 |
import java.util.Vector; |
44 |
|
45 |
import es.gva.cit.catalogClient.metadataXML.XMLNode; |
46 |
import es.gva.cit.catalogClient.metadataXML.XMLTree; |
47 |
import es.gva.cit.catalogClient.querys.Coordinates; |
48 |
import es.gva.cit.gazetteer.drivers.WFSGazetteerServiceDriver; |
49 |
import es.gva.cit.gazetteer.querys.ThesaurusName; |
50 |
|
51 |
/**
|
52 |
* This class parses a WFs-G getCapabilities file
|
53 |
*
|
54 |
* @author Jorge Piera Llodra (piera_jor@gva.es)
|
55 |
*/
|
56 |
public class WfsgCapabilitiesParser { |
57 |
WFSGazetteerServiceDriver driver; |
58 |
XMLNode rootNode = null;
|
59 |
|
60 |
public WfsgCapabilitiesParser(WFSGazetteerServiceDriver driver) {
|
61 |
this.driver = driver;
|
62 |
} |
63 |
|
64 |
public boolean parse(XMLNode node){ |
65 |
if ((node == null) || !(node.getName().equals("WFS_Capabilities"))){ |
66 |
driver.setServerAnswerReady("El servidor no soporta el protocolo " +
|
67 |
"especificado");
|
68 |
return false; |
69 |
} |
70 |
|
71 |
|
72 |
setRootNode(node); |
73 |
|
74 |
driver.setServerAnswerReady(XMLTree.searchNodeValue(node, |
75 |
"Service->Title") + "\n" + |
76 |
XMLTree.searchNodeValue(node, |
77 |
"Service->Abstract"));
|
78 |
|
79 |
parseGetCapabilities(); |
80 |
parseDescribeFeatureType(); |
81 |
parseGetFeature(); |
82 |
parseFeatures(); |
83 |
|
84 |
return true; |
85 |
} |
86 |
|
87 |
/**
|
88 |
* It parses the getCapabilities operation options
|
89 |
*
|
90 |
*/
|
91 |
public void parseGetCapabilities() { |
92 |
driver.setOperations(new WfsgProtocolsOperations());
|
93 |
driver.getOperations().setGetCapabilities(getOperations("GetCapabilities"));
|
94 |
} |
95 |
|
96 |
/**
|
97 |
* It parses the DescribeFeatureType operation options
|
98 |
*
|
99 |
*/
|
100 |
public void parseDescribeFeatureType(){ |
101 |
driver.getOperations().setDescribeFeatureType(getOperations("DescribeFeatureType"));
|
102 |
} |
103 |
|
104 |
/**
|
105 |
* It parses the GetFeature operation options
|
106 |
*
|
107 |
*/
|
108 |
public void parseGetFeature(){ |
109 |
driver.getOperations().setGetFeature(getOperations("GetFeature"));
|
110 |
} |
111 |
|
112 |
/**
|
113 |
* It parses the Feature Types
|
114 |
*
|
115 |
*/
|
116 |
public void parseFeatures(){ |
117 |
XMLNode[] features = XMLTree.searchMultipleNode(getRootNode(),"FeatureTypeList->FeatureType"); |
118 |
Vector v = new Vector(); |
119 |
for (int i=0 ; i<features.length ; i++){ |
120 |
v.add(parseFeature(features[i])); |
121 |
} |
122 |
driver.setVectorFeatures(v); |
123 |
|
124 |
} |
125 |
|
126 |
/**
|
127 |
* It parses a Feature Node.
|
128 |
* @param featureNode
|
129 |
* @return
|
130 |
*/
|
131 |
public ThesaurusName parseFeature(XMLNode featureNode){
|
132 |
ThesaurusName f = new ThesaurusName();
|
133 |
f.setName(XMLTree.searchNodeValue(featureNode,"Name"));
|
134 |
f.setTitle(XMLTree.searchNodeValue(featureNode,"Title"));
|
135 |
if (f.getTitle() == null) |
136 |
f.setTitle(f.getName()); |
137 |
f.setAbstract(XMLTree.searchNodeValue(featureNode,"Abstract"));
|
138 |
f.setKeywords(XMLTree.searchNodeValue(featureNode,"Keywords"));
|
139 |
f.setSrs(XMLTree.searchNodeValue(featureNode,"SRS"));
|
140 |
f.setCoordinates(new Coordinates(XMLTree.searchNodeAtribute(featureNode,"LatLongBoundingBox","minx"), |
141 |
XMLTree.searchNodeAtribute(featureNode,"LatLongBoundingBox","miny"), |
142 |
XMLTree.searchNodeAtribute(featureNode,"LatLongBoundingBox","maxx"), |
143 |
XMLTree.searchNodeAtribute(featureNode,"LatLongBoundingBox","maxy"))); |
144 |
|
145 |
return f;
|
146 |
} |
147 |
/**
|
148 |
* This function parses the protocols of an operation
|
149 |
* @param operation
|
150 |
* Operation to find the supported protocols
|
151 |
* @return
|
152 |
*/
|
153 |
|
154 |
public String[] getOperations(String operation){ |
155 |
XMLNode[] protocols = XMLTree.searchMultipleNode(getRootNode(),"Capability->Request->" + operation + "->DCPType"); |
156 |
Vector vProtocols = new Vector(); |
157 |
|
158 |
for (int i=0 ; i<protocols.length ; i++){ |
159 |
if (XMLTree.searchNode(protocols[i],"HTTP->Get") != null){ |
160 |
vProtocols.add("GET");
|
161 |
} |
162 |
if (XMLTree.searchNode(protocols[i],"HTTP->Post") != null){ |
163 |
vProtocols.add("POST");
|
164 |
} |
165 |
|
166 |
} |
167 |
|
168 |
String[] sProtocols = new String[vProtocols.size()]; |
169 |
for (int i=0 ; i<vProtocols.size() ; i++){ |
170 |
sProtocols[i] = (String) vProtocols.get(i);
|
171 |
} |
172 |
|
173 |
return sProtocols;
|
174 |
} |
175 |
|
176 |
/**
|
177 |
* @return Returns the rootNode.
|
178 |
*/
|
179 |
public XMLNode getRootNode() {
|
180 |
return rootNode;
|
181 |
} |
182 |
/**
|
183 |
* @param rootNode The rootNode to set.
|
184 |
*/
|
185 |
public void setRootNode(XMLNode rootNode) { |
186 |
this.rootNode = rootNode;
|
187 |
} |
188 |
} |