Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libRemoteServices / src / org / gvsig / remoteclient / wfs / wfs_1_0_0 / WFSFeature1_0_0.java @ 34026

History | View | Annotate | Download (7.52 KB)

1
package org.gvsig.remoteclient.wfs.wfs_1_0_0;
2

    
3
import java.io.IOException;
4

    
5
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
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.WFSServiceInformation;
15
import org.gvsig.remoteclient.wfs.schema.GMLTags;
16
import org.gvsig.remoteclient.wfs.schema.XMLNameSpace;
17

    
18
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
19
 *
20
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
21
 *
22
 * This program is free software; you can redistribute it and/or
23
 * modify it under the terms of the GNU General Public License
24
 * as published by the Free Software Foundation; either version 2
25
 * of the License, or (at your option) any later version.
26
 *
27
 * This program is distributed in the hope that it will be useful,
28
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
30
 * GNU General Public License for more details.
31
 *
32
 * You should have received a copy of the GNU General Public License
33
 * along with this program; if not, write to the Free Software
34
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
35
 *
36
 * For more information, contact:
37
 *
38
 *  Generalitat Valenciana
39
 *   Conselleria d'Infraestructures i Transport
40
 *   Av. Blasco Ib??ez, 50
41
 *   46010 VALENCIA
42
 *   SPAIN
43
 *
44
 *      +34 963862235
45
 *   gvsig@gva.es
46
 *      www.gvsig.gva.es
47
 *
48
 *    or
49
 *
50
 *   IVER T.I. S.A
51
 *   Salamanca 50
52
 *   46005 Valencia
53
 *   Spain
54
 *
55
 *   +34 963163400
56
 *   dac@iver.es
57
 */
58
/* CVS MESSAGES:
59
 *
60
 * $Id: WFSFeature1_0_0.java 34026 2010-11-08 13:06:02Z jpiera $
61
 * $Log$
62
 * Revision 1.8  2007-09-20 09:30:12  jaume
63
 * removed unnecessary imports
64
 *
65
 * Revision 1.7  2007/02/09 14:11:01  jorpiell
66
 * Primer piloto del soporte para WFS 1.1 y para WFS-T
67
 *
68
 * Revision 1.6  2006/07/12 06:23:31  jorpiell
69
 * Soportados tipos m?s complejos
70
 *
71
 * Revision 1.5  2006/06/15 09:05:06  jorpiell
72
 * Actualizados los WFS
73
 *
74
 * Revision 1.4  2006/05/23 13:23:22  jorpiell
75
 * Se ha cambiado el final del bucle de parseado y se tiene en cuenta el online resource
76
 *
77
 * Revision 1.2  2006/04/20 16:39:16  jorpiell
78
 * A?adida la operacion de describeFeatureType y el parser correspondiente.
79
 *
80
 * Revision 1.1  2006/04/19 12:51:35  jorpiell
81
 * A?adidas algunas de las clases del servicio WFS
82
 *
83
 *
84
 */
85
/**
86
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
87
 */
