svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.remoteclient / src / main / java / org / gvsig / remoteclient / wfs / WFSFeature.java @ 40559
History | View | Annotate | Download (7.77 KB)
1 | 40559 | jjdelcerro | /**
|
---|---|---|---|
2 | * gvSIG. Desktop Geographic Information System.
|
||
3 | *
|
||
4 | * Copyright (C) 2007-2013 gvSIG Association.
|
||
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 3
|
||
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., 51 Franklin Street, Fifth Floor, Boston,
|
||
19 | * MA 02110-1301, USA.
|
||
20 | *
|
||
21 | * For any additional information, do not hesitate to contact us
|
||
22 | * at info AT gvsig.com, or visit our website www.gvsig.com.
|
||
23 | */
|
||
24 | 40435 | jjdelcerro | package org.gvsig.remoteclient.wfs; |
25 | |||
26 | import java.util.Hashtable; |
||
27 | import java.util.Vector; |
||
28 | |||
29 | import org.gvsig.remoteclient.utils.BoundaryBox; |
||
30 | import org.gvsig.remoteclient.wfs.schema.XMLNameSpace; |
||
31 | |||
32 | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
||
33 | *
|
||
34 | * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
||
35 | *
|
||
36 | * This program is free software; you can redistribute it and/or
|
||
37 | * modify it under the terms of the GNU General Public License
|
||
38 | * as published by the Free Software Foundation; either version 2
|
||
39 | * of the License, or (at your option) any later version.
|
||
40 | *
|
||
41 | * This program is distributed in the hope that it will be useful,
|
||
42 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
43 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
44 | * GNU General Public License for more details.
|
||
45 | *
|
||
46 | * You should have received a copy of the GNU General Public License
|
||
47 | * along with this program; if not, write to the Free Software
|
||
48 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
49 | *
|
||
50 | * For more information, contact:
|
||
51 | *
|
||
52 | * Generalitat Valenciana
|
||
53 | * Conselleria d'Infraestructures i Transport
|
||
54 | * Av. Blasco Ib??ez, 50
|
||
55 | * 46010 VALENCIA
|
||
56 | * SPAIN
|
||
57 | *
|
||
58 | * +34 963862235
|
||
59 | * gvsig@gva.es
|
||
60 | * www.gvsig.gva.es
|
||
61 | *
|
||
62 | * or
|
||
63 | *
|
||
64 | * IVER T.I. S.A
|
||
65 | * Salamanca 50
|
||
66 | * 46005 Valencia
|
||
67 | * Spain
|
||
68 | *
|
||
69 | * +34 963163400
|
||
70 | * dac@iver.es
|
||
71 | */
|
||
72 | /* CVS MESSAGES:
|
||
73 | *
|
||
74 | * $Id: WFSFeature.java 34132 2010-11-15 09:27:20Z jpiera $
|
||
75 | * $Log$
|
||
76 | * Revision 1.7 2007-09-20 09:30:12 jaume
|
||
77 | * removed unnecessary imports
|
||
78 | *
|
||
79 | * Revision 1.6 2007/02/09 14:11:01 jorpiell
|
||
80 | * Primer piloto del soporte para WFS 1.1 y para WFS-T
|
||
81 | *
|
||
82 | * Revision 1.5 2006/06/15 09:05:06 jorpiell
|
||
83 | * Actualizados los WFS
|
||
84 | *
|
||
85 | * Revision 1.4 2006/05/23 13:23:22 jorpiell
|
||
86 | * Se ha cambiado el final del bucle de parseado y se tiene en cuenta el online resource
|
||
87 | *
|
||
88 | * Revision 1.2 2006/04/20 16:39:16 jorpiell
|
||
89 | * A?adida la operacion de describeFeatureType y el parser correspondiente.
|
||
90 | *
|
||
91 | * Revision 1.1 2006/04/19 12:51:35 jorpiell
|
||
92 | * A?adidas algunas de las clases del servicio WFS
|
||
93 | *
|
||
94 | *
|
||
95 | */
|
||
96 | /**
|
||
97 | * @author Jorge Piera Llodr? (piera_jor@gva.es)
|
||
98 | */
|
||
99 | public class WFSFeature extends WFSFeatureField { |
||
100 | private String localName = null; |
||
101 | private String title = null; |
||
102 | private String _abstract = null; |
||
103 | private Vector srs = new Vector(); |
||
104 | private String defaultSRS = null; |
||
105 | private BoundaryBox latLonBbox = null; |
||
106 | private Hashtable bBoxes = new Hashtable(); |
||
107 | private Vector keywords = new Vector(); |
||
108 | private XMLNameSpace namespace = null; |
||
109 | private WFSServiceInformation serviceInformation;
|
||
110 | private boolean isCompleted = false; |
||
111 | |||
112 | protected WFSFeature(WFSServiceInformation serviceInformation){
|
||
113 | super();
|
||
114 | this.serviceInformation = serviceInformation;
|
||
115 | } |
||
116 | |||
117 | protected WFSFeature(WFSServiceInformation serviceInformation, String name){ |
||
118 | super();
|
||
119 | this.serviceInformation = serviceInformation;
|
||
120 | setName(name); |
||
121 | } |
||
122 | |||
123 | /**
|
||
124 | * @return Returns the _abstract.
|
||
125 | */
|
||
126 | public String getAbstract() { |
||
127 | return _abstract;
|
||
128 | } |
||
129 | /**
|
||
130 | * @param _abstract The _abstract to set.
|
||
131 | */
|
||
132 | public void setAbstract(String _abstract) { |
||
133 | this._abstract = _abstract;
|
||
134 | } |
||
135 | |||
136 | /**
|
||
137 | * @param name The name to set.
|
||
138 | */
|
||
139 | public void setName(String name) { |
||
140 | this.name = name;
|
||
141 | int index = name.indexOf(":"); |
||
142 | if (index > 0){ |
||
143 | String prefix = name.substring(0, index); |
||
144 | localName = name.substring(index+1, name.length());
|
||
145 | String nameSpace = serviceInformation.getNamespace(prefix);
|
||
146 | this.setNamespace(new XMLNameSpace(prefix, nameSpace)); |
||
147 | } |
||
148 | } |
||
149 | |||
150 | /**
|
||
151 | * @return Returns the title.
|
||
152 | */
|
||
153 | public String getTitle() { |
||
154 | if ((title == null) || |
||
155 | (title.equals(""))){
|
||
156 | return name;
|
||
157 | } |
||
158 | return title;
|
||
159 | } |
||
160 | |||
161 | /**
|
||
162 | * @param title The title to set.
|
||
163 | */
|
||
164 | public void setTitle(String title) { |
||
165 | this.title = title;
|
||
166 | } |
||
167 | |||
168 | /**
|
||
169 | * @return Returns the latLonBbox.
|
||
170 | */
|
||
171 | public BoundaryBox getLatLonBbox() {
|
||
172 | return latLonBbox;
|
||
173 | } |
||
174 | /**
|
||
175 | * @param latLonBbox The latLonBbox to set.
|
||
176 | */
|
||
177 | public void setLatLonBbox(BoundaryBox latLonBbox) { |
||
178 | this.latLonBbox = latLonBbox;
|
||
179 | } |
||
180 | /**
|
||
181 | * @return Returns the keywords.
|
||
182 | */
|
||
183 | public Vector getKeywords() { |
||
184 | return keywords;
|
||
185 | } |
||
186 | |||
187 | public void addKeyword(String keyword){ |
||
188 | keywords.add(keyword); |
||
189 | } |
||
190 | /**
|
||
191 | * @return Returns the srs.
|
||
192 | */
|
||
193 | public Vector getSrs() { |
||
194 | return srs;
|
||
195 | } |
||
196 | |||
197 | public void addSRS(String key){ |
||
198 | String epsgCode = getEPSGCode(key);
|
||
199 | if (!this.srs.contains(epsgCode)){ |
||
200 | srs.add(epsgCode); |
||
201 | } |
||
202 | if (defaultSRS == null){ |
||
203 | defaultSRS = epsgCode; |
||
204 | } |
||
205 | } |
||
206 | |||
207 | /**
|
||
208 | * <p>Adds a bbox to the Bboxes vector</p>
|
||
209 | * @param bbox
|
||
210 | */
|
||
211 | public void addBBox(BoundaryBox bbox) { |
||
212 | bBoxes.put(bbox.getSrs(), bbox); |
||
213 | } |
||
214 | |||
215 | /**
|
||
216 | * <p>returns the bbox with that id in the Bboxes vector</p>
|
||
217 | * @param id
|
||
218 | */
|
||
219 | public BoundaryBox getBbox(String id) { |
||
220 | return (BoundaryBox)bBoxes.get(id);
|
||
221 | } |
||
222 | /**
|
||
223 | * @return Returns the namespace.
|
||
224 | */
|
||
225 | public XMLNameSpace getNamespace() {
|
||
226 | return namespace;
|
||
227 | } |
||
228 | /**
|
||
229 | * @param namespace The namespace to set.
|
||
230 | */
|
||
231 | public void setNamespace(XMLNameSpace namespace) { |
||
232 | this.namespace = namespace;
|
||
233 | } |
||
234 | |||
235 | /**
|
||
236 | * @return the localName
|
||
237 | */
|
||
238 | public String getLocalName() { |
||
239 | return localName;
|
||
240 | } |
||
241 | |||
242 | |||
243 | /**
|
||
244 | * @return the isCompleted
|
||
245 | */
|
||
246 | public boolean isCompleted() { |
||
247 | return isCompleted;
|
||
248 | } |
||
249 | |||
250 | /**
|
||
251 | * @param isCompleted the isCompleted to set
|
||
252 | */
|
||
253 | public void setCompleted(boolean isCompleted) { |
||
254 | this.isCompleted = isCompleted;
|
||
255 | } |
||
256 | |||
257 | /**
|
||
258 | * @return the defaultSRS
|
||
259 | */
|
||
260 | public String getDefaultSRS() { |
||
261 | return defaultSRS;
|
||
262 | } |
||
263 | |||
264 | |||
265 | /**
|
||
266 | * @param defaultSRS the defaultSRS to set
|
||
267 | */
|
||
268 | public void setDefaultSRS(String defaultSRS) { |
||
269 | this.defaultSRS = getEPSGCode(defaultSRS);
|
||
270 | addSRS(defaultSRS); |
||
271 | } |
||
272 | |||
273 | private String getEPSGCode(String srs){ |
||
274 | if (srs == null){ |
||
275 | return null; |
||
276 | } |
||
277 | if ((srs.startsWith("urn:x-ogc:def:crs:")) || srs.startsWith("urn:ogc:def:crs:")){ |
||
278 | String newString = srs.substring(srs.lastIndexOf(":") + 1, srs.length()); |
||
279 | if (srs.indexOf("EPSG") > 0){ |
||
280 | if (newString.indexOf("EPSG") < 0){ |
||
281 | newString = "EPSG:" + newString;
|
||
282 | } |
||
283 | } |
||
284 | return newString;
|
||
285 | } |
||
286 | if (srs.toLowerCase().startsWith("crs:")){ |
||
287 | return srs.substring(4, srs.length()); |
||
288 | } |
||
289 | return srs;
|
||
290 | } |
||
291 | |||
292 | } |