Back to project page GoogleDirectionsClient.
The source code is released under:
Apache License
If you think the Android project GoogleDirectionsClient listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.manuelpeinado.googledirectionsclient; // w w w .j a v a2 s .c o m import java.util.ArrayList; import java.util.List; import com.google.gson.annotations.SerializedName; public class Polyline { @SerializedName("points") public String encodedPoints; public List<RoutePoint> decodePoints() { List<RoutePoint> poly = new ArrayList<RoutePoint>(); int index = 0, len = encodedPoints.length(); int lat = 0, lng = 0; while (index < len) { int b, shift = 0, result = 0; do { b = encodedPoints.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 = encodedPoints.charAt(index++) - 63; result |= (b & 0x1f) << shift; shift += 5; } while (b >= 0x20); int dlng = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1)); lng += dlng; poly.add(new RoutePoint((double) lat / 1E5, (double) lng / 1E5)); } return poly; } }