Coverage decodeGrid(CdmrFeatureProto.Coverage proto, CoverageReader reader) { DataType dataType = NcStream.convertDataType(proto.getDataType()); List<Attribute> atts = new ArrayList<>(); for (ucar.nc2.stream.NcStreamProto.Attribute patt : proto.getAttsList()) atts.add(NcStream.decodeAtt(patt)); return new Coverage(proto.getName(), dataType, atts, proto.getCoordSys(), proto.getUnits(), proto.getDescription(), reader, null); }
CoverageTransform decodeCoordTransform(CdmrFeatureProto.CoordTransform proto) { String name = proto.getName(); AttributeContainerHelper atts = new AttributeContainerHelper(name); for (ucar.nc2.stream.NcStreamProto.Attribute patt : proto.getParamsList()) atts.addAttribute(NcStream.decodeAtt(patt)); // public CoverageCoordTransform(String name, AttributeContainerHelper attributes, boolean isHoriz) { return new CoverageTransform(name, atts, proto.getIsHoriz()); }
CoverageCollection decodeHeader(CdmrFeatureProto.CoverageDataset proto, CdmrCoverageReader reader) { String name = endpoint; FeatureType csysType = convertCoverageType(proto.getCoverageType()); LatLonRect latLonBoundingBox = decodeLatLonRectangle(proto.getLatlonRect()); ProjectionRect projBoundingBox = decodeProjRectangle(proto.getProjRect()); CalendarDateRange calendarDateRange = proto.hasDateRange() ? decodeDateRange(proto.getDateRange()) : null; AttributeContainerHelper gatts = new AttributeContainerHelper(name); for (ucar.nc2.stream.NcStreamProto.Attribute patt : proto.getAttsList()) gatts.addAttribute(NcStream.decodeAtt(patt)); List<CoverageCoordSys> coordSys = new ArrayList<>(); for (CdmrFeatureProto.CoordSys pgrid : proto.getCoordSysList()) coordSys.add(decodeCoordSys(pgrid)); List<CoverageTransform> transforms = new ArrayList<>(); for (CdmrFeatureProto.CoordTransform ptransform : proto.getCoordTransformsList()) transforms.add(decodeCoordTransform(ptransform)); List<CoverageCoordAxis> axes = new ArrayList<>(); for (CdmrFeatureProto.CoordAxis paxes : proto.getCoordAxesList()) axes.add(decodeCoordAxis(paxes, reader)); List<Coverage> coverages = new ArrayList<>(); for (CdmrFeatureProto.Coverage pgrid : proto.getGridsList()) coverages.add(decodeGrid(pgrid, reader)); // public CoverageDataset(String name, AttributeContainerHelper atts, LatLonRect latLonBoundingBox, ProjectionRect projBoundingBox, // CalendarDateRange calendarDateRange, List<CoverageCoordSys > coordSys, List< CoverageCoordTransform > coordTransforms, // List< CoverageCoordAxis > coordAxes, List< Coverage > coverages) { return new CoverageCollection(name, csysType, gatts, latLonBoundingBox, projBoundingBox, calendarDateRange, coordSys, transforms, axes, coverages, reader); }
ncvar.addAttribute(decodeAtt(att));
static Structure decodeStructure(NetcdfFile ncfile, Group g, Structure parent, NcStreamProto.Structure s) { Structure ncvar = (s.getDataType() == ucar.nc2.stream.NcStreamProto.DataType.SEQUENCE) ? new Sequence(ncfile, g, parent, s.getName()) : new Structure(ncfile, g, parent, s.getName()); ncvar.setDataType(decodeDataType(s.getDataType())); List<Dimension> dims = new ArrayList<Dimension>(6); for (ucar.nc2.stream.NcStreamProto.Dimension dim : s.getShapeList()) { Dimension ncdim = decodeDim(dim); if (!ncdim.isShared()) dims.add(ncdim); else { Dimension d = g.findDimension(ncdim.getShortName()); if (d == null) throw new IllegalStateException("Can find shared dimension " + dim.getName()); dims.add(d); } } ncvar.setDimensions(dims); for (ucar.nc2.stream.NcStreamProto.Attribute att : s.getAttsList()) ncvar.addAttribute(decodeAtt(att)); for (ucar.nc2.stream.NcStreamProto.Variable vp : s.getVarsList()) ncvar.addMemberVariable(decodeVar(ncfile, g, ncvar, vp)); for (NcStreamProto.Structure sp : s.getStructsList()) ncvar.addMemberVariable(decodeStructure(ncfile, g, ncvar, sp)); return ncvar; }
static Structure decodeStructure(NetcdfFile ncfile, Group g, Structure parent, NcStreamProto.Structure s) { Structure ncvar = (s.getDataType() == ucar.nc2.stream.NcStreamProto.DataType.SEQUENCE) ? new Sequence(ncfile, g, parent, s.getName()) : new Structure(ncfile, g, parent, s.getName()); ncvar.setDataType(convertDataType(s.getDataType())); List<Dimension> dims = new ArrayList<>(6); for (ucar.nc2.stream.NcStreamProto.Dimension dim : s.getShapeList()) { Dimension ncdim = decodeDim(dim); if (!ncdim.isShared()) dims.add(ncdim); else { Dimension d = g.findDimension(ncdim.getShortName()); if (d == null) throw new IllegalStateException("Can find shared dimension " + dim.getName()); dims.add(d); } } ncvar.setDimensions(dims); for (ucar.nc2.stream.NcStreamProto.Attribute att : s.getAttsList()) ncvar.addAttribute(decodeAtt(att)); for (ucar.nc2.stream.NcStreamProto.Variable vp : s.getVarsList()) ncvar.addMemberVariable(decodeVar(ncfile, g, ncvar, vp)); for (NcStreamProto.Structure sp : s.getStructsList()) ncvar.addMemberVariable(decodeStructure(ncfile, g, ncvar, sp)); return ncvar; }
atts.addAttribute(NcStream.decodeAtt(patt));
ncvar.addAttribute(decodeAtt(att));
ncvar.addAttribute(decodeAtt(att));
static Structure decodeStructure(NetcdfFile ncfile, Group g, Structure parent, NcStreamProto.Structure s) { Structure ncvar = (s.getDataType() == ucar.nc2.stream.NcStreamProto.DataType.SEQUENCE) ? new Sequence(ncfile, g, parent, s.getName()) : new Structure(ncfile, g, parent, s.getName()); ncvar.setDataType(decodeDataType(s.getDataType())); List<Dimension> dims = new ArrayList<Dimension>(6); for (ucar.nc2.stream.NcStreamProto.Dimension dim : s.getShapeList()) { if (dim.getIsPrivate() || dim.getIsVlen()) dims.add(new Dimension(dim.getName(), (int) dim.getLength(), false, dim.getIsUnlimited(), dim.getIsVlen())); else { Dimension d = g.findDimension(dim.getName()); if (d == null) throw new IllegalStateException("Can find shared dimension " + dim.getName()); dims.add(d); } } ncvar.setDimensions(dims); for (ucar.nc2.stream.NcStreamProto.Attribute att : s.getAttsList()) ncvar.addAttribute(decodeAtt(att)); for (ucar.nc2.stream.NcStreamProto.Variable vp : s.getVarsList()) ncvar.addMemberVariable(decodeVar(ncfile, g, ncvar, vp)); for (NcStreamProto.Structure sp : s.getStructsList()) ncvar.addMemberVariable(decodeStructure(ncfile, g, ncvar, sp)); return ncvar; }
static void readGroup(NcStreamProto.Group proto, NetcdfFile ncfile, Group g) throws InvalidProtocolBufferException { for (NcStreamProto.Dimension dim : proto.getDimsList()) g.addDimension(NcStream.decodeDim(dim)); for (NcStreamProto.Attribute att : proto.getAttsList()) g.addAttribute(NcStream.decodeAtt(att)); for (NcStreamProto.EnumTypedef enumType : proto.getEnumTypesList()) g.addEnumeration(NcStream.decodeEnumTypedef(enumType)); for (NcStreamProto.Variable var : proto.getVarsList()) g.addVariable(NcStream.decodeVar(ncfile, g, null, var)); for (NcStreamProto.Structure s : proto.getStructsList()) g.addVariable(NcStream.decodeStructure(ncfile, g, null, s)); for (NcStreamProto.Group gp : proto.getGroupsList()) { Group ng = new Group(ncfile, g, gp.getName()); g.addGroup(ng); readGroup(gp, ncfile, ng); } }
static void readGroup(NcStreamProto.Group proto, NetcdfFile ncfile, Group g) throws InvalidProtocolBufferException { for (NcStreamProto.Dimension dim : proto.getDimsList()) g.addDimension(NcStream.decodeDim(dim)); for (NcStreamProto.Attribute att : proto.getAttsList()) g.addAttribute(NcStream.decodeAtt(att)); for (NcStreamProto.EnumTypedef enumType : proto.getEnumTypesList()) g.addEnumeration(NcStream.decodeEnumTypedef(enumType)); for (NcStreamProto.Variable var : proto.getVarsList()) g.addVariable(NcStream.decodeVar(ncfile, g, null, var)); for (NcStreamProto.Structure s : proto.getStructsList()) g.addVariable(NcStream.decodeStructure(ncfile, g, null, s)); for (NcStreamProto.Group gp : proto.getGroupsList()) { Group ng = new Group(ncfile, g, gp.getName()); g.addGroup(ng); readGroup(gp, ncfile, ng); } }
static void readGroup(NcStreamProto.Group proto, NetcdfFile ncfile, Group g) throws InvalidProtocolBufferException { for (NcStreamProto.Dimension dim : proto.getDimsList()) g.addDimension(NcStream.decodeDim(dim)); for (NcStreamProto.Attribute att : proto.getAttsList()) g.addAttribute(NcStream.decodeAtt(att)); for (NcStreamProto.EnumTypedef enumType : proto.getEnumTypesList()) g.addEnumeration(NcStream.decodeEnumTypedef(enumType)); for (NcStreamProto.Variable var : proto.getVarsList()) g.addVariable(NcStream.decodeVar(ncfile, g, null, var)); for (NcStreamProto.Structure s : proto.getStructsList()) g.addVariable(NcStream.decodeStructure(ncfile, g, null, s)); for (NcStreamProto.Group gp : proto.getGroupsList()) { Group ng = new Group(ncfile, g, gp.getName()); g.addGroup(ng); readGroup(gp, ncfile, ng); } }