return false;
}
public TableConfig getConfig(FeatureType wantFeatureType, NetcdfDataset ds, Formatter errlog) {
Dimension obsDim = UnidataPointDatasetHelper.findObsDimension(ds);
if (obsDim == null) {
errlog.format("Must have an Observation dimension: named by global attribute 'observationDimension', or unlimited dimension");
return null;
}
boolean hasStruct = Evaluator.hasRecordStructure(ds);
FeatureType ft = Evaluator.getFeatureType(ds, ":cdm_datatype", null);
if (ft == null )
ft = Evaluator.getFeatureType(ds, ":cdm_data_type", null);
// its really a point
if (ft == FeatureType.POINT) {
TableConfig obsTable = new TableConfig(Table.Type.Structure, hasStruct ? "record" : obsDim.getName());
obsTable.structureType = hasStruct ? TableConfig.StructureType.Structure : TableConfig.StructureType.PsuedoStructure;
obsTable.featureType = FeatureType.POINT;
obsTable.structName = "record";
obsTable.time = UnidataPointDatasetHelper.getCoordinateName(ds, AxisType.Time, obsDim);
obsTable.lat = UnidataPointDatasetHelper.getCoordinateName(ds, AxisType.Lat, obsDim);
obsTable.lon = UnidataPointDatasetHelper.getCoordinateName(ds, AxisType.Lon, obsDim);
obsTable.elev = UnidataPointDatasetHelper.getCoordinateName(ds, AxisType.Height, obsDim);
obsTable.dimName = obsDim.getName();
return obsTable;
}
// we want a point dataset, but its really a station
// iterate over obs struct, in file order
// extra join on station structure
if ((ft == FeatureType.STATION) && (wantFeatureType == FeatureType.POINT)) {
TableConfig obsTable = new TableConfig(Table.Type.Structure, hasStruct ? "record" : obsDim.getName() );
obsTable.structureType = hasStruct ? TableConfig.StructureType.Structure : TableConfig.StructureType.PsuedoStructure;
obsTable.featureType = FeatureType.POINT;
obsTable.dimName = obsDim.getName();
obsTable.structName = "record";
obsTable.time = UnidataPointDatasetHelper.getCoordinateName(ds, AxisType.Time, obsDim);
obsTable.lat = UnidataPointDatasetHelper.getCoordinateName(ds, AxisType.Lat, obsDim);
obsTable.lon = UnidataPointDatasetHelper.getCoordinateName(ds, AxisType.Lon, obsDim);
obsTable.stnAlt = UnidataPointDatasetHelper.getCoordinateName(ds, AxisType.Height, obsDim);
// if they have lat and lon in the obs, then use it
if ((obsTable.lat != null) && (obsTable.lon != null)) {
return obsTable;
}
// otherwise join it to the station with a parent_index
String parentIndexVar = UnidataPointDatasetHelper.findVariableName(ds, "parent_index");
if (parentIndexVar == null) {
errlog.format("Must have a parent_index variable");
return null;
}
Dimension stationDim = UnidataPointDatasetHelper.findDimension(ds, "station");
if (stationDim == null) {
errlog.format("Must have a station dimension");
return null;
}
// TableConfig stationTable = new TableConfig(Table.Type.Structure, "station");
//stationTable.isPsuedoStructure = true;
//stationTable.dim = stationDim;
obsTable.lat = UnidataPointDatasetHelper.getCoordinateName(ds, AxisType.Lat, stationDim);
obsTable.lon = UnidataPointDatasetHelper.getCoordinateName(ds, AxisType.Lon, stationDim);
obsTable.elev = UnidataPointDatasetHelper.getCoordinateName(ds, AxisType.Height, stationDim);
StructureDS stns = new StructurePseudoDS(ds, null, "stationPsuedoStructure", null, stationDim);
obsTable.addJoin( new JoinParentIndex(stns, parentIndexVar));
return obsTable;
}
// its really a trajectory
if (ft == FeatureType.TRAJECTORY) {
TableConfig obsTable = new TableConfig(Table.Type.Structure, hasStruct ? "record" : obsDim.getName());
obsTable.structureType = hasStruct ? TableConfig.StructureType.Structure : TableConfig.StructureType.PsuedoStructure;
obsTable.featureType = FeatureType.TRAJECTORY;
obsTable.time = UnidataPointDatasetHelper.getCoordinateName(ds, AxisType.Time, obsDim);
obsTable.lat = UnidataPointDatasetHelper.getCoordinateName(ds, AxisType.Lat, obsDim);
obsTable.lon = UnidataPointDatasetHelper.getCoordinateName(ds, AxisType.Lon, obsDim);
obsTable.elev = UnidataPointDatasetHelper.getCoordinateName(ds, AxisType.Height, obsDim);
obsTable.dimName = obsDim.getName();
Dimension trajDim = UnidataPointDatasetHelper.findDimension(ds, "trajectory");
if (trajDim != null) {
log.error("Ignoring trajectory structure "+ds.getLocation());
}
return obsTable;
}
// otherwise its a Station
Dimension stationDim = UnidataPointDatasetHelper.findDimension(ds, "station");
if (stationDim == null) {
errlog.format("Must have a dimension named station, or named by global attribute 'stationDimension'");
return null;
}
String lastVar = UnidataPointDatasetHelper.findVariableName(ds, "lastChild");
String prevVar = UnidataPointDatasetHelper.findVariableName(ds, "prevChild");
String firstVar = UnidataPointDatasetHelper.findVariableName(ds, "firstChild");
String nextVar = UnidataPointDatasetHelper.findVariableName(ds, "nextChild");
String numChildrenVar = UnidataPointDatasetHelper.findVariableName(ds, "numChildren");
boolean isForwardLinkedList = (firstVar != null) && (nextVar != null);
boolean isBackwardLinkedList = (lastVar != null) && (prevVar != null);
boolean isContiguousList = !isForwardLinkedList && !isBackwardLinkedList && (firstVar != null) && (numChildrenVar != null);
boolean isMultiDim = !isForwardLinkedList && !isBackwardLinkedList && !isContiguousList;
// station table
TableConfig stationTable = new TableConfig(Table.Type.Structure, "station");
stationTable.structureType = TableConfig.StructureType.PsuedoStructure;
stationTable.featureType = FeatureType.STATION;
stationTable.dimName = stationDim.getName();
stationTable.limit = Evaluator.getVariableName(ds, "number_stations", null);
stationTable.stnId = Evaluator.getVariableName(ds, "station_id", null);
stationTable.stnDesc = Evaluator.getVariableName(ds, "station_description", null);
stationTable.stnWmoId = Evaluator.getVariableName(ds, "wmo_id", null);
stationTable.lat = UnidataPointDatasetHelper.getCoordinateName(ds, AxisType.Lat);
stationTable.lon = UnidataPointDatasetHelper.getCoordinateName(ds, AxisType.Lon);
stationTable.stnAlt = UnidataPointDatasetHelper.getCoordinateName(ds, AxisType.Height);
// obs table
TableConfig obsTable;
if (isMultiDim) {
obsTable = new TableConfig(Table.Type.MultidimInner, "obs");
obsTable.outerName = stationDim.getName();
obsTable.innerName = obsDim.getName();
obsTable.dimName = obsDim.getName();
} else {