Statistics
| Revision:

root / trunk / libraries / libGPE-GML / src / org / gvsig / gpe / gml / parser / sfp0 / geometries / UpperCornerTypeBinding.java @ 18773

History | View | Annotate | Download (3.12 KB)

1
package org.gvsig.gpe.gml.parser.sfp0.geometries;
2

    
3
import java.io.IOException;
4

    
5
import org.gvsig.gpe.gml.GMLTags;
6
import org.gvsig.gpe.gml.GPEDefaultGmlParser;
7
import org.gvsig.gpe.gml.parser.v2.geometries.DoubleTypeBinding;
8
import org.gvsig.gpe.gml.utils.CompareUtils;
9
import org.kxml2.io.KXmlParser;
10
import org.xmlpull.v1.XmlPullParser;
11
import org.xmlpull.v1.XmlPullParserException;
12

    
13
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
14
 *
15
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
16
 *
17
 * This program is free software; you can redistribute it and/or
18
 * modify it under the terms of the GNU General Public License
19
 * as published by the Free Software Foundation; either version 2
20
 * of the License, or (at your option) any later version.
21
 *
22
 * This program is distributed in the hope that it will be useful,
23
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25
 * GNU General Public License for more details.
26
 *
27
 * You should have received a copy of the GNU General Public License
28
 * along with this program; if not, write to the Free Software
29
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
30
 *
31
 * For more information, contact:
32
 *
33
 *  Generalitat Valenciana
34
 *   Conselleria d'Infraestructures i Transport
35
 *   Av. Blasco Ib??ez, 50
36
 *   46010 VALENCIA
37
 *   SPAIN
38
 *
39
 *      +34 963862235
40
 *   gvsig@gva.es
41
 *      www.gvsig.gva.es
42
 *
43
 *    or
44
 *
45
 *   IVER T.I. S.A
46
 *   Salamanca 50
47
 *   46005 Valencia
48
 *   Spain
49
 *
50
 *   +34 963163400
51
 *   dac@iver.es
52
 */
53

    
54
public class UpperCornerTypeBinding {
55
                
56
        public double[] parse(XmlPullParser parser,GPEDefaultGmlParser handler) throws XmlPullParserException, IOException  {
57
                boolean endFeature = false;
58
                int currentTag;
59
                
60
                String TUPLES_SEPARATOR = GMLTags.GML_DEFAULT_TUPLES_SEPARATOR;
61
                        
62
                double[] aCoordinates = null;
63
                String[] coordinate = null;
64
                
65
                String tag = parser.getName();
66
                currentTag = parser.getEventType();
67

    
68
                while (!endFeature){
69
                        switch(currentTag){
70
                        case KXmlParser.START_TAG:
71
                                if (CompareUtils.compareWithOutNamespace(tag,GMLTags.GML_UPPERCORNER)){
72
                                        parser.next();                                                
73
                                        String[] coordinates = org.gvsig.gpe.gml.utils.StringUtils.splitString(parser.getText().trim(),TUPLES_SEPARATOR);
74
                                        //String[] coordinates = parser.getText().trim().split(TUPLES_SEPARATOR);
75
                                        aCoordinates = new double[3];
76
                                        for (int i=0 ; i < coordinates.length; i++){                                        
77
                                                        aCoordinates[i] = DoubleTypeBinding.parse(coordinates[i],".");
78
                                        }
79
                                        if (coordinates.length == 2){
80
                                                aCoordinates[2] = 0.0;
81
                                        }
82
                                        else if (coordinates.length == 1){
83
                                                aCoordinates[1] = 0.0;
84
                                                aCoordinates[2] = 0.0;        
85
                                        }
86
                                        else
87
                                        {
88
                                                aCoordinates[0] = 0.0;
89
                                                aCoordinates[1] = 0.0;
90
                                                aCoordinates[2] = 0.0;
91
                                        }
92
                                }
93
                                break;
94
                        case KXmlParser.END_TAG:
95
                                if (CompareUtils.compareWithOutNamespace(tag,GMLTags.GML_UPPERCORNER)){                                                
96
                                        endFeature = true;
97
                                }
98
                                break;
99
                        case KXmlParser.TEXT:                                        
100
                                break;
101
                        }
102
                        if (!endFeature){                                        
103
                                currentTag = parser.next();
104
                                tag = parser.getName();
105
                        }
106
                }                        
107
                return aCoordinates;        
108
        }
109
}
110