Skip to content

Commit a4b3fa2

Browse files
committed
updated typing
1 parent 73f3f60 commit a4b3fa2

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

geowarp.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export default function geowarp(options: {
2929
method?: string | ((arg: { values: number[] }) => number) | undefined,
3030
round?: boolean | undefined,
3131
row_start?: number | undefined,
32+
row_end?: number | undefined,
3233
theoretical_min?: number | undefined,
3334
theoretical_max?: number | undefined,
3435
expr?: ((arg: { pixel: number[] }) => number[]) | undefined,

geowarp.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ const geowarp = function geowarp({
108108
method = "median",
109109
read_bands = undefined, // which bands to read, used in conjunction with expr
110110
row_start = 0, // which row in output data to start writing at
111+
row_end,
111112
expr = undefined, // band expression function
112113
round = false, // whether to round output
113114
theoretical_min, // minimum theoretical value (e.g., 0 for unsigned integer arrays)
@@ -289,9 +290,12 @@ const geowarp = function geowarp({
289290
});
290291
};
291292

293+
row_end ??= out_height;
294+
292295
if (method === "near") {
293296
const select = xdim.prepareSelect({ data: in_data, layout: in_layout, sizes: in_sizes });
294-
for (let r = row_start; r < out_height; r++) {
297+
const rmax = Math.min(row_end, out_height);
298+
for (let r = row_start; r < rmax; r++) {
295299
const y = out_ymax - out_pixel_height * r;
296300
const segments = segments_by_row[r];
297301
for (let iseg = 0; iseg < segments.length; iseg++) {
@@ -327,7 +331,8 @@ const geowarp = function geowarp({
327331
}
328332
} else if (method === "bilinear") {
329333
const select = xdim.prepareSelect({ data: in_data, layout: in_layout, sizes: in_sizes });
330-
for (let r = row_start; r < out_height; r++) {
334+
const rmax = Math.min(row_end, out_height);
335+
for (let r = row_start; r < rmax; r++) {
331336
const y = out_ymax - out_pixel_height * r;
332337
const segments = segments_by_row[r];
333338
for (let iseg = 0; iseg < segments.length; iseg++) {
@@ -407,7 +412,8 @@ const geowarp = function geowarp({
407412
} else {
408413
let top, left, bottom, right;
409414
bottom = out_ymax;
410-
for (let r = row_start; r < out_height; r++) {
415+
const rmax = Math.min(row_end, out_height);
416+
for (let r = row_start; r < rmax; r++) {
411417
top = bottom;
412418
bottom = top - out_pixel_height;
413419
const segments = segments_by_row[r];

0 commit comments

Comments
 (0)