Packagecom.distriqt.extension.nativemaps.utils
Classpublic class PolyUtil
InheritancePolyUtil Inheritance Object

Utility class that encodes and decodes Polylines.

See the detailed explanation of polyline encoding.



Public Methods
 MethodDefined By
  
decode(encodedPath:String):Array
[static] Not yet implemented
PolyUtil
  
encode(points:Vector.<LatLng>):String
[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
Method Detail
decode()method
public static function decode(encodedPath:String):Array

Not yet implemented

Parameters

encodedPath:String

Returns
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

Returns
String — The encoded path string

Example
Encode a vector of LatLng points
         var encodedPath:String = PolyUtil.encode(
             new <LatLng>[
                 new LatLng( -27, 152 ),    new LatLng( -27, 153 )
             ]
         );
         
Use an encoded path as the path of a polyline
         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);