-
Notifications
You must be signed in to change notification settings - Fork 515
feat:VT tile data support gzip decode #2779
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
+90
−18
Conversation
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
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
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.