nakarte

Source code of https://map.sikmir.ru (fork)
git clone git://git.sikmir.ru/nakarte
Log | Files | Refs | LICENSE

commit feb3af6dff0a1e91451cc7d248ac231fb5051498
parent 75c2e5775c42c574e3091d44f823601ae3d8bdf0
Author: Sergej Orlov <wladimirych@gmail.com>
Date:   Mon, 19 Mar 2018 22:10:20 +0300

tracks: removed now unused functions for making old urls

Diffstat:
Msrc/lib/leaflet.control.track-list/lib/geo_file_exporters.js | 108-------------------------------------------------------------------------------
1 file changed, 0 insertions(+), 108 deletions(-)

diff --git a/src/lib/leaflet.control.track-list/lib/geo_file_exporters.js b/src/lib/leaflet.control.track-list/lib/geo_file_exporters.js @@ -103,113 +103,5 @@ function saveKml(segments, name, points) { return kml; } -function packNumber(n) { - var bytes = []; - if (n >= -64 && n <= 63) { - n += 64; - bytes.push(n); - } else if (n >= -8192 && n <= 8191) { - n += 8192; - bytes.push((n & 0x7f) | 0x80); - bytes.push(n >> 7); - /* } else if (n >= -2097152 && n <= 2097151) { - n += 2097152; - bytes.push((n & 0x7f) | 0x80); - bytes.push(((n >> 7) & 0x7f) | 0x80); - bytes.push(n >> 14); - */ - } else if (n >= -1048576 && n <= 1048575) { - n += 1048576; - bytes.push((n & 0x7f) | 0x80); - bytes.push(((n >> 7) & 0x7f) | 0x80); - bytes.push(n >> 14); - } else if (n >= -268435456 && n <= 268435455) { - n += 268435456; - bytes.push((n & 0x7f) | 0x80); - bytes.push(((n >> 7) & 0x7f) | 0x80); - bytes.push(((n >> 14) & 0x7f) | 0x80); - bytes.push(n >> 21); - } else { - throw new Error('Number ' + n + ' too big to pack in 29 bits'); - } - return String.fromCharCode.apply(null, bytes); -} - - -function encodeUrlSafeBase64(s) { - return (btoa(s) - .replace(/\+/g, '-') - .replace(/\//g, '_') - .replace(/=+$/, '') - ); -} - -function saveToString(segments, name, color, measureTicksShown, wayPoints, trackHidden) { - var stringified = []; - stringified.push(packNumber(3)); // version - name = utf8.encode(name); - stringified.push(packNumber(name.length)); - stringified.push(name); - - var arcUnit = ((1 << 24) - 1) / 360; - segments = segments.filter(function(segment) { - return segment.length > 1; - } - ); - - stringified.push(packNumber(segments.length)); - segments.forEach(function(points) { - var lastX = 0, - lastY = 0, - x, y, - deltaX, deltaY, - p; - stringified.push(packNumber(points.length)); - for (var i = 0, len = points.length; i < len; i++) { - p = points[i]; - x = Math.round(p.lng * arcUnit); - y = Math.round(p.lat * arcUnit); - deltaX = x - lastX; - deltaY = y - lastY; - stringified.push(packNumber(deltaX)); - stringified.push(packNumber(deltaY)); - lastX = x; - lastY = y; - } - } - ); - stringified.push(packNumber(+color || 0)); - stringified.push(packNumber(measureTicksShown ? 1 : 0)); - stringified.push(packNumber(trackHidden ? 1 : 0)); - - stringified.push(packNumber(wayPoints.length)); - if (wayPoints.length) { - var midX = 0, midY = 0; - wayPoints.forEach(function(p) { - midX += p.latlng.lng; - midY += p.latlng.lat; - } - ); - midX = Math.round(midX * arcUnit / wayPoints.length); - midY = Math.round(midY * arcUnit / wayPoints.length); - stringified.push(packNumber(midX)); - stringified.push(packNumber(midY)); - wayPoints.forEach(function(p) { - var deltaX = Math.round(p.latlng.lng * arcUnit) - midX, - deltaY = Math.round(p.latlng.lat * arcUnit) - midY, - symbol = 1, - name = utf8.encode(p.label); - stringified.push(packNumber(name.length)); - stringified.push(name); - stringified.push(packNumber(symbol)); - stringified.push(packNumber(deltaX)); - stringified.push(packNumber(deltaY)); - } - ); - } - - return encodeUrlSafeBase64(stringified.join('')); -} - export default {saveGpx, saveKml, saveToString: saveNktk};