Skip to content
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

feat(lambda-xyz): Serve local images with set priority #755

Merged
merged 2 commits into from
Jun 10, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion packages/lambda-xyz/src/cli/tile.set.local.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { CogSourceAwsS3 } from '@cogeotiff/source-aws';
import { CogSourceFile } from '@cogeotiff/source-file';
import { TileSet } from '../tile.set';
import { Epsg } from '@basemaps/geo';
import { promises as fsPromises } from 'fs';
import { join } from 'path';

function getTiffs(fs: FileProcessor, tiffList: string[]): CogSource[] {
if (fs instanceof FileOperatorS3) {
Expand Down Expand Up @@ -43,7 +45,20 @@ export class TileSetLocal extends TileSet {

const fileList = isTiff(this.filePath) ? [this.filePath] : await tiffFs.list(this.filePath);
const files = fileList.filter(isTiff);
if (files.length == 0) throw new Error(`No tiff files found in ${this.filePath}`);
if (files.length == 0 && !FileOperator.isS3(this.filePath)) {
for (const dir of fileList.sort()) {
const st = await fsPromises.stat(dir);
if (st.isDirectory()) {
for (const file of await fsPromises.readdir(dir)) {
const filePath = join(dir, file);
if (isTiff(filePath)) files.push(filePath);
}
}
}
}
if (files.length == 0) {
throw new Error(`No tiff files found in ${this.filePath}`);
}

this.tiffs = getTiffs(tiffFs, files).map((c) => new CogTiff(c));

Expand Down