svn-gvsig-desktop / tags / v2_0_0_Build_2020 / libraries / libRemoteServices / src / org / gvsig / remoteclient / wfs / wfs_1_1_0 / WFSFeature1_1_0.java @ 33910
History | View | Annotate | Download (8.75 KB)
1 | 29661 | jpiera | package org.gvsig.remoteclient.wfs.wfs_1_1_0; |
---|---|---|---|
2 | |||
3 | import java.io.IOException; |
||
4 | |||
5 | 33738 | jpiera | import org.kxml2.io.KXmlParser; |
6 | import org.xmlpull.v1.XmlPullParserException; |
||
7 | |||
8 | import org.gvsig.compat.CompatLocator; |
||
9 | import org.gvsig.compat.lang.StringUtils; |
||
10 | 29661 | jpiera | import org.gvsig.remoteclient.utils.BoundaryBox; |
11 | import org.gvsig.remoteclient.utils.CapabilitiesTags; |
||
12 | import org.gvsig.remoteclient.utils.Utilities; |
||
13 | import org.gvsig.remoteclient.wfs.WFSFeature; |
||
14 | import org.gvsig.remoteclient.wfs.schema.GMLTags; |
||
15 | import org.gvsig.remoteclient.wfs.schema.XMLNameSpace; |
||
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$
|
||
60 | * $Log$
|
||
61 | * Revision 1.1 2007-02-09 14:11:01 jorpiell
|
||
62 | * Primer piloto del soporte para WFS 1.1 y para WFS-T
|
||
63 | *
|
||
64 | *
|
||
65 | */
|
||
66 | /**
|
||
67 | * @author Jorge Piera Llodr? (piera_jor@gva.es)
|
||
68 | */
|
||
69 | public class WFSFeature1_1_0 extends WFSFeature{ |
||
70 | 33738 | jpiera | |
71 | private static final StringUtils stringUtils = CompatLocator.getStringUtils(); |
||
72 | |||
73 | 29661 | jpiera | public WFSFeature1_1_0() {
|
74 | |||
75 | } |
||
76 | |||
77 | public WFSFeature1_1_0(String name) { |
||
78 | super(name);
|
||
79 | } |
||
80 | |||
81 | /**
|
||
82 | * <p>Parses the contents of the parser(WMSCapabilities)
|
||
83 | * to extract the information about an WMSLayer</p>
|
||
84 | * @throws IOException
|
||
85 | * @throws XmlPullParserException
|
||
86 | *
|
||
87 | */
|
||
88 | public void parse(KXmlParser parser) throws XmlPullParserException, IOException{ |
||
89 | int currentTag;
|
||
90 | boolean end = false; |
||
91 | |||
92 | parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.WFS_FEATURETYPE);
|
||
93 | |||
94 | for (int i=0 ; i<parser.getAttributeCount() ; i++){ |
||
95 | 33738 | jpiera | String[] attName = stringUtils.split(parser.getAttributeName(i), ":"); |
96 | 29661 | jpiera | if (attName.length == 2){ |
97 | if (attName[0].compareTo(GMLTags.XML_NAMESPACE)==0){ |
||
98 | XMLNameSpace nameSpace = new XMLNameSpace(attName[1],parser.getAttributeValue(i)); |
||
99 | this.setNamespace(nameSpace);
|
||
100 | } |
||
101 | } |
||
102 | } |
||
103 | |||
104 | currentTag = parser.next(); |
||
105 | while (!end)
|
||
106 | { |
||
107 | switch(currentTag)
|
||
108 | { |
||
109 | case KXmlParser.START_TAG:
|
||
110 | if (parser.getName().compareToIgnoreCase(CapabilitiesTags.NAME)==0) |
||
111 | { |
||
112 | this.setName(parser.nextText());
|
||
113 | }else if (parser.getName().compareToIgnoreCase(CapabilitiesTags.TITLE)==0){ |
||
114 | this.setTitle(parser.nextText());
|
||
115 | }else if (parser.getName().compareToIgnoreCase(CapabilitiesTags.WFS_KEYWORDS)==0){ |
||
116 | parser.nextTag(); |
||
117 | while (parser.getName().compareTo(CapabilitiesTags.KEYWORD)==0){ |
||
118 | parser.next(); |
||
119 | String keyword = parser.getText();
|
||
120 | if ((keyword != null) || (!(keyword.equals("")))){ |
||
121 | this.addKeyword(keyword);
|
||
122 | } |
||
123 | //Keyword end tag
|
||
124 | parser.nextTag(); |
||
125 | //Keyword start tag?
|
||
126 | parser.nextTag(); |
||
127 | } |
||
128 | |||
129 | |||
130 | } else if (parser.getName().compareToIgnoreCase(CapabilitiesTags.KEYWORD)==0){ |
||
131 | this.addKeyword(parser.nextText());
|
||
132 | } else if (parser.getName().compareToIgnoreCase(CapabilitiesTags.SRS)==0){ |
||
133 | String value = parser.nextText();
|
||
134 | if (value != null){ |
||
135 | 33738 | jpiera | String[] mySRSs = stringUtils.split(value, " "); |
136 | 29661 | jpiera | for (int i = 0; i < mySRSs.length; i++) { |
137 | this.addSRS(mySRSs[i]);
|
||
138 | } |
||
139 | |||
140 | } |
||
141 | } else if (parser.getName().compareToIgnoreCase(CapabilitiesTags.DEAFAULTSRS)==0){ |
||
142 | String value = parser.nextText();
|
||
143 | addSRS(value.trim()); |
||
144 | } else if (parser.getName().compareToIgnoreCase(CapabilitiesTags.LATLONGBOUNDINGBOX)==0){ |
||
145 | BoundaryBox bbox = new BoundaryBox();
|
||
146 | bbox.setSrs(CapabilitiesTags.EPSG_4326); |
||
147 | String value = parser.getAttributeValue("",CapabilitiesTags.MINX); |
||
148 | if ((value != null) && (Utilities.isNumber(value))) |
||
149 | bbox.setXmin(Double.parseDouble(value));
|
||
150 | value = parser.getAttributeValue("",CapabilitiesTags.MINY);
|
||
151 | if ((value != null) && (Utilities.isNumber(value))) |
||
152 | bbox.setYmin(Double.parseDouble(value));
|
||
153 | value = parser.getAttributeValue("",CapabilitiesTags.MAXX);
|
||
154 | if ((value != null) && (Utilities.isNumber(value))) |
||
155 | bbox.setXmax(Double.parseDouble(value));
|
||
156 | value = parser.getAttributeValue("",CapabilitiesTags.MAXY);
|
||
157 | if ((value != null) && (Utilities.isNumber(value))) |
||
158 | bbox.setYmax(Double.parseDouble(value));
|
||
159 | this.addBBox(bbox);
|
||
160 | this.setLatLonBbox(bbox);
|
||
161 | } else if (parser.getName().compareTo(CapabilitiesTags.BOUNDINGBOX)==0){ |
||
162 | BoundaryBox bbox = new BoundaryBox();
|
||
163 | String value = parser.getAttributeValue("",CapabilitiesTags.SRS); |
||
164 | if (value != null) |
||
165 | bbox.setSrs(value); |
||
166 | value = parser.getAttributeValue("",CapabilitiesTags.MINX);
|
||
167 | if ((value != null) && (Utilities.isNumber(value))) |
||
168 | bbox.setXmin(Double.parseDouble(value));
|
||
169 | value = parser.getAttributeValue("",CapabilitiesTags.MINY);
|
||
170 | if ((value != null) && (Utilities.isNumber(value))) |
||
171 | bbox.setYmin(Double.parseDouble(value));
|
||
172 | value = parser.getAttributeValue("",CapabilitiesTags.MAXX);
|
||
173 | if ((value != null) && (Utilities.isNumber(value))) |
||
174 | bbox.setXmax(Double.parseDouble(value));
|
||
175 | value = parser.getAttributeValue("",CapabilitiesTags.MAXY);
|
||
176 | if ((value != null) && (Utilities.isNumber(value))) |
||
177 | bbox.setYmax(Double.parseDouble(value));
|
||
178 | if (bbox.getSrs() != null){ |
||
179 | this.addBBox(bbox);
|
||
180 | this.addSRS(bbox.getSrs());
|
||
181 | } |
||
182 | 32673 | jpiera | } else if (CapabilitiesTags.WGS84BOUNDINGBOX.equals(parser.getName())){ |
183 | String lowerCorner = null; |
||
184 | String upperCorner = null; |
||
185 | parser.next(); |
||
186 | String tagName = parser.getName();
|
||
187 | while(!CapabilitiesTags.WGS84BOUNDINGBOX.equals(tagName)){
|
||
188 | if ((CapabilitiesTags.LOWERCORNER.equals(tagName)) && (KXmlParser.START_TAG == currentTag)){
|
||
189 | parser.next(); |
||
190 | lowerCorner = parser.getText(); |
||
191 | }else if ((CapabilitiesTags.UPPERCORNER.equals(tagName)) && (KXmlParser.START_TAG == currentTag)){ |
||
192 | parser.next(); |
||
193 | upperCorner = parser.getText(); |
||
194 | } |
||
195 | currentTag = parser.next(); |
||
196 | tagName = parser.getName(); |
||
197 | } |
||
198 | if ((lowerCorner != null) && (upperCorner != null)){ |
||
199 | BoundaryBox bbox = new BoundaryBox();
|
||
200 | bbox.setSrs("EPSG:4326");
|
||
201 | 33738 | jpiera | String[] lowerCoordinates = stringUtils.split(lowerCorner, "[! \t\r\n]"); |
202 | 32673 | jpiera | if (lowerCoordinates.length >= 2){ |
203 | try{
|
||
204 | 33738 | jpiera | bbox.setXmin(Double.valueOf(lowerCoordinates[0]).doubleValue()); |
205 | bbox.setYmin(Double.valueOf(lowerCoordinates[1]).doubleValue()); |
||
206 | 32673 | jpiera | }catch(NumberFormatException e){ |
207 | //Is not a number
|
||
208 | } |
||
209 | } |
||
210 | 33738 | jpiera | String[] upperCoordinates = stringUtils.split(upperCorner, "[! \t\r\n]"); |
211 | 32673 | jpiera | if (upperCoordinates.length >= 2){ |
212 | try{
|
||
213 | 33738 | jpiera | bbox.setXmax(Double.valueOf(upperCoordinates[0]).doubleValue()); |
214 | bbox.setYmax(Double.valueOf(upperCoordinates[1]).doubleValue()); |
||
215 | 32673 | jpiera | }catch(NumberFormatException e){ |
216 | //Is not a number
|
||
217 | } |
||
218 | } |
||
219 | this.addBBox(bbox);
|
||
220 | this.setLatLonBbox(bbox);
|
||
221 | } |
||
222 | 29661 | jpiera | } |
223 | |||
224 | break;
|
||
225 | case KXmlParser.END_TAG:
|
||
226 | if (parser.getName().compareTo(CapabilitiesTags.WFS_FEATURETYPE) == 0) |
||
227 | end = true;
|
||
228 | break;
|
||
229 | case KXmlParser.TEXT:
|
||
230 | break;
|
||
231 | } |
||
232 | if (!end){
|
||
233 | currentTag = parser.next(); |
||
234 | } |
||
235 | } |
||
236 | } |
||
237 | } |