public static function decode($encodedPath) {
        
        $len = strlen( $encodedPath ) -1;
        // For speed we preallocate to an upper bound on the final length, then
        // truncate the array before returning.
        $path = [];
        $index = 0;
        $lat = 0;
        $lng = 0;

        while( $index < $len) {
            $result = 1;
            $shift = 0;
            $b;
            do {
                $b = ord($encodedPath{$index++}) - 63 - 1;
                $result += $b << $shift;
                $shift += 5;
            } while ($b >= hexdec("0x1f"));
            
            $lat += ($result & 1) != 0 ? ~($result >> 1) : ($result >> 1);

            $result = 1;
            $shift = 0;
            do {
                $b = ord($encodedPath{$index++}) - 63 - 1;
                $result += $b << $shift;
                $shift += 5;
            } while ($b >= hexdec("0x1f"));
            $lng += ($result & 1) != 0 ? ~($result >> 1) : ($result >> 1);
            
            array_push($path, ['lat' => $lat * 1e-5, 'lng' => $lng * 1e-5]);
        }

        return $path;
    }
public static function decode($encodedPath) {
        
        $len = strlen( $encodedPath ) -1;
        // For speed we preallocate to an upper bound on the final length, then
        // truncate the array before returning.
        $path = [];
        $index = 0;
        $lat = 0;
        $lng = 0;

        while( $index < $len) {
            $result = 1;
            $shift = 0;
            $b;
            do {
                $b = ord($encodedPath{$index++}) - 63 - 1;
                $result += $b << $shift;
                $shift += 5;
            } while ($b >= hexdec("0x1f"));
            
            $lat += ($result & 1) != 0 ? ~($result >> 1) : ($result >> 1);

            $result = 1;
            $shift = 0;
            do {
                $b = ord($encodedPath{$index++}) - 63 - 1;
                $result += $b << $shift;
                $shift += 5;
            } while ($b >= hexdec("0x1f"));
            $lng += ($result & 1) != 0 ? ~($result >> 1) : ($result >> 1);
            
            array_push($path, ['lat' => $lat * 1e-5, 'lng' => $lng * 1e-5]);
        }

        return $path;
    }
public static function decode ( $ encodedPath ) { $ len = strlen ( $ encodedPath ) - 1 ; // For speed we preallocate to an upper bound on the final length, then // truncate the array before returning. $ path = [ ] ; $ index = 0 ; $ lat = 0 ; $ lng = 0 ; while ( $ index < $ len ) { $ result = 1 ; $ shift = 0 ; $ b ; do { $ b = ord ( $ encodedPath { $ index ++ } ) - 63 - 1 ; $ result += $ b << $ shift ; $ shift += 5 ; } while ( $ b >= hexdec ( "0x1f" ) ) ; $ lat += ( $ result & 1 ) != 0 ? ~ ( $ result >> 1 ) : ( $ result >> 1 ) ; $ result = 1 ; $ shift = 0 ; do { $ b = ord ( $ encodedPath { $ index ++ } ) - 63 - 1 ; $ result += $ b << $ shift ; $ shift += 5 ; } while ( $ b >= hexdec ( "0x1f" ) ) ; $ lng += ( $ result & 1 ) != 0 ? ~ ( $ result >> 1 ) : ( $ result >> 1 ) ; array_push ( $ path , [ 'lat' => $ lat * 1e-5 , 'lng' => $ lng * 1e-5 ] ) ; } return $ path ; }
Decodes an encoded path string into a sequence of LatLngs.
Decodes an encoded path string into a sequence of LatLngs .