/**
   * convert a GTSWrapper into GeoTimeSerie
   *
   * @param wrapper
   * @return GeoTimeSerie
   */
  public static GeoTimeSerie fromGTSWrapperToGTS(GTSWrapper wrapper) {

    Metadata metadata = wrapper.getMetadata();
    GeoTimeSerie gts = null;

    if (null != wrapper.getEncoded()) {

      byte[] bytes = null;

      if (wrapper.isCompressed()) {
        bytes = unwrapEncoded(wrapper);
      } else {
        bytes = wrapper.getEncoded();
      }

      ByteBuffer bb = ByteBuffer.wrap(bytes);

      GTSDecoder decoder = new GTSDecoder(wrapper.getBase(), bb);

      decoder.setCount(0 != wrapper.getCount() ? wrapper.getCount() : bytes.length / 10);

      gts = decoder.decode();

    } else {
      gts = new GeoTimeSerie();
    }

    if (null == metadata) {
      metadata = new Metadata();
    }

    gts.setMetadata(metadata);

    return gts;
  }
  public static GTSDecoder fromGTSWrapperToGTSDecoder(GTSWrapper wrapper) {

    byte[] unwrapped = unwrapEncoded(wrapper);

    GTSDecoder decoder =
        new GTSDecoder(wrapper.getBase(), ByteBuffer.wrap(unwrapped).order(ByteOrder.BIG_ENDIAN));
    decoder.setMetadata(wrapper.getMetadata());
    decoder.setCount(wrapper.getCount());

    return decoder;
  }