Statistics
| Revision:

root / trunk / libraries / libGPE-GML / src / org / gvsig / gpe / gml / bindings / geometries / LineStringTypeBinding.java @ 11464

History | View | Annotate | Download (2.8 KB)

1
package org.gvsig.gpe.gml.bindings.geometries;
2

    
3
import java.io.IOException;
4

    
5
import org.gvsig.gpe.gml.GMLTags;
6
import org.gvsig.gpe.gml.GPEGmlParser;
7
import org.kxml2.io.KXmlParser;
8
import org.xmlpull.v1.XmlPullParser;
9
import org.xmlpull.v1.XmlPullParserException;
10

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

    
65
        public static Object parse(XmlPullParser parser,GPEGmlParser handler) throws XmlPullParserException, IOException {
66
                boolean endFeature = false;
67
                int currentTag;
68
                Object lineString = null;
69

    
70
                String srsName = AGeometryBinding.getSrsName(parser, handler);
71
                String id = AGeometryBinding.getID(parser, handler);
72

    
73

    
74
                String tag = parser.getName();
75
                currentTag = parser.getEventType();
76

    
77
                while (!endFeature){
78
                        switch(currentTag){
79
                        case KXmlParser.START_TAG:
80
                                if (tag.compareTo(GMLTags.GML_COORDINATES) == 0){
81
                                        double[][] coordinates = CoordinatesBinding.parse(parser, handler);
82
                                        lineString = handler.getContentHandler().startLineString(id,
83
                                                        coordinates[0],
84
                                                        coordinates[1],
85
                                                        coordinates[2],                                                                
86
                                                        srsName);                                                
87
                                }
88
                                break;
89
                        case KXmlParser.END_TAG:
90
                                if (tag.compareTo(GMLTags.GML_LINESTRING) == 0){                                                
91
                                        endFeature = true;
92
                                        handler.getContentHandler().endLineString(lineString);
93
                                }
94
                                break;
95
                        case KXmlParser.TEXT:                                        
96

    
97
                                break;
98
                        }
99
                        if (!endFeature){                                        
100
                                currentTag = parser.next();
101
                                tag = parser.getName();
102
                        }
103
                }                
104

    
105
                return lineString;        
106
        }
107
}