Exemplo n.º 1
0
 protected GribCollectionProto.Coord writeCoordProto(EnsCoord ec, int index) throws IOException {
   GribCollectionProto.Coord.Builder b = GribCollectionProto.Coord.newBuilder();
   b.setCode(0);
   b.setUnit("");
   for (EnsCoord.Coord coord : ec.getCoords()) {
     b.addValues((float) coord.getCode());
     b.addValues((float) coord.getEnsMember());
   }
   return b.build();
 }
Exemplo n.º 2
0
 private VertCoord readVertCoord(GribCollectionProto.Coord pc) throws IOException {
   boolean isLayer = (pc.getBoundCount() > 0);
   List<VertCoord.Level> coords = new ArrayList<VertCoord.Level>(pc.getValuesCount());
   for (int i = 0; i < pc.getValuesCount(); i++)
     coords.add(new VertCoord.Level(pc.getValues(i), isLayer ? pc.getBound(i) : 0));
   return new VertCoord(pc.getCode(), coords, isLayer);
 }
Exemplo n.º 3
0
 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();
 }
Exemplo n.º 4
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();
 }
Exemplo n.º 5
0
 private EnsCoord readEnsCoord(GribCollectionProto.Coord pc) throws IOException {
   List<EnsCoord.Coord> coords = new ArrayList<EnsCoord.Coord>(pc.getValuesCount());
   for (int i = 0; i < pc.getValuesCount(); i += 2)
     coords.add(new EnsCoord.Coord((int) pc.getValues(i), (int) pc.getValues(i + 1)));
   return new EnsCoord(coords);
 }
Exemplo n.º 6
0
 private TimeCoord readTimeCoord(GribCollectionProto.Coord pc) throws IOException {
   if (pc.getBoundCount() > 0) { // its an interval
     List<TimeCoord.Tinv> coords = new ArrayList<TimeCoord.Tinv>(pc.getValuesCount());
     for (int i = 0; i < pc.getValuesCount(); i++)
       coords.add(new TimeCoord.Tinv((int) pc.getValues(i), (int) pc.getBound(i)));
     return new TimeCoord(pc.getCode(), pc.getUnit(), coords);
   } else {
     List<Integer> coords = new ArrayList<Integer>(pc.getValuesCount());
     for (float value : pc.getValuesList()) coords.add((int) value);
     return new TimeCoord(pc.getCode(), pc.getUnit(), coords);
   }
 }