kopia lustrzana https://github.com/paraboul/mapchecking
Add support for compressed URL
rodzic
633033b4d1
commit
ba573ed2fd
|
@ -10,6 +10,7 @@
|
|||
"@types/google.maps": "^3.48.3",
|
||||
"@vitejs/plugin-vue": "^2.2.4",
|
||||
"@vueuse/core": "^8.2.0",
|
||||
"fflate": "^0.7.3",
|
||||
"js-base64": "^3.5.2",
|
||||
"tailwindcss": "^3.0.23",
|
||||
"tatween": "^0.2.0",
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
import { Base64 } from 'js-base64'
|
||||
import { onMounted, ref, watch, computed } from 'vue';
|
||||
import { watchDebounced } from '@vueuse/core'
|
||||
import { zlibSync, unzlibSync } from 'fflate';
|
||||
|
||||
const DEFAULT_MAP_POSITION = [48.862895, 2.286978, 18]
|
||||
|
||||
|
@ -167,15 +168,21 @@
|
|||
}
|
||||
|
||||
const loadHash = (hash: string) => {
|
||||
if (hash[0] != 'b') {
|
||||
if (hash[0] != 'b' && hash[0] != 'c') {
|
||||
return loadLegacyHash(hash);
|
||||
}
|
||||
|
||||
const buf = Base64.toUint8Array(hash.substr(1));
|
||||
const isCompressed = hash[0] == 'c';
|
||||
let buf = Base64.toUint8Array(hash.substr(1));
|
||||
|
||||
if (!buf) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isCompressed) {
|
||||
buf = unzlibSync(buf)
|
||||
}
|
||||
|
||||
const meta = new Float32Array(buf.buffer, 0, 4);
|
||||
const data = new Float32Array(buf.buffer, 4*4);
|
||||
|
||||
|
@ -240,7 +247,15 @@
|
|||
buf[4+i*2] = arrPoly.value[i].lat();
|
||||
buf[4+i*2+1] = arrPoly.value[i].lng();
|
||||
}
|
||||
return 'b' + Base64.fromUint8Array(new Uint8Array(buf.buffer), true);
|
||||
|
||||
let outbuf = new Uint8Array(buf.buffer);
|
||||
const isCompressed = outbuf.byteLength >= 150;
|
||||
|
||||
if (isCompressed) {
|
||||
outbuf = zlibSync(outbuf, { level: 9 });
|
||||
}
|
||||
|
||||
return (isCompressed ? 'c' : 'b') + Base64.fromUint8Array(outbuf, true);
|
||||
})
|
||||
|
||||
watch(() => props.density, () => updatePolygonColor());
|
||||
|
|
|
@ -596,6 +596,11 @@ fastq@^1.6.0:
|
|||
dependencies:
|
||||
reusify "^1.0.4"
|
||||
|
||||
fflate@^0.7.3:
|
||||
version "0.7.3"
|
||||
resolved "https://registry.yarnpkg.com/fflate/-/fflate-0.7.3.tgz#288b034ff0e9c380eaa2feff48c787b8371b7fa5"
|
||||
integrity sha512-0Zz1jOzJWERhyhsimS54VTqOteCNwRtIlh8isdL0AXLo0g7xNTfTL7oWrkmCnPhZGocKIkWHBistBrrpoNH3aw==
|
||||
|
||||
fill-range@^7.0.1:
|
||||
version "7.0.1"
|
||||
resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40"
|
||||
|
|
Ładowanie…
Reference in New Issue