Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.remoteclient / src / main / java / org / gvsig / remoteclient / wfs / wfs_1_0_0 / WFSFeature1_0_0.java @ 40596

History | View | Annotate | Download (6.54 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.wfs_1_0_0;
25

    
26
import java.io.IOException;
27

    
28
import org.kxml2.io.KXmlParser;
29
import org.xmlpull.v1.XmlPullParserException;
30

    
31
import org.gvsig.compat.CompatLocator;
32
import org.gvsig.compat.lang.StringUtils;
33
import org.gvsig.remoteclient.utils.BoundaryBox;
34
import org.gvsig.remoteclient.utils.CapabilitiesTags;
35
import org.gvsig.remoteclient.utils.Utilities;
36
import org.gvsig.remoteclient.wfs.WFSFeature;
37
import org.gvsig.remoteclient.wfs.WFSServiceInformation;
38
import org.gvsig.remoteclient.wfs.schema.GMLTags;
39
import org.gvsig.remoteclient.wfs.schema.XMLNameSpace;
40

    
41
/**
42
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
43
 */
44
public class WFSFeature1_0_0 extends WFSFeature{
45
    private static final StringUtils stringUtils = CompatLocator.getStringUtils();
46
    
47
    WFSFeature1_0_0(WFSServiceInformation serviceInformation) {
48
                super(serviceInformation);
49
        }
50

    
51
    WFSFeature1_0_0(WFSServiceInformation serviceInformation, String name) {
52
                super(serviceInformation, name);                
53
        }
54

    
55
        /**
56
         * <p>Parses the contents of the parser(WMSCapabilities)
57
         * to extract the information about an WMSLayer</p>
58
         * @throws IOException 
59
         * @throws XmlPullParserException 
60
         * 
61
         */
62
        public void parse(KXmlParser parser) throws XmlPullParserException, IOException{
63
                int currentTag;
64
                boolean end = false;
65
                
66
                parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.WFS_FEATURETYPE);
67
                
68
                for (int i=0 ; i<parser.getAttributeCount() ; i++){
69
                        String[] attName = stringUtils.split(parser.getAttributeName(i), ":");
70
                        if (attName.length == 2){
71
                                if (attName[0].compareTo(GMLTags.XML_NAMESPACE)==0){
72
                                        XMLNameSpace nameSpace = new XMLNameSpace(attName[1],parser.getAttributeValue(i));
73
                                        this.setNamespace(nameSpace);
74
                                }
75
                        }
76
                }
77
                
78
                currentTag = parser.next();                
79
                while (!end) 
80
                {
81
                        switch(currentTag)
82
                        {
83
                        case KXmlParser.START_TAG:
84
                                if (parser.getName().compareToIgnoreCase(CapabilitiesTags.NAME)==0)
85
                                {
86
                                        this.setName(parser.nextText());
87
                                } 
88
                                if (parser.getName().compareToIgnoreCase(CapabilitiesTags.TITLE)==0)
89
                                {
90
                                        this.setTitle(parser.nextText());
91
                                } 
92
                                if (parser.getName().compareToIgnoreCase(CapabilitiesTags.WFS_KEYWORDS)==0)
93
                                {
94
                                        String keyword = parser.nextText();
95
                                        if ((keyword != null) || (!(keyword.equals("")))){
96
                                                this.addKeyword(keyword);
97
                                        }                                        
98
                                } 
99
                                if (parser.getName().compareToIgnoreCase(CapabilitiesTags.KEYWORD)==0)
100
                                {
101
                                        this.addKeyword(parser.nextText());                                                                        
102
                                } 
103
                                if (parser.getName().compareToIgnoreCase(CapabilitiesTags.SRS)==0)
104
                                {
105
                                     String value = parser.nextText();
106
                     if (value != null){
107
                         String[] mySRSs = stringUtils.split(value, " ");
108
                         for (int i = 0; i < mySRSs.length; i++) {
109
                             this.addSRS(mySRSs[i]);    
110
                         }
111
                         
112
                     }
113
                                } 
114
                                if (parser.getName().compareToIgnoreCase(CapabilitiesTags.LATLONGBOUNDINGBOX)==0)
115
                                {
116
                                        BoundaryBox bbox = new BoundaryBox();
117
                                        bbox.setSrs(CapabilitiesTags.EPSG_4326);
118
                    String value = parser.getAttributeValue("",CapabilitiesTags.MINX);
119
                    if ((value != null) && (Utilities.isNumber(value)))
120
                        bbox.setXmin(Double.parseDouble(value));        
121
                    value = parser.getAttributeValue("",CapabilitiesTags.MINY);
122
                    if ((value != null) && (Utilities.isNumber(value)))
123
                        bbox.setYmin(Double.parseDouble(value));        
124
                    value = parser.getAttributeValue("",CapabilitiesTags.MAXX);
125
                    if ((value != null) && (Utilities.isNumber(value)))
126
                        bbox.setXmax(Double.parseDouble(value));        
127
                    value = parser.getAttributeValue("",CapabilitiesTags.MAXY);
128
                    if ((value != null) && (Utilities.isNumber(value)))
129
                        bbox.setYmax(Double.parseDouble(value));
130
                    this.addBBox(bbox);
131
                    this.setLatLonBbox(bbox);                                 
132
                                } 
133
                                if (parser.getName().compareTo(CapabilitiesTags.BOUNDINGBOX)==0)
134
                {
135
                                        BoundaryBox bbox = new BoundaryBox();
136
                    String value = parser.getAttributeValue("",CapabilitiesTags.SRS);
137
                    if (value != null)
138
                        bbox.setSrs(value);
139
                    value = parser.getAttributeValue("",CapabilitiesTags.MINX);
140
                    if ((value != null) && (Utilities.isNumber(value)))
141
                        bbox.setXmin(Double.parseDouble(value));        
142
                    value = parser.getAttributeValue("",CapabilitiesTags.MINY);
143
                    if ((value != null) && (Utilities.isNumber(value)))
144
                        bbox.setYmin(Double.parseDouble(value));        
145
                    value = parser.getAttributeValue("",CapabilitiesTags.MAXX);
146
                    if ((value != null) && (Utilities.isNumber(value)))
147
                        bbox.setXmax(Double.parseDouble(value));        
148
                    value = parser.getAttributeValue("",CapabilitiesTags.MAXY);
149
                    if ((value != null) && (Utilities.isNumber(value)))
150
                        bbox.setYmax(Double.parseDouble(value));        
151
                    if (bbox.getSrs() != null){
152
                            this.addBBox(bbox);
153
                            this.addSRS(bbox.getSrs());
154
                    }
155
                }         
156
                                
157
                                break;
158
                        case KXmlParser.END_TAG:
159
                                if (parser.getName().compareTo(CapabilitiesTags.WFS_FEATURETYPE) == 0)
160
                                        end = true;
161
                                break;
162
                        case KXmlParser.TEXT:                   
163
                                break;
164
                        }
165
                        if (!end){
166
                                currentTag = parser.next();
167
                        }
168
                }    
169
        }
170
}