public static List<Position> decode(final String encodedPath,int precision){
  int len=encodedPath.length();
  double factor=Math.pow(10,precision);
  final List<Position> path=new ArrayList<>();
  int index=0;
  int lat=0;
  int lng=0;
  while (index < len) {
    int result=1;
    int shift=0;
    int b;
    do {
      b=encodedPath.charAt(index++) - 63 - 1;
      result+=b << shift;
      shift+=5;
    }
 while (b >= 0x1f);
    lat+=(result & 1) != 0 ? ~(result >> 1) : (result >> 1);
    result=1;
    shift=0;
    do {
      b=encodedPath.charAt(index++) - 63 - 1;
      result+=b << shift;
      shift+=5;
    }
 while (b >= 0x1f);
    lng+=(result & 1) != 0 ? ~(result >> 1) : (result >> 1);
    path.add(Position.fromCoordinates(lng / factor,lat / factor));
  }
  return path;
}

public static List < Position > decode ( final String encodedPath , int precision ) { int len = encodedPath . length ( ) ; double factor = Math . pow ( 10 , precision ) ; final List < Position > path = new ArrayList < > ( ) ; int index = 0 ; int lat = 0 ; int lng = 0 ; while ( index < len ) { int result = 1 ; int shift = 0 ; int b ; do { b = encodedPath . charAt ( index ++ ) - 63 - 1 ; result += b << shift ; shift += 5 ; } while ( b >= 0x1f ) ; lat += ( result & 1 ) != 0 ? ~ ( result > > 1 ) : ( result > > 1 ) ; result = 1 ; shift = 0 ; do { b = encodedPath . charAt ( index ++ ) - 63 - 1 ; result += b << shift ; shift += 5 ; } while ( b >= 0x1f ) ; lng += ( result & 1 ) != 0 ? ~ ( result > > 1 ) : ( result > > 1 ) ; path . add ( Position . fromCoordinates ( lng / factor , lat / factor ) ) ; } return path ; }
decodes an encoded path string into a sequence of positions .
