Skip to content

Commit

Permalink
added more logging, added eslint and prettier to dev deps
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielJDufour committed Dec 22, 2023
1 parent 2b2e458 commit a3aa819
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
13 changes: 9 additions & 4 deletions geowarp.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ const geowarp = function geowarp({
if (debug_level >= 1) console.log("[geowarp] starting");
const start_time = debug_level >= 1 ? performance.now() : 0;

if (isNaN(out_height)) throw new Error("[geowarp] out_height is NaN");
if (isNaN(out_width)) throw new Error("[geowarp] out_width is NaN");

// track pending promises without the memory overhead
// of holding all the promises in memory
let pending = 0;
Expand Down Expand Up @@ -592,8 +595,8 @@ const geowarp = function geowarp({
skip_no_data_strategy === "any"
? px => px.includes(undefined) || px.includes(in_no_data)
: skip_no_data_strategy === "all"
? px => px.every(n => n === in_no_data)
: () => false;
? px => px.every(n => n === in_no_data)
: () => false;

if (method === "vectorize") {
// const [cfwd, clear_forward_cache] = cacheFunction(fwd);
Expand All @@ -605,14 +608,14 @@ const geowarp = function geowarp({
out_sample_height_in_srs ??= (top - bottom) / out_height_in_samples;
if (in_pixel_height < out_sample_height_in_srs) {
if (debug_level >= 1) {
console.warn(`normalized height of sample area of ${out_sample_height_in_srs} is larger than input pixel height of ${in_pixel_height}`);
console.warn(`[geowarp] normalized height of sample area of ${out_sample_height_in_srs} is larger than input pixel height of ${in_pixel_height}`);
}
}

out_sample_width_in_srs ??= (right - left) / out_width;
if (in_pixel_width < out_sample_width_in_srs) {
if (debug_level >= 1) {
console.warn(`normalized width of sample area of ${out_sample_width_in_srs} is larger than input pixel width of ${in_pixel_width}`);
console.warn(`[geowarp] normalized width of sample area of ${out_sample_width_in_srs} is larger than input pixel width of ${in_pixel_width}`);
}
}

Expand All @@ -625,9 +628,11 @@ const geowarp = function geowarp({
if (!cutline || booleanIntersects(in_bbox, cutline_bbox_in_srs)) {
// update bounding box we sample from based on extent of cutline
[left, bottom, right, top] = cutline && cutline_strategy !== "inside" ? intersect(out_bbox_in_srs, cutline_bbox_in_srs) : out_bbox_in_srs;
if (debug_level >= 1) console.log("[geowarp] [left, bottom, right, top]:", [left, bottom, right, top]);

if ((left < in_xmax && bottom < in_ymax && right > in_xmin) || top < in_ymin) {
const out_bbox_in_input_image_coords = reprojectBoundingBox(out_bbox_in_srs, in_srs_pt_to_in_img_pt);
if (debug_level >= 1) console.log("[geowarp] out_bbox_in_input_image_coords:", out_bbox_in_input_image_coords);

// need to double check intersection in image space in case of rotation/skew
if (booleanIntersects(out_bbox_in_input_image_coords, [0, 0, in_width, in_height])) {
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
],
"scripts": {
"clean": "rm -fr ./test-data/*.png && rm -fr ./test-output/*.png",
"format": "npm run lint -- --fix && npx prettier --arrow-parens=avoid --print-width=160 --trailing-comma=none --write *.js *.ts",
"lint": "npx eslint *.js",
"format": "npm run lint -- --fix && prettier --arrow-parens=avoid --print-width=160 --trailing-comma=none --write *.js *.ts",
"lint": "eslint *.js",
"perf": "TEST_NAME=*perf* LOG_SKIP=false TEST_TIMED=true node test.js",
"prepublish": "npm run lint",
"setup": "cd ./test-data && ./setup.sh",
Expand Down Expand Up @@ -47,6 +47,7 @@
"devDependencies": {
"@mapbox/tilebelt": "^1.0.2",
"@types/node": "^20.4.4",
"eslint": "^8.56.0",
"fast-counter": "^0.1.0",
"find-and-read": "^1.2.0",
"flug": "^2.6.0",
Expand All @@ -55,6 +56,7 @@
"geotiff-precise-bbox": "^0.2.0",
"geotiff-read-bbox": "^2.0.2",
"pngjs": "^7.0.0",
"prettier": "^3.1.1",
"proj4-fully-loaded": "^0.2.0",
"typescript": "^5.1.6",
"write-image": "^0.2.0"
Expand Down

0 comments on commit a3aa819

Please sign in to comment.