Statistics
| Revision:

root / trunk / libraries / libGPE-KML / src / org / gvsig / gpe / kml / bindings / LookAtBinding.java @ 11205

History | View | Annotate | Download (3.87 KB)

1
package org.gvsig.gpe.kml.bindings;
2

    
3
import java.io.IOException;
4
import java.util.LinkedHashMap;
5

    
6
import org.gvsig.gpe.kml.GPEKmlParser;
7
import org.gvsig.gpe.kml.KmlTags;
8
import org.gvsig.gpe.kml.exceptions.KmlBodyParseException;
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
/* CVS MESSAGES:
54
 *
55
 * $Id: LookAtBinding.java 11205 2007-04-13 13:16:21Z jorpiell $
56
 * $Log$
57
 * Revision 1.2  2007-04-13 13:16:21  jorpiell
58
 * Add KML reading support
59
 *
60
 * Revision 1.1  2007/03/07 08:19:10  jorpiell
61
 * Pasadas las clases de KML de libGPE-GML a libGPE-KML
62
 *
63
 * Revision 1.1  2007/02/28 11:48:31  csanchez
64
 * *** empty log message ***
65
 *
66
 * Revision 1.1  2007/02/20 10:53:20  jorpiell
67
 * A?adidos los proyectos de kml y gml antiguos
68
 *
69
 * Revision 1.1  2007/02/12 13:49:18  jorpiell
70
 * A?adido el driver de KML
71
 *
72
 *
73
 */
74
/**
75
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
76
 */
77
public class LookAtBinding{
78
        
79
        /*
80
         *  (non-Javadoc)
81
         * @see org.gvsig.remoteClient.kml.bindings.ComplexBinding#parse(org.gvsig.remoteClient.gmlEngine.readers.IReaderFile)
82
         */
83
        public static void parse(XmlPullParser parser,GPEKmlParser handler) throws KmlBodyParseException {
84
                boolean endFeature = false;
85
                int currentTag;                
86
                double longitude;
87
                double latitude;
88
                double altitude;
89
                double range;
90
                float tilt;
91
                float heading;
92
                
93
                try {
94
                        String tag = parser.getName();
95
                        currentTag = parser.getEventType();
96
                        
97
                        while (!endFeature){
98
                                switch(currentTag){
99
                                case KXmlParser.START_TAG:
100
                                        if (tag.compareTo(KmlTags.LONGITUDE) == 0){
101
                                                parser.next();
102
                                                longitude = new Double(parser.getText()).doubleValue();
103
                                        }else if (tag.compareTo(KmlTags.LATITUDE) == 0){
104
                                                parser.next();
105
                                                latitude = new Double(parser.getText()).doubleValue();                                                
106
                                        }else if (tag.compareTo(KmlTags.ALTITUDE) == 0){
107
                                                parser.next();
108
                                                altitude = new Double(parser.getText()).doubleValue();
109
                                        }else if (tag.compareTo(KmlTags.RANGE) == 0){
110
                                                parser.next();
111
                                                altitude = new Double(parser.getText()).doubleValue();
112
                                        }else if (tag.compareTo(KmlTags.TILT) == 0){
113
                                                parser.next();
114
                                                tilt = new Float(parser.getText()).floatValue();
115
                                        }else if (tag.compareTo(KmlTags.HEADING) == 0){
116
                                                parser.next();
117
                                                longitude = new Float(parser.getText()).floatValue();
118
                                        }
119
                                        break;
120
                                case KXmlParser.END_TAG:
121
                                        if (tag.compareTo(KmlTags.LOOKAT) == 0){                                                
122
                                                endFeature = true;
123
                                        }
124
                                        break;
125
                                case KXmlParser.TEXT:                                        
126
                                        
127
                                        break;
128
                                }
129
                                if (!endFeature){                                        
130
                                        currentTag = parser.next();
131
                                        tag = parser.getName();
132
                                }
133
                        }                        
134
                } catch (XmlPullParserException e) {
135
                        throw new KmlBodyParseException(e);
136
                } catch (IOException e) {
137
                        throw new KmlBodyParseException(e);
138
                }                
139
        }
140
}