use of org.geotoolkit.data.kml.model.DefaultExtendedData in project geotoolkit by Geomatys.
the class KmlFeatureUtilities method fillGeometryListFromFeature.
/**
* recursive method on feature to find geometries
* @param feature {@link org.opengis.feature.Feature} traveled to find geometry
* @param geometries {@link List} where we add {@link Geometry}
*/
public static void fillGeometryListFromFeature(final Feature feature, final List<Map.Entry<Object, Map<String, String>>> geometries) {
final Object geometry = feature.getPropertyValue("geometry");
if (geometry != null) {
// create map which have other data value
final Map<String, String> values = new HashMap<>(0);
// get feature name
final String name = (String) feature.getPropertyValue("name");
if (name != null) {
values.put("name", name);
}
// get extendedData
final DefaultExtendedData extendData = (DefaultExtendedData) feature.getPropertyValue("ExtendedData");
if (extendData != null) {
// loop on extendedSchemaData to find data
final List<SchemaData> schemaDatas = extendData.getSchemaData();
for (SchemaData schemaData : schemaDatas) {
// get simples data to add it on values map
final List<SimpleData> simpleDataList = schemaData.getSimpleDatas();
for (SimpleData simpleData : simpleDataList) {
values.put(simpleData.getName(), simpleData.getContent());
}
}
}
// add geometry on list
geometries.add(new AbstractMap.SimpleEntry<Object, Map<String, String>>(geometry, values));
// it's a folder, go recursivly on childs
} else {
final Iterator<?> iterator = ((Iterable<?>) feature.getPropertyValue(KmlConstants.TAG_FEATURES)).iterator();
while (iterator.hasNext()) {
final Object object = iterator.next();
if (object instanceof Feature) {
final Feature candidat = (Feature) object;
// recursive call
fillGeometryListFromFeature(candidat, geometries);
}
}
}
}
Aggregations