PHP Class Polyline, google-map-polyline-encoding-tool

Convert list of points to encoded string following Google's Polyline Algorithm.
Exibir arquivo Open project: emcconville/google-map-polyline-encoding-tool Class Usage Examples

Protected Properties

Property Type Description
$precision integer Overwrite this property in extended class to adjust precision of numbers. !!!CAUTION!!! 1) Adjusting this value will not guarantee that third party libraries will understand the change. 2) Float point arithmetic IS NOT real number arithmetic. PHP's internal float precision may contribute to undesired rounding.

Public Methods

Method Description
decode ( string $string ) : array Reverse Google Polyline algorithm on encoded string.
encode ( array $points ) : string Apply Google Polyline algorithm to list of points.
flatten ( array $array ) : array Reduce multi-dimensional to single list
pair ( array $list ) : array Concat list into pairs of points

Method Details

decode() final public static method

Reverse Google Polyline algorithm on encoded string.
final public static decode ( string $string ) : array
$string string Encoded string to extract points from.
return array points

encode() final public static method

Apply Google Polyline algorithm to list of points.
final public static encode ( array $points ) : string
$points array List of points to encode. Can be a list of tuples, or a flat on dimensional array.
return string encoded string

flatten() final public static method

Reduce multi-dimensional to single list
final public static flatten ( array $array ) : array
$array array Subject array to flatten.
return array flattened

pair() final public static method

Concat list into pairs of points
final public static pair ( array $list ) : array
$list array One-dimensional array to segment into list of tuples.
return array pairs

Property Details

$precision protected_oe static_oe property

Overwrite this property in extended class to adjust precision of numbers. !!!CAUTION!!! 1) Adjusting this value will not guarantee that third party libraries will understand the change. 2) Float point arithmetic IS NOT real number arithmetic. PHP's internal float precision may contribute to undesired rounding.
protected static int $precision
return integer