public static final GeoTimeSerie subSerie(GeoTimeSerie gts,long starttimestamp,long stoptimestamp,boolean overwrite,boolean copyLabels,GeoTimeSerie subgts){
  if (null == subgts) {
    subgts=new GeoTimeSerie(128);
    subgts.setName(gts.getName());
    if (copyLabels) {
      subgts.setLabels(gts.getLabels());
    }
  }
 else {
    GTSHelper.reset(subgts);
  }
  if (null == gts.ticks || 0 == gts.values) {
    return subgts;
  }
  GTSHelper.sort(gts);
  int lastidx=Arrays.binarySearch(gts.ticks,0,gts.values,stoptimestamp);
  if (-1 == lastidx) {
    return subgts;
  }
 else   if (lastidx < 0) {
    lastidx=-lastidx - 1;
    if (lastidx >= gts.values) {
      lastidx=gts.values - 1;
    }
  }
  int firstidx=Arrays.binarySearch(gts.ticks,0,lastidx + 1,starttimestamp);
  if (firstidx < 0) {
    firstidx=-firstidx - 1;
  }
  if (firstidx >= gts.values) {
    return subgts;
  }
  for (int i=firstidx; i <= lastidx; i++) {
    if (gts.ticks[i] >= starttimestamp && gts.ticks[i] <= stoptimestamp) {
      setValue(subgts,gts.ticks[i],null != gts.locations ? gts.locations[i] : GeoTimeSerie.NO_LOCATION,null != gts.elevations ? gts.elevations[i] : GeoTimeSerie.NO_ELEVATION,valueAtIndex(gts,i),overwrite);
    }
  }
  return subgts;
}

public static final GeoTimeSerie subSerie ( GeoTimeSerie gts , long starttimestamp , long stoptimestamp , boolean overwrite , boolean copyLabels , GeoTimeSerie subgts ) { if ( null == subgts ) { subgts = new GeoTimeSerie ( 128 ) ; subgts . setName ( gts . getName ( ) ) ; if ( copyLabels ) { subgts . setLabels ( gts . getLabels ( ) ) ; } } else { GTSHelper . reset ( subgts ) ; } if ( null == gts . ticks || 0 == gts . values ) { return subgts ; } GTSHelper . sort ( gts ) ; int lastidx = Arrays . binarySearch ( gts . ticks , 0 , gts . values , stoptimestamp ) ; if ( - 1 == lastidx ) { return subgts ; } else if ( lastidx < 0 ) { lastidx = - lastidx - 1 ; if ( lastidx >= gts . values ) { lastidx = gts . values - 1 ; } } int firstidx = Arrays . binarySearch ( gts . ticks , 0 , lastidx + 1 , starttimestamp ) ; if ( firstidx < 0 ) { firstidx = - firstidx - 1 ; } if ( firstidx >= gts . values ) { return subgts ; } for ( int i = firstidx ; i <= lastidx ; i ++ ) { if ( gts . ticks [ i ] >= starttimestamp && gts . ticks [ i ] <= stoptimestamp ) { setValue ( subgts , gts . ticks [ i ] , null != gts . locations ? gts . locations [ i ] : GeoTimeSerie . NO_LOCATION , null != gts . elevations ? gts . elevations [ i ] : GeoTimeSerie . NO_ELEVATION , valueAtIndex ( gts , i ) , overwrite ) ; } } return subgts ; }
return a new geotimeserie instance containing only the value of ' gts ' which fall between ' timestamp ' ( inclusive ) and ' timestamp ' - ' span ' ( exclusive ) the resulting gts instance will be sorted .
