question: public static ArrayList < GeoPoint > reduceWithTolerance ( ArrayList < GeoPoint > shape , double tolerance ) { int n = shape . size ( ) ; if ( tolerance <= 0 || n < 3 ) { return shape ; } boolean [ ] marked = new boolean [ n ] ; for ( int i = 1 ; i < n - 1 ; i ++ ) marked [ i ] = false ; marked [ 0 ] = marked [ n - 1 ] = true ; douglasPeuckerReduction ( shape , marked , tolerance , 0 , n - 1 ) ; ArrayList < GeoPoint > newShape = new ArrayList < GeoPoint > ( n ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( marked [ i ] ) newShape . add ( shape . get ( i ) ) ; } return newShape ; }
target:  Reduce the number of points in a shape using the Douglas-Peucker algorithm