svn-gvsig-desktop / trunk / libraries / libGPE-KML / src / org / gvsig / gpe / kml / reader / bindings / LookAtBinding.java @ 12071
History | View | Annotate | Download (4.48 KB)
1 |
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.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: LookAtBinding.java 12071 2007-06-07 14:53:59Z jorpiell $
|
54 |
* $Log$
|
55 |
* Revision 1.2 2007-06-07 14:53:59 jorpiell
|
56 |
* Add the schema support
|
57 |
*
|
58 |
* Revision 1.1 2007/05/11 07:06:29 jorpiell
|
59 |
* Refactoring of some package names
|
60 |
*
|
61 |
* Revision 1.4 2007/05/08 08:22:37 jorpiell
|
62 |
* Add comments to create javadocs
|
63 |
*
|
64 |
* Revision 1.3 2007/04/14 16:08:07 jorpiell
|
65 |
* Kml writing support added
|
66 |
*
|
67 |
* Revision 1.2 2007/04/13 13:16:21 jorpiell
|
68 |
* Add KML reading support
|
69 |
*
|
70 |
* Revision 1.1 2007/03/07 08:19:10 jorpiell
|
71 |
* Pasadas las clases de KML de libGPE-GML a libGPE-KML
|
72 |
*
|
73 |
* Revision 1.1 2007/02/28 11:48:31 csanchez
|
74 |
* *** empty log message ***
|
75 |
*
|
76 |
* Revision 1.1 2007/02/20 10:53:20 jorpiell
|
77 |
* A?adidos los proyectos de kml y gml antiguos
|
78 |
*
|
79 |
* Revision 1.1 2007/02/12 13:49:18 jorpiell
|
80 |
* A?adido el driver de KML
|
81 |
*
|
82 |
*
|
83 |
*/
|
84 |
/**
|
85 |
* This class parses a LookAt tag. Example:
|
86 |
* <p>
|
87 |
* <pre>
|
88 |
* <code>
|
89 |
* <LookAt>
|
90 |
* <longitude>-2.935547902482675</longitude>
|
91 |
* <latitude>43.41884927185296</latitude>
|
92 |
* <range>406.2340631356369</range>
|
93 |
* <tilt>5.122096682951607e-010</tilt>
|
94 |
* <heading>-0.005135845406706679</heading>
|
95 |
* </LookAt>
|
96 |
* </code>
|
97 |
* </pre>
|
98 |
* </p>
|
99 |
* @author Jorge Piera LLodr? (jorge.piera@iver.es)
|
100 |
* @see http://code.google.com/apis/kml/documentation/kml_tags_21.html#lookat
|
101 |
*/
|
102 |
public class LookAtBinding{ |
103 |
|
104 |
/**
|
105 |
* It parses the LookAt tag
|
106 |
* @param parser
|
107 |
* The XML parser
|
108 |
* @param handler
|
109 |
* The GPE parser that contains the content handler and
|
110 |
* the error handler
|
111 |
* @throws XmlPullParserException
|
112 |
* @throws IOException
|
113 |
*/
|
114 |
public static void parse(XmlPullParser parser,GPEKmlParser handler) throws XmlPullParserException, IOException { |
115 |
boolean endFeature = false; |
116 |
int currentTag;
|
117 |
double longitude;
|
118 |
double latitude;
|
119 |
double altitude;
|
120 |
double range;
|
121 |
float tilt;
|
122 |
float heading;
|
123 |
|
124 |
|
125 |
String tag = parser.getName();
|
126 |
currentTag = parser.getEventType(); |
127 |
|
128 |
while (!endFeature){
|
129 |
switch(currentTag){
|
130 |
case KXmlParser.START_TAG:
|
131 |
if (tag.compareTo(KmlTags.LONGITUDE) == 0){ |
132 |
parser.next(); |
133 |
longitude = new Double(parser.getText()).doubleValue(); |
134 |
}else if (tag.compareTo(KmlTags.LATITUDE) == 0){ |
135 |
parser.next(); |
136 |
latitude = new Double(parser.getText()).doubleValue(); |
137 |
}else if (tag.compareTo(KmlTags.ALTITUDE) == 0){ |
138 |
parser.next(); |
139 |
altitude = new Double(parser.getText()).doubleValue(); |
140 |
}else if (tag.compareTo(KmlTags.RANGE) == 0){ |
141 |
parser.next(); |
142 |
altitude = new Double(parser.getText()).doubleValue(); |
143 |
}else if (tag.compareTo(KmlTags.TILT) == 0){ |
144 |
parser.next(); |
145 |
tilt = new Float(parser.getText()).floatValue(); |
146 |
}else if (tag.compareTo(KmlTags.HEADING) == 0){ |
147 |
parser.next(); |
148 |
longitude = new Float(parser.getText()).floatValue(); |
149 |
} |
150 |
break;
|
151 |
case KXmlParser.END_TAG:
|
152 |
if (tag.compareTo(KmlTags.LOOKAT) == 0){ |
153 |
endFeature = true;
|
154 |
} |
155 |
break;
|
156 |
case KXmlParser.TEXT:
|
157 |
|
158 |
break;
|
159 |
} |
160 |
if (!endFeature){
|
161 |
currentTag = parser.next(); |
162 |
tag = parser.getName(); |
163 |
} |
164 |
} |
165 |
|
166 |
} |
167 |
} |