public static GeoTimeSerie normalize(GeoTimeSerie gts){
  if ((TYPE.DOUBLE != gts.getType() && TYPE.LONG != gts.getType()) || 0 == gts.values) {
    return gts.clone();
  }
  double dmin=Double.POSITIVE_INFINITY;
  double dmax=Double.NEGATIVE_INFINITY;
  long lmin=Long.MAX_VALUE;
  long lmax=Long.MIN_VALUE;
  if (TYPE.LONG == gts.getType()) {
    for (int i=0; i < gts.values; i++) {
      long value=(long)GTSHelper.valueAtIndex(gts,i);
      if (value > lmax) {
        lmax=value;
      }
      if (value < lmin) {
        lmin=value;
      }
    }
  }
 else {
    for (int i=0; i < gts.values; i++) {
      double value=(double)GTSHelper.valueAtIndex(gts,i);
      if (value > dmax) {
        dmax=value;
      }
      if (value < dmin) {
        dmin=value;
      }
    }
  }
  boolean constant=false;
  if (lmin == lmax || dmin == dmax) {
    constant=true;
  }
  GeoTimeSerie normalized=new GeoTimeSerie(gts.lastbucket,gts.bucketcount,gts.bucketspan,gts.values);
  normalized.setName(gts.getName());
  normalized.setLabels(gts.getLabels());
  for (int i=0; i < gts.values; i++) {
    Object value;
    if (constant) {
      value=1.0D;
    }
 else     if (TYPE.LONG == gts.getType()) {
      value=((long)GTSHelper.valueAtIndex(gts,i) - lmin) / (double)(lmax - lmin);
    }
 else {
      value=((double)GTSHelper.valueAtIndex(gts,i) - dmin) / (double)(dmax - dmin);
    }
    GTSHelper.setValue(normalized,gts.ticks[i],GTSHelper.locationAtIndex(gts,i),GTSHelper.elevationAtIndex(gts,i),value,false);
  }
  return normalized;
}

public static GeoTimeSerie normalize ( GeoTimeSerie gts ) { if ( ( TYPE . DOUBLE != gts . getType ( ) && TYPE . LONG != gts . getType ( ) ) || 0 == gts . values ) { return gts . clone ( ) ; } double dmin = Double . POSITIVE_INFINITY ; double dmax = Double . NEGATIVE_INFINITY ; long lmin = Long . MAX_VALUE ; long lmax = Long . MIN_VALUE ; if ( TYPE . LONG == gts . getType ( ) ) { for ( int i = 0 ; i < gts . values ; i ++ ) { long value = ( long ) GTSHelper . valueAtIndex ( gts , i ) ; if ( value > lmax ) { lmax = value ; } if ( value < lmin ) { lmin = value ; } } } else { for ( int i = 0 ; i < gts . values ; i ++ ) { double value = ( double ) GTSHelper . valueAtIndex ( gts , i ) ; if ( value > dmax ) { dmax = value ; } if ( value < dmin ) { dmin = value ; } } } boolean constant = false ; if ( lmin == lmax || dmin == dmax ) { constant = true ; } GeoTimeSerie normalized = new GeoTimeSerie ( gts . lastbucket , gts . bucketcount , gts . bucketspan , gts . values ) ; normalized . setName ( gts . getName ( ) ) ; normalized . setLabels ( gts . getLabels ( ) ) ; for ( int i = 0 ; i < gts . values ; i ++ ) { Object value ; if ( constant ) { value = 1.0D ; } else if ( TYPE . LONG == gts . getType ( ) ) { value = ( ( long ) GTSHelper . valueAtIndex ( gts , i ) - lmin ) / ( double ) ( lmax - lmin ) ; } else { value = ( ( double ) GTSHelper . valueAtIndex ( gts , i ) - dmin ) / ( double ) ( dmax - dmin ) ; } GTSHelper . setValue ( normalized , gts . ticks [ i ] , GTSHelper . locationAtIndex ( gts , i ) , GTSHelper . elevationAtIndex ( gts , i ) , value , false ) ; } return normalized ; }
normalize a gts , replacing x by ( x - min ) / ( max - min ) or 1 . 0
