예제 #1
0
 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();
 }
  protected GribCollectionProto.TimeCoordUnion writeTimeCoordUnionProto(
      TimeCoordUnion tcu, int index) throws IOException {
    GribCollectionProto.TimeCoordUnion.Builder b = GribCollectionProto.TimeCoordUnion.newBuilder();
    b.setCode(index);
    b.setUnit(tcu.getUnits());

    if (tcu.isInterval()) {
      for (TimeCoord.Tinv tinv : tcu.getIntervals()) {
        b.addValues((float) tinv.getBounds1());
        b.addBound((float) tinv.getBounds2());
      }
    } else {
      for (int value : tcu.getCoords()) b.addValues((float) value);
    }
    for (TimeCoordUnion.Val val : tcu.getValues()) {
      b.addPartition(val.getPartition());
      b.addIndex(val.getIndex());
    }

    return b.build();
  }