Statistics
| Revision:

svn-gvsig-desktop / tags / v2_0_0_Build_2020 / libraries / libRemoteServices / src / org / gvsig / remoteclient / wfs / wfs_1_0_0 / WFSFeature1_0_0.java @ 33910

History | View | Annotate | Download (7.35 KB)

1 29662 jpiera
package org.gvsig.remoteclient.wfs.wfs_1_0_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 29662 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.8  2007-09-20 09:30:12  jaume
62
 * removed unnecessary imports
63
 *
64
 * Revision 1.7  2007/02/09 14:11:01  jorpiell
65
 * Primer piloto del soporte para WFS 1.1 y para WFS-T
66
 *
67
 * Revision 1.6  2006/07/12 06:23:31  jorpiell
68
 * Soportados tipos m?s complejos
69
 *
70
 * Revision 1.5  2006/06/15 09:05:06  jorpiell
71
 * Actualizados los WFS
72
 *
73
 * Revision 1.4  2006/05/23 13:23:22  jorpiell
74
 * Se ha cambiado el final del bucle de parseado y se tiene en cuenta el online resource
75
 *
76
 * Revision 1.2  2006/04/20 16:39:16  jorpiell
77
 * A?adida la operacion de describeFeatureType y el parser correspondiente.
78
 *
79
 * Revision 1.1  2006/04/19 12:51:35  jorpiell
80
 * A?adidas algunas de las clases del servicio WFS
81
 *
82
 *
83
 */
84
/**
85
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
86
 */
87
public class WFSFeature1_0_0 extends WFSFeature{
88 33738 jpiera
    private static final StringUtils stringUtils = CompatLocator.getStringUtils();
89
90 29662 jpiera
        public WFSFeature1_0_0() {
91
92
        }
93
94
        public WFSFeature1_0_0(String name) {
95
                super(name);
96
        }
97
98
        /**
99
         * <p>Parses the contents of the parser(WMSCapabilities)
100
         * to extract the information about an WMSLayer</p>
101
         * @throws IOException
102
         * @throws XmlPullParserException
103
         *
104
         */
105
        public void parse(KXmlParser parser) throws XmlPullParserException, IOException{
106
                int currentTag;
107
                boolean end = false;
108
109
                parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.WFS_FEATURETYPE);
110
111
                for (int i=0 ; i<parser.getAttributeCount() ; i++){
112 33738 jpiera
                        String[] attName = stringUtils.split(parser.getAttributeName(i), ":");
113 29662 jpiera
                        if (attName.length == 2){
114
                                if (attName[0].compareTo(GMLTags.XML_NAMESPACE)==0){
115
                                        XMLNameSpace nameSpace = new XMLNameSpace(attName[1],parser.getAttributeValue(i));
116
                                        this.setNamespace(nameSpace);
117
                                }
118
                        }
119
                }
120
121
                currentTag = parser.next();
122
                while (!end)
123
                {
124
                        switch(currentTag)
125
                        {
126
                        case KXmlParser.START_TAG:
127
                                if (parser.getName().compareToIgnoreCase(CapabilitiesTags.NAME)==0)
128
                                {
129
                                        this.setName(parser.nextText());
130
                                }
131
                                if (parser.getName().compareToIgnoreCase(CapabilitiesTags.TITLE)==0)
132
                                {
133
                                        this.setTitle(parser.nextText());
134
                                }
135
                                if (parser.getName().compareToIgnoreCase(CapabilitiesTags.WFS_KEYWORDS)==0)
136
                                {
137
                                        String keyword = parser.nextText();
138
                                        if ((keyword != null) || (!(keyword.equals("")))){
139
                                                this.addKeyword(keyword);
140
                                        }
141
                                }
142
                                if (parser.getName().compareToIgnoreCase(CapabilitiesTags.KEYWORD)==0)
143
                                {
144
                                        this.addKeyword(parser.nextText());
145
                                }
146
                                if (parser.getName().compareToIgnoreCase(CapabilitiesTags.SRS)==0)
147
                                {
148
                                     String value = parser.nextText();
149
                     if (value != null){
150 33738 jpiera
                         String[] mySRSs = stringUtils.split(value, " ");
151 29662 jpiera
                         for (int i = 0; i < mySRSs.length; i++) {
152
                             this.addSRS(mySRSs[i]);
153
                         }
154
155
                     }
156
                                }
157
                                if (parser.getName().compareToIgnoreCase(CapabilitiesTags.LATLONGBOUNDINGBOX)==0)
158
                                {
159
                                        BoundaryBox bbox = new BoundaryBox();
160
                                        bbox.setSrs(CapabilitiesTags.EPSG_4326);
161
                    String value = parser.getAttributeValue("",CapabilitiesTags.MINX);
162
                    if ((value != null) && (Utilities.isNumber(value)))
163
                        bbox.setXmin(Double.parseDouble(value));
164
                    value = parser.getAttributeValue("",CapabilitiesTags.MINY);
165
                    if ((value != null) && (Utilities.isNumber(value)))
166
                        bbox.setYmin(Double.parseDouble(value));
167
                    value = parser.getAttributeValue("",CapabilitiesTags.MAXX);
168
                    if ((value != null) && (Utilities.isNumber(value)))
169
                        bbox.setXmax(Double.parseDouble(value));
170
                    value = parser.getAttributeValue("",CapabilitiesTags.MAXY);
171
                    if ((value != null) && (Utilities.isNumber(value)))
172
                        bbox.setYmax(Double.parseDouble(value));
173
                    this.addBBox(bbox);
174
                    this.setLatLonBbox(bbox);
175
                                }
176
                                if (parser.getName().compareTo(CapabilitiesTags.BOUNDINGBOX)==0)
177
                {
178
                                        BoundaryBox bbox = new BoundaryBox();
179
                    String value = parser.getAttributeValue("",CapabilitiesTags.SRS);
180
                    if (value != null)
181
                        bbox.setSrs(value);
182
                    value = parser.getAttributeValue("",CapabilitiesTags.MINX);
183
                    if ((value != null) && (Utilities.isNumber(value)))
184
                        bbox.setXmin(Double.parseDouble(value));
185
                    value = parser.getAttributeValue("",CapabilitiesTags.MINY);
186
                    if ((value != null) && (Utilities.isNumber(value)))
187
                        bbox.setYmin(Double.parseDouble(value));
188
                    value = parser.getAttributeValue("",CapabilitiesTags.MAXX);
189
                    if ((value != null) && (Utilities.isNumber(value)))
190
                        bbox.setXmax(Double.parseDouble(value));
191
                    value = parser.getAttributeValue("",CapabilitiesTags.MAXY);
192
                    if ((value != null) && (Utilities.isNumber(value)))
193
                        bbox.setYmax(Double.parseDouble(value));
194
                    if (bbox.getSrs() != null){
195
                            this.addBBox(bbox);
196
                            this.addSRS(bbox.getSrs());
197
                    }
198
                }
199
200
                                break;
201
                        case KXmlParser.END_TAG:
202
                                if (parser.getName().compareTo(CapabilitiesTags.WFS_FEATURETYPE) == 0)
203
                                        end = true;
204
                                break;
205
                        case KXmlParser.TEXT:
206
                                break;
207
                        }
208
                        if (!end){
209
                                currentTag = parser.next();
210
                        }
211
                }
212
        }
213
}