diff --git a/README.md b/README.md index f73021de..73af373e 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Load a COG from a URL using `fetch` import { SourceHttp } from '@chunkd/source-http'; const source = new SourceHttp('https://example.com/cog.tif'); -const cog = await CogTiff.create(source); +const cog = await Tiff.create(source); const img = cog.images[0]; if (img.isTiled()) throw new Error('Tiff is not tiled'); diff --git a/packages/cli/src/commands/dump.ts b/packages/cli/src/commands/dump.ts index a98ba577..d6510e6a 100644 --- a/packages/cli/src/commands/dump.ts +++ b/packages/cli/src/commands/dump.ts @@ -3,7 +3,7 @@ import { basename } from 'node:path'; import { pathToFileURL } from 'node:url'; import { fsa } from '@chunkd/fs'; -import { CogTiff, TiffMimeType } from '@cogeotiff/core'; +import { Tiff, TiffMimeType } from '@cogeotiff/core'; import { log } from '@linzjs/tracing'; import { command, number, option, optional, restPositionals } from 'cmd-ts'; import pLimit from 'p-limit'; @@ -59,7 +59,7 @@ export const commandDump = command({ if (path == null) continue; if (path.protocol === 's3:') await ensureS3fs(); const source = fsa.source(path); - const tiff = await new CogTiff(source).init(); + const tiff = await new Tiff(source).init(); const img = tiff.images[args.image]; if (!img.isTiled()) throw Error(`Tiff: ${path.href} file is not tiled.`); const output = new URL(`${basename(path.href)}-i${args.image}/`, args.output ?? cwd); @@ -71,7 +71,7 @@ export const commandDump = command({ }, }); -async function dumpBounds(tiff: CogTiff, target: URL, index: number): Promise { +async function dumpBounds(tiff: Tiff, target: URL, index: number): Promise { const img = tiff.images[index]; if (!img.isTiled() || !img.isGeoLocated) return; @@ -115,7 +115,7 @@ async function dumpBounds(tiff: CogTiff, target: URL, index: number): Promise { +async function dumpTiles(tiff: Tiff, target: URL, index: number, logger: typeof log): Promise { const promises: Promise[] = []; const img = tiff.images[index]; if (!img.isTiled()) return 0; diff --git a/packages/cli/src/commands/info.ts b/packages/cli/src/commands/info.ts index f59a5a13..3cd65c5e 100644 --- a/packages/cli/src/commands/info.ts +++ b/packages/cli/src/commands/info.ts @@ -1,8 +1,9 @@ import { fsa } from '@chunkd/fs'; import { - CogTiff, Tag, TagOffset, + Tiff, + TiffImage, TiffTag, TiffTagGeo, TiffTagGeoValueLookup, @@ -10,7 +11,6 @@ import { TiffTagValueType, TiffVersion, } from '@cogeotiff/core'; -import { CogTiffImage } from '@cogeotiff/core/src/cog.tiff.image.js'; import c from 'ansi-colors'; import { command, flag, option, optional, restPositionals } from 'cmd-ts'; @@ -45,7 +45,7 @@ export const commandInfo = command({ FetchLog.reset(); const source = fsa.source(path); - const tiff = await new CogTiff(source).init(); + const tiff = await new Tiff(source).init(); const header = [ { key: 'Tiff type', value: `${TiffVersion[tiff.version]} (v${String(tiff.version)})` }, @@ -123,7 +123,7 @@ export const commandInfo = command({ }, }); -const TiffImageInfoTable = new CliTable(); +const TiffImageInfoTable = new CliTable(); TiffImageInfoTable.add({ name: 'Id', width: 4, get: (_i, index) => String(index) }); TiffImageInfoTable.add({ name: 'Size', width: 20, get: (i) => `${i.size.width}x${i.size.height}` }); TiffImageInfoTable.add({ @@ -169,7 +169,7 @@ TiffImageInfoTable.add({ * TODO using a XML Parser will make this even better * @param img */ -function parseGdalMetadata(img: CogTiffImage): string[] | null { +function parseGdalMetadata(img: TiffImage): string[] | null { const metadata = img.value(TiffTag.GdalMetadata); if (typeof metadata !== 'string') return null; if (!metadata.startsWith('')) return null; diff --git a/packages/cli/src/util.tile.ts b/packages/cli/src/util.tile.ts index bf071f73..a3d75d35 100644 --- a/packages/cli/src/util.tile.ts +++ b/packages/cli/src/util.tile.ts @@ -1,6 +1,6 @@ import { promises as fs } from 'node:fs'; -import { CogTiff, TiffMimeType } from '@cogeotiff/core'; +import { Tiff, TiffMimeType } from '@cogeotiff/core'; import { log } from '@linzjs/tracing'; const FileExtension: Record = { @@ -34,7 +34,7 @@ export function getTileName(mimeType: string, index: number, x: number, y: numbe } export async function writeTile( - tiff: CogTiff, + tiff: Tiff, x: number, y: number, index: number, diff --git a/packages/core/README.md b/packages/core/README.md index a404a89b..0eea5f16 100644 --- a/packages/core/README.md +++ b/packages/core/README.md @@ -15,10 +15,10 @@ Load a COG from a remote http source ```typescript import { SourceHttp } from '@chunkd/source-url'; -import { CogTiff } from '@cogeotiff/core' +import { Tiff } from '@cogeotiff/core' const source = new SourceHttp('https://example.com/cog.tif'); -const tiff = await CogTiff.create(source); +const tiff = await Tiff.create(source); /** Load a specific tile from a specific image */ const tile = await tiff.images[5].getTile(2, 2); diff --git a/packages/core/src/__benchmark__/cog.read.benchmark.ts b/packages/core/src/__benchmark__/cog.read.benchmark.ts index 313a6196..4c68be74 100644 --- a/packages/core/src/__benchmark__/cog.read.benchmark.ts +++ b/packages/core/src/__benchmark__/cog.read.benchmark.ts @@ -1,7 +1,7 @@ import { readFile } from 'fs/promises'; -import { CogTiff } from '../cog.tiff.js'; import { TiffTag } from '../index.js'; +import { Tiff } from '../tiff.js'; import { SourceMemory } from './source.memory.js'; // console.log = console.trace; @@ -10,10 +10,10 @@ async function main(): Promise { const buf = await readFile(process.argv[process.argv.length - 1]); const source = new SourceMemory(buf); for (let i = 0; i < 5_000; i++) { - performance.mark('cog:init'); - const tiff = new CogTiff(source); + performance.mark('tiff:init'); + const tiff = new Tiff(source); await tiff.init(); - performance.mark('cog:init:done'); + performance.mark('tiff:init:done'); // 6 images for (const img of tiff.images) await img.getTile(0, 0); diff --git a/packages/core/src/__test__/cog.image.test.ts b/packages/core/src/__test__/cog.image.test.ts index 3f9fead1..e2f4124e 100644 --- a/packages/core/src/__test__/cog.image.test.ts +++ b/packages/core/src/__test__/cog.image.test.ts @@ -5,8 +5,8 @@ import { promises as fs } from 'fs'; import { TestFileSource } from '../__benchmark__/source.file.js'; import { SourceMemory } from '../__benchmark__/source.memory.js'; -import { CogTiff } from '../cog.tiff.js'; import { TiffMimeType } from '../const/tiff.mime.js'; +import { Tiff } from '../tiff.js'; import { ByteSize } from '../util/bytes.js'; // 900913 properties. @@ -17,9 +17,9 @@ function getResolution(zoom: number): number { return InitialResolution / 2 ** zoom; } -describe('CogTiled', () => { +describe('TiffTiled', () => { const cogSourceFile = new TestFileSource(new URL('../../data/rgba8_tiled.tiff', import.meta.url)); - const cog = new CogTiff(cogSourceFile); + const cog = new Tiff(cogSourceFile); beforeEach(() => cog.init()); @@ -87,7 +87,7 @@ describe('Cog.Big', () => { it('should support reading from memory', async () => { const fullSource = new TestFileSource(new URL('../../data/sparse.tiff', import.meta.url)); - const cog = new CogTiff(fullSource); + const cog = new Tiff(fullSource); await cog.init(); const [firstImage] = cog.images; @@ -101,7 +101,7 @@ describe('Cog.Big', () => { it('should read using a memory source', async () => { const bytes = await fs.readFile(new URL('../../data/sparse.tiff', import.meta.url)); const source = new SourceMemory(bytes.buffer); - const cog = new CogTiff(source); + const cog = new Tiff(source); await cog.init(); const [firstImage] = cog.images; @@ -115,7 +115,7 @@ describe('Cog.Big', () => { describe('Cog.Sparse', () => { const cogSourceFile = new TestFileSource(new URL('../../data/sparse.tiff', import.meta.url)); - const cog = new CogTiff(cogSourceFile); + const cog = new Tiff(cogSourceFile); it('should read metadata', async () => { await cog.init(); @@ -164,7 +164,7 @@ describe('Cog.Sparse', () => { describe('CogStrip', () => { const cogSourceFile = new TestFileSource(new URL('../../data/rgba8_strip.tiff', import.meta.url)); - const cog = new CogTiff(cogSourceFile); + const cog = new Tiff(cogSourceFile); beforeEach(() => cog.init()); diff --git a/packages/core/src/__test__/cog.read.test.ts b/packages/core/src/__test__/cog.read.test.ts index f9810f20..5dfc9e66 100644 --- a/packages/core/src/__test__/cog.read.test.ts +++ b/packages/core/src/__test__/cog.read.test.ts @@ -2,12 +2,12 @@ import assert from 'node:assert'; import { describe, it } from 'node:test'; import { TestFileSource } from '../__benchmark__/source.file.js'; -import { CogTiff } from '../cog.tiff.js'; import { TiffMimeType } from '../const/tiff.mime.js'; import { TiffVersion } from '../const/tiff.version.js'; import { TiffTag, TiffTagGeo } from '../index.js'; +import { Tiff } from '../tiff.js'; -function validate(tif: CogTiff): void { +function validate(tif: Tiff): void { assert.equal(tif.images.length, 5); const [firstTif] = tif.images; @@ -20,7 +20,7 @@ describe('CogRead', () => { // TODO this does not load 100% yet // it('should read big endian', async () => { // const source = new TestFileSource(new URL('../../data/big_cog.tiff', import.meta.url)); - // const tiff = new CogTiff(source); + // const tiff = new Tiff(source); // await tiff.init(); @@ -31,7 +31,7 @@ describe('CogRead', () => { it('should read big tiff', async () => { const source = new TestFileSource(new URL('../../data/big_cog.tiff', import.meta.url)); - const tiff = new CogTiff(source); + const tiff = new Tiff(source); await tiff.init(); @@ -42,7 +42,7 @@ describe('CogRead', () => { it('should read tiff', async () => { const source = new TestFileSource(new URL('../../data/cog.tiff', import.meta.url)); - const tiff = new CogTiff(source); + const tiff = new Tiff(source); await tiff.init(); @@ -56,7 +56,7 @@ describe('CogRead', () => { it('should allow multiple init', async () => { const source = new TestFileSource(new URL('../../data/cog.tiff', import.meta.url)); - const tiff = new CogTiff(source); + const tiff = new Tiff(source); assert.equal(tiff.isInitialized, false); await tiff.init(); @@ -70,7 +70,7 @@ describe('CogRead', () => { it('should read ifds from anywhere in the file', async () => { const source = new TestFileSource(new URL('../../data/DEM_BS28_2016_1000_1141.tif', import.meta.url)); - const tiff = await CogTiff.create(source); + const tiff = await Tiff.create(source); assert.equal(tiff.images.length, 1); const im = tiff.images[0]; @@ -88,7 +88,7 @@ describe('CogRead', () => { const source = new TestFileSource( new URL('../../data/east_coast_phase3_2023_AY31_1000_3335.tif.gz', import.meta.url), ); - const tiff = await CogTiff.create(source); + const tiff = await Tiff.create(source); assert.equal(tiff.images.length, 5); const im = tiff.images[0]; diff --git a/packages/core/src/__test__/example.ts b/packages/core/src/__test__/example.ts index 00661af2..8358a465 100644 --- a/packages/core/src/__test__/example.ts +++ b/packages/core/src/__test__/example.ts @@ -1,10 +1,10 @@ import { SourceHttp } from '@chunkd/source-http'; -import { CogTiff } from '../index.js'; +import { Tiff } from '../index.js'; async function main(): Promise { const source = new SourceHttp('https://example.com/cog.tif'); - const tiff = await CogTiff.create(source); + const tiff = await Tiff.create(source); /** Load a specific tile from a specific image */ const tile = await tiff.images[5].getTile(2, 2); diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index a4d21ed2..c87def5b 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -1,5 +1,3 @@ -export { CogTiffImage } from './cog.tiff.image.js'; -export { CogTiff } from './cog.tiff.js'; export { TiffEndian } from './const/tiff.endian.js'; export { TiffCompression, TiffMimeType } from './const/tiff.mime.js'; export { TiffTag, TiffTagGeo, TiffTagGeoValueLookup, TiffTagValueLookup } from './const/tiff.tag.id.js'; @@ -8,5 +6,7 @@ export { TiffVersion } from './const/tiff.version.js'; export { Tag, TagInline, TagLazy, TagOffset } from './read/tiff.tag.js'; export { getTiffTagSize } from './read/tiff.value.reader.js'; export { Source } from './source.js'; +export { TiffImage } from './tiff.image.js'; +export { Tiff } from './tiff.js'; export { toHex } from './util/util.hex.js'; export type { BoundingBox, Point, Size, Vector } from './vector.js'; diff --git a/packages/core/src/read/tiff.gdal.ts b/packages/core/src/read/tiff.gdal.ts index 64f04dfb..64cf889a 100644 --- a/packages/core/src/read/tiff.gdal.ts +++ b/packages/core/src/read/tiff.gdal.ts @@ -22,7 +22,7 @@ export enum GhostOptionTileLeader { * GDAL has made a ghost set of options for Tiff files * this class represents the optimizations that GDAL has applied */ -export class CogTifGhostOptions { +export class TiffGhostOptions { options: Map = new Map(); /** diff --git a/packages/core/src/read/tiff.tag.factory.ts b/packages/core/src/read/tiff.tag.factory.ts index 1d7694f9..578755eb 100644 --- a/packages/core/src/read/tiff.tag.factory.ts +++ b/packages/core/src/read/tiff.tag.factory.ts @@ -1,6 +1,6 @@ -import { CogTiff } from '../cog.tiff.js'; import { TiffTag } from '../const/tiff.tag.id.js'; import { TiffTagValueType } from '../const/tiff.tag.value.js'; +import { Tiff } from '../tiff.js'; import { getUint, getUint64 } from '../util/bytes.js'; import { DataViewOffset, hasBytes } from './data.view.offset.js'; import { Tag, TagLazy, TagOffset } from './tiff.tag.js'; @@ -54,7 +54,7 @@ function readTagValue( } } -function readValue(tiff: CogTiff, bytes: DataView, offset: number, type: TiffTagValueType, count: number): T { +function readValue(tiff: Tiff, bytes: DataView, offset: number, type: TiffTagValueType, count: number): T { const typeSize = getTiffTagSize(type); const dataLength = count * typeSize; @@ -77,7 +77,7 @@ function readValue(tiff: CogTiff, bytes: DataView, offset: number, type: Tiff } /** - * Determine if all the data for the tiff tag is loaded in and use that to create the specific CogTiffTag + * Determine if all the data for the tiff tag is loaded in and use that to create the specific TiffTag * * @see {@link Tag} * @@ -85,7 +85,7 @@ function readValue(tiff: CogTiff, bytes: DataView, offset: number, type: Tiff * @param view Bytes to read from * @param offset Offset in the dataview to read a tag */ -export function createTag(tiff: CogTiff, view: DataViewOffset, offset: number): Tag { +export function createTag(tiff: Tiff, view: DataViewOffset, offset: number): Tag { const tagId = view.getUint16(offset + 0, tiff.isLittleEndian); const dataType = view.getUint16(offset + 2, tiff.isLittleEndian) as TiffTagValueType; @@ -131,7 +131,7 @@ export function createTag(tiff: CogTiff, view: DataViewOffset, offset: number): } /** Fetch the value from a {@link TagLazy} tag */ -export async function fetchLazy(tag: TagLazy, tiff: CogTiff): Promise { +export async function fetchLazy(tag: TagLazy, tiff: Tiff): Promise { if (tag.value != null) return tag.value; const dataTypeSize = getTiffTagSize(tag.dataType); const dataLength = dataTypeSize * tag.count; @@ -144,7 +144,7 @@ export async function fetchLazy(tag: TagLazy, tiff: CogTiff): Promise { /** * Fetch all the values from a {@link TagOffset} */ -export async function fetchAllOffsets(tiff: CogTiff, tag: TagOffset): Promise { +export async function fetchAllOffsets(tiff: Tiff, tag: TagOffset): Promise { const dataTypeSize = getTiffTagSize(tag.dataType); if (tag.view == null) { @@ -166,7 +166,7 @@ export function setBytes(tag: TagOffset, view: DataViewOffset): void { } /** Partially fetch the values of a {@link TagOffset} and return the value for the offset */ -export async function getValueAt(tiff: CogTiff, tag: TagOffset, index: number): Promise { +export async function getValueAt(tiff: Tiff, tag: TagOffset, index: number): Promise { if (index > tag.count || index < 0) throw new Error('TagOffset: out of bounds :' + index); if (tag.value[index] != null) return tag.value[index]; const dataTypeSize = getTiffTagSize(tag.dataType); diff --git a/packages/core/src/cog.tiff.image.ts b/packages/core/src/tiff.image.ts similarity index 96% rename from packages/core/src/cog.tiff.image.ts rename to packages/core/src/tiff.image.ts index 867b61d9..d2f76ed5 100644 --- a/packages/core/src/cog.tiff.image.ts +++ b/packages/core/src/tiff.image.ts @@ -1,8 +1,8 @@ -import { CogTiff } from './cog.tiff.js'; import { TiffCompression, TiffMimeType } from './const/tiff.mime.js'; import { SubFileType, TiffTag, TiffTagGeo, TiffTagGeoType, TiffTagType } from './const/tiff.tag.id.js'; import { fetchAllOffsets, fetchLazy, getValueAt } from './read/tiff.tag.factory.js'; import { Tag, TagInline, TagOffset } from './read/tiff.tag.js'; +import { Tiff } from './tiff.js'; import { getUint } from './util/bytes.js'; import { BoundingBox, Size } from './vector.js'; @@ -12,7 +12,7 @@ export const InvalidProjectionCode = 32767; /** * Number of tiles used inside this image */ -export interface CogTiffImageTiledCount { +export interface TiffImageTileCount { /** Number of tiles on the x axis */ x: number; /** Number of tiles on the y axis */ @@ -38,14 +38,14 @@ export const ImportantTags = new Set([ /** * Size of a individual tile */ -export interface CogTiffImageTileSize { +export interface TiffImageTileSize { /** Tile width (pixels) */ width: number; /** Tile height (pixels) */ height: number; } -export class CogTiffImage { +export class TiffImage { /** * Id of the tif image, generally the image index inside the tif * where 0 is the root image, and every sub image is +1 @@ -54,7 +54,7 @@ export class CogTiffImage { */ id: number; /** Reference to the TIFF that owns this image */ - tiff: CogTiff; + tiff: Tiff; /** Has loadGeoTiffTags been called */ isGeoTagsLoaded = false; /** Sub tags stored in TiffTag.GeoKeyDirectory */ @@ -62,7 +62,7 @@ export class CogTiffImage { /** All IFD tags that have been read for the image */ tags: Map; - constructor(tiff: CogTiff, id: number, tags: Map) { + constructor(tiff: Tiff, id: number, tags: Map) { this.tiff = tiff; this.id = id; this.tags = tags; @@ -98,8 +98,8 @@ export class CogTiffImage { /** * Get the value of a TiffTag if it has been loaded, null otherwise. * - * If the value is not loaded use {@link CogTiffImage.fetch} to load the value - * Or use {@link CogTiffImage.has} to check if the tag exists + * If the value is not loaded use {@link TiffImage.fetch} to load the value + * Or use {@link TiffImage.has} to check if the tag exists * * * @returns value if loaded, null otherwise @@ -356,7 +356,7 @@ export class CogTiffImage { /** * Get size of individual tiles */ - get tileSize(): CogTiffImageTileSize { + get tileSize(): TiffImageTileSize { const width = this.value(TiffTag.TileWidth); const height = this.value(TiffTag.TileHeight); if (width == null || height == null) throw new Error('Tiff is not tiled'); @@ -366,7 +366,7 @@ export class CogTiffImage { /** * Number of tiles used to create this image */ - get tileCount(): CogTiffImageTiledCount { + get tileCount(): TiffImageTileCount { const size = this.size; const tileSize = this.tileSize; const x = Math.ceil(size.width / tileSize.width); @@ -532,7 +532,7 @@ export class CogTiffImage { const leaderBytes = this.tiff.options?.tileLeaderByteSize; if (leaderBytes) { const offset = await getOffset(this.tiff, this.tileOffset, index); - // Sparse COG no data found + // Sparse tiff no data found if (offset === 0) return { offset: 0, imageSize: 0 }; // This fetch will generally load in the bytes needed for the image too @@ -551,11 +551,7 @@ export class CogTiffImage { } } -function getOffset( - tiff: CogTiff, - x: TagOffset | TagInline, - index: number, -): number | Promise { +function getOffset(tiff: Tiff, x: TagOffset | TagInline, index: number): number | Promise { if (index > x.count || index < 0) throw new Error('TagIndex: out of bounds ' + x.id + ' @ ' + index); if (x.type === 'inline') { if (x.count > 1) return (x.value as number[])[index] as number; diff --git a/packages/core/src/cog.tiff.ts b/packages/core/src/tiff.ts similarity index 89% rename from packages/core/src/cog.tiff.ts rename to packages/core/src/tiff.ts index 18c67eae..0d84ead6 100644 --- a/packages/core/src/cog.tiff.ts +++ b/packages/core/src/tiff.ts @@ -1,17 +1,17 @@ -import { CogTiffImage } from './cog.tiff.image.js'; import { TiffEndian } from './const/tiff.endian.js'; import { TiffTag } from './const/tiff.tag.id.js'; import { TiffVersion } from './const/tiff.version.js'; import { Tag } from './index.js'; import { DataViewOffset, hasBytes } from './read/data.view.offset.js'; -import { CogTifGhostOptions } from './read/tiff.gdal.js'; +import { TiffGhostOptions } from './read/tiff.gdal.js'; import { TagTiffBigConfig, TagTiffConfig, TiffIfdConfig } from './read/tiff.ifd.config.js'; import { createTag } from './read/tiff.tag.factory.js'; import { Source } from './source.js'; +import { TiffImage } from './tiff.image.js'; import { getUint } from './util/bytes.js'; import { toHex } from './util/util.hex.js'; -export class CogTiff { +export class Tiff { /** Read 16KB blocks at a time */ defaultReadSize = 16 * 1024; /** Where this cog is fetching its data from */ @@ -19,9 +19,9 @@ export class CogTiff { /** Big or small Tiff */ version = TiffVersion.Tiff; /** List of images, o is the base image */ - images: CogTiffImage[] = []; + images: TiffImage[] = []; /** Ghost header options */ - options?: CogTifGhostOptions; + options?: TiffGhostOptions; /** Configuration for the size of the IFD */ ifdConfig: TiffIfdConfig = TagTiffConfig; /** Is the tiff being read is little Endian */ @@ -29,20 +29,20 @@ export class CogTiff { /** Has init() been called */ isInitialized = false; - private _initPromise?: Promise; + private _initPromise?: Promise; constructor(source: Source) { this.source = source; } - /** Create a COG and initialize it by reading the COG headers */ - static create(source: Source): Promise { - return new CogTiff(source).init(); + /** Create a tiff and initialize it by reading the tiff headers */ + static create(source: Source): Promise { + return new Tiff(source).init(); } /** - * Initialize the COG loading in the header and all image headers + * Initialize the tiff loading in the header and all image headers */ - init(): Promise { + init(): Promise { if (this._initPromise) return this._initPromise; this._initPromise = this.readHeader(); return this._initPromise; @@ -53,7 +53,7 @@ export class CogTiff { * * @param resolution resolution to find */ - getImageByResolution(resolution: number): CogTiffImage { + getImageByResolution(resolution: number): TiffImage { const firstImage = this.images[0]; const firstImageSize = firstImage.size; const [refX] = firstImage.resolution; @@ -74,7 +74,7 @@ export class CogTiff { } /** Read the Starting header and all Image headers from the source */ - private async readHeader(): Promise { + private async readHeader(): Promise { if (this.isInitialized) return this; const bytes = new DataView(await this.source.fetch(0, this.defaultReadSize)) as DataViewOffset; bytes.sourceOffset = 0; @@ -109,7 +109,7 @@ export class CogTiff { const ghostSize = nextOffsetIfd - offset; // GDAL now stores metadata between the IFD inside a ghost storage area if (ghostSize > 0 && ghostSize < 16 * 1024) { - this.options = new CogTifGhostOptions(); + this.options = new TiffGhostOptions(); this.options.process(bytes, offset, ghostSize); } @@ -159,7 +159,7 @@ export class CogTiff { tags.set(tag.id, tag); } - this.images.push(new CogTiffImage(this, this.images.length, tags)); + this.images.push(new TiffImage(this, this.images.length, tags)); return getUint(view, startOffset + tagCount * ifdSize, this.ifdConfig.pointer, this.isLittleEndian); } } diff --git a/packages/examples/src/browser/example.single.tile.ts b/packages/examples/src/browser/example.single.tile.ts index d8daf4c3..dc88cd98 100644 --- a/packages/examples/src/browser/example.single.tile.ts +++ b/packages/examples/src/browser/example.single.tile.ts @@ -1,7 +1,7 @@ -import { CogTiff } from '@cogeotiff/core'; +import { Tiff } from '@cogeotiff/core'; /** Loads a single tile from a COG and renders it as a element */ -export async function loadSingleTile(tiff: CogTiff): Promise { +export async function loadSingleTile(tiff: Tiff): Promise { const startTime = performance.now(); const img = tiff.images[tiff.images.length - 1]; const tile = await img.getTile(0, 0); diff --git a/packages/examples/src/browser/index.ts b/packages/examples/src/browser/index.ts index bbeb4b13..00ca45cd 100644 --- a/packages/examples/src/browser/index.ts +++ b/packages/examples/src/browser/index.ts @@ -1,7 +1,7 @@ import { SourceCache, SourceChunk } from '@chunkd/middleware'; import { SourceCallback, SourceMiddleware, SourceRequest, SourceView } from '@chunkd/source'; import { SourceHttp } from '@chunkd/source-http'; -import { CogTiff } from '@cogeotiff/core'; +import { Tiff } from '@cogeotiff/core'; import { loadSingleTile } from './example.single.tile'; @@ -24,7 +24,7 @@ document.addEventListener('DOMContentLoaded', async () => { cache, fetchLog, ]); - const tiff = await CogTiff.create(tiffSource); + const tiff = await Tiff.create(tiffSource); const mainEl = document.createElement('div'); console.log('Loaded: ', tiff.source.url, '\nImages:', tiff.images.length);