svn-gvsig-desktop / trunk / libraries / libGPE-KML / src / org / gvsig / gpe / kml / reader / bindings / LookAtBinding.java @ 11573
History | View | Annotate | Download (4.46 KB)
1 | 11573 | jorpiell | package org.gvsig.gpe.kml.reader.bindings; |
---|---|---|---|
2 | |||
3 | import java.io.IOException; |
||
4 | |||
5 | import org.gvsig.gpe.kml.GPEKmlParser; |
||
6 | import org.gvsig.gpe.kml.KmlTags; |
||
7 | import org.gvsig.gpe.kml.exceptions.KmlBodyParseException; |
||
8 | import org.kxml2.io.KXmlParser; |
||
9 | import org.xmlpull.v1.XmlPullParser; |
||
10 | import org.xmlpull.v1.XmlPullParserException; |
||
11 | |||
12 | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
||
13 | *
|
||
14 | * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
||
15 | *
|
||
16 | * This program is free software; you can redistribute it and/or
|
||
17 | * modify it under the terms of the GNU General Public License
|
||
18 | * as published by the Free Software Foundation; either version 2
|
||
19 | * of the License, or (at your option) any later version.
|
||
20 | *
|
||
21 | * This program is distributed in the hope that it will be useful,
|
||
22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
24 | * GNU General Public License for more details.
|
||
25 | *
|
||
26 | * You should have received a copy of the GNU General Public License
|
||
27 | * along with this program; if not, write to the Free Software
|
||
28 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
29 | *
|
||
30 | * For more information, contact:
|
||
31 | *
|
||
32 | * Generalitat Valenciana
|
||
33 | * Conselleria d'Infraestructures i Transport
|
||
34 | * Av. Blasco Ib??ez, 50
|
||
35 | * 46010 VALENCIA
|
||
36 | * SPAIN
|
||
37 | *
|
||
38 | * +34 963862235
|
||
39 | * gvsig@gva.es
|
||
40 | * www.gvsig.gva.es
|
||
41 | *
|
||
42 | * or
|
||
43 | *
|
||
44 | * IVER T.I. S.A
|
||
45 | * Salamanca 50
|
||
46 | * 46005 Valencia
|
||
47 | * Spain
|
||
48 | *
|
||
49 | * +34 963163400
|
||
50 | * dac@iver.es
|
||
51 | */
|
||
52 | /* CVS MESSAGES:
|
||
53 | *
|
||
54 | * $Id$
|
||
55 | * $Log$
|
||
56 | * Revision 1.1 2007-05-11 07:06:29 jorpiell
|
||
57 | * Refactoring of some package names
|
||
58 | *
|
||
59 | * Revision 1.4 2007/05/08 08:22:37 jorpiell
|
||
60 | * Add comments to create javadocs
|
||
61 | *
|
||
62 | * Revision 1.3 2007/04/14 16:08:07 jorpiell
|
||
63 | * Kml writing support added
|
||
64 | *
|
||
65 | * Revision 1.2 2007/04/13 13:16:21 jorpiell
|
||
66 | * Add KML reading support
|
||
67 | *
|
||
68 | * Revision 1.1 2007/03/07 08:19:10 jorpiell
|
||
69 | * Pasadas las clases de KML de libGPE-GML a libGPE-KML
|
||
70 | *
|
||
71 | * Revision 1.1 2007/02/28 11:48:31 csanchez
|
||
72 | * *** empty log message ***
|
||
73 | *
|
||
74 | * Revision 1.1 2007/02/20 10:53:20 jorpiell
|
||
75 | * A?adidos los proyectos de kml y gml antiguos
|
||
76 | *
|
||
77 | * Revision 1.1 2007/02/12 13:49:18 jorpiell
|
||
78 | * A?adido el driver de KML
|
||
79 | *
|
||
80 | *
|
||
81 | */
|
||
82 | /**
|
||
83 | * This class parses a LookAt tag. Example:
|
||
84 | * <p>
|
||
85 | * <pre>
|
||
86 | * <code>
|
||
87 | * <LookAt>
|
||
88 | * <longitude>-2.935547902482675</longitude>
|
||
89 | * <latitude>43.41884927185296</latitude>
|
||
90 | * <range>406.2340631356369</range>
|
||
91 | * <tilt>5.122096682951607e-010</tilt>
|
||
92 | * <heading>-0.005135845406706679</heading>
|
||
93 | * </LookAt>
|
||
94 | * </code>
|
||
95 | * </pre>
|
||
96 | * </p>
|
||
97 | * @author Jorge Piera LLodr? (jorge.piera@iver.es)
|
||
98 | * @see http://code.google.com/apis/kml/documentation/kml_tags_21.html#lookat
|
||
99 | */
|
||
100 | public class LookAtBinding{ |
||
101 | |||
102 | /**
|
||
103 | * It parses the LookAt tag
|
||
104 | * @param parser
|
||
105 | * The XML parser
|
||
106 | * @param handler
|
||
107 | * The GPE parser that contains the content handler and
|
||
108 | * the error handler
|
||
109 | * @throws XmlPullParserException
|
||
110 | * @throws IOException
|
||
111 | */
|
||
112 | public static void parse(XmlPullParser parser,GPEKmlParser handler) throws XmlPullParserException, IOException { |
||
113 | boolean endFeature = false; |
||
114 | int currentTag;
|
||
115 | double longitude;
|
||
116 | double latitude;
|
||
117 | double altitude;
|
||
118 | double range;
|
||
119 | float tilt;
|
||
120 | float heading;
|
||
121 | |||
122 | |||
123 | String tag = parser.getName();
|
||
124 | currentTag = parser.getEventType(); |
||
125 | |||
126 | while (!endFeature){
|
||
127 | switch(currentTag){
|
||
128 | case KXmlParser.START_TAG:
|
||
129 | if (tag.compareTo(KmlTags.LONGITUDE) == 0){ |
||
130 | parser.next(); |
||
131 | longitude = new Double(parser.getText()).doubleValue(); |
||
132 | }else if (tag.compareTo(KmlTags.LATITUDE) == 0){ |
||
133 | parser.next(); |
||
134 | latitude = new Double(parser.getText()).doubleValue(); |
||
135 | }else if (tag.compareTo(KmlTags.ALTITUDE) == 0){ |
||
136 | parser.next(); |
||
137 | altitude = new Double(parser.getText()).doubleValue(); |
||
138 | }else if (tag.compareTo(KmlTags.RANGE) == 0){ |
||
139 | parser.next(); |
||
140 | altitude = new Double(parser.getText()).doubleValue(); |
||
141 | }else if (tag.compareTo(KmlTags.TILT) == 0){ |
||
142 | parser.next(); |
||
143 | tilt = new Float(parser.getText()).floatValue(); |
||
144 | }else if (tag.compareTo(KmlTags.HEADING) == 0){ |
||
145 | parser.next(); |
||
146 | longitude = new Float(parser.getText()).floatValue(); |
||
147 | } |
||
148 | break;
|
||
149 | case KXmlParser.END_TAG:
|
||
150 | if (tag.compareTo(KmlTags.LOOKAT) == 0){ |
||
151 | endFeature = true;
|
||
152 | } |
||
153 | break;
|
||
154 | case KXmlParser.TEXT:
|
||
155 | |||
156 | break;
|
||
157 | } |
||
158 | if (!endFeature){
|
||
159 | currentTag = parser.next(); |
||
160 | tag = parser.getName(); |
||
161 | } |
||
162 | } |
||
163 | |||
164 | } |
||
165 | } |