-
Notifications
You must be signed in to change notification settings - Fork 195
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
chore(tile-converter): Support for SLPKs larger than 2 Gb #2547
Conversation
Bigint logic implementation
modules/i3s/src/i3s-slpk-loader.ts
Outdated
@@ -12,6 +13,13 @@ export type SLPKLoaderOptions = LoaderOptions & { | |||
}; | |||
}; | |||
|
|||
async function parseSLPK(data: ArrayBuffer, options: SLPKLoaderOptions = {}) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add TSDoc comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move the function under the loader declaration. It is general practice in loaders.gl that the loader is declared first
@@ -0,0 +1,26 @@ | |||
import {FileProvider} from 'modules/i3s/src/lib/parsers/parse-zip/file-provider'; | |||
|
|||
export const searchFromTheEnd = async (file: FileProvider, target: number[]): Promise<bigint> => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add TSDoc comments and tests
@@ -0,0 +1,70 @@ | |||
import {FileProvider} from './file-provider'; | |||
|
|||
const toNumber = (bigint: bigint) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add TSDoc comments
/** | ||
* Provides file data using DataView | ||
*/ | ||
export class DataViewFileProvider implements FileProvider { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add tests for the class
} | ||
|
||
/** | ||
* Gets an unsigned 16-bit integer (unsigned byte) at the specified byte offset from the start of the file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unsigned 16-bit integer
!= unsigned byte
. It is unsigned short
getUint8(offset: bigint): Promise<number> { | ||
return Promise.resolve(this.file.getUint8(toNumber(offset))); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getUint8(offset: bigint): Promise<number> { | |
return Promise.resolve(this.file.getUint8(toNumber(offset))); | |
} | |
async getUint8(offset: bigint): Promise<number> { | |
return this.file.getUint8(toNumber(offset)); | |
} |
and for all async methods...
|
||
let offsetInZip64Data = 4n; | ||
// looking for info that might be also be in zip64 extra field | ||
if (uncompressedSize === BigInt(0xffffffff)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add test cases for these cases?
* Gets an unsigned 32-bit integer (unsigned byte) at the specified byte offset from the start of the file. | ||
* @param offset The offset, in bytes, from the start of the file where to read the data. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment looks like copy&paste from getUint32
buffer: Buffer; | ||
}; | ||
|
||
export class FileHandle { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add TSDoc comments and tests
export default class SLPKConverter { | ||
/** | ||
* extract slpk to i3s | ||
* Convert slpk to i3s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename
@@ -6,17 +6,17 @@ import {FileProvider} from './file-provider'; | |||
*/ | |||
export type ZipCDFileHeader = { | |||
/** Compressed size */ | |||
compressedSize: number; | |||
compressedSize: bigint; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
const uncompressedSize = await buffer.getUint32( | ||
headerOffset + offsets.CD_UNCOMPRESSED_SIZE_OFFSET | ||
let uncompressedSize = BigInt( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please test BigInts on Safari / iOS. It should be supported now but better find out early
@@ -0,0 +1,34 @@ | |||
import test from 'tape-promise/tape'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI: It is possible to make *.ts tests
@@ -0,0 +1,2 @@ | |||
/** Description of zip signature type */ | |||
export type ZipSignature = [number, number, number, number]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit. The type is so simple. The better is just declare a variable with this tuple:
const zipSignature: [number, number, number, number] = [1,2,3,4];
The separate file is too much for it.
No description provided.