- Регистрация
- 15.05.2017
- Сообщения
- 436
- Благодарностей
- 104
- Баллы
- 43
Hello, maybe a little stupid question, but how to run such javascript function in zenno? Never really needed to do so, but using external services for this job is not suitable for the job. Thank you!
JavaScript:
function decompress (encoded, precision) {
precision = Math.pow (10, -precision);
var len = encoded.length, index = 0, lat = 0, lng = 0, array = [];
while (index <len) {
var b, shift = 0, result = 0;
do {
b = encoded.charCodeAt (index ++) - 63;
result | = (b & 0x1f) << shift;
shift + = 5;
} while (b> = 0x20);
var dlat = ((result & 1)? ~ (result >> 1): (result >> 1));
lat + = dlat;
shift = 0;
result = 0;
do {
b = encoded.charCodeAt (index ++) - 63;
result | = (b & 0x1f) << shift;
shift + = 5;
} while (b> = 0x20);
var dlng = ((result & 1)? ~ (result >> 1): (result >> 1));
lng + = dlng;
array.push (lat * precision);
array.push (lng * precision);
}
return array;
}