private void amendFromODL(NetcdfFile ncfile, String structMetadata) throws IOException {
Group rootg = ncfile.getRootGroup();
ODLparser parser = new ODLparser();
Element root = parser.parseFromString(structMetadata); // now we have the ODL in JDOM elements
FeatureType featureType = null;
// SWATH
Element swathStructure = root.getChild("SwathStructure");
if (swathStructure != null) {
List<Element> swaths = (List<Element>) swathStructure.getChildren();
for (Element elemSwath : swaths) {
Element swathNameElem = elemSwath.getChild("SwathName");
if (swathNameElem == null) {
log.warn("No SwathName element in " + elemSwath.getName());
continue;
}
String swathName = swathNameElem.getText();
Group swathGroup = findGroupNested(rootg, swathName);
//if (swathGroup == null)
// swathGroup = findGroupNested(rootg, H4header.createValidObjectName(swathName));
if (swathGroup != null) {
featureType = amendSwath(ncfile, elemSwath, swathGroup);
} else {
log.warn("Cant find swath group " + swathName);
}
}
}
// GRID
Element gridStructure = root.getChild("GridStructure");
if (gridStructure != null) {
List<Element> grids = (List<Element>) gridStructure.getChildren();
for (Element elemGrid : grids) {
Element gridNameElem = elemGrid.getChild("GridName");
if (gridNameElem == null) {
log.warn("Ne GridName element in " + elemGrid.getName());
continue;
}
String gridName = gridNameElem.getText();
Group gridGroup = findGroupNested(rootg, gridName);
//if (gridGroup == null)
// gridGroup = findGroupNested(rootg, H4header.createValidObjectName(gridName));
if (gridGroup != null) {
featureType = amendGrid(elemGrid, gridGroup);
} else {
log.warn("Cant find Grid group " + gridName);
}
}
}
// POINT - NOT DONE YET
Element pointStructure = root.getChild("PointStructure");
if (pointStructure != null) {
List<Element> pts = (List<Element>) pointStructure.getChildren();
for (Element elem : pts) {
Element nameElem = elem.getChild("PointName");
if (nameElem == null) {
log.warn("No PointName element in " + elem.getName());
continue;
}
String name = nameElem.getText();
Group ptGroup = findGroupNested(rootg, name);
//if (ptGroup == null)
// ptGroup = findGroupNested(rootg, H4header.createValidObjectName(name));
if (ptGroup != null) {
featureType = FeatureType.POINT;
} else {
log.warn("Cant find Point group " + name);
}
}
}
if (featureType != null) {
if (showWork) System.out.println("***EOS featureType= "+featureType.toString());
rootg.addAttribute(new Attribute("cdm_data_type", featureType.toString()));
}
}