Exemple #1
0
 /**
  * Western Longitude
  *
  * @return Western Longitude
  */
 public final float getWestLongitude() {
   if (length > 75 && ((getType() == 4) || (getType() == 5))) {
     return GribNumbers.int3(getOctet(74), getOctet(75), getOctet(76)) / 1000;
   } else {
     return GribNumbers.UNDEFINED;
   }
 }
Exemple #2
0
 /**
  * Eastern Longitude
  *
  * @return Eastern Longitude
  */
 public final float getEastLongitude() {
   if (length > 72 && ((getType() == 4) || (getType() == 5))) {
     return GribNumbers.int3(getOctet(71), getOctet(72), getOctet(73)) / 1000;
   } else {
     return GribNumbers.UNDEFINED;
   }
 }
Exemple #3
0
 /**
  * Northern latitude
  *
  * @return Northern latitude
  */
 public final float getNorthLatitude() {
   if (length > 66 && ((getType() == 4) || (getType() == 5))) {
     return GribNumbers.int3(getOctet(65), getOctet(66), getOctet(67)) / 1000;
   } else {
     return GribNumbers.UNDEFINED;
   }
 }
Exemple #4
0
 /**
  * Southern latitude
  *
  * @return Southern latitude
  */
 public final float getSouthLatitude() {
   if (length > 69 && ((getType() == 4) || (getType() == 5))) {
     return GribNumbers.int3(getOctet(68), getOctet(69), getOctet(70)) / 1000;
   } else {
     return GribNumbers.UNDEFINED;
   }
 }
Exemple #5
0
  /**
   * Constructs Grib1PDSVariables from a byte[].
   *
   * @param input PDS
   * @param cal use this calendar to set the date
   * @throws java.io.IOException byte[] read
   */
  public Grib1Pds(byte[] input, Calendar cal) throws IOException {
    this.input = input;
    this.length = GribNumbers.int3(getOctet(1), getOctet(2), getOctet(3));
    this.level = new GribPDSLevel(getOctet(10), getOctet(11), getOctet(12));

    // calculate the reference date
    // octet 25
    int century = getOctet(25) - 1;
    if (century == -1) century = 20;
    // octets 13-17 (base time for reference time)
    int year = getOctet(13);
    int month = getOctet(14);
    int day = getOctet(15);
    int hour = getOctet(16);
    int minute = getOctet(17);

    cal.clear();
    cal.setTimeZone(java.util.TimeZone.getTimeZone("GMT"));
    cal.set(Calendar.DST_OFFSET, 0);
    cal.set((century * 100 + year), month - 1, day, hour, minute, 0);
    refTime = cal.getTimeInMillis();

    // calculate the valid date
    int type = 1;
    int factor = 1;
    switch (getTimeUnit()) {
      case 0:
        type = Calendar.MINUTE;
        break;
      case 1:
        type = Calendar.HOUR_OF_DAY;
        break;
      case 2:
        type = Calendar.HOUR_OF_DAY;
        factor = 24;
        break;
      case 3:
        type = Calendar.MONTH;
        break;
      case 4:
        type = Calendar.YEAR;
        break;
      case 5:
        type = Calendar.YEAR;
        factor = 10;
        break;
      case 6:
        type = Calendar.YEAR;
        factor = 30;
        break;
      case 7:
        type = Calendar.YEAR;
        factor = 100;
        break;
      case 10:
        type = Calendar.HOUR_OF_DAY;
        factor = 3;
        break;
      case 11:
        type = Calendar.HOUR_OF_DAY;
        factor = 6;
        break;
      case 12:
        type = Calendar.HOUR_OF_DAY;
        factor = 12;
        break;
      default:
        throw new IllegalArgumentException("Unknown timeUnit= " + getTimeUnit());
    }
    cal.add(type, factor * getForecastTime());
    validTime = cal.getTimeInMillis();
  }