88
public class WFSFeature1_0_0 extends WFSFeature{
89
    private static final StringUtils stringUtils = CompatLocator.getStringUtils();
90
    
91
    WFSFeature1_0_0(WFSServiceInformation serviceInformation) {
92
                super(serviceInformation);
93
        }
94

    
95
    WFSFeature1_0_0(WFSServiceInformation serviceInformation, String name) {
96
                super(serviceInformation, name);                
97
        }
98

    
99
        /**
100
         * <p>Parses the contents of the parser(WMSCapabilities)
101
         * to extract the information about an WMSLayer</p>
102
         * @throws IOException 
103
         * @throws XmlPullParserException 
104
         * 
105
         */
106
        public void parse(KXmlParser parser) throws XmlPullParserException, IOException{
107
                int currentTag;
108
                boolean end = false;
109
                
110
                parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.WFS_FEATURETYPE);
111
                
112
                for (int i=0 ; i<parser.getAttributeCount() ; i++){
113
                        String[] attName = stringUtils.split(parser.getAttributeName(i), ":");
114
                        if (attName.length == 2){
115
                                if (attName[0].compareTo(GMLTags.XML_NAMESPACE)==0){
116
                                        XMLNameSpace nameSpace = new XMLNameSpace(attName[1],parser.getAttributeValue(i));
117
                                        this.setNamespace(nameSpace);
118
                                }
119
                        }
120
                }
121
                
122
                currentTag = parser.next();                
123
                while (!end) 
124
                {
125
                        switch(currentTag)
126
                        {
127
                        case KXmlParser.START_TAG:
128
                                if (parser.getName().compareToIgnoreCase(CapabilitiesTags.NAME)==0)
129
                                {
130
                                        this.setName(parser.nextText());
131
                                } 
132
                                if (parser.getName().compareToIgnoreCase(CapabilitiesTags.TITLE)==0)
133
                                {
134
                                        this.setTitle(parser.nextText());
135
                                } 
136
                                if (parser.getName().compareToIgnoreCase(CapabilitiesTags.WFS_KEYWORDS)==0)
137
                                {
138
                                        String keyword = parser.nextText();
139
                                        if ((keyword != null) || (!(keyword.equals("")))){
140
                                                this.addKeyword(keyword);
141
                                        }                                        
142
                                } 
143
                                if (parser.getName().compareToIgnoreCase(CapabilitiesTags.KEYWORD)==0)
144
                                {
145
                                        this.addKeyword(parser.nextText());                                                                        
146
                                } 
147
                                if (parser.getName().compareToIgnoreCase(CapabilitiesTags.SRS)==0)
148
                                {
149
                                     String value = parser.nextText();
150
                     if (value != null){
151
                         String[] mySRSs = stringUtils.split(value, " ");
152
                         for (int i = 0; i < mySRSs.length; i++) {
153
                             this.addSRS(mySRSs[i]);    
154
                         }
155
                         
156
                     }
157
                                } 
158
                                if (parser.getName().compareToIgnoreCase(CapabilitiesTags.LATLONGBOUNDINGBOX)==0)
159
                                {
160
                                        BoundaryBox bbox = new BoundaryBox();
161
                                        bbox.setSrs(CapabilitiesTags.EPSG_4326);
162
                    String value = parser.getAttributeValue("",CapabilitiesTags.MINX);
163
                    if ((value != null) && (Utilities.isNumber(value)))
164
                        bbox.setXmin(Double.parseDouble(value));        
165
                    value = parser.getAttributeValue("",CapabilitiesTags.MINY);
166
                    if ((value != null) && (Utilities.isNumber(value)))
167
                        bbox.setYmin(Double.parseDouble(value));        
168
                    value = parser.getAttributeValue("",CapabilitiesTags.MAXX);
169
                    if ((value != null) && (Utilities.isNumber(value)))
170
                        bbox.setXmax(Double.parseDouble(value));        
171
                    value = parser.getAttributeValue("",CapabilitiesTags.MAXY);
172
                    if ((value != null) && (Utilities.isNumber(value)))
173
                        bbox.setYmax(Double.parseDouble(value));
174
                    this.addBBox(bbox);
175
                    this.setLatLonBbox(bbox);                                 
176
                                } 
177
                                if (parser.getName().compareTo(CapabilitiesTags.BOUNDINGBOX)==0)
178
                {
179
                                        BoundaryBox bbox = new BoundaryBox();
180
                    String value = parser.getAttributeValue("",CapabilitiesTags.SRS);
181
                    if (value != null)
182
                        bbox.setSrs(value);
183
                    value = parser.getAttributeValue("",CapabilitiesTags.MINX);
184
                    if ((value != null) && (Utilities.isNumber(value)))
185
                        bbox.setXmin(Double.parseDouble(value));        
186
                    value = parser.getAttributeValue("",CapabilitiesTags.MINY);
187
                    if ((value != null) && (Utilities.isNumber(value)))
188
                        bbox.setYmin(Double.parseDouble(value));        
189
                    value = parser.getAttributeValue("",CapabilitiesTags.MAXX);
190
                    if ((value != null) && (Utilities.isNumber(value)))
191
                        bbox.setXmax(Double.parseDouble(value));        
192
                    value = parser.getAttributeValue("",CapabilitiesTags.MAXY);
193
                    if ((value != null) && (Utilities.isNumber(value)))
194
                        bbox.setYmax(Double.parseDouble(value));        
195
                    if (bbox.getSrs() != null){
196
                            this.addBBox(bbox);
197
                            this.addSRS(bbox.getSrs());
198
                    }
199
                }         
200
                                
201
                                break;
202
                        case KXmlParser.END_TAG:
203
                                if (parser.getName().compareTo(CapabilitiesTags.WFS_FEATURETYPE) == 0)
204
                                        end = true;
205
                                break;
206
                        case KXmlParser.TEXT:                   
207
                                break;
208
                        }
209
                        if (!end){
210
                                currentTag = parser.next();
211
                        }
212
                }    
213
        }
214
}