private void algorithmDouglasPeucker(List<Entry> entries,double epsilon,int start,int end){
  if (end <= start + 1) {
    return;
  }
  int maxDistIndex=0;
  double distMax=0;
  Entry firstEntry=entries.get(start);
  Entry lastEntry=entries.get(end);
  for (int i=start + 1; i < end; i++) {
    double dist=calcAngleBetweenLines(firstEntry,lastEntry,firstEntry,entries.get(i));
    if (dist > distMax) {
      distMax=dist;
      maxDistIndex=i;
    }
  }
  if (distMax > epsilon) {
    keep[maxDistIndex]=true;
    algorithmDouglasPeucker(entries,epsilon,start,maxDistIndex);
    algorithmDouglasPeucker(entries,epsilon,maxDistIndex,end);
  }
}

private void algorithmDouglasPeucker ( List < Entry > entries , double epsilon , int start , int end ) { if ( end <= start + 1 ) { return ; } int maxDistIndex = 0 ; double distMax = 0 ; Entry firstEntry = entries . get ( start ) ; Entry lastEntry = entries . get ( end ) ; for ( int i = start + 1 ; i < end ; i ++ ) { double dist = calcAngleBetweenLines ( firstEntry , lastEntry , firstEntry , entries . get ( i ) ) ; if ( dist > distMax ) { distMax = dist ; maxDistIndex = i ; } } if ( distMax > epsilon ) { keep [ maxDistIndex ] = true ; algorithmDouglasPeucker ( entries , epsilon , start , maxDistIndex ) ; algorithmDouglasPeucker ( entries , epsilon , maxDistIndex , end ) ; } }
apply the douglas - peucker - reduction to an list of entry with a given epsilon ( tolerance )
