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