Skip to content

Commit

Permalink
feat(cli): remove one cog covering logic as its not used (#2592)
Browse files Browse the repository at this point in the history
  • Loading branch information
blacha committed Nov 16, 2022
1 parent 7b251d5 commit a8e39a2
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 32 deletions.
2 changes: 1 addition & 1 deletion packages/cli/src/cli/cogify/action.cog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export class CommandCogCreate extends CommandLineAction {
} else {
logger.warn('CutLine:Skip');
}
const cutline = new Cutline(job.tileMatrix, cutlineJson, job.output.cutline?.blend, job.output.oneCogCovering);
const cutline = new Cutline(job.tileMatrix, cutlineJson, job.output.cutline?.blend);

const tmpVrtPath = await CogVrt.buildVrt(tiffFolder, job, cutline, tiffName, logger);

Expand Down
19 changes: 1 addition & 18 deletions packages/cli/src/cog/__tests__/cutline.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,25 +142,8 @@ o.spec('cutline', () => {
o((cutline as any).srcPoly.length).equals(1);
});

o.spec('optmize', async () => {
o.spec('optimize', async () => {
const bounds = SourceTiffTestHelper.tiffNztmBounds();
o('one-cog', () => {
const cutline = new Cutline(Nztm2000Tms, undefined, 0, true);
const covering = cutline.optimizeCovering({
projection: EpsgCode.Nztm2000,
bounds,
resZoom: 14,
} as SourceMetadata);

o(covering.length).equals(1);
o(covering[0]).deepEquals({
x: 274000,
y: 3087000,
width: 3053000,
height: 4086000,
name: '0-0-0',
});
});

o('full-extent 3857', () => {
const cutline = new Cutline(GoogleTms);
Expand Down
16 changes: 4 additions & 12 deletions packages/cli/src/cog/cutline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ export class Cutline {
tileMatrix: TileMatrixSet; // convience to targetPtms.tms
/** How much blending to apply at the clip line boundary */
blend: number;
/** For just one cog to cover the imagery */
oneCogCovering: boolean;

/** the polygon outlining a area covered by the source imagery and clip polygon */
srcPoly: MultiPolygon = [];

Expand All @@ -75,10 +74,9 @@ export class Cutline {
* @param blend How much blending to consider when working out boundaries.
*/
constructor(tileMatrix: TileMatrixSet, clipPoly?: FeatureCollection, blend = 0, oneCogCovering = false) {
constructor(tileMatrix: TileMatrixSet, clipPoly?: FeatureCollection, blend = 0) {
this.tileMatrix = tileMatrix;
this.blend = blend;
this.oneCogCovering = oneCogCovering;
if (clipPoly == null) {
this.clipPoly = [];
return;
Expand Down Expand Up @@ -115,7 +113,6 @@ export class Cutline {
* @returns names of source files required to render Cog
*/
filterSourcesForName(name: string, job: CogJob): string[] {
if (this.oneCogCovering) return job.source.files.map(({ name }) => name);
const tile = TileMatrixSet.nameToTile(name);
const sourceCode = Projection.get(job.source.epsg);
const targetCode = Projection.get(this.tileMatrix);
Expand Down Expand Up @@ -156,12 +153,7 @@ export class Cutline {
* @param sourceMetadata contains images bounds and projection info
*/
optimizeCovering(sourceMetadata: SourceMetadata, alignedLevel: number = AlignedLevel): NamedBounds[] {
if (this.oneCogCovering) {
const extent = this.tileMatrix.extent.toJson();
return [{ ...extent, name: '0-0-0' }];
}
this.findCovering(sourceMetadata);

const { resZoom } = sourceMetadata;

// Fix the cog Minimum Zoom by the aligned level
Expand Down Expand Up @@ -205,9 +197,9 @@ export class Cutline {
/**
* Merge child nodes that have at least a covering fraction
* @param tile the tile to descend
* @param srcArea the aread of interest
* @param srcArea the area of interest
* @param minZ Only produce tiles for zoom levels at least `minZ` and no sibling tiles
* greater than `minZ +2`
* greater than `minZ + 4`
* @param coveringFraction merge tiles that cover at least this fraction
* @return the tiles and fraction covered of the tile by this srcArea
*/
Expand Down
1 change: 0 additions & 1 deletion packages/cli/src/cog/job.factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ export const CogJobFactory = {
ctx.tileMatrix,
ctx.cutline && (await Cutline.loadCutline(ctx.cutline.href)),
ctx.cutline?.blend,
ctx.oneCogCovering,
);

const builder = new CogBuilder(ctx.tileMatrix, maxConcurrency, logger, ctx.override?.projection);
Expand Down

0 comments on commit a8e39a2

Please sign in to comment.