protected GribCollectionProto.Coord writeCoordProto(VertCoord vc, int index) throws IOException { GribCollectionProto.Coord.Builder b = GribCollectionProto.Coord.newBuilder(); b.setCode(vc.getCode()); b.setUnit(vc.getUnits()); for (VertCoord.Level coord : vc.getCoords()) { if (vc.isLayer()) { b.addValues((float) coord.getValue1()); b.addBound((float) coord.getValue2()); } else { b.addValues((float) coord.getValue1()); } } return b.build(); }
protected GribCollectionProto.Coord writeCoordProto(TimeCoord tc, int index) throws IOException { GribCollectionProto.Coord.Builder b = GribCollectionProto.Coord.newBuilder(); b.setCode(index); b.setUnit(tc.getUnits()); float scale = (float) tc.getTimeUnitScale(); // deal with, eg, "6 hours" by multiplying values by 6 if (tc.isInterval()) { for (TimeCoord.Tinv tinv : tc.getIntervals()) { b.addValues(tinv.getBounds1() * scale); b.addBound(tinv.getBounds2() * scale); } } else { for (int value : tc.getCoords()) b.addValues(value * scale); } return b.build(); }