feat:VT tile data support gzip decode#2779
Merged
fuzhenn merged 15 commits intomaptalks:masterfrom Jan 16, 2026
Merged
Conversation
Member
|
如果能自动识别mvt被gzip压缩过,就可以省略掉 loadTileDecodeGZip 设置了。 我记得zip压缩后的数据头部都有固定的标识符。 |
Member
|
deepseek老师提供的答案: function isGzipBuffer(arrayBuffer) {
if (!arrayBuffer || arrayBuffer.byteLength < 3) {
return false;
}
const view = new Uint8Array(arrayBuffer);
const header = new DataView(arrayBuffer);
// 检查magic number
if (view[0] !== 0x1F || view[1] !== 0x8B) {
return false;
}
// 检查压缩方法(应该是DEFLATE,即0x08)
const compressionMethod = view[2];
if (compressionMethod !== 0x08) {
console.warn('Gzip found but with non-DEFLATE compression method:', compressionMethod);
return false;
}
return true;
} |
Member
|
是否可以用 DecompressionStream (chrome 80版开始支持)来解压gzip数据? |
Collaborator
Author
不好搞:
|
Member
|
问了一下deepseek,可通过blob来实现: javascript
async function decompressGzipWithBlob(compressedArrayBuffer) {
try {
// 创建解压缩流
const decompressionStream = new DecompressionStream('gzip');
// 创建 Blob 并获取可读流
const blob = new Blob([compressedArrayBuffer]);
const readableStream = blob.stream();
// 管道传输
const decompressedStream = readableStream.pipeThrough(decompressionStream);
// 转换为响应并获取数据
const response = new Response(decompressedStream);
const result = await response.arrayBuffer();
return result;
} catch (error) {
console.error('解压失败:', error);
throw error;
}
} |
fuzhenn
approved these changes
Jan 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.