Skip to content

Commit 544e6bf

Browse files
Merge branch 'master' into 241-xml-utils
2 parents 9ad2625 + e00372e commit 544e6bf

File tree

7 files changed

+6419
-5056
lines changed

7 files changed

+6419
-5056
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
name: Node.js CI
22

33
on:
4-
[ push ]
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
58

69
jobs:
710
ci:
@@ -25,4 +28,4 @@ jobs:
2528
fields: repo,message,commit,author,action,eventName,ref,workflow,job,took
2629
env:
2730
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
28-
if: always()
31+
if: ${{ github.event_name != 'pull_request'}}

package-lock.json

Lines changed: 6353 additions & 5045 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "geotiff",
3-
"version": "1.0.6",
3+
"version": "1.0.7",
44
"description": "GeoTIFF image decoding in JavaScript",
55
"repository": "https://github.com/geotiffjs/geotiff.js",
66
"keywords": [
@@ -22,12 +22,12 @@
2222
"browsers": "defaults"
2323
},
2424
"dependencies": {
25-
"@petamoriken/float16": "^1.0.7",
25+
"@petamoriken/float16": "^3.4.7",
2626
"lerc": "^3.0.0",
2727
"lru-cache": "^6.0.0",
2828
"pako": "^2.0.4",
2929
"parse-headers": "^2.0.2",
30-
"threads": "^1.3.1",
30+
"threads": "^1.7.0",
3131
"xml-utils": "^1.0.2"
3232
},
3333
"devDependencies": {
@@ -54,7 +54,7 @@
5454
"parcel-bundler": "^1.12.4",
5555
"parcel-plugin-bundle-visualiser": "^1.2.0",
5656
"rimraf": "^3.0.2",
57-
"send-ranges": "^3.0.0",
57+
"send-ranges": "^4.0.0",
5858
"serve-static": "^1.14.1"
5959
},
6060
"scripts": {
@@ -76,7 +76,8 @@
7676
"fs": false,
7777
"http": false,
7878
"https": false,
79-
"url": false
79+
"url": false,
80+
"./src/txml": "./src/browser/txml"
8081
},
8182
"sideEffects": false,
8283
"contributors": [

src/browser/txml.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { parse } from 'txml/dist/txml';

src/geotiffimage.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -413,16 +413,18 @@ class GeoTIFFImage {
413413
height, resampleMethod, signal) {
414414
const tileWidth = this.getTileWidth();
415415
const tileHeight = this.getTileHeight();
416+
const imageWidth = this.getWidth();
417+
const imageHeight = this.getHeight();
416418

417419
const minXTile = Math.max(Math.floor(imageWindow[0] / tileWidth), 0);
418420
const maxXTile = Math.min(
419421
Math.ceil(imageWindow[2] / tileWidth),
420-
Math.ceil(this.getWidth() / this.getTileWidth()),
422+
Math.ceil(imageWidth / tileWidth),
421423
);
422424
const minYTile = Math.max(Math.floor(imageWindow[1] / tileHeight), 0);
423425
const maxYTile = Math.min(
424426
Math.ceil(imageWindow[3] / tileHeight),
425-
Math.ceil(this.getHeight() / this.getTileHeight()),
427+
Math.ceil(imageHeight / tileHeight),
426428
);
427429
const windowWidth = imageWindow[2] - imageWindow[0];
428430

@@ -462,8 +464,8 @@ class GeoTIFFImage {
462464
const lastCol = (tile.x + 1) * tileWidth;
463465
const reader = sampleReaders[si];
464466

465-
const ymax = Math.min(blockHeight, blockHeight - (lastLine - imageWindow[3]));
466-
const xmax = Math.min(tileWidth, tileWidth - (lastCol - imageWindow[2]));
467+
const ymax = Math.min(blockHeight, blockHeight - (lastLine - imageWindow[3]), imageHeight - firstLine);
468+
const xmax = Math.min(tileWidth, tileWidth - (lastCol - imageWindow[2]), imageWidth - firstCol);
467469

468470
for (let y = Math.max(0, imageWindow[1] - firstLine); y < ymax; ++y) {
469471
for (let x = Math.max(0, imageWindow[0] - firstCol); x < xmax; ++x) {

src/txml.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { parse } from 'txml';

test/geotiff.spec.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,53 @@ describe('COG tests', async () => {
549549
expect(ghostValues).to.be.null;
550550
});
551551
});
552+
553+
describe('fillValue', async () => {
554+
it('should fill pixels outside the image area (to the left and above)', async () => {
555+
const tiff = await GeoTIFF.fromSource(createSource('cog.tiff'));
556+
const image = await tiff.getImage(0);
557+
const data = await image.readRasters({ window: [-1, -1, 0, 0], fillValue: 42 });
558+
expect(data).to.have.lengthOf(15);
559+
for (const band of data) {
560+
expect(band).to.have.lengthOf(1);
561+
expect(band).to.deep.equal(new Uint16Array([42]));
562+
}
563+
});
564+
565+
it('should fill pixels outside the image area (to the right and below)', async () => {
566+
const tiff = await GeoTIFF.fromSource(createSource('cog.tiff'));
567+
const image = await tiff.getImage(0);
568+
const data = await image.readRasters({ window: [512, 512, 513, 513], fillValue: 42 });
569+
expect(data).to.have.lengthOf(15);
570+
for (const band of data) {
571+
expect(band).to.have.lengthOf(1);
572+
expect(band).to.deep.equal(new Uint16Array([42]));
573+
}
574+
});
575+
576+
it('should fill areas in overview tiles outside the image extent (left)', async () => {
577+
const tiff = await GeoTIFF.fromSource(createSource('cog.tiff'));
578+
const image = await tiff.getImage(1);
579+
const data = await image.readRasters({ window: [269, 0, 270, 1], fillValue: 42 });
580+
expect(data).to.have.lengthOf(15);
581+
for (const band of data) {
582+
expect(band).to.have.lengthOf(1);
583+
expect(band).to.deep.equal(new Uint16Array([42]));
584+
}
585+
});
586+
587+
it('should fill areas in overview tiles outside the image extent (below)', async () => {
588+
const tiff = await GeoTIFF.fromSource(createSource('cog.tiff'));
589+
const image = await tiff.getImage(1);
590+
const data = await image.readRasters({ window: [0, 224, 1, 225], fillValue: 42 });
591+
expect(data).to.have.lengthOf(15);
592+
for (const band of data) {
593+
expect(band).to.have.lengthOf(1);
594+
expect(band).to.deep.equal(new Uint16Array([42]));
595+
}
596+
});
597+
});
598+
552599
describe("64 bit tests", () => {
553600
it("DataView64 uint64 tests", () => {
554601
const littleEndianBytes = new Uint8Array([

0 commit comments

Comments
 (0)