Package dap4.servlet
Class CDMWrap
- java.lang.Object
-
- dap4.servlet.CDMWrap
-
public class CDMWrap extends Object
Wrap CDM source (NetcdfDataset) to Provide a DAP4 API. More or less the inverse of a DSP. This basically means wrapping various (CDM)Array object to look like DataVariable objects.
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanclosedprotected dap4.dap4lib.cdm.NodeMap<ucar.nc2.Variable,dap4.core.dmr.DapStructure>compoundmapprotected static booleanDEBUGprotected dap4.core.dmr.DapDatasetdmrprotected dap4.core.dmr.DMRFactorydmrfactoryprotected static booleanDUMPCDLprotected static Set<ucar.nc2.dataset.NetcdfDataset.Enhance>ENHANCEMENTprotected static StringFILLVALUEprotected Stringlocationprotected static booleannc4loadedprotected ucar.nc2.dataset.NetcdfDatasetncdfileprotected dap4.dap4lib.cdm.NodeMap<ucar.nc2.CDMNode,dap4.core.dmr.DapNode>nodemapprotected Map<dap4.core.dmr.DapVariable,CDMData>variablesprotected dap4.dap4lib.cdm.NodeMap<ucar.nc2.Variable,dap4.core.dmr.DapVariable>varmapprotected dap4.dap4lib.cdm.NodeMap<ucar.nc2.Variable,dap4.core.dmr.DapSequence>vlenmap
-
Constructor Summary
Constructors Constructor Description CDMWrap()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddToParent(dap4.core.dmr.DapNode parent, dap4.core.dmr.DapVariable dapvar)voidaddVariableData(dap4.core.dmr.DapVariable var, CDMData cursor)protected dap4.core.dmr.DapVariablebuildatomicvar(ucar.nc2.Variable cdmvar, dap4.core.dmr.DapNode parent)protected dap4.core.dmr.DapAttributebuildattribute(ucar.nc2.Attribute cdmattr)protected voidbuildattributes(dap4.core.dmr.DapNode node, ucar.nc2.AttributeContainer attributes)protected dap4.core.dmr.DapStructurebuildcompoundtype(ucar.nc2.Variable cdmvar, dap4.core.dmr.DapNode parent)protected dap4.core.dmr.DapDimensionbuilddim(ucar.nc2.Dimension cdmdim)protected voidbuilddimrefs(dap4.core.dmr.DapVariable dapvar, List<ucar.nc2.Dimension> cdmdims)Assign dimensions to a variablevoidbuildDMR()Extract the metadata from the NetcdfDataset and build the DMR.protected dap4.core.dmr.DapEnumerationbuildenum(ucar.nc2.EnumTypedef cdmenum)protected dap4.core.dmr.DapVariablebuildenumvar(ucar.nc2.Variable cdmvar)protected dap4.core.dmr.DapGroupbuildgroup(ucar.nc2.Group cdmgroup)protected voidbuildmaps(dap4.core.dmr.DapVariable dapvar, ucar.nc2.Variable var)protected dap4.core.dmr.DapVariablebuildopaquevar(ucar.nc2.Variable cdmvar)protected dap4.core.dmr.DapSequencebuildseqtype(ucar.nc2.Variable cdmvar)protected voidbuildseqtypes(ucar.nc2.Variable cdmvar)Walk this variable, including fields, to construct sequence types for any contained vlen dimensionsprotected dap4.core.dmr.DapVariablebuildstringvar(ucar.nc2.Variable cdmvar)protected dap4.core.dmr.DapVariablebuildstructvar(ucar.nc2.Variable cdmvar)protected dap4.core.dmr.DapVariablebuildvariable(ucar.nc2.Variable cdmbasevar, dap4.core.dmr.DapNode parent, List<ucar.nc2.Dimension> cdmdims)voidclose()protected ucar.nc2.NetcdfFilecreateNetcdfFile(String location, ucar.nc2.util.CancelTask canceltask)protected longdapsize(ucar.nc2.Dimension cdmdim)protected voidfillgroup(dap4.core.dmr.DapGroup dapgroup, ucar.nc2.Group cdmgroup)protected ucar.nc2.Dimensionfinddimdecl(ucar.nc2.Dimension dimref)protected ucar.nc2.EnumTypedeffindMatchingEnum(ucar.nc2.EnumTypedef varenum)Unfortunately, the CDM Iosp does not actually use the declared enums.dap4.core.dmr.DapDatasetgetDMR()StringgetLocation()ucar.nc2.dataset.NetcdfDatasetgetNetcdfDataset()CDMDatagetVariableData(dap4.core.dmr.DapVariable var)protected booleanisDimDeclFor(ucar.nc2.Dimension decl, ucar.nc2.Dimension ref)CDMWrapopen(String filepath)CDMWrapopen(ucar.nc2.dataset.NetcdfDataset ncd)protected voidprocessmappedvariables(ucar.nc2.Group g)protected voidrecordNode(ucar.nc2.CDMNode cdm, dap4.core.dmr.DapNode dap)Track generic CDMNode <-> DapNodeprotected voidrecordSeq(ucar.nc2.Variable cdm, dap4.core.dmr.DapSequence dap)Track Variable <-> DapSequenceprotected voidrecordStruct(ucar.nc2.Variable cdm, dap4.core.dmr.DapStructure dap)Track Variable <-> DapStructureprotected voidrecordVar(ucar.nc2.Variable cdm, dap4.core.dmr.DapVariable dap)Track Variable <-> DapVariableCDMWrapsetDMR(dap4.core.dmr.DapDataset dmr)CDMWrapsetLocation(String path)protected booleanshadows(ucar.nc2.Group parent, ucar.nc2.Group child)protected booleansuppress(String attrname)Some attributes that are added by the NetcdfDataset need to be kept out of the DMR.protected booleanvalidatecdmtype(ucar.ma2.DataType datatype, Class typeclass)
-
-
-
Field Detail
-
DEBUG
protected static final boolean DEBUG
- See Also:
- Constant Field Values
-
DUMPCDL
protected static final boolean DUMPCDL
- See Also:
- Constant Field Values
-
ENHANCEMENT
protected static Set<ucar.nc2.dataset.NetcdfDataset.Enhance> ENHANCEMENT
-
FILLVALUE
protected static final String FILLVALUE
- See Also:
- Constant Field Values
-
nc4loaded
protected static boolean nc4loaded
-
location
protected String location
-
ncdfile
protected ucar.nc2.dataset.NetcdfDataset ncdfile
-
closed
protected boolean closed
-
dmr
protected dap4.core.dmr.DapDataset dmr
-
dmrfactory
protected dap4.core.dmr.DMRFactory dmrfactory
-
varmap
protected dap4.dap4lib.cdm.NodeMap<ucar.nc2.Variable,dap4.core.dmr.DapVariable> varmap
-
compoundmap
protected dap4.dap4lib.cdm.NodeMap<ucar.nc2.Variable,dap4.core.dmr.DapStructure> compoundmap
-
vlenmap
protected dap4.dap4lib.cdm.NodeMap<ucar.nc2.Variable,dap4.core.dmr.DapSequence> vlenmap
-
nodemap
protected dap4.dap4lib.cdm.NodeMap<ucar.nc2.CDMNode,dap4.core.dmr.DapNode> nodemap
-
-
Method Detail
-
getDMR
public dap4.core.dmr.DapDataset getDMR()
-
setDMR
public CDMWrap setDMR(dap4.core.dmr.DapDataset dmr)
-
getLocation
public String getLocation()
-
getVariableData
public CDMData getVariableData(dap4.core.dmr.DapVariable var) throws dap4.core.util.DapException
- Throws:
dap4.core.util.DapException
-
addVariableData
public void addVariableData(dap4.core.dmr.DapVariable var, CDMData cursor)
-
getNetcdfDataset
public ucar.nc2.dataset.NetcdfDataset getNetcdfDataset()
-
open
public CDMWrap open(String filepath) throws dap4.core.util.DapException
- Parameters:
filepath- - absolute path to a file- Returns:
- CDMDSP instance
- Throws:
dap4.core.util.DapException
-
open
public CDMWrap open(ucar.nc2.dataset.NetcdfDataset ncd) throws dap4.core.util.DapException
- Parameters:
ncd- netcdf dataset- Returns:
- the cdmdsp
- Throws:
dap4.core.util.DapException
-
close
public void close() throws IOException- Throws:
IOException
-
recordNode
protected void recordNode(ucar.nc2.CDMNode cdm, dap4.core.dmr.DapNode dap)Track generic CDMNode <-> DapNode
-
recordVar
protected void recordVar(ucar.nc2.Variable cdm, dap4.core.dmr.DapVariable dap)Track Variable <-> DapVariable
-
recordStruct
protected void recordStruct(ucar.nc2.Variable cdm, dap4.core.dmr.DapStructure dap)Track Variable <-> DapStructure
-
recordSeq
protected void recordSeq(ucar.nc2.Variable cdm, dap4.core.dmr.DapSequence dap)Track Variable <-> DapSequence
-
buildDMR
public void buildDMR() throws dap4.core.util.DapExceptionExtract the metadata from the NetcdfDataset and build the DMR.- Throws:
dap4.core.util.DapException
-
fillgroup
protected void fillgroup(dap4.core.dmr.DapGroup dapgroup, ucar.nc2.Group cdmgroup) throws dap4.core.util.DapException- Throws:
dap4.core.util.DapException
-
builddim
protected dap4.core.dmr.DapDimension builddim(ucar.nc2.Dimension cdmdim) throws dap4.core.util.DapException- Throws:
dap4.core.util.DapException
-
buildenum
protected dap4.core.dmr.DapEnumeration buildenum(ucar.nc2.EnumTypedef cdmenum) throws dap4.core.util.DapException- Throws:
dap4.core.util.DapException
-
buildcompoundtype
protected dap4.core.dmr.DapStructure buildcompoundtype(ucar.nc2.Variable cdmvar, dap4.core.dmr.DapNode parent) throws dap4.core.util.DapException- Throws:
dap4.core.util.DapException
-
buildvariable
protected dap4.core.dmr.DapVariable buildvariable(ucar.nc2.Variable cdmbasevar, dap4.core.dmr.DapNode parent, List<ucar.nc2.Dimension> cdmdims) throws dap4.core.util.DapException- Throws:
dap4.core.util.DapException
-
buildatomicvar
protected dap4.core.dmr.DapVariable buildatomicvar(ucar.nc2.Variable cdmvar, dap4.core.dmr.DapNode parent) throws dap4.core.util.DapException- Throws:
dap4.core.util.DapException
-
buildopaquevar
protected dap4.core.dmr.DapVariable buildopaquevar(ucar.nc2.Variable cdmvar) throws dap4.core.util.DapException- Throws:
dap4.core.util.DapException
-
buildstringvar
protected dap4.core.dmr.DapVariable buildstringvar(ucar.nc2.Variable cdmvar) throws dap4.core.util.DapException- Throws:
dap4.core.util.DapException
-
buildenumvar
protected dap4.core.dmr.DapVariable buildenumvar(ucar.nc2.Variable cdmvar) throws dap4.core.util.DapException- Throws:
dap4.core.util.DapException
-
buildstructvar
protected dap4.core.dmr.DapVariable buildstructvar(ucar.nc2.Variable cdmvar) throws dap4.core.util.DapException- Throws:
dap4.core.util.DapException
-
buildseqtype
protected dap4.core.dmr.DapSequence buildseqtype(ucar.nc2.Variable cdmvar) throws dap4.core.util.DapException- Throws:
dap4.core.util.DapException
-
buildseqtypes
protected void buildseqtypes(ucar.nc2.Variable cdmvar) throws dap4.core.util.DapExceptionWalk this variable, including fields, to construct sequence types for any contained vlen dimensions- Parameters:
cdmvar- variable to walk- Throws:
dap4.core.util.DapException
-
buildattributes
protected void buildattributes(dap4.core.dmr.DapNode node, ucar.nc2.AttributeContainer attributes) throws dap4.core.util.DapException- Throws:
dap4.core.util.DapException
-
buildattribute
protected dap4.core.dmr.DapAttribute buildattribute(ucar.nc2.Attribute cdmattr) throws dap4.core.util.DapException- Throws:
dap4.core.util.DapException
-
builddimrefs
protected void builddimrefs(dap4.core.dmr.DapVariable dapvar, List<ucar.nc2.Dimension> cdmdims) throws dap4.core.util.DapExceptionAssign dimensions to a variable- Parameters:
dapvar- The variable to which we wish to assign dimensionscdmdims- The cdm dimensions from which we will find the dimension info- Throws:
dap4.core.util.DapException
-
processmappedvariables
protected void processmappedvariables(ucar.nc2.Group g) throws dap4.core.util.DapException- Throws:
dap4.core.util.DapException
-
buildmaps
protected void buildmaps(dap4.core.dmr.DapVariable dapvar, ucar.nc2.Variable var) throws dap4.core.util.DapException- Parameters:
dapvar- The variable to which we wish to assign mapsvar- The NetcdfDataset variable from which to extract coord system- Throws:
dap4.core.util.DapException
-
buildgroup
protected dap4.core.dmr.DapGroup buildgroup(ucar.nc2.Group cdmgroup) throws dap4.core.util.DapException- Throws:
dap4.core.util.DapException
-
findMatchingEnum
protected ucar.nc2.EnumTypedef findMatchingEnum(ucar.nc2.EnumTypedef varenum) throws dap4.core.util.DapExceptionUnfortunately, the CDM Iosp does not actually use the declared enums. Rather, for every enum type'd variable, a new enum decl is defined. So, we need to find the original enum decl that matches the variable's enum.- Throws:
dap4.core.util.DapException
-
shadows
protected boolean shadows(ucar.nc2.Group parent, ucar.nc2.Group child)
-
dapsize
protected long dapsize(ucar.nc2.Dimension cdmdim)
-
validatecdmtype
protected boolean validatecdmtype(ucar.ma2.DataType datatype, Class typeclass)
-
finddimdecl
protected ucar.nc2.Dimension finddimdecl(ucar.nc2.Dimension dimref)
-
isDimDeclFor
protected boolean isDimDeclFor(ucar.nc2.Dimension decl, ucar.nc2.Dimension ref)
-
createNetcdfFile
protected ucar.nc2.NetcdfFile createNetcdfFile(String location, ucar.nc2.util.CancelTask canceltask) throws dap4.core.util.DapException
- Throws:
dap4.core.util.DapException
-
suppress
protected boolean suppress(String attrname)
Some attributes that are added by the NetcdfDataset need to be kept out of the DMR. This function defines that set.- Parameters:
attrname- A non-escaped attribute name to be tested for suppression- Returns:
- true if the attribute should be suppressed, false otherwise.
-
addToParent
protected void addToParent(dap4.core.dmr.DapNode parent, dap4.core.dmr.DapVariable dapvar) throws dap4.core.util.DapException- Throws:
dap4.core.util.DapException
-
-