Skip to content

Commit 265e03a

Browse files
author
Andrew Jacombs
authored
fix: increase PixelPadding to 200 (#2723)
* fix: increase PixelPadding to 200 * fix: make tests pass * fix: remove stray console.log
1 parent b6dafa1 commit 265e03a

File tree

2 files changed

+21
-31
lines changed

2 files changed

+21
-31
lines changed

packages/cli/src/cog/__tests__/cutline.test.ts

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -249,21 +249,17 @@ o.spec('cutline', () => {
249249
8,
250250
);
251251

252-
o(round(cutline.clipPoly, 4)).deepEquals([
253-
[
254-
[
255-
[19468580.0838, -4993280.8853],
256-
[19471098.3762, -4993280.8853],
257-
[19471932.5568, -4992600.0637],
258-
[19472092.0139, -4992352.6942],
259-
[19472092.0139, -4987203.6846],
260-
[19471983.8261, -4987203.6846],
261-
[19470978.4379, -4989417.4454],
262-
[19468800.9775, -4991497.5405],
263-
[19468580.0838, -4991792.2037],
264-
[19468580.0838, -4993280.8853],
265-
],
266-
],
252+
o(round(cutline.clipPoly, 4)[0][0]).deepEquals([
253+
[19468576.3516, -4993284.6176],
254+
[19471093.8032, -4993284.6176],
255+
[19471932.5568, -4992600.0637],
256+
[19472095.7462, -4992346.9043],
257+
[19472095.7462, -4987199.9524],
258+
[19471985.5211, -4987199.9524],
259+
[19470978.4379, -4989417.4454],
260+
[19468800.9775, -4991497.5405],
261+
[19468576.3516, -4991797.1824],
262+
[19468576.3516, -4993284.6176],
267263
]);
268264

269265
o(covering.map((c) => c.name)).deepEquals([
@@ -297,17 +293,13 @@ o.spec('cutline', () => {
297293
8,
298294
);
299295

300-
o(round(cutline.clipPoly, 4)).deepEquals([
301-
[
302-
[
303-
[19470015.7313, -4990337.1045],
304-
[19472091.9684, -4990337.1045],
305-
[19472091.9684, -4987203.6846],
306-
[19471983.8261, -4987203.6846],
307-
[19470978.4379, -4989417.4454],
308-
[19470015.7313, -4990337.1045],
309-
],
310-
],
296+
o(round(cutline.clipPoly, 4)[0][0]).deepEquals([
297+
[19470011.8243, -4990340.8368],
298+
[19472095.7007, -4990340.8368],
299+
[19472095.7007, -4987199.9524],
300+
[19471985.5211, -4987199.9524],
301+
[19470978.4379, -4989417.4454],
302+
[19470011.8243, -4990340.8368],
311303
]);
312304

313305
o(covering.map((c) => c.name)).deepEquals([

packages/cli/src/cog/cutline.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { AlignedLevel, CoveringFraction } from './constants.js';
1414
import { CogJob, FeatureCollectionWithCrs, SourceMetadata } from './types.js';
1515

1616
/** Padding to always apply to image boundies */
17-
const PixelPadding = 100;
17+
const PixelPadding = 200;
1818

1919
/** fraction to scale source imagery to avoid degenerate edges */
2020
const SourceSmoothScale = 1 + 1e-8;
@@ -296,11 +296,9 @@ export class Cutline {
296296
*/
297297
private padBounds(bounds: Bounds, resZoom: number): Bounds {
298298
const px = this.tileMatrix.pixelScale(resZoom);
299-
const pixelPadding = px > 1 ? PixelPadding * 2 : PixelPadding; //Double the padding to remove the white edges for low resolution imagery.
300-
301299
// Ensure cutline blend does not interferre with non-costal edges
302-
const widthScale = (bounds.width + px * (pixelPadding + this.blend) * 2) / bounds.width;
303-
const heightScale = (bounds.height + px * (pixelPadding + this.blend) * 2) / bounds.height;
300+
const widthScale = (bounds.width + px * (PixelPadding + this.blend) * 2) / bounds.width;
301+
const heightScale = (bounds.height + px * (PixelPadding + this.blend) * 2) / bounds.height;
304302
return bounds.scaleFromCenter(widthScale, heightScale);
305303
}
306304
}

0 commit comments

Comments
 (0)