ppamorim

Bad programmer

Aug 24th, 2014
374
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.94 KB | None | 0 0
  1. List<LatLng> poly = new ArrayList<LatLng>();
  2.         int index = 0, len = encoded.length();
  3.         int lat = 0, lng = 0;
  4.         while (index < len) {
  5.             int b, shift = 0, result = 0;
  6.             do {
  7.                 b = encoded.charAt(index++) - 63;
  8.                 result |= (b & 0x1f) << shift;
  9.                 shift += 5;
  10.             } while (b >= 0x20);
  11.             int dlat = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
  12.             lat += dlat;
  13.             shift = 0;
  14.             result = 0;
  15.             do {
  16.                 b = encoded.charAt(index++) - 63;
  17.                 result |= (b & 0x1f) << shift;
  18.                 shift += 5;
  19.             } while (b >= 0x20);
  20.             int dlng = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
  21.             lng += dlng;
  22.  
  23.             LatLng position = new LatLng((double) lat / 1E5, (double) lng / 1E5);
  24.             poly.add(position);
  25.         }
  26.         return poly;
Advertisement
Add Comment
Please, Sign In to add comment