Package dap4.servlet
Class CDMWrap
java.lang.Object
dap4.servlet.CDMWrap
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
FieldsModifier and TypeFieldDescriptionprotected booleanprotected dap4.dap4lib.cdm.NodeMap<ucar.nc2.Variable,dap4.core.dmr.DapStructure> protected static final booleanprotected dap4.core.dmr.DapDatasetprotected dap4.core.dmr.DMRFactoryprotected static final booleanprotected static Set<ucar.nc2.dataset.NetcdfDataset.Enhance>protected static final Stringprotected Stringprotected static booleanprotected ucar.nc2.dataset.NetcdfDatasetprotected dap4.dap4lib.cdm.NodeMap<ucar.nc2.CDMNode,dap4.core.dmr.DapNode> protected dap4.dap4lib.cdm.NodeMap<ucar.nc2.Variable,dap4.core.dmr.DapVariable> protected dap4.dap4lib.cdm.NodeMap<ucar.nc2.Variable,dap4.core.dmr.DapSequence> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected 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()ucar.nc2.dataset.NetcdfDatasetgetVariableData(dap4.core.dmr.DapVariable var) protected booleanisDimDeclFor(ucar.nc2.Dimension decl, ucar.nc2.Dimension ref) open(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 <-> DapVariablesetDMR(dap4.core.dmr.DapDataset dmr) setLocation(String path) protected booleanshadows(ucar.nc2.Group parent, ucar.nc2.Group child) protected booleanSome attributes that are added by the NetcdfDataset need to be kept out of the DMR.protected booleanvalidatecdmtype(ucar.ma2.DataType datatype, Class typeclass)
-
Field Details
-
DEBUG
protected static final boolean DEBUG- See Also:
-
DUMPCDL
protected static final boolean DUMPCDL- See Also:
-
ENHANCEMENT
-
FILLVALUE
- See Also:
-
nc4loaded
protected static boolean nc4loaded -
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 -
variables
-
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
-
-
Constructor Details
-
CDMWrap
public CDMWrap()
-
-
Method Details
-
getDMR
public dap4.core.dmr.DapDataset getDMR() -
setDMR
-
getLocation
-
setLocation
-
getVariableData
- Throws:
dap4.core.util.DapException
-
addVariableData
-
getNetcdfDataset
public ucar.nc2.dataset.NetcdfDataset getNetcdfDataset() -
open
- Parameters:
filepath- - absolute path to a file- Returns:
- CDMDSP instance
- Throws:
dap4.core.util.DapException
-
open
- Parameters:
ncd- netcdf dataset- Returns:
- the cdmdsp
- Throws:
dap4.core.util.DapException
-
close
- 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.DapException Walk 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.DapException Assign 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.DapException Unfortunately, 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
-
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
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
-