Revision 11205 trunk/libraries/libGPE-KML/src/org/gvsig/gpe/kml/bindings/FolderBinding.java
FolderBinding.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import java.io.IOException; |
4 | 4 |
|
5 |
import org.gvsig.gpe.gml.factories.IGeometriesFactory;
|
|
5 |
import org.gvsig.gpe.kml.GPEKmlParser;
|
|
6 | 6 |
import org.gvsig.gpe.kml.KmlTags; |
7 |
import org.gvsig.gpe.kml.engine.IReaderFile; |
|
8 | 7 |
import org.gvsig.gpe.kml.exceptions.KmlBodyParseException; |
9 | 8 |
import org.kxml2.io.KXmlParser; |
9 |
import org.xmlpull.v1.XmlPullParser; |
|
10 | 10 |
import org.xmlpull.v1.XmlPullParserException; |
11 | 11 |
|
12 | 12 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
... | ... | |
53 | 53 |
* |
54 | 54 |
* $Id$ |
55 | 55 |
* $Log$ |
56 |
* Revision 1.1 2007-03-07 08:19:10 jorpiell |
|
56 |
* Revision 1.2 2007-04-13 13:16:21 jorpiell |
|
57 |
* Add KML reading support |
|
58 |
* |
|
59 |
* Revision 1.1 2007/03/07 08:19:10 jorpiell |
|
57 | 60 |
* Pasadas las clases de KML de libGPE-GML a libGPE-KML |
58 | 61 |
* |
59 | 62 |
* Revision 1.1 2007/02/28 11:48:31 csanchez |
... | ... | |
70 | 73 |
/** |
71 | 74 |
* @author Jorge Piera Llodr? (piera_jor@gva.es) |
72 | 75 |
*/ |
73 |
public class FolderBinding extends AbstractComplexBinding { |
|
74 |
|
|
75 |
public FolderBinding(IGeometriesFactory gFactory) { |
|
76 |
super(gFactory); |
|
77 |
} |
|
78 |
|
|
79 |
/* |
|
80 |
* (non-Javadoc) |
|
81 |
* @see org.gvsig.remoteClient.kml.bindings.ComplexBinding#parse(org.gvsig.remoteClient.gmlEngine.readers.IReaderFile) |
|
82 |
*/ |
|
83 |
public Object parse(IReaderFile reader) throws KmlBodyParseException { |
|
76 |
public class FolderBinding { |
|
77 |
|
|
78 |
public static void parse(XmlPullParser parser,GPEKmlParser handler) throws KmlBodyParseException { |
|
84 | 79 |
boolean endFeature = false; |
85 |
int currentTag; |
|
86 |
String folderName = null; |
|
87 |
|
|
80 |
int currentTag; |
|
81 |
|
|
82 |
Object layer = handler.getContentHandler().startLayer(null, null, null, null, null, null); |
|
83 |
|
|
88 | 84 |
try { |
89 |
String tag = reader.getName();
|
|
90 |
currentTag = reader.getEventType();
|
|
85 |
String tag = parser.getName();
|
|
86 |
currentTag = parser.getEventType();
|
|
91 | 87 |
|
92 | 88 |
while (!endFeature){ |
93 | 89 |
switch(currentTag){ |
94 | 90 |
case KXmlParser.START_TAG: |
95 |
if (tag.compareTo(KmlTags.PLACEMARK) == 0){
|
|
96 |
endFeature = true;
|
|
97 |
}else if (tag.compareTo(KmlTags.NAME) == 0){
|
|
98 |
reader.next();
|
|
99 |
folderName = reader.getText();
|
|
100 |
endFeature = true;
|
|
91 |
if (tag.compareTo(KmlTags.NAME) == 0){
|
|
92 |
parser.next();
|
|
93 |
handler.getContentHandler().addNameToLayer(layer, parser.getText());
|
|
94 |
}else if (tag.compareTo(KmlTags.DESCRIPTION) == 0){
|
|
95 |
parser.next();
|
|
96 |
handler.getContentHandler().addDescriptionToLayer(layer, parser.getText());
|
|
101 | 97 |
}else if (tag.compareTo(KmlTags.LOOKAT) == 0){ |
102 |
new LookAtBinding(getGFactory()).parse(reader); |
|
98 |
LookAtBinding.parse(parser, handler); |
|
99 |
}else if (tag.compareTo(KmlTags.PLACEMARK) == 0){ |
|
100 |
PlaceMarketBinding.parse(parser, handler); |
|
103 | 101 |
} |
104 | 102 |
break; |
105 | 103 |
case KXmlParser.END_TAG: |
106 | 104 |
if (tag.compareTo(KmlTags.FOLDER) == 0){ |
107 | 105 |
endFeature = true; |
106 |
handler.getContentHandler().endLayer(layer); |
|
108 | 107 |
} |
109 | 108 |
break; |
110 | 109 |
case KXmlParser.TEXT: |
... | ... | |
112 | 111 |
break; |
113 | 112 |
} |
114 | 113 |
if (!endFeature){ |
115 |
currentTag = reader.next();
|
|
116 |
tag = reader.getName();
|
|
114 |
currentTag = parser.next();
|
|
115 |
tag = parser.getName();
|
|
117 | 116 |
} |
118 | 117 |
} |
119 | 118 |
} catch (XmlPullParserException e) { |
120 | 119 |
throw new KmlBodyParseException(e); |
121 | 120 |
} catch (IOException e) { |
122 | 121 |
throw new KmlBodyParseException(e); |
123 |
} |
|
124 |
return folderName; |
|
122 |
} |
|
125 | 123 |
} |
126 | 124 |
|
127 | 125 |
} |
Also available in: Unified diff