Revision 8017 trunk/libraries/libRemoteServices/src/org/gvsig/remoteClient/gml/v2/GMLFeaturesIterator_v2.java
GMLFeaturesIterator_v2.java | ||
---|---|---|
6 | 6 |
import java.util.Vector; |
7 | 7 |
|
8 | 8 |
import org.gvsig.remoteClient.gml.GMLException; |
9 |
import org.gvsig.remoteClient.gml.GMLTags; |
|
9 | 10 |
import org.gvsig.remoteClient.gml.IGMLFeaturesIterator; |
10 | 11 |
import org.gvsig.remoteClient.gml.factories.IGeometriesFactory; |
11 | 12 |
import org.gvsig.remoteClient.gml.factories.XMLElementsFactory; |
... | ... | |
16 | 17 |
import org.gvsig.remoteClient.gml.schemas.XMLSchemaParser; |
17 | 18 |
import org.gvsig.remoteClient.gml.schemas.XMLSimpleType; |
18 | 19 |
import org.gvsig.remoteClient.gml.utils.GMLUtilsParser; |
20 |
import org.gvsig.remoteClient.utils.CapabilitiesTags; |
|
19 | 21 |
import org.kxml2.io.KXmlParser; |
20 | 22 |
import org.xmlpull.v1.XmlPullParserException; |
21 | 23 |
|
... | ... | |
63 | 65 |
* |
64 | 66 |
* $Id$ |
65 | 67 |
* $Log$ |
66 |
* Revision 1.3 2006-10-02 08:33:49 jorpiell |
|
68 |
* Revision 1.4 2006-10-10 12:52:28 jorpiell |
|
69 |
* Soporte para features complejas. |
|
70 |
* |
|
71 |
* Revision 1.3 2006/10/02 08:33:49 jorpiell |
|
67 | 72 |
* Cambios del 10 copiados al head |
68 | 73 |
* |
69 | 74 |
* Revision 1.1.2.2 2006/09/25 11:35:15 jorpiell |
... | ... | |
178 | 183 |
int currentTag; |
179 | 184 |
boolean end = false; |
180 | 185 |
ArrayList params = new ArrayList(); |
181 |
ArrayList values = new ArrayList(); |
|
182 |
Hashtable duplicates = new Hashtable(); |
|
186 |
ArrayList values = new ArrayList(); |
|
183 | 187 |
Object geom = null; |
188 |
XMLElement entity = null; |
|
184 | 189 |
|
185 |
XMLElement element = XMLElementsFactory.getElement(elementName); |
|
186 |
if (element != null){ |
|
187 |
XMLComplexType elementType = (XMLComplexType)element.getType(); |
|
188 |
try{ |
|
189 |
currentTag = getParser().next(); |
|
190 |
while (!end){ |
|
191 |
switch(currentTag){ |
|
192 |
case KXmlParser.START_TAG: |
|
190 |
try{ |
|
191 |
currentTag = getParser().nextTag(); |
|
192 |
while (!end){ |
|
193 |
switch(currentTag){ |
|
194 |
case KXmlParser.START_TAG: |
|
195 |
entity = XMLElementsFactory.getElement(getParser().getName()); |
|
196 |
if (entity != null){ |
|
197 |
geom = parseComplexFeature(entity,params,values); |
|
198 |
end = true; |
|
199 |
} |
|
200 |
break; |
|
201 |
case KXmlParser.END_TAG: |
|
202 |
if ((getParser().getName().compareTo(elementName) == 0)) |
|
203 |
end = true; |
|
204 |
break; |
|
205 |
case KXmlParser.TEXT: |
|
206 |
break; |
|
207 |
} |
|
208 |
if (!end){ |
|
209 |
currentTag = getParser().next(); |
|
210 |
} |
|
211 |
} |
|
212 |
}catch (XmlPullParserException e) { |
|
213 |
// TODO Auto-generated catch block |
|
214 |
e.printStackTrace(); |
|
215 |
throw new GMLException(GMLException.EXC_PARSE); |
|
216 |
} catch (IOException e) { |
|
217 |
// TODO Auto-generated catch block |
|
218 |
e.printStackTrace(); |
|
219 |
throw new GMLException(GMLException.EXC_READ_FILE); |
|
220 |
} |
|
221 |
|
|
222 |
return getFactory().createSimpleFeature(entity.getName(),geom,params,values); |
|
223 |
} |
|
224 |
|
|
225 |
/** |
|
226 |
* Parses a Complex type |
|
227 |
* @param complexTypeName |
|
228 |
* @param params |
|
229 |
* @param values |
|
230 |
* @return |
|
231 |
* The geom |
|
232 |
* @throws GMLException |
|
233 |
*/ |
|
234 |
private Object parseComplexFeature(XMLElement entity,ArrayList params,ArrayList values) throws GMLException{ |
|
235 |
int currentTag; |
|
236 |
boolean end = false; |
|
237 |
Object geom = null; |
|
238 |
ArrayList myValues = new ArrayList(); |
|
239 |
ArrayList myParams = new ArrayList(); |
|
240 |
|
|
241 |
params.add(entity.getName()); |
|
242 |
values.add(null); |
|
243 |
|
|
244 |
params.add(myParams); |
|
245 |
values.add(myValues); |
|
246 |
|
|
247 |
XMLComplexType entityType = (XMLComplexType)entity.getEntityType(); |
|
248 |
try{ |
|
249 |
currentTag = getParser().nextTag(); |
|
250 |
while (!end){ |
|
251 |
switch(currentTag){ |
|
252 |
case KXmlParser.START_TAG: |
|
253 |
if (getParser().getName().compareTo(GMLTags.GML_BOUNDEDBY)==0){ |
|
254 |
GMLUtilsParser.parseBoundedBy(getParser()); |
|
255 |
}else{ |
|
193 | 256 |
String attName = getParser().getName(); |
194 |
XMLElement attribute = elementType.getElement(attName);
|
|
257 |
XMLElement attribute = entityType.getAttribute(attName);
|
|
195 | 258 |
if (attribute != null){ |
196 |
if (attribute.getType() != null){ |
|
197 |
if (attribute.getType().getType() == IXMLType.SIMPLE){ |
|
198 |
if (duplicates.get(attName) == null){ |
|
199 |
params.add(attName); |
|
200 |
duplicates.put(attName,attName); |
|
201 |
getParser().next(); |
|
202 |
values.add(((XMLSimpleType)attribute.getType()).getObject(getParser().getText())); |
|
203 |
} |
|
204 |
}else if (attribute.getType().getType() == IXMLType.GML_GEOMETRY){ |
|
259 |
if (attribute.getEntityType() != null){ |
|
260 |
if (attribute.getEntityType().getType() == IXMLType.SIMPLE){ |
|
261 |
myParams.add(attName); |
|
262 |
getParser().next(); |
|
263 |
myValues.add(((XMLSimpleType)attribute.getEntityType()).getObject(getParser().getText())); |
|
264 |
}else if (attribute.getEntityType().getType() == IXMLType.GML_GEOMETRY){ |
|
205 | 265 |
geom = GMLUtilsParser.parseGeometry(getParser(),attName,getFactory()); |
206 |
}else if (attribute.getType().getType() == IXMLType.COMPLEX){ |
|
207 |
//Not in GML v2
|
|
266 |
}else if (attribute.getEntityType().getType() == IXMLType.COMPLEX){
|
|
267 |
parseComplexFeature(attribute,myParams,myValues);
|
|
208 | 268 |
} |
209 | 269 |
} |
210 | 270 |
} |
211 |
break; |
|
212 |
case KXmlParser.END_TAG: |
|
213 |
if ((getParser().getName().compareTo(elementName) == 0)) |
|
214 |
end = true; |
|
215 |
break; |
|
216 |
case KXmlParser.TEXT: |
|
217 |
break; |
|
218 | 271 |
} |
219 |
if (!end){ |
|
220 |
currentTag = getParser().next(); |
|
221 |
} |
|
272 |
break; |
|
273 |
case KXmlParser.END_TAG: |
|
274 |
if ((getParser().getName().compareTo(entity.getName()) == 0)) |
|
275 |
end = true; |
|
276 |
break; |
|
277 |
case KXmlParser.TEXT: |
|
278 |
break; |
|
222 | 279 |
} |
223 |
}catch (XmlPullParserException e) { |
|
224 |
// TODO Auto-generated catch block |
|
225 |
e.printStackTrace(); |
|
226 |
throw new GMLException(GMLException.EXC_PARSE); |
|
227 |
} catch (IOException e) { |
|
228 |
// TODO Auto-generated catch block |
|
229 |
e.printStackTrace(); |
|
230 |
throw new GMLException(GMLException.EXC_READ_FILE); |
|
231 |
} |
|
232 |
} |
|
233 |
return getFactory().createSimpleFeature(elementName,geom,params,values); |
|
280 |
if (!end){ |
|
281 |
currentTag = getParser().next(); |
|
282 |
} |
|
283 |
} |
|
284 |
}catch (XmlPullParserException e) { |
|
285 |
// TODO Auto-generated catch block |
|
286 |
e.printStackTrace(); |
|
287 |
throw new GMLException(GMLException.EXC_PARSE); |
|
288 |
} catch (IOException e) { |
|
289 |
// TODO Auto-generated catch block |
|
290 |
e.printStackTrace(); |
|
291 |
throw new GMLException(GMLException.EXC_READ_FILE); |
|
292 |
} |
|
293 |
|
|
294 |
return geom; |
|
234 | 295 |
} |
235 | 296 |
|
236 | 297 |
} |
Also available in: Unified diff