| Package | com.distriqt.extension.nativemaps.utils |
| Class | public class PolyUtil |
| Inheritance | PolyUtil Object |
See the detailed explanation of polyline encoding.
| Method | Defined By | ||
|---|---|---|---|
decode(encodedPath:String):Array [static]
Not yet implemented
| PolyUtil | ||
[static]
Encode a path represented by a series of points into a string
Polyline encoding is a lossy compression algorithm that allows you
to store a series of coordinates as a single string. | PolyUtil | ||
| decode | () | method |
public static function decode(encodedPath:String):ArrayNot yet implemented
Parameters
encodedPath:String |
Array — |
| encode | () | method |
public static function encode(points:Vector.<LatLng>):String
Encode a path represented by a series of points into a string
Polyline encoding is a lossy compression algorithm that allows you to store a series of coordinates as a single string. Point coordinates are encoded using signed values.
The encoding process converts a binary value into a series of character codes for ASCII characters using the familiar base64 encoding scheme: to ensure proper display of these characters, encoded values are summed with 63 (the ASCII character '?') before converting them into ASCII. The algorithm also checks for additional character codes for a given point by checking the least significant bit of each byte group; if this bit is set to 1, the point is not yet fully formed and additional data must follow.
Additionally, to conserve space, points only include the offset from the previous point (except of course for the first point). All points are encoded in Base64 as signed integers, as latitudes and longitudes are signed values. The encoding format within a polyline needs to represent two coordinates representing latitude and longitude to a reasonable precision. Given a maximum longitude of +/- 180 degrees to a precision of 5 decimal places (180.00000 to -180.00000), this results in the need for a 32 bit signed binary integer value.
Parameters
points:Vector.<LatLng> — The Vector array of LatLng objects
|
String — The encoded path string
|
var encodedPath:String = PolyUtil.encode(
new <LatLng>[
new LatLng( -27, 152 ), new LatLng( -27, 153 )
]
);
var points:Vector.<LatLng> = new <LatLng>[ new LatLng( -27, 152 ), new LatLng( -27, 153 ) ];
var polyline:Polyline = new Polyline();
polyline.colour = 0xFFFF00FF;
polyline.encodedPath = PolyUtil.encode(points);