Revision 28330
branches/v2_0_0_prep/applications/appCatalogClient/src/es/gva/cit/catalog/csw/drivers/CSWISO19115CatalogServiceDriver.java | ||
---|---|---|
1 |
package es.gva.cit.catalog.csw.drivers; |
|
2 |
|
|
3 |
import java.net.MalformedURLException; |
|
4 |
import java.net.URI; |
|
5 |
import java.net.URL; |
|
6 |
import java.util.Collection; |
|
7 |
|
|
8 |
import es.gva.cit.catalog.csw.drivers.profiles.CSWISO19115Profile; |
|
9 |
import es.gva.cit.catalog.csw.drivers.profiles.CSWAbstractProfile; |
|
10 |
import es.gva.cit.catalog.csw.drivers.profiles.CSWebRIMProfile; |
|
11 |
import es.gva.cit.catalog.csw.parsers.CSWConstants; |
|
12 |
import es.gva.cit.catalog.drivers.GetRecordsReply; |
|
13 |
import es.gva.cit.catalog.drivers.profiles.IProfile; |
|
14 |
import es.gva.cit.catalog.metadataxml.XMLNode; |
|
15 |
import es.gva.cit.catalog.metadataxml.XMLTree; |
|
16 |
import es.gva.cit.catalog.protocols.HTTPPostProtocol; |
|
17 |
import es.gva.cit.catalog.querys.CatalogQuery; |
|
18 |
|
|
19 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
20 |
* |
|
21 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
22 |
* |
|
23 |
* This program is free software; you can redistribute it and/or |
|
24 |
* modify it under the terms of the GNU General Public License |
|
25 |
* as published by the Free Software Foundation; either version 2 |
|
26 |
* of the License, or (at your option) any later version. |
|
27 |
* |
|
28 |
* This program is distributed in the hope that it will be useful, |
|
29 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
30 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
31 |
* GNU General Public License for more details. |
|
32 |
* |
|
33 |
* You should have received a copy of the GNU General Public License |
|
34 |
* along with this program; if not, write to the Free Software |
|
35 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
36 |
* |
|
37 |
* For more information, contact: |
|
38 |
* |
|
39 |
* Generalitat Valenciana |
|
40 |
* Conselleria d'Infraestructures i Transport |
|
41 |
* Av. Blasco Ib??ez, 50 |
|
42 |
* 46010 VALENCIA |
|
43 |
* SPAIN |
|
44 |
* |
|
45 |
* +34 963862235 |
|
46 |
* gvsig@gva.es |
|
47 |
* www.gvsig.gva.es |
|
48 |
* |
|
49 |
* or |
|
50 |
* |
|
51 |
* IVER T.I. S.A |
|
52 |
* Salamanca 50 |
|
53 |
* 46005 Valencia |
|
54 |
* Spain |
|
55 |
* |
|
56 |
* +34 963163400 |
|
57 |
* dac@iver.es |
|
58 |
*/ |
|
59 |
/* CVS MESSAGES: |
|
60 |
* |
|
61 |
* $Id$ |
|
62 |
* $Log$ |
|
63 |
* |
|
64 |
*/ |
|
65 |
/** |
|
66 |
* @author Jorge Piera LLodr? (jorge.piera@iver.es) |
|
67 |
*/ |
|
68 |
public class CSWISO19115CatalogServiceDriver extends CSWCatalogServiceDriver{ |
|
69 |
public static String SERVICE_NAME = "CSW/ISO 19115"; |
|
70 |
|
|
71 |
/* |
|
72 |
* (non-Javadoc) |
|
73 |
* @see es.gva.cit.catalogClient.drivers.ICatalogServiceDriver#getServiceName() |
|
74 |
*/ |
|
75 |
public String getServiceName() { |
|
76 |
return SERVICE_NAME; |
|
77 |
} |
|
78 |
|
|
79 |
/* |
|
80 |
* (non-Javadoc) |
|
81 |
* @see es.gva.cit.catalog.csw.drivers.CSWCatalogServiceDriver#retrieveResults(es.gva.cit.catalog.metadataxml.XMLNode) |
|
82 |
*/ |
|
83 |
protected XMLNode[] retrieveResults(XMLNode root){ |
|
84 |
XMLNode resultNode = XMLTree.searchNode(root, CSWConstants.SEARCH_RESULTS); |
|
85 |
if (resultNode == null){ |
|
86 |
return new XMLNode[0]; |
|
87 |
} |
|
88 |
XMLNode[] results = new XMLNode[resultNode.getNumSubNodes()]; |
|
89 |
for (int i=0 ; i<resultNode.getNumSubNodes() ; i++){ |
|
90 |
results[i] = resultNode.getSubNode(i); |
|
91 |
} |
|
92 |
return results; |
|
93 |
} |
|
94 |
|
|
95 |
/* |
|
96 |
* (non-Javadoc) |
|
97 |
* @see es.gva.cit.catalog.drivers.AbstractCatalogServiceDriver#getProfile() |
|
98 |
*/ |
|
99 |
public IProfile getProfile() { |
|
100 |
return new CSWISO19115Profile(); |
|
101 |
} |
|
102 |
|
|
103 |
} |
branches/v2_0_0_prep/applications/appCatalogClient/src/es/gva/cit/catalog/csw/drivers/CSWebRIMCatalogServiceDriver.java | ||
---|---|---|
1 |
package es.gva.cit.catalog.csw.drivers; |
|
2 |
|
|
3 |
import java.net.MalformedURLException; |
|
4 |
import java.net.URL; |
|
5 |
|
|
6 |
import org.apache.commons.httpclient.NameValuePair; |
|
7 |
|
|
8 |
import es.gva.cit.catalog.csw.drivers.profiles.CSWebRIMProfile; |
|
9 |
import es.gva.cit.catalog.csw.parsers.CSWConstants; |
|
10 |
import es.gva.cit.catalog.drivers.profiles.IProfile; |
|
11 |
import es.gva.cit.catalog.metadataxml.XMLNode; |
|
12 |
import es.gva.cit.catalog.protocols.HTTPGetProtocol; |
|
13 |
|
|
14 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
15 |
* |
|
16 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
17 |
* |
|
18 |
* This program is free software; you can redistribute it and/or |
|
19 |
* modify it under the terms of the GNU General Public License |
|
20 |
* as published by the Free Software Foundation; either version 2 |
|
21 |
* of the License, or (at your option) any later version. |
|
22 |
* |
|
23 |
* This program is distributed in the hope that it will be useful, |
|
24 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
25 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
26 |
* GNU General Public License for more details. |
|
27 |
* |
|
28 |
* You should have received a copy of the GNU General Public License |
|
29 |
* along with this program; if not, write to the Free Software |
|
30 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
31 |
* |
|
32 |
* For more information, contact: |
|
33 |
* |
|
34 |
* Generalitat Valenciana |
|
35 |
* Conselleria d'Infraestructures i Transport |
|
36 |
* Av. Blasco Ib??ez, 50 |
|
37 |
* 46010 VALENCIA |
|
38 |
* SPAIN |
|
39 |
* |
|
40 |
* +34 963862235 |
|
41 |
* gvsig@gva.es |
|
42 |
* www.gvsig.gva.es |
|
43 |
* |
|
44 |
* or |
|
45 |
* |
|
46 |
* IVER T.I. S.A |
|
47 |
* Salamanca 50 |
|
48 |
* 46005 Valencia |
|
49 |
* Spain |
|
50 |
* |
|
51 |
* +34 963163400 |
|
52 |
* dac@iver.es |
|
53 |
*/ |
|
54 |
/* CVS MESSAGES: |
|
55 |
* |
|
56 |
* $Id$ |
|
57 |
* $Log$ |
|
58 |
* |
|
59 |
*/ |
|
60 |
/** |
|
61 |
* @author Jorge Piera LLodr? (jorge.piera@iver.es) |
|
62 |
*/ |
|
63 |
public class CSWebRIMCatalogServiceDriver extends CSWCatalogServiceDriver{ |
|
64 |
public static String SERVICE_NAME = "CSW/ebRIM"; |
|
65 |
|
|
66 |
/* |
|
67 |
* (non-Javadoc) |
|
68 |
* @see es.gva.cit.catalogClient.drivers.ICatalogServiceDriver#getServiceName() |
|
69 |
*/ |
|
70 |
public String getServiceName() { |
|
71 |
return SERVICE_NAME; |
|
72 |
} |
|
73 |
|
|
74 |
/* |
|
75 |
* (non-Javadoc) |
|
76 |
* @see es.gva.cit.catalog.drivers.AbstractCatalogServiceDriver#getProfile() |
|
77 |
*/ |
|
78 |
public IProfile getProfile() { |
|
79 |
return new CSWebRIMProfile(); |
|
80 |
} |
|
81 |
|
|
82 |
/* |
|
83 |
* (non-Javadoc) |
|
84 |
* @see es.gva.cit.catalog.csw.drivers.CSWCatalogServiceDriver#retrieveResults(es.gva.cit.catalog.metadataxml.XMLNode) |
|
85 |
*/ |
|
86 |
protected XMLNode[] retrieveResults(XMLNode root) { |
|
87 |
XMLNode resultNode = root.searchNode(CSWConstants.SEARCH_RESULTS); |
|
88 |
if (resultNode == null){ |
|
89 |
return new XMLNode[0]; |
|
90 |
} |
|
91 |
XMLNode[] results = new XMLNode[resultNode.getNumSubNodes()]; |
|
92 |
for (int i=0 ; i<resultNode.getNumSubNodes() ; i++){ |
|
93 |
results[i] = resultNode.getSubNode(i); |
|
94 |
} |
|
95 |
return getEbRIMNodes(results); |
|
96 |
} |
|
97 |
|
|
98 |
/** |
|
99 |
* This function retrieve the nodes for one ebRIM answer |
|
100 |
* @return Medatada Nodes. |
|
101 |
* @param nodes Server URL |
|
102 |
* @param url |
|
103 |
*/ |
|
104 |
private XMLNode[] getEbRIMNodes(XMLNode[] nodes) { |
|
105 |
//if the getExtrinsincContentOperation is not supported |
|
106 |
if (capabilities.getOperations().getGetExtrinsicContent().size() == 0){ |
|
107 |
return nodes; |
|
108 |
} |
|
109 |
XMLNode[] auxNodes = new XMLNode[nodes.length]; |
|
110 |
for (int i = 0; i < nodes.length; i++) { |
|
111 |
String id = nodes[i].searchAtribute(CSWConstants.ID); |
|
112 |
URL url = (URL)capabilities.getOperations().getGetExtrinsicContent().get(CSWConstants.GET); |
|
113 |
auxNodes[i] = (XMLNode)new HTTPGetProtocol().doQuery(url, |
|
114 |
getEbRIMRequestParameters(id), 0).toArray()[0]; |
|
115 |
} |
|
116 |
return auxNodes; |
|
117 |
} |
|
118 |
|
|
119 |
/** |
|
120 |
* It Returns the parameters needed by getExtrinsicContent |
|
121 |
* @return |
|
122 |
* @param id Record id |
|
123 |
*/ |
|
124 |
private NameValuePair[] getEbRIMRequestParameters(String id) { |
|
125 |
NameValuePair nvp1 = new NameValuePair(CSWConstants.REQUEST, CSWConstants.EXTRISIC_CONTENT); |
|
126 |
NameValuePair nvp2 = new NameValuePair(CSWConstants.ID, id); |
|
127 |
return new NameValuePair[] { nvp1, nvp2 }; |
|
128 |
} |
|
129 |
} |
branches/v2_0_0_prep/applications/appCatalogClient/src/es/gva/cit/catalog/csw/drivers/CSWCatalogServiceDriver.java | ||
---|---|---|
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.catalog.csw.drivers; |
|
43 |
import java.net.MalformedURLException; |
|
44 |
import java.net.URI; |
|
45 |
import java.net.URL; |
|
46 |
import java.util.Collection; |
|
47 |
|
|
48 |
import com.sun.org.apache.xalan.internal.xsltc.runtime.Hashtable; |
|
49 |
|
|
50 |
import es.gva.cit.catalog.csw.drivers.profiles.CSWAbstractProfile; |
|
51 |
import es.gva.cit.catalog.csw.messages.CSWAbstractMessages; |
|
52 |
import es.gva.cit.catalog.csw.messages.CSWMessagesFactory; |
|
53 |
import es.gva.cit.catalog.csw.parsers.CSWCapabilitiesParser; |
|
54 |
import es.gva.cit.catalog.csw.parsers.CSWDescribeRecordParser; |
|
55 |
import es.gva.cit.catalog.drivers.AbstractCatalogServiceDriver; |
|
56 |
import es.gva.cit.catalog.drivers.DiscoveryServiceCapabilities; |
|
57 |
import es.gva.cit.catalog.drivers.GetRecordsReply; |
|
58 |
import es.gva.cit.catalog.exceptions.NotSupportedVersionException; |
|
59 |
import es.gva.cit.catalog.metadataxml.XMLNode; |
|
60 |
import es.gva.cit.catalog.protocols.HTTPGetProtocol; |
|
61 |
import es.gva.cit.catalog.protocols.HTTPPostProtocol; |
|
62 |
import es.gva.cit.catalog.querys.CatalogQuery; |
|
63 |
|
|
64 |
/** |
|
65 |
* This class implements the CSW protocol. |
|
66 |
* |
|
67 |
* |
|
68 |
* @author Jorge Piera Llodra (piera_jor@gva.es) |
|
69 |
* @see http://portal.opengeospatial.org/files/?artifact_id=5929&version=1 |
|
70 |
*/ |
|
71 |
public abstract class CSWCatalogServiceDriver extends AbstractCatalogServiceDriver { |
|
72 |
protected CSWCapabilities capabilities = null; |
|
73 |
protected CSWAbstractProfile profile = null; |
|
74 |
private static Hashtable servers = new Hashtable(); |
|
75 |
|
|
76 |
/** |
|
77 |
* @return |
|
78 |
* @param url |
|
79 |
* @throws NotSupportedVersionException |
|
80 |
*/ |
|
81 |
public DiscoveryServiceCapabilities getCapabilities(URI uri) throws NotSupportedVersionException { |
|
82 |
URL url = null; |
|
83 |
try { |
|
84 |
url = uri.toURL(); |
|
85 |
} catch (MalformedURLException e) { |
|
86 |
setServerAnswerReady("errorServerNotFound"); |
|
87 |
return null; |
|
88 |
} |
|
89 |
Collection nodes = new java.util.ArrayList(); |
|
90 |
nodes = new HTTPGetProtocol().doQuery(url, CSWAbstractMessages.getHTTPGETCapabilities(), 0); |
|
91 |
CSWCapabilitiesParser parser = new CSWCapabilitiesParser(url, this); |
|
92 |
capabilities = parser.parse((XMLNode)nodes.toArray()[0]); |
|
93 |
//There are servers that need the getCapabilities operation (instead of GetCapabilities) |
|
94 |
if (!(capabilities.isAvailable()) && (capabilities.getException() != null)){ |
|
95 |
CSWException exception = capabilities.getException(); |
|
96 |
if ((exception.getCode().equals(CSWException.CODE_ERROR)) && |
|
97 |
(exception.getSubcode().equals(CSWException.SUBCODE_ERROR))){ |
|
98 |
nodes = new HTTPGetProtocol().doQuery(url, CSWAbstractMessages.getHTTPGETCapabilitiesLower(), 0); |
|
99 |
capabilities = parser.parse((XMLNode)nodes.toArray()[0]); |
|
100 |
} |
|
101 |
} |
|
102 |
//If the version can be retrieved the CSWAbstractMessages object |
|
103 |
//cant be created |
|
104 |
setMessages(uri,url); |
|
105 |
return capabilities; |
|
106 |
} |
|
107 |
|
|
108 |
/* |
|
109 |
* (non-Javadoc) |
|
110 |
* @see es.gva.cit.catalog.drivers.ICatalogServiceDriver#getRecords(java.net.URI, es.gva.cit.catalog.querys.CatalogQuery, int) |
|
111 |
*/ |
|
112 |
public GetRecordsReply getRecords(URI uri, CatalogQuery query, |
|
113 |
int firstRecord) { |
|
114 |
URL url = capabilities.getOperations().getGetRecordsURLPost(); |
|
115 |
setQuery(query); |
|
116 |
Collection nodes = new java.util.ArrayList(); |
|
117 |
try { |
|
118 |
System.out.println(getMessages(uri).getHTTPPostGetRecordsMessage(capabilities, getQuery(), getServerData(), firstRecord)); |
|
119 |
nodes = new HTTPPostProtocol().doQuery(url, |
|
120 |
getMessages(uri).getHTTPPostGetRecordsMessage(capabilities, getQuery(), getServerData(), firstRecord), |
|
121 |
firstRecord); |
|
122 |
} catch (NotSupportedVersionException e) { |
|
123 |
//This exception never will be thrown |
|
124 |
} |
|
125 |
|
|
126 |
if (nodes == null) |
|
127 |
return null; |
|
128 |
|
|
129 |
XMLNode root = (XMLNode)nodes.toArray()[0]; |
|
130 |
int numberOfRecords = getNumberOfRecords(root); |
|
131 |
if (numberOfRecords == -1) { |
|
132 |
return null; |
|
133 |
} |
|
134 |
|
|
135 |
getRecordsReply().setNumRecords(numberOfRecords); |
|
136 |
XMLNode[] results = retrieveResults(root); |
|
137 |
for (int i=0 ; i<results.length ; i++){ |
|
138 |
getRecordsReply().addRecord(uri, results[i]); |
|
139 |
} |
|
140 |
return getRecordsReply(); |
|
141 |
} |
|
142 |
|
|
143 |
/** |
|
144 |
* Retrieve and parse the results |
|
145 |
* @param root |
|
146 |
* XML root node |
|
147 |
* @return |
|
148 |
*/ |
|
149 |
protected abstract XMLNode[] retrieveResults(XMLNode root); |
|
150 |
|
|
151 |
/** |
|
152 |
* This function returns the number of records that have been retrieved. |
|
153 |
* It Reads a Node value. |
|
154 |
* |
|
155 |
* |
|
156 |
* @return The number of records |
|
157 |
* @param node The answer tree |
|
158 |
*/ |
|
159 |
protected int getNumberOfRecords(XMLNode node) { |
|
160 |
int numberOfRecords = getNumberOfRecords(node,"csw:SearchResults","numberOfRecordsMatched"); |
|
161 |
if (numberOfRecords == -1) |
|
162 |
numberOfRecords = getNumberOfRecords(node,"SearchResults","numberOfRecordsMatched"); |
|
163 |
|
|
164 |
return numberOfRecords; |
|
165 |
} |
|
166 |
|
|
167 |
/* |
|
168 |
* (non-Javadoc) |
|
169 |
* @see es.gva.cit.catalogClient.drivers.ICatalogServiceDriver#getDefaultPort() |
|
170 |
*/ |
|
171 |
public int getDefaultPort() { |
|
172 |
return 80; |
|
173 |
} |
|
174 |
|
|
175 |
/* |
|
176 |
* (non-Javadoc) |
|
177 |
* @see es.gva.cit.catalogClient.drivers.ICatalogServiceDriver#getDefaultSchema() |
|
178 |
*/ |
|
179 |
public String getDefaultSchema() { |
|
180 |
return "http"; |
|
181 |
} |
|
182 |
|
|
183 |
/* |
|
184 |
* (non-Javadoc) |
|
185 |
* @see es.gva.cit.catalogClient.drivers.ICatalogServiceDriver#isProtocolSupported(java.net.URI) |
|
186 |
*/ |
|
187 |
public boolean isProtocolSupported(URI uri) { |
|
188 |
return true; |
|
189 |
} |
|
190 |
|
|
191 |
/** |
|
192 |
* @return the class to generate the messages. It depends |
|
193 |
* of the server version |
|
194 |
* @throws NotSupportedVersionException |
|
195 |
*/ |
|
196 |
private CSWAbstractMessages getMessages(URI uri) throws NotSupportedVersionException{ |
|
197 |
if (servers.containsKey(uri)){ |
|
198 |
return (CSWAbstractMessages)servers.get(uri); |
|
199 |
} |
|
200 |
CSWAbstractMessages messages = CSWMessagesFactory.getMessages(capabilities.getVersion(), |
|
201 |
(CSWAbstractProfile)getProfile()); |
|
202 |
servers.put(uri, messages); |
|
203 |
return messages; |
|
204 |
} |
|
205 |
|
|
206 |
/** |
|
207 |
* Create and sets the Messages obejct if it is possible |
|
208 |
* @param uri |
|
209 |
* Server URI |
|
210 |
* @param url |
|
211 |
* Server url |
|
212 |
* @throws NotSupportedVersionException |
|
213 |
*/ |
|
214 |
private void setMessages(URI uri,URL url)throws NotSupportedVersionException{ |
|
215 |
Collection nodes = new java.util.ArrayList(); |
|
216 |
nodes = new HTTPGetProtocol().doQuery(url, CSWAbstractMessages.getHTTPGETDescribeRecord(capabilities.getVersion()), 0); |
|
217 |
CSWDescribeRecordParser parser = new CSWDescribeRecordParser(url, this); |
|
218 |
parser.parse((XMLNode)nodes.toArray()[0]); |
|
219 |
} |
|
220 |
} |
branches/v2_0_0_prep/applications/appCatalogClient/src/es/gva/cit/catalog/csw/drivers/CSWCapabilities.java | ||
---|---|---|
1 |
package es.gva.cit.catalog.csw.drivers; |
|
2 |
|
|
3 |
import java.net.URL; |
|
4 |
|
|
5 |
import es.gva.cit.catalog.csw.parsers.CSWSupportedProtocolOperations; |
|
6 |
import es.gva.cit.catalog.drivers.CatalogCapabilities; |
|
7 |
|
|
8 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
9 |
* |
|
10 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
11 |
* |
|
12 |
* This program is free software; you can redistribute it and/or |
|
13 |
* modify it under the terms of the GNU General Public License |
|
14 |
* as published by the Free Software Foundation; either version 2 |
|
15 |
* of the License, or (at your option) any later version. |
|
16 |
* |
|
17 |
* This program is distributed in the hope that it will be useful, |
|
18 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
19 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
20 |
* GNU General Public License for more details. |
|
21 |
* |
|
22 |
* You should have received a copy of the GNU General Public License |
|
23 |
* along with this program; if not, write to the Free Software |
|
24 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
25 |
* |
|
26 |
* For more information, contact: |
|
27 |
* |
|
28 |
* Generalitat Valenciana |
|
29 |
* Conselleria d'Infraestructures i Transport |
|
30 |
* Av. Blasco Ib??ez, 50 |
|
31 |
* 46010 VALENCIA |
|
32 |
* SPAIN |
|
33 |
* |
|
34 |
* +34 963862235 |
|
35 |
* gvsig@gva.es |
|
36 |
* www.gvsig.gva.es |
|
37 |
* |
|
38 |
* or |
|
39 |
* |
|
40 |
* IVER T.I. S.A |
|
41 |
* Salamanca 50 |
|
42 |
* 46005 Valencia |
|
43 |
* Spain |
|
44 |
* |
|
45 |
* +34 963163400 |
|
46 |
* dac@iver.es |
|
47 |
*/ |
|
48 |
/* CVS MESSAGES: |
|
49 |
* |
|
50 |
* $Id$ |
|
51 |
* $Log$ |
|
52 |
* |
|
53 |
*/ |
|
54 |
/** |
|
55 |
* @author Jorge Piera LLodr? (jorge.piera@iver.es) |
|
56 |
*/ |
|
57 |
public class CSWCapabilities extends CatalogCapabilities { |
|
58 |
private CSWSupportedProtocolOperations operations = null; |
|
59 |
private String responseHandler = null; |
|
60 |
private String hopCount = null; |
|
61 |
private String distributedSearch = null; |
|
62 |
private String constraint = null; |
|
63 |
private String[] CONSTRAINTLANGUAGE = null; |
|
64 |
private String[] elementSetName = null; |
|
65 |
private String[] typeNames = null; |
|
66 |
private String[] resultType = null; |
|
67 |
private String[] NAMESPACE = null; |
|
68 |
private String[] outputFormat = null; |
|
69 |
private String[] outputSchema = null; |
|
70 |
private CSWException exception = null; |
|
71 |
|
|
72 |
/** |
|
73 |
* @return the exception |
|
74 |
*/ |
|
75 |
public CSWException getException() { |
|
76 |
return exception; |
|
77 |
} |
|
78 |
|
|
79 |
/** |
|
80 |
* @param exception the exception to set |
|
81 |
*/ |
|
82 |
public void setException(CSWException exception) { |
|
83 |
this.exception = exception; |
|
84 |
} |
|
85 |
|
|
86 |
/** |
|
87 |
* @return the outputSchema |
|
88 |
*/ |
|
89 |
public String[] getOutputSchema() { |
|
90 |
return outputSchema; |
|
91 |
} |
|
92 |
|
|
93 |
/** |
|
94 |
* @param outputSchema the outputSchema to set |
|
95 |
*/ |
|
96 |
public void setOutputSchema(String[] outputSchema) { |
|
97 |
this.outputSchema = outputSchema; |
|
98 |
} |
|
99 |
|
|
100 |
/** |
|
101 |
* @return the operations |
|
102 |
*/ |
|
103 |
public CSWSupportedProtocolOperations getOperations() { |
|
104 |
return operations; |
|
105 |
} |
|
106 |
|
|
107 |
/** |
|
108 |
* @param operations the operations to set |
|
109 |
*/ |
|
110 |
public void setOperations(CSWSupportedProtocolOperations operations) { |
|
111 |
this.operations = operations; |
|
112 |
} |
|
113 |
|
|
114 |
/** |
|
115 |
* @return the outputFormat |
|
116 |
*/ |
|
117 |
public String[] getOutputFormat() { |
|
118 |
return outputFormat; |
|
119 |
} |
|
120 |
|
|
121 |
/** |
|
122 |
* @param outputFormat the outputFormat to set |
|
123 |
*/ |
|
124 |
public void setOutputFormat(String[] outputFormat) { |
|
125 |
this.outputFormat = outputFormat; |
|
126 |
} |
|
127 |
|
|
128 |
public CSWCapabilities(URL url) { |
|
129 |
super(); |
|
130 |
operations = new CSWSupportedProtocolOperations(url); |
|
131 |
} |
|
132 |
|
|
133 |
/** |
|
134 |
* @return the responseHandler |
|
135 |
*/ |
|
136 |
public String getResponseHandler() { |
|
137 |
return responseHandler; |
|
138 |
} |
|
139 |
|
|
140 |
/** |
|
141 |
* @param responseHandler the responseHandler to set |
|
142 |
*/ |
|
143 |
public void setResponseHandler(String responseHandler) { |
|
144 |
this.responseHandler = responseHandler; |
|
145 |
} |
|
146 |
|
|
147 |
/** |
|
148 |
* @return the hopCount |
|
149 |
*/ |
|
150 |
public String getHopCount() { |
|
151 |
return hopCount; |
|
152 |
} |
|
153 |
|
|
154 |
/** |
|
155 |
* @param hopCount the hopCount to set |
|
156 |
*/ |
|
157 |
public void setHopCount(String hopCount) { |
|
158 |
this.hopCount = hopCount; |
|
159 |
} |
|
160 |
|
|
161 |
/** |
|
162 |
* @return the distributedSearch |
|
163 |
*/ |
|
164 |
public String getDistributedSearch() { |
|
165 |
return distributedSearch; |
|
166 |
} |
|
167 |
|
|
168 |
/** |
|
169 |
* @param distributedSearch the distributedSearch to set |
|
170 |
*/ |
|
171 |
public void setDistributedSearch(String distributedSearch) { |
|
172 |
this.distributedSearch = distributedSearch; |
|
173 |
} |
|
174 |
|
|
175 |
/** |
|
176 |
* @return the constraint |
|
177 |
*/ |
|
178 |
public String getConstraint() { |
|
179 |
return constraint; |
|
180 |
} |
|
181 |
|
|
182 |
/** |
|
183 |
* @param constraint the constraint to set |
|
184 |
*/ |
|
185 |
public void setConstraint(String constraint) { |
|
186 |
this.constraint = constraint; |
|
187 |
} |
|
188 |
|
|
189 |
/** |
|
190 |
* @return the cONSTRAINTLANGUAGE |
|
191 |
*/ |
|
192 |
public String[] getCONSTRAINTLANGUAGE() { |
|
193 |
return CONSTRAINTLANGUAGE; |
|
194 |
} |
|
195 |
|
|
196 |
/** |
|
197 |
* @param constraintlanguage the cONSTRAINTLANGUAGE to set |
|
198 |
*/ |
|
199 |
public void setCONSTRAINTLANGUAGE(String[] constraintlanguage) { |
|
200 |
CONSTRAINTLANGUAGE = constraintlanguage; |
|
201 |
} |
|
202 |
|
|
203 |
/** |
|
204 |
* @return the elementSetName |
|
205 |
*/ |
|
206 |
public String[] getElementSetName() { |
|
207 |
return elementSetName; |
|
208 |
} |
|
209 |
|
|
210 |
/** |
|
211 |
* @param elementSetName the elementSetName to set |
|
212 |
*/ |
|
213 |
public void setElementSetName(String[] elementSetName) { |
|
214 |
this.elementSetName = elementSetName; |
|
215 |
} |
|
216 |
|
|
217 |
/** |
|
218 |
* @return the typeNames |
|
219 |
*/ |
|
220 |
public String[] getTypeNames() { |
|
221 |
return typeNames; |
|
222 |
} |
|
223 |
|
|
224 |
/** |
|
225 |
* @param typeNames the typeNames to set |
|
226 |
*/ |
|
227 |
public void setTypeNames(String[] typeNames) { |
|
228 |
this.typeNames = typeNames; |
|
229 |
} |
|
230 |
|
|
231 |
/** |
|
232 |
* @return the resultType |
|
233 |
*/ |
|
234 |
public String[] getResultType() { |
|
235 |
return resultType; |
|
236 |
} |
|
237 |
|
|
238 |
/** |
|
239 |
* @param resultType the resultType to set |
|
240 |
*/ |
|
241 |
public void setResultType(String[] resultType) { |
|
242 |
this.resultType = resultType; |
|
243 |
} |
|
244 |
|
|
245 |
/** |
|
246 |
* @return the nAMESPACE |
|
247 |
*/ |
|
248 |
public String[] getNAMESPACE() { |
|
249 |
return NAMESPACE; |
|
250 |
} |
|
251 |
|
|
252 |
/** |
|
253 |
* @param namespace the nAMESPACE to set |
|
254 |
*/ |
|
255 |
public void setNAMESPACE(String[] namespace) { |
|
256 |
NAMESPACE = namespace; |
|
257 |
} |
|
258 |
|
|
259 |
|
|
260 |
} |
branches/v2_0_0_prep/applications/appCatalogClient/src/es/gva/cit/catalog/csw/drivers/CSWException.java | ||
---|---|---|
1 |
package es.gva.cit.catalog.csw.drivers; |
|
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 |
/* CVS MESSAGES: |
|
43 |
* |
|
44 |
* $Id$ |
|
45 |
* $Log$ |
|
46 |
* |
|
47 |
*/ |
|
48 |
/** |
|
49 |
* @author Jorge Piera LLodr? (jorge.piera@iver.es) |
|
50 |
*/ |
|
51 |
public class CSWException { |
|
52 |
public static final String CODE_DEFAULT = "-1"; |
|
53 |
public static final String CODE_ERROR = "8001"; |
|
54 |
public static final String SUBCODE_ERROR = "5002"; |
|
55 |
private String code = null; |
|
56 |
private String subcode = null; |
|
57 |
private String reason = null; |
|
58 |
private String _abstract = null; |
|
59 |
|
|
60 |
public CSWException() { |
|
61 |
super(); |
|
62 |
this.code = CODE_DEFAULT; |
|
63 |
} |
|
64 |
/** |
|
65 |
* @return the code |
|
66 |
*/ |
|
67 |
public String getCode() { |
|
68 |
return code; |
|
69 |
} |
|
70 |
/** |
|
71 |
* @param code the code to set |
|
72 |
*/ |
|
73 |
public void setCode(String code) { |
|
74 |
this.code = code; |
|
75 |
} |
|
76 |
/** |
|
77 |
* @return the subcode |
|
78 |
*/ |
|
79 |
public String getSubcode() { |
|
80 |
return subcode; |
|
81 |
} |
|
82 |
/** |
|
83 |
* @param subcode the subcode to set |
|
84 |
*/ |
|
85 |
public void setSubcode(String subcode) { |
|
86 |
this.subcode = subcode; |
|
87 |
} |
|
88 |
/** |
|
89 |
* @return the reason |
|
90 |
*/ |
|
91 |
public String getReason() { |
|
92 |
return reason; |
|
93 |
} |
|
94 |
/** |
|
95 |
* @param reason the reason to set |
|
96 |
*/ |
|
97 |
public void setReason(String reason) { |
|
98 |
this.reason = reason; |
|
99 |
} |
|
100 |
/** |
|
101 |
* @return the _abstract |
|
102 |
*/ |
|
103 |
public String getAbstract() { |
|
104 |
return _abstract; |
|
105 |
} |
|
106 |
/** |
|
107 |
* @param _abstract the _abstract to set |
|
108 |
*/ |
|
109 |
public void setAbstract(String _abstract) { |
|
110 |
this._abstract = _abstract; |
|
111 |
} |
|
112 |
|
|
113 |
|
|
114 |
} |
branches/v2_0_0_prep/applications/appCatalogClient/src/es/gva/cit/gazetteer/utils/GazetteerFormatter.java | ||
---|---|---|
1 |
package es.gva.cit.gazetteer.utils; |
|
2 |
|
|
3 |
import org.gvsig.remoteClient.wfs.filters.FilterEncoding; |
|
4 |
import org.gvsig.remoteClient.wfs.filters.ISQLExpressionFormat; |
|
5 |
|
|
6 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
7 |
* |
|
8 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
9 |
* |
|
10 |
* This program is free software; you can redistribute it and/or |
|
11 |
* modify it under the terms of the GNU General Public License |
|
12 |
* as published by the Free Software Foundation; either version 2 |
|
13 |
* of the License, or (at your option) any later version. |
|
14 |
* |
|
15 |
* This program is distributed in the hope that it will be useful, |
|
16 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
18 |
* GNU General Public License for more details. |
|
19 |
* |
|
20 |
* You should have received a copy of the GNU General Public License |
|
21 |
* along with this program; if not, write to the Free Software |
|
22 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
23 |
* |
|
24 |
* For more information, contact: |
|
25 |
* |
|
26 |
* Generalitat Valenciana |
|
27 |
* Conselleria d'Infraestructures i Transport |
|
28 |
* Av. Blasco Ib??ez, 50 |
|
29 |
* 46010 VALENCIA |
|
30 |
* SPAIN |
|
31 |
* |
|
32 |
* +34 963862235 |
|
33 |
* gvsig@gva.es |
|
34 |
* www.gvsig.gva.es |
|
35 |
* |
|
36 |
* or |
|
37 |
* |
|
38 |
* IVER T.I. S.A |
|
39 |
* Salamanca 50 |
|
40 |
* 46005 Valencia |
|
41 |
* Spain |
|
42 |
* |
|
43 |
* +34 963163400 |
|
44 |
* dac@iver.es |
|
45 |
*/ |
|
46 |
/* CVS MESSAGES: |
|
47 |
* |
|
48 |
* $Id: GazetteerFormatter.java 499 2007-07-10 11:18:10 +0000 (Tue, 10 Jul 2007) jorpiell $ |
|
49 |
* $Log$ |
|
50 |
* Revision 1.1.2.1 2007/07/10 11:18:04 jorpiell |
|
51 |
* Added the registers |
|
52 |
* |
|
53 |
* |
|
54 |
*/ |
|
55 |
/** |
|
56 |
* @author Jorge Piera LLodr? (jorge.piera@iver.es) |
|
57 |
*/ |
|
58 |
public class GazetteerFormatter implements ISQLExpressionFormat{ |
|
59 |
|
|
60 |
/* |
|
61 |
* (non-Javadoc) |
|
62 |
* @see org.gvsig.remoteClient.wfs.filters.ISQLExpressionFormat#format(java.lang.String) |
|
63 |
*/ |
|
64 |
public String format(String expression) { |
|
65 |
return expression; |
|
66 |
} |
|
67 |
|
|
68 |
|
|
69 |
/** |
|
70 |
* Creates a Filter Encoding creator that uses this |
|
71 |
* formatter to parse the SQL |
|
72 |
* @return |
|
73 |
*/ |
|
74 |
public static FilterEncoding createFilter(){ |
|
75 |
return new FilterEncoding(new GazetteerFormatter()); |
|
76 |
} |
|
77 |
} |
branches/v2_0_0_prep/applications/appCatalogClient/src/es/gva/cit/gazetteer/utils/GazetteerGeometriesFactory.java | ||
---|---|---|
1 |
package es.gva.cit.gazetteer.utils; |
|
2 |
|
|
3 |
import java.awt.geom.Point2D; |
|
4 |
import java.util.ArrayList; |
|
5 |
import java.util.Map; |
|
6 |
|
|
7 |
import org.apache.log4j.Logger; |
|
8 |
import org.gvsig.remoteClient.gml.types.IXMLType; |
|
9 |
|
|
10 |
import com.vividsolutions.jts.geom.Geometry; |
|
11 |
import com.vividsolutions.jts.geom.GeometryFactory; |
|
12 |
import com.vividsolutions.jts.geom.Point; |
|
13 |
import com.vividsolutions.jts.io.gml2.GMLReader; |
|
14 |
|
|
15 |
import es.gva.cit.gazetteer.querys.Feature; |
|
16 |
|
|
17 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
18 |
* |
|
19 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
20 |
* |
|
21 |
* This program is free software; you can redistribute it and/or |
|
22 |
* modify it under the terms of the GNU General Public License |
|
23 |
* as published by the Free Software Foundation; either version 2 |
|
24 |
* of the License, or (at your option) any later version. |
|
25 |
* |
|
26 |
* This program is distributed in the hope that it will be useful, |
|
27 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
28 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
29 |
* GNU General Public License for more details. |
|
30 |
* |
|
31 |
* You should have received a copy of the GNU General Public License |
|
32 |
* along with this program; if not, write to the Free Software |
|
33 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
34 |
* |
|
35 |
* For more information, contact: |
|
36 |
* |
|
37 |
* Generalitat Valenciana |
|
38 |
* Conselleria d'Infraestructures i Transport |
|
39 |
* Av. Blasco Ib??ez, 50 |
|
40 |
* 46010 VALENCIA |
|
41 |
* SPAIN |
|
42 |
* |
|
43 |
* +34 963862235 |
|
44 |
* gvsig@gva.es |
|
45 |
* www.gvsig.gva.es |
|
46 |
* |
|
47 |
* or |
|
48 |
* |
|
49 |
* IVER T.I. S.A |
|
50 |
* Salamanca 50 |
|
51 |
* 46005 Valencia |
|
52 |
* Spain |
|
53 |
* |
|
54 |
* +34 963163400 |
|
55 |
* dac@iver.es |
|
56 |
*/ |
|
57 |
/* CVS MESSAGES: |
|
58 |
* |
|
59 |
* $Id: GazetteerGeometriesFactory.java 572 2007-07-27 12:40:11 +0000 (Fri, 27 Jul 2007) jpiera $ |
|
60 |
* $Log$ |
|
61 |
* Revision 1.1.2.2 2007/07/13 12:00:35 jorpiell |
|
62 |
* Add the posibility to add a new panel |
|
63 |
* |
|
64 |
* Revision 1.1.2.1 2007/07/10 11:18:04 jorpiell |
|
65 |
* Added the registers |
|
66 |
* |
|
67 |
* |
|
68 |
*/ |
|
69 |
/** |
|
70 |
* @author Jorge Piera LLodr? (jorge.piera@iver.es) |
|
71 |
*/ |
|
72 |
public class GazetteerGeometriesFactory { |
|
73 |
private static Logger logger = Logger.getLogger(GazetteerGeometriesFactory.class); |
|
74 |
private String attName = null; |
|
75 |
|
|
76 |
public GazetteerGeometriesFactory(String attName) { |
|
77 |
super(); |
|
78 |
this.attName = attName; |
|
79 |
} |
|
80 |
|
|
81 |
/* |
|
82 |
* (non-Javadoc) |
|
83 |
* @see org.gvsig.remoteClient.gml.factories.IGeometriesFactory#createGeometry(java.lang.String) |
|
84 |
*/ |
|
85 |
public Object createGeometry(String gmlGeometry) { |
|
86 |
GMLReader reader = new GMLReader(); |
|
87 |
try { |
|
88 |
Geometry geom = reader.read(gmlGeometry,new GeometryFactory()); |
|
89 |
Point point = geom.getInteriorPoint(); |
|
90 |
return new Point2D.Double(point.getX(),point.getY()); |
|
91 |
} catch (Exception e){ |
|
92 |
logger.error("Can't parse: " + gmlGeometry,e); |
|
93 |
} |
|
94 |
return null; |
|
95 |
} |
|
96 |
|
|
97 |
/* |
|
98 |
* (non-Javadoc) |
|
99 |
* @see org.gvsig.remoteClient.gml.factories.IGeometriesFactory#createMultipoint2D(double[], double[]) |
|
100 |
*/ |
|
101 |
public Object createMultipoint2D(double[] x, double[] y) { |
|
102 |
double xTotal = 0; |
|
103 |
double yTotal = 0; |
|
104 |
for (int i=0 ; i<x.length ; i++){ |
|
105 |
xTotal = xTotal + x[i]; |
|
106 |
yTotal = yTotal + y[i]; |
|
107 |
} |
|
108 |
if (x.length > 0){ |
|
109 |
return new Point2D.Double(xTotal/x.length, |
|
110 |
yTotal/y.length); |
|
111 |
} |
|
112 |
return new Point2D.Double(0, |
|
113 |
0); |
|
114 |
} |
|
115 |
|
|
116 |
/* |
|
117 |
* (non-Javadoc) |
|
118 |
* @see org.gvsig.remoteClient.gml.factories.IGeometriesFactory#createPoint2D(java.awt.geom.Point2D) |
|
119 |
*/ |
|
120 |
public Object createPoint2D(Point2D point) { |
|
121 |
return point; |
|
122 |
} |
|
123 |
|
|
124 |
/* |
|
125 |
* (non-Javadoc) |
|
126 |
* @see org.gvsig.remoteClient.gml.factories.IGeometriesFactory#createPoint2D(double, double) |
|
127 |
*/ |
|
128 |
public Object createPoint2D(double x, double y) { |
|
129 |
return new Point2D.Double(x,y); |
|
130 |
} |
|
131 |
|
|
132 |
/* |
|
133 |
* (non-Javadoc) |
|
134 |
* @see org.gvsig.remoteClient.gml.factories.IGeometriesFactory#createSimpleFeature(java.lang.String, org.gvsig.remoteClient.gml.types.IXMLType, java.util.Map, java.lang.Object) |
|
135 |
*/ |
|
136 |
public Object createSimpleFeature(String element, IXMLType type,Map values,Object geometry) { |
|
137 |
String sGeoname = element; |
|
138 |
if (attName != null){ |
|
139 |
if (values.get(attName) != null){ |
|
140 |
ArrayList array = (ArrayList)values.get(attName); |
|
141 |
if (array.size() > 0){ |
|
142 |
sGeoname = (String)array.get(0); |
|
143 |
} |
|
144 |
} |
|
145 |
} |
|
146 |
return new Feature(null, |
|
147 |
sGeoname, |
|
148 |
sGeoname, |
|
149 |
(Point2D)geometry); |
|
150 |
} |
|
151 |
|
|
152 |
/* |
|
153 |
* (non-Javadoc) |
|
154 |
* @see org.gvsig.remoteClient.gml.factories.IGeometriesFactory#createPolygon2D(double[], double[]) |
|
155 |
*/ |
|
156 |
public Object createPolygon2D(double[] x, double[] y) { |
|
157 |
double avX = 0; |
|
158 |
double avY = 0; |
|
159 |
for (int i=0 ; i<x.length ; i++){ |
|
160 |
avX = avX + x[i]; |
|
161 |
avY = avY + y[i]; |
|
162 |
} |
|
163 |
if (x.length > 0){ |
|
164 |
avX = avX/x.length; |
|
165 |
avY = avY/y.length; |
|
166 |
} |
|
167 |
return new Point2D.Double(avX, avY); |
|
168 |
} |
|
169 |
} |
branches/v2_0_0_prep/applications/appCatalogClient/src/es/gva/cit/gazetteer/utils/GazetteerDriverRegister.java | ||
---|---|---|
1 |
package es.gva.cit.gazetteer.utils; |
|
2 |
|
|
3 |
import java.util.Iterator; |
|
4 |
|
|
5 |
import com.iver.utiles.extensionPoints.ExtensionPoint; |
|
6 |
import com.iver.utiles.extensionPoints.ExtensionPoints; |
|
7 |
import com.iver.utiles.extensionPoints.ExtensionPointsSingleton; |
|
8 |
|
|
9 |
import es.gva.cit.gazetteer.drivers.IGazetteerServiceDriver; |
|
10 |
|
|
11 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
12 |
* |
|
13 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
14 |
* |
|
15 |
* This program is free software; you can redistribute it and/or |
|
16 |
* modify it under the terms of the GNU General Public License |
|
17 |
* as published by the Free Software Foundation; either version 2 |
|
18 |
* of the License, or (at your option) any later version. |
|
19 |
* |
|
20 |
* This program is distributed in the hope that it will be useful, |
|
21 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
22 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
23 |
* GNU General Public License for more details. |
|
24 |
* |
|
25 |
* You should have received a copy of the GNU General Public License |
|
26 |
* along with this program; if not, write to the Free Software |
|
27 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
28 |
* |
|
29 |
* For more information, contact: |
|
30 |
* |
|
31 |
* Generalitat Valenciana |
|
32 |
* Conselleria d'Infraestructures i Transport |
|
33 |
* Av. Blasco Ib??ez, 50 |
|
34 |
* 46010 VALENCIA |
|
35 |
* SPAIN |
|
36 |
* |
|
37 |
* +34 963862235 |
|
38 |
* gvsig@gva.es |
|
39 |
* www.gvsig.gva.es |
|
40 |
* |
|
41 |
* or |
|
42 |
* |
|
43 |
* IVER T.I. S.A |
|
44 |
* Salamanca 50 |
|
45 |
* 46005 Valencia |
|
46 |
* Spain |
|
47 |
* |
|
48 |
* +34 963163400 |
|
49 |
* dac@iver.es |
|
50 |
*/ |
|
51 |
/* CVS MESSAGES: |
|
52 |
* |
|
53 |
* $Id: GazetteerDriverRegister.java 512 2007-07-24 11:25:43 +0000 (Tue, 24 Jul 2007) jorpiell $ |
|
54 |
* $Log$ |
|
55 |
* Revision 1.1.2.1 2007/07/24 11:25:42 jorpiell |
|
56 |
* The registers has been refactorized |
|
57 |
* |
|
58 |
* Revision 1.1.2.1 2007/07/10 11:18:04 jorpiell |
|
59 |
* Added the registers |
|
60 |
* |
|
61 |
* |
|
62 |
*/ |
|
63 |
/** |
|
64 |
* This class is used to register the different gazetteer |
|
65 |
* drivers and to retrieve them. It uses the gvSIG extension |
|
66 |
* points. |
|
67 |
* @author Jorge Piera LLodr? (jorge.piera@iver.es) |
|
68 |
*/ |
|
69 |
public class GazetteerDriverRegister { |
|
70 |
private static GazetteerDriverRegister instance = null; |
|
71 |
private static final String DRIVER_REGISTER_NAME = "GazetteerDrivers"; |
|
72 |
|
|
73 |
/** |
|
74 |
* This method cretaes the singleton instance |
|
75 |
* |
|
76 |
*/ |
|
77 |
private synchronized static void createInstance() { |
|
78 |
if (instance == null) { |
|
79 |
instance = new GazetteerDriverRegister(); |
|
80 |
} |
|
81 |
} |
|
82 |
|
|
83 |
/** |
|
84 |
* @return the remote service instance instance |
|
85 |
*/ |
|
86 |
public static GazetteerDriverRegister getInstance() { |
|
87 |
if (instance == null){ |
|
88 |
createInstance(); |
|
89 |
} |
|
90 |
return instance; |
|
91 |
} |
|
92 |
|
|
93 |
/** |
|
94 |
* This method is used to register a new gazetter driver |
|
95 |
* that manage a concrete protocol |
|
96 |
* @param driver |
|
97 |
* Gazetteer driver to register |
|
98 |
*/ |
|
99 |
public void register(IGazetteerServiceDriver driver){ |
|
100 |
ExtensionPoints extensionPoints = ExtensionPointsSingleton.getInstance(); |
|
101 |
extensionPoints.add(DRIVER_REGISTER_NAME,driver.getServiceName(), driver); |
|
102 |
} |
|
103 |
|
|
104 |
/** |
|
105 |
* It is used to retrieve a driver that supports a concrete |
|
106 |
* protocol |
|
107 |
* @param protocol |
|
108 |
* Gazetteer protocol |
|
109 |
* @return |
|
110 |
* The concrete gazatteer service driver |
|
111 |
*/ |
|
112 |
public IGazetteerServiceDriver getDriver(String protocol){ |
|
113 |
ExtensionPoint extensionPoint = (ExtensionPoint)ExtensionPointsSingleton.getInstance().get(DRIVER_REGISTER_NAME); |
|
114 |
Iterator keys = extensionPoint.keySet().iterator(); |
|
115 |
while (keys.hasNext()){ |
|
116 |
Object driver = extensionPoint.get(keys.next()); |
|
117 |
if (((IGazetteerServiceDriver)driver).getServiceName().compareTo(protocol) == 0){ |
|
118 |
return (IGazetteerServiceDriver)driver; |
|
119 |
} |
|
120 |
} |
|
121 |
return null; |
|
122 |
} |
|
123 |
|
|
124 |
/** |
|
125 |
* @return a list with all the gazetteer drivers |
|
126 |
*/ |
|
127 |
public IGazetteerServiceDriver[] getDrivers(){ |
|
128 |
IGazetteerServiceDriver[] drivers = null; |
|
129 |
ExtensionPoint extensionPoint = (ExtensionPoint)ExtensionPointsSingleton.getInstance().get(DRIVER_REGISTER_NAME); |
|
130 |
drivers = new IGazetteerServiceDriver[extensionPoint.keySet().size()]; |
|
131 |
Iterator keys = extensionPoint.keySet().iterator(); |
|
132 |
int i = 0; |
|
133 |
while (keys.hasNext()){ |
|
134 |
drivers[i] = (IGazetteerServiceDriver)extensionPoint.get(keys.next()); |
|
135 |
i++; |
|
136 |
} |
|
137 |
return drivers; |
|
138 |
} |
|
139 |
} |
Also available in: Unified diff