MCPcopy Index your code
hub / github.com/ColmapView/Colmapview.github.io / loadZipFromUrl

Function loadZipFromUrl

src/utils/zipLoader.ts:203–242  ·  view source on GitHub ↗
(
  url: string,
  onProgress: (progress: ZipProgress) => void
)

Source from the content-addressed store, hash-verified

201 * Downloads the ZIP, extracts COLMAP files immediately, and builds an index for lazy image extraction.
202 */
203export async function loadZipFromUrl(
204 url: string,
205 onProgress: (progress: ZipProgress) => void
206): Promise<ZipLoadResult> {
207 // Initialize libarchive.js
208 await initializeArchive();
209
210 onProgress({ percent: 0, message: 'Checking archive...' });
211
212 // Validate size
213 const validation = await validateZipUrl(url);
214 if (!validation.valid) {
215 throw new Error(validation.error ?? 'Invalid archive');
216 }
217
218 // Download archive
219 const blob = await downloadZip(url, onProgress);
220
221 // Validate downloaded size
222 validateDownloadedArchiveSize(blob, ARCHIVE_SIZE_LIMIT);
223
224 onProgress({ percent: 40, message: 'Opening archive...' });
225
226 // Preserve original filename so libarchive.js can sniff format from extension.
227 const archiveName = getFilenameFromUrl(url) || 'archive.zip';
228 const file = new File([blob], archiveName);
229 const archive = await Archive.open(file);
230
231 // Process archive
232 const { colmapFiles, imageIndex, imageCount } = await processZipArchive(archive, onProgress);
233
234 // Verify we have required COLMAP files
235 if (!hasRequiredColmapArchiveFiles(colmapFiles.keys())) {
236 throw new Error(
237 'Archive does not contain valid COLMAP files (cameras.bin, images.bin, points3D.bin)'
238 );
239 }
240
241 return { colmapFiles, imageIndex, archive, fileSize: blob.size, imageCount };
242}
243
244/**
245 * Load a ZIP file from a local File object.

Callers

nothing calls this directly

Calls 8

validateZipUrlFunction · 0.90
downloadZipFunction · 0.90
getFilenameFromUrlFunction · 0.90
initializeArchiveFunction · 0.85
processZipArchiveFunction · 0.85
openMethod · 0.45

Tested by

no test coverage detected