protected GribCollectionProto.Parameter writeParamProto(Parameter param) throws IOException { GribCollectionProto.Parameter.Builder b = GribCollectionProto.Parameter.newBuilder(); b.setName(param.getName()); if (param.isString()) b.setSdata(param.getStringValue()); else { for (int i = 0; i < param.getLength(); i++) b.addData(param.getNumericValue(i)); } return b.build(); }
private Parameter readParam(GribCollectionProto.Parameter pp) throws IOException { if (pp.hasSdata()) return new Parameter(pp.getName(), pp.getSdata()); int count = 0; double[] vals = new double[pp.getDataCount()]; for (double val : pp.getDataList()) vals[count++] = val; return new Parameter(pp.getName(), vals); }