public static String encode(ArrayList<GeoPoint> polyline,int precision){
  StringBuilder encodedPoints=new StringBuilder();
  int prev_lat=0, prev_lng=0;
  for (  GeoPoint trackpoint : polyline) {
    int lat=trackpoint.getLatitudeE6() / precision;
    int lng=trackpoint.getLongitudeE6() / precision;
    encodedPoints.append(encodeSignedNumber(lat - prev_lat));
    encodedPoints.append(encodeSignedNumber(lng - prev_lng));
    prev_lat=lat;
    prev_lng=lng;
  }
  return encodedPoints.toString();
}

public static String encode ( ArrayList < GeoPoint > polyline , int precision ) { StringBuilder encodedPoints = new StringBuilder ( ) ; int prev_lat = 0 , prev_lng = 0 ; for ( GeoPoint trackpoint : polyline ) { int lat = trackpoint . getLatitudeE6 ( ) / precision ; int lng = trackpoint . getLongitudeE6 ( ) / precision ; encodedPoints . append ( encodeSignedNumber ( lat - prev_lat ) ) ; encodedPoints . append ( encodeSignedNumber ( lng - prev_lng ) ) ; prev_lat = lat ; prev_lng = lng ; } return encodedPoints . toString ( ) ; }
encode a polyline with google polyline encoding method
