RealTimeBusNavigation_5.0/app/src/main/java/com/example/saurabh/realtimebusnavigation/MapsActivity.java
private List<LatLng> decodePolyLine(final String poly) {
        int len = poly.length();
        int index = 0;
        List<LatLng> decoded = new ArrayList<LatLng>();
        int lat = 0;
        int lng = 0;

        while (index < len) {
            int b;
            int shift = 0;
            int result = 0;
            do {
                b = poly.charAt(index++) - 63;
                result |= (b & 0x1f) << shift;
                shift += 5;
            } while (b >= 0x20);
            int dlat = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
            lat += dlat;

            shift = 0;
            result = 0;
            do {
                b = poly.charAt(index++) - 63;
                result |= (b & 0x1f) << shift;
                shift += 5;
            } while (b >= 0x20);
            int dlng = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
            lng += dlng;

            decoded.add(new LatLng((((double) lat / 1e5)),
                    (((double) lng / 1e5))));
        }

        return decoded;
    }
//Formula for decoding encrypted PolyLine string and return list of LatLng for endpoint of each sub_path.
Formula for decoding encrypted PolyLine string and return list of LatLng for endpoint of each sub_path.
Formula for decoding encrypted PolyLine string and return list of LatLng for endpoint of each sub_path .
private List<LatLng> decodePolyLine(final String poly) {
        int len = poly.length();
        int index = 0;
        List<LatLng> decoded = new ArrayList<LatLng>();
        int lat = 0;
        int lng = 0;
        while (index < len) {
            int b;
            int shift = 0;
            int result = 0;
            do {
                b = poly.charAt(index++) - 63;
                result |= (b & 0x1f) << shift;
                shift += 5;
            } while (b >= 0x20);
            int dlat = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
            lat += dlat;
            shift = 0;
            result = 0;
            do {
                b = poly.charAt(index++) - 63;
                result |= (b & 0x1f) << shift;
                shift += 5;
            } while (b >= 0x20);
            int dlng = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
            lng += dlng;
            decoded.add(new LatLng((((double) lat / 1e5)),
                    (((double) lng / 1e5))));
        }
        return decoded;
    }
private List < LatLng > decodePolyLine ( final String poly ) { int len = poly . length ( ) ; int index = 0 ; List < LatLng > decoded = new ArrayList < LatLng > ( ) ; int lat = 0 ; int lng = 0 ; while ( index < len ) { int b ; int shift = 0 ; int result = 0 ; do { b = poly . charAt ( index ++ ) - 63 ; result |= ( b & 0x1f ) << shift ; shift += 5 ; } while ( b >= 0x20 ) ; int dlat = ( ( result & 1 ) != 0 ? ~ ( result >> 1 ) : ( result >> 1 ) ) ; lat += dlat ; shift = 0 ; result = 0 ; do { b = poly . charAt ( index ++ ) - 63 ; result |= ( b & 0x1f ) << shift ; shift += 5 ; } while ( b >= 0x20 ) ; int dlng = ( ( result & 1 ) != 0 ? ~ ( result >> 1 ) : ( result >> 1 ) ) ; lng += dlng ; decoded . add ( new LatLng ( ( ( ( double ) lat / 1e5 ) ) , ( ( ( double ) lng / 1e5 ) ) ) ) ; } return decoded ; }
Formula for decoding encrypted PolyLine string and return list of LatLng for endpoint of each sub_path.
Formula for decoding encrypted PolyLine string and return list of LatLng for endpoint of each sub_path .