svn-gvsig-desktop / trunk / libraries / libGPE-KML / src / org / gvsig / gpe / kml / reader / bindings / geometries / OuterBoundaryIsBinding.java @ 11573
History | View | Annotate | Download (3.5 KB)
1 | 11573 | jorpiell | package org.gvsig.gpe.kml.reader.bindings.geometries; |
---|---|---|---|
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.3 2007/05/08 08:22:37 jorpiell
|
||
60 | * Add comments to create javadocs
|
||
61 | *
|
||
62 | * Revision 1.2 2007/04/14 16:08:07 jorpiell
|
||
63 | * Kml writing support added
|
||
64 | *
|
||
65 | * Revision 1.1 2007/04/13 13:16:21 jorpiell
|
||
66 | * Add KML reading support
|
||
67 | *
|
||
68 | *
|
||
69 | */
|
||
70 | /**
|
||
71 | * It parses the outerBoundary tag. Example:
|
||
72 | * <p>
|
||
73 | * <pre>
|
||
74 | * <code>
|
||
75 | * <outerBoundaryIs>
|
||
76 | * <LinearRing>
|
||
77 | * <coordinates>10.0,10.0 10.0,40.0 40.0,40.0 40.0,10.0 10.0,10.0</coordinates>
|
||
78 | * </LinearRing>
|
||
79 | * </outerBoundaryIs>
|
||
80 | * </code>
|
||
81 | * </pre>
|
||
82 | * </p>
|
||
83 | * @author Jorge Piera LLodr? (jorge.piera@iver.es)
|
||
84 | * @see http://code.google.com/apis/kml/documentation/kml_tags_21.html#outerboundaryis
|
||
85 | */
|
||
86 | public class OuterBoundaryIsBinding { |
||
87 | |||
88 | /**
|
||
89 | * It parses the outerBoundaryIs tag
|
||
90 | * @param parser
|
||
91 | * The XML parser
|
||
92 | * @param handler
|
||
93 | * The GPE parser that contains the content handler and
|
||
94 | * the error handler
|
||
95 | * @return
|
||
96 | * It retuns a matrix of doubles with 3 columns (x,y,z) and
|
||
97 | * one row for each coordinate.
|
||
98 | * @throws IOException
|
||
99 | * @throws XmlPullParserException
|
||
100 | * @throws XmlPullParserException
|
||
101 | * @throws IOException
|
||
102 | */
|
||
103 | public static double[][] parse(XmlPullParser parser,GPEKmlParser handler) throws XmlPullParserException, IOException { |
||
104 | boolean endFeature = false; |
||
105 | int currentTag;
|
||
106 | |||
107 | double[][] coordinates = null; |
||
108 | |||
109 | String tag = parser.getName();
|
||
110 | currentTag = parser.getEventType(); |
||
111 | |||
112 | while (!endFeature){
|
||
113 | switch(currentTag){
|
||
114 | case KXmlParser.START_TAG:
|
||
115 | if (tag.compareTo(KmlTags.LINEARRING) == 0){ |
||
116 | coordinates = LinearRingBinding.parse(parser, handler); |
||
117 | } |
||
118 | break;
|
||
119 | case KXmlParser.END_TAG:
|
||
120 | if (tag.compareTo(KmlTags.OUTERBOUNDARYIS) == 0){ |
||
121 | endFeature = true;
|
||
122 | } |
||
123 | break;
|
||
124 | case KXmlParser.TEXT:
|
||
125 | |||
126 | break;
|
||
127 | } |
||
128 | if (!endFeature){
|
||
129 | currentTag = parser.next(); |
||
130 | tag = parser.getName(); |
||
131 | } |
||
132 | } |
||
133 | return coordinates;
|
||
134 | } |
||
135 | } |