I have found some c# code for decoding polyline (without needing a device with maps/routes) but need a little help converting to monkeyc

This is the code, some of the syntax looks familiar but I’m not sure 100% if monkeyc will understand it correctly and I don’t want to break it by fiddling around too much. Some help from someone a bit more experience than I would be appreciated.

int index = 0;

        var polylineChars = encodedPoints.ToCharArray();

        var poly = new List<LatLng>();

        int currentLat = 0;

        int currentLng = 0;

        int next5Bits;

 

        while (index < polylineChars.Length)

        {

            // calculate next latitude

            int sum = 0;

            int shifter = 0;

 

            do

            {

                next5Bits = polylineChars[index++] - 63;

                sum |= (next5Bits & 31) << shifter;

                shifter += 5;

            }

            while (next5Bits >= 32 && index < polylineChars.Length);

 

            if (index >= polylineChars.Length)

            {

                break;

            }

 

            currentLat += (sum & 1) == 1 ? ~(sum >> 1) : (sum >> 1);

 

            // calculate next longitude

            sum = 0;

            shifter = 0;

 

            do

            {

                next5Bits = polylineChars[index++] - 63;

                sum |= (next5Bits & 31) << shifter;

                shifter += 5;

            }

            while (next5Bits >= 32 && index < polylineChars.Length);

 

            if (index >= polylineChars.Length && next5Bits >= 32)

            {

                break;

            }

 

            currentLng += (sum & 1) == 1 ? ~(sum >> 1) : (sum >> 1);

 

            var mLatLng = new LatLng(Convert.ToDouble(currentLat) / 100000.0, Convert.ToDouble(currentLng) / 100000.0);

            poly.Add(mLatLng);

        }

 

        return poly;

    }