Revision 18851
branches/v10/applications/appCatalogAndGazetteerClient/.classpath | ||
---|---|---|
30 | 30 |
<classpathentry kind="lib" path="/libFMap/lib/kxml2.jar"/> |
31 | 31 |
<classpathentry kind="lib" path="/libFMap/lib/jtsio-1.7.jar"/> |
32 | 32 |
<classpathentry kind="lib" path="/libFMap/lib/jts-1.7.jar"/> |
33 |
<classpathentry kind="lib" path="/extGPE-gvSIG/lib/org.gvsig.gpe.jar"/> |
|
34 |
<classpathentry kind="lib" path="/extGPE-gvSIG/lib/gvsig-exceptions.jar"/> |
|
35 |
<classpathentry kind="lib" path="/extGPE-gvSIG/lib/org.gvsig.gpe.gml.jar"/> |
|
33 | 36 |
<classpathentry kind="output" path="bin"/> |
34 | 37 |
</classpath> |
branches/v10/applications/appCatalogAndGazetteerClient/src/es/gva/cit/gazetteer/wfsg/drivers/WFSGServiceDriver.java | ||
---|---|---|
1 | 1 |
package es.gva.cit.gazetteer.wfsg.drivers; |
2 | 2 |
|
3 |
import java.io.File; |
|
4 |
import java.io.IOException; |
|
5 |
import java.net.ConnectException; |
|
3 | 6 |
import java.net.MalformedURLException; |
4 | 7 |
import java.net.URI; |
5 | 8 |
import java.net.URL; |
9 |
import java.net.UnknownHostException; |
|
6 | 10 |
import java.util.Collection; |
7 | 11 |
|
12 |
import org.gvsig.i18n.Messages; |
|
8 | 13 |
import org.gvsig.remoteClient.gml.exceptions.GMLException; |
14 |
import org.gvsig.remoteClient.utils.Utilities; |
|
9 | 15 |
|
10 | 16 |
import com.iver.utiles.swing.jcomboServer.ServerData; |
11 | 17 |
|
... | ... | |
94 | 100 |
WFSGMessages.getHTTPPOSTCapabilities(), 0); |
95 | 101 |
|
96 | 102 |
GazetteerCapabilities capabilities = new GazetteerCapabilities(); |
97 |
capabilities.setFeatureTypes(new WfsgCapabilitiesParser(this).parse((XMLNode)nodes.toArray()[0])); |
|
103 |
if (nodes != null){ |
|
104 |
capabilities.setFeatureTypes(new WfsgCapabilitiesParser(this).parse((XMLNode)nodes.toArray()[0])); |
|
105 |
}else{ |
|
106 |
capabilities.setAvailable(false); |
|
107 |
capabilities.setServerMessage(Messages.getText("errorNotParsedReply")); |
|
108 |
} |
|
98 | 109 |
return capabilities; |
99 | 110 |
} |
100 | 111 |
|
... | ... | |
110 | 121 |
setServerAnswerReady("errorServerNotFound"); |
111 | 122 |
return null; |
112 | 123 |
} |
113 |
query.setFieldAttribute("geographicIdentifier"); |
|
114 |
Collection nodes = new HTTPPostProtocol().doQuery(url,
|
|
115 |
WFSGMessages.getHTTPPOSTFeature(query,0),
|
|
116 |
0);
|
|
117 |
|
|
118 |
return new WfsgFeatureParser().parse((XMLNode)nodes.toArray()[0]);
|
|
119 |
|
|
124 |
query.setFieldAttribute("geographicIdentifier");
|
|
125 |
try {
|
|
126 |
File file = Utilities.downloadFile(url, WFSGMessages.getHTTPPOSTFeature(query,0), "wfsg_getFeature.xml", null);
|
|
127 |
return parseOutputFile(file,query.getFieldAttribute());
|
|
128 |
} catch (Exception e) { |
|
129 |
throw new GMLException(e);
|
|
130 |
} |
|
120 | 131 |
} |
121 | 132 |
|
122 | 133 |
/* |
branches/v10/applications/appCatalogAndGazetteerClient/src/es/gva/cit/gazetteer/wfs/drivers/WFSGPEErrorHandler.java | ||
---|---|---|
1 |
package es.gva.cit.gazetteer.wfs.drivers; |
|
2 |
|
|
3 |
import org.gvsig.gpe.GPEErrorHandler; |
|
4 |
|
|
5 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
6 |
* |
|
7 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
8 |
* |
|
9 |
* This program is free software; you can redistribute it and/or |
|
10 |
* modify it under the terms of the GNU General Public License |
|
11 |
* as published by the Free Software Foundation; either version 2 |
|
12 |
* of the License, or (at your option) any later version. |
|
13 |
* |
|
14 |
* This program is distributed in the hope that it will be useful, |
|
15 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
17 |
* GNU General Public License for more details. |
|
18 |
* |
|
19 |
* You should have received a copy of the GNU General Public License |
|
20 |
* along with this program; if not, write to the Free Software |
|
21 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
22 |
* |
|
23 |
* For more information, contact: |
|
24 |
* |
|
25 |
* Generalitat Valenciana |
|
26 |
* Conselleria d'Infraestructures i Transport |
|
27 |
* Av. Blasco Ib??ez, 50 |
|
28 |
* 46010 VALENCIA |
|
29 |
* SPAIN |
|
30 |
* |
|
31 |
* +34 963862235 |
|
32 |
* gvsig@gva.es |
|
33 |
* www.gvsig.gva.es |
|
34 |
* |
|
35 |
* or |
|
36 |
* |
|
37 |
* IVER T.I. S.A |
|
38 |
* Salamanca 50 |
|
39 |
* 46005 Valencia |
|
40 |
* Spain |
|
41 |
* |
|
42 |
* +34 963163400 |
|
43 |
* dac@iver.es |
|
44 |
*/ |
|
45 |
/* CVS MESSAGES: |
|
46 |
* |
|
47 |
* $Id$ |
|
48 |
* $Log$ |
|
49 |
* |
|
50 |
*/ |
|
51 |
/** |
|
52 |
* @author Jorge Piera Llodr? (jorge.piera@iver.es) |
|
53 |
*/ |
|
54 |
public class WFSGPEErrorHandler extends GPEErrorHandler{ |
|
55 |
|
|
56 |
} |
branches/v10/applications/appCatalogAndGazetteerClient/src/es/gva/cit/gazetteer/wfs/drivers/WFSGPEContentHandler.java | ||
---|---|---|
1 |
package es.gva.cit.gazetteer.wfs.drivers; |
|
2 |
|
|
3 |
import java.awt.geom.Point2D; |
|
4 |
import java.util.ArrayList; |
|
5 |
|
|
6 |
import org.gvsig.gpe.GPEContentHandler; |
|
7 |
|
|
8 |
import es.gva.cit.gazetteer.querys.Feature; |
|
9 |
|
|
10 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
11 |
* |
|
12 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
13 |
* |
|
14 |
* This program is free software; you can redistribute it and/or |
|
15 |
* modify it under the terms of the GNU General Public License |
|
16 |
* as published by the Free Software Foundation; either version 2 |
|
17 |
* of the License, or (at your option) any later version. |
|
18 |
* |
|
19 |
* This program is distributed in the hope that it will be useful, |
|
20 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
21 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
22 |
* GNU General Public License for more details. |
|
23 |
* |
|
24 |
* You should have received a copy of the GNU General Public License |
|
25 |
* along with this program; if not, write to the Free Software |
|
26 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
27 |
* |
|
28 |
* For more information, contact: |
|
29 |
* |
|
30 |
* Generalitat Valenciana |
|
31 |
* Conselleria d'Infraestructures i Transport |
|
32 |
* Av. Blasco Ib??ez, 50 |
|
33 |
* 46010 VALENCIA |
|
34 |
* SPAIN |
|
35 |
* |
|
36 |
* +34 963862235 |
|
37 |
* gvsig@gva.es |
|
38 |
* www.gvsig.gva.es |
|
39 |
* |
|
40 |
* or |
|
41 |
* |
|
42 |
* IVER T.I. S.A |
|
43 |
* Salamanca 50 |
|
44 |
* 46005 Valencia |
|
45 |
* Spain |
|
46 |
* |
|
47 |
* +34 963163400 |
|
48 |
* dac@iver.es |
|
49 |
*/ |
|
50 |
/* CVS MESSAGES: |
|
51 |
* |
|
52 |
* $Id$ |
|
53 |
* $Log$ |
|
54 |
* |
|
55 |
*/ |
|
56 |
/** |
|
57 |
* ContentHandler for the WFS |
|
58 |
* @author Jorge Piera Llodr? (jorge.piera@iver.es) |
|
59 |
*/ |
|
60 |
public class WFSGPEContentHandler extends GPEContentHandler{ |
|
61 |
private ArrayList features = null; |
|
62 |
private String searchField = null; |
|
63 |
|
|
64 |
public WFSGPEContentHandler(String searchField) { |
|
65 |
super(); |
|
66 |
this.searchField = searchField; |
|
67 |
features = new ArrayList(); |
|
68 |
} |
|
69 |
|
|
70 |
/* |
|
71 |
* (non-Javadoc) |
|
72 |
* @see org.gvsig.gpe.GPEContentHandler#addElementToFeature(java.lang.Object, java.lang.Object) |
|
73 |
*/ |
|
74 |
public void addElementToFeature(Object element, Object feature) { |
|
75 |
if ((element != null) && (((Element)element).getName().equals(searchField))){ |
|
76 |
((Feature)feature).setName(String.valueOf(((Element)element).getValue())); |
|
77 |
((Feature)feature).setDescription(String.valueOf(((Element)element).getValue())); |
|
78 |
} |
|
79 |
} |
|
80 |
|
|
81 |
/* |
|
82 |
* (non-Javadoc) |
|
83 |
* @see org.gvsig.gpe.GPEContentHandler#addGeometryToFeature(java.lang.Object, java.lang.Object) |
|
84 |
*/ |
|
85 |
public void addGeometryToFeature(Object geometry, Object feature) { |
|
86 |
((Feature)feature).setCoordinates((Point2D)geometry); |
|
87 |
} |
|
88 |
|
|
89 |
/* |
|
90 |
* (non-Javadoc) |
|
91 |
* @see org.gvsig.gpe.GPEContentHandler#endFeature(java.lang.Object) |
|
92 |
*/ |
|
93 |
public void endFeature(Object feature) { |
|
94 |
features.add(feature); |
|
95 |
} |
|
96 |
|
|
97 |
/* |
|
98 |
* (non-Javadoc) |
|
99 |
* @see org.gvsig.gpe.GPEContentHandler#startElement(java.lang.String, java.lang.Object, java.lang.String, java.lang.Object) |
|
100 |
*/ |
|
101 |
public Object startElement(String name, Object value, String xsElementName, |
|
102 |
Object parentElement) { |
|
103 |
return new Element(name, value); |
|
104 |
} |
|
105 |
|
|
106 |
/* |
|
107 |
* (non-Javadoc) |
|
108 |
* @see org.gvsig.gpe.GPEContentHandler#startFeature(java.lang.String, java.lang.String, java.lang.String, java.lang.Object) |
|
109 |
*/ |
|
110 |
public Object startFeature(String id, String name, String xsElementName, |
|
111 |
Object layer) { |
|
112 |
return new Feature(id, name, name, null); |
|
113 |
} |
|
114 |
|
|
115 |
/* |
|
116 |
* (non-Javadoc) |
|
117 |
* @see org.gvsig.gpe.GPEContentHandler#startPoint(java.lang.String, double, double, double, java.lang.String) |
|
118 |
*/ |
|
119 |
public Object startPoint(String id, double x, double y, double z, String srs) { |
|
120 |
return new Point2D.Double(x, y); |
|
121 |
} |
|
122 |
|
|
123 |
/* (non-Javadoc) |
|
124 |
* @see org.gvsig.gpe.GPEContentHandler#startLineString(java.lang.String, double[], double[], double[], java.lang.String) |
|
125 |
*/ |
|
126 |
public Object startLineString(String id, double[] x, double[] y, |
|
127 |
double[] z, String srs) { |
|
128 |
return getPoint(x, y); |
|
129 |
} |
|
130 |
|
|
131 |
/* (non-Javadoc) |
|
132 |
* @see org.gvsig.gpe.GPEContentHandler#startPolygon(java.lang.String, double[], double[], double[], java.lang.String) |
|
133 |
*/ |
|
134 |
public Object startPolygon(String id, double[] x, double[] y, double[] z, |
|
135 |
String srs) { |
|
136 |
return getPoint(x, y); |
|
137 |
} |
|
138 |
|
|
139 |
private Point2D getPoint(double[] x, double y[]) { |
|
140 |
double xs = 0.0; |
|
141 |
double ys = 0.0; |
|
142 |
for (int i=0 ; i<x.length ; i++){ |
|
143 |
xs = xs + x[i]; |
|
144 |
ys = ys + y[i]; |
|
145 |
} |
|
146 |
if (x.length == 0){ |
|
147 |
return new Point2D.Double(xs,ys); |
|
148 |
}else{ |
|
149 |
return new Point2D.Double(xs/x.length,ys/x.length); |
|
150 |
} |
|
151 |
} |
|
152 |
|
|
153 |
/** |
|
154 |
* @author Jorge Piera Llodr? (jorge.piera@iver.es) |
|
155 |
*/ |
|
156 |
private class Element{ |
|
157 |
private String name = null; |
|
158 |
private Object value = null; |
|
159 |
|
|
160 |
public Element(String name, Object value) { |
|
161 |
super(); |
|
162 |
this.name = name; |
|
163 |
this.value = value; |
|
164 |
} |
|
165 |
|
|
166 |
/** |
|
167 |
* @return the name |
|
168 |
*/ |
|
169 |
public String getName() { |
|
170 |
return name; |
|
171 |
} |
|
172 |
|
|
173 |
/** |
|
174 |
* @param name the name to set |
|
175 |
*/ |
|
176 |
public void setName(String name) { |
|
177 |
this.name = name; |
|
178 |
} |
|
179 |
|
|
180 |
/** |
|
181 |
* @return the value |
|
182 |
*/ |
|
183 |
public Object getValue() { |
|
184 |
return value; |
|
185 |
} |
|
186 |
|
|
187 |
/** |
|
188 |
* @param value the value to set |
|
189 |
*/ |
|
190 |
public void setValue(Object value) { |
|
191 |
this.value = value; |
|
192 |
} |
|
193 |
} |
|
194 |
|
|
195 |
/** |
|
196 |
* @return the features |
|
197 |
*/ |
|
198 |
public ArrayList getFeatures() { |
|
199 |
return features; |
|
200 |
} |
|
201 |
|
|
202 |
} |
branches/v10/applications/appCatalogAndGazetteerClient/src/es/gva/cit/gazetteer/wfs/drivers/WFSServiceDriver.java | ||
---|---|---|
43 | 43 |
import java.io.File; |
44 | 44 |
import java.net.MalformedURLException; |
45 | 45 |
import java.net.URI; |
46 |
import java.net.URISyntaxException; |
|
46 | 47 |
import java.util.ArrayList; |
47 | 48 |
import java.util.Hashtable; |
48 | 49 |
import java.util.Iterator; |
49 | 50 |
import java.util.Vector; |
50 | 51 |
|
52 |
import org.gvsig.gpe.GPEParser; |
|
53 |
import org.gvsig.gpe.GPERegister; |
|
54 |
import org.gvsig.gpe.exceptions.GPEParserCreationException; |
|
55 |
import org.gvsig.gpe.gml.GPEGmlSFP0Parser; |
|
56 |
import org.gvsig.gpe.writers.GPEGeometryWithIdTest; |
|
51 | 57 |
import org.gvsig.remoteClient.gml.GMLReader; |
52 | 58 |
import org.gvsig.remoteClient.gml.IGMLFeaturesIterator; |
53 | 59 |
import org.gvsig.remoteClient.gml.exceptions.GMLException; |
... | ... | |
190 | 196 |
File file = client.getFeature(status, false, null); |
191 | 197 |
return parseOutputFile(file,query.getFieldAttribute()); |
192 | 198 |
}catch(Exception e){ |
199 |
e.printStackTrace(); |
|
193 | 200 |
return new Feature[0]; |
194 | 201 |
} |
195 | 202 |
} |
... | ... | |
198 | 205 |
* Parses the GML file |
199 | 206 |
* @param file |
200 | 207 |
* @return |
201 |
* @throws GMLException |
|
208 |
* @throws GPEParserCreationException |
|
209 |
* @throws URISyntaxException |
|
202 | 210 |
*/ |
203 |
protected Feature[] parseOutputFile(File file, String fieldAttribute) throws GMLException{ |
|
204 |
GMLReader reader = new GMLReader(file,new GazetteerGeometriesFactory(fieldAttribute)); |
|
205 |
IGMLFeaturesIterator it = reader.getFeaturesIterator(); |
|
206 |
ArrayList features = new ArrayList(); |
|
207 |
while (it.hasNext()){ |
|
208 |
Object feature = it.next(); |
|
209 |
if (feature != null){ |
|
210 |
features.add(feature); |
|
211 |
} |
|
212 |
} |
|
211 |
protected Feature[] parseOutputFile(File file, String fieldAttribute) throws URISyntaxException, GPEParserCreationException { |
|
212 |
URI uri = file.toURI(); |
|
213 |
GPEParser parser = new GPEGmlSFP0Parser(null,null); |
|
214 |
WFSGPEErrorHandler errorHandler = new WFSGPEErrorHandler(); |
|
215 |
WFSGPEContentHandler contentHandler = new WFSGPEContentHandler(fieldAttribute); |
|
216 |
parser.parse(contentHandler, errorHandler, uri); |
|
217 |
ArrayList features = contentHandler.getFeatures(); |
|
213 | 218 |
Feature[] auxFeatures = new Feature[features.size()]; |
214 | 219 |
for (int i=0 ; i<features.size() ; i++){ |
215 | 220 |
auxFeatures[i] = (Feature)features.get(i); |
branches/v10/applications/appCatalogAndGazetteerClient/src/es/gva/cit/gazetteer/adl/protocols/ADLThesaurus.java | ||
---|---|---|
79 | 79 |
return; |
80 | 80 |
} |
81 | 81 |
Collection nodes = new HTTPGetProtocol().doQuery(urlNarrower, getNarrowerParams(), 0); |
82 |
parseGetNarrowAnswer((XMLNode)nodes.toArray()[0]); |
|
82 |
if (nodes != null){ |
|
83 |
parseGetNarrowAnswer((XMLNode)nodes.toArray()[0]); |
|
84 |
}else{ |
|
85 |
setFeatures(new FeatureType[0]); |
|
86 |
} |
|
83 | 87 |
} |
84 | 88 |
|
85 | 89 |
/** |
branches/v10/applications/appCatalogAndGazetteerClient/src/es/gva/cit/gazetteer/adl/drivers/ADLGazetteerServiceDriver.java | ||
---|---|---|
45 | 45 |
import java.net.URL; |
46 | 46 |
import java.util.Collection; |
47 | 47 |
|
48 |
import org.gvsig.i18n.Messages; |
|
49 |
|
|
48 | 50 |
import com.iver.utiles.swing.jcomboServer.ServerData; |
49 | 51 |
|
50 | 52 |
import es.gva.cit.catalog.drivers.DiscoveryServiceCapabilities; |
... | ... | |
73 | 75 |
public DiscoveryServiceCapabilities getCapabilities(URI uri) { |
74 | 76 |
GazetteerCapabilities capabilities = new GazetteerCapabilities(); |
75 | 77 |
Collection nodes = new java.util.ArrayList(); |
76 |
URL url = null; |
|
77 |
try { |
|
78 |
url = uri.toURL(); |
|
79 |
} catch (MalformedURLException e) { |
|
80 |
capabilities.setServerMessage("errorServerNotFound"); |
|
81 |
capabilities.setAvailable(false); |
|
82 |
return capabilities; |
|
83 |
} |
|
78 |
URL url = null; |
|
84 | 79 |
try { |
80 |
url = uri.toURL(); |
|
81 |
} catch (MalformedURLException e) { |
|
82 |
capabilities.setServerMessage("errorServerNotFound"); |
|
83 |
capabilities.setAvailable(false); |
|
84 |
return capabilities; |
|
85 |
} |
|
86 |
try { |
|
85 | 87 |
nodes = new HTTPPostProtocol().doQuery(uri.toURL(), |
86 | 88 |
getPOSTMessageCapabilities(), 0); |
87 | 89 |
} catch (MalformedURLException e) { |
... | ... | |
89 | 91 |
capabilities.setAvailable(false); |
90 | 92 |
return capabilities; |
91 | 93 |
} |
92 |
new AdlCapabilitiesParser(this).parse((XMLNode)nodes.toArray()[0]); |
|
93 |
capabilities.setFeatureTypes(getFeatureTypes()); |
|
94 |
capabilities.setServerMessage(getServerAnswerReady()); |
|
94 |
if (nodes != null){ |
|
95 |
new AdlCapabilitiesParser(this).parse((XMLNode)nodes.toArray()[0]); |
|
96 |
capabilities.setFeatureTypes(getFeatureTypes()); |
|
97 |
capabilities.setServerMessage(getServerAnswerReady()); |
|
98 |
}else{ |
|
99 |
capabilities.setAvailable(false); |
|
100 |
capabilities.setServerMessage(Messages.getText("errorNotParsedReply")); |
|
101 |
} |
|
95 | 102 |
return capabilities; |
96 | 103 |
} |
97 |
|
|
104 |
|
|
98 | 105 |
/** |
99 | 106 |
* It creates the XML for the getCapabilities request |
100 | 107 |
* @return Name-value pair with a XML request |
... | ... | |
107 | 114 |
"<get-capabilities-request/>" + |
108 | 115 |
"</gazetteer-service>"; |
109 | 116 |
} |
110 |
|
|
117 |
|
|
111 | 118 |
/* |
112 | 119 |
* (non-Javadoc) |
113 | 120 |
* @see es.gva.cit.gazetteer.drivers.IGazetteerServiceDriver#getFeature(java.net.URI, es.gva.cit.gazetteer.querys.Query) |
... | ... | |
152 | 159 |
new ADLFilter(withAccents).getQuery(query) + |
153 | 160 |
"</gazetteer-service>" ; |
154 | 161 |
} |
155 |
|
|
162 |
|
|
156 | 163 |
/* |
157 | 164 |
* (non-Javadoc) |
158 | 165 |
* @see es.gva.cit.gazetteer.drivers.IGazetteerServiceDriver#isProtocolSupported(java.net.URI) |
Also available in: Unified diff