svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.remoteclient / src / main / java / org / gvsig / remoteclient / wfs / WFSFeature.java @ 40769
History | View | Annotate | Download (5.88 KB)
1 |
/**
|
---|---|
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 |
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 |
/**
|
33 |
* @author Jorge Piera Llodr? (piera_jor@gva.es)
|
34 |
*/
|
35 |
public class WFSFeature extends WFSFeatureField { |
36 |
private String localName = null; |
37 |
private String title = null; |
38 |
private String _abstract = null; |
39 |
private Vector srs = new Vector(); |
40 |
private String defaultSRS = null; |
41 |
private BoundaryBox latLonBbox = null; |
42 |
private Hashtable bBoxes = new Hashtable(); |
43 |
private Vector keywords = new Vector(); |
44 |
private XMLNameSpace namespace = null; |
45 |
private WFSServiceInformation serviceInformation;
|
46 |
private boolean isCompleted = false; |
47 |
|
48 |
protected WFSFeature(WFSServiceInformation serviceInformation){
|
49 |
super();
|
50 |
this.serviceInformation = serviceInformation;
|
51 |
} |
52 |
|
53 |
protected WFSFeature(WFSServiceInformation serviceInformation, String name){ |
54 |
super();
|
55 |
this.serviceInformation = serviceInformation;
|
56 |
setName(name); |
57 |
} |
58 |
|
59 |
/**
|
60 |
* @return Returns the _abstract.
|
61 |
*/
|
62 |
public String getAbstract() { |
63 |
return _abstract;
|
64 |
} |
65 |
/**
|
66 |
* @param _abstract The _abstract to set.
|
67 |
*/
|
68 |
public void setAbstract(String _abstract) { |
69 |
this._abstract = _abstract;
|
70 |
} |
71 |
|
72 |
/**
|
73 |
* @param name The name to set.
|
74 |
*/
|
75 |
public void setName(String name) { |
76 |
this.name = name;
|
77 |
int index = name.indexOf(":"); |
78 |
if (index > 0){ |
79 |
String prefix = name.substring(0, index); |
80 |
localName = name.substring(index+1, name.length());
|
81 |
String nameSpace = serviceInformation.getNamespace(prefix);
|
82 |
this.setNamespace(new XMLNameSpace(prefix, nameSpace)); |
83 |
} |
84 |
} |
85 |
|
86 |
/**
|
87 |
* @return Returns the title.
|
88 |
*/
|
89 |
public String getTitle() { |
90 |
if ((title == null) || |
91 |
(title.equals(""))){
|
92 |
return name;
|
93 |
} |
94 |
return title;
|
95 |
} |
96 |
|
97 |
/**
|
98 |
* @param title The title to set.
|
99 |
*/
|
100 |
public void setTitle(String title) { |
101 |
this.title = title;
|
102 |
} |
103 |
|
104 |
/**
|
105 |
* @return Returns the latLonBbox.
|
106 |
*/
|
107 |
public BoundaryBox getLatLonBbox() {
|
108 |
return latLonBbox;
|
109 |
} |
110 |
/**
|
111 |
* @param latLonBbox The latLonBbox to set.
|
112 |
*/
|
113 |
public void setLatLonBbox(BoundaryBox latLonBbox) { |
114 |
this.latLonBbox = latLonBbox;
|
115 |
} |
116 |
/**
|
117 |
* @return Returns the keywords.
|
118 |
*/
|
119 |
public Vector getKeywords() { |
120 |
return keywords;
|
121 |
} |
122 |
|
123 |
public void addKeyword(String keyword){ |
124 |
keywords.add(keyword); |
125 |
} |
126 |
/**
|
127 |
* @return Returns the srs.
|
128 |
*/
|
129 |
public Vector getSrs() { |
130 |
return srs;
|
131 |
} |
132 |
|
133 |
public void addSRS(String key){ |
134 |
String epsgCode = getEPSGCode(key);
|
135 |
if (!this.srs.contains(epsgCode)){ |
136 |
srs.add(epsgCode); |
137 |
} |
138 |
if (defaultSRS == null){ |
139 |
defaultSRS = epsgCode; |
140 |
} |
141 |
} |
142 |
|
143 |
/**
|
144 |
* <p>Adds a bbox to the Bboxes vector</p>
|
145 |
* @param bbox
|
146 |
*/
|
147 |
public void addBBox(BoundaryBox bbox) { |
148 |
bBoxes.put(bbox.getSrs(), bbox); |
149 |
} |
150 |
|
151 |
/**
|
152 |
* <p>returns the bbox with that id in the Bboxes vector</p>
|
153 |
* @param id
|
154 |
*/
|
155 |
public BoundaryBox getBbox(String id) { |
156 |
return (BoundaryBox)bBoxes.get(id);
|
157 |
} |
158 |
/**
|
159 |
* @return Returns the namespace.
|
160 |
*/
|
161 |
public XMLNameSpace getNamespace() {
|
162 |
return namespace;
|
163 |
} |
164 |
/**
|
165 |
* @param namespace The namespace to set.
|
166 |
*/
|
167 |
public void setNamespace(XMLNameSpace namespace) { |
168 |
this.namespace = namespace;
|
169 |
} |
170 |
|
171 |
/**
|
172 |
* @return the localName
|
173 |
*/
|
174 |
public String getLocalName() { |
175 |
return localName;
|
176 |
} |
177 |
|
178 |
|
179 |
/**
|
180 |
* @return the isCompleted
|
181 |
*/
|
182 |
public boolean isCompleted() { |
183 |
return isCompleted;
|
184 |
} |
185 |
|
186 |
/**
|
187 |
* @param isCompleted the isCompleted to set
|
188 |
*/
|
189 |
public void setCompleted(boolean isCompleted) { |
190 |
this.isCompleted = isCompleted;
|
191 |
} |
192 |
|
193 |
/**
|
194 |
* @return the defaultSRS
|
195 |
*/
|
196 |
public String getDefaultSRS() { |
197 |
return defaultSRS;
|
198 |
} |
199 |
|
200 |
|
201 |
/**
|
202 |
* @param defaultSRS the defaultSRS to set
|
203 |
*/
|
204 |
public void setDefaultSRS(String defaultSRS) { |
205 |
this.defaultSRS = getEPSGCode(defaultSRS);
|
206 |
addSRS(defaultSRS); |
207 |
} |
208 |
|
209 |
private String getEPSGCode(String srs){ |
210 |
if (srs == null){ |
211 |
return null; |
212 |
} |
213 |
if ((srs.startsWith("urn:x-ogc:def:crs:")) || srs.startsWith("urn:ogc:def:crs:")){ |
214 |
String newString = srs.substring(srs.lastIndexOf(":") + 1, srs.length()); |
215 |
if (srs.indexOf("EPSG") > 0){ |
216 |
if (newString.indexOf("EPSG") < 0){ |
217 |
newString = "EPSG:" + newString;
|
218 |
} |
219 |
} |
220 |
return newString;
|
221 |
} |
222 |
if (srs.toLowerCase().startsWith("crs:")){ |
223 |
return srs.substring(4, srs.length()); |
224 |
} |
225 |
return srs;
|
226 |
} |
227 |
|
228 |
} |