Skip to content

Commit

Permalink
cleaned up a little code in get.module.js
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielJDufour committed Jun 10, 2023
1 parent 3bc2480 commit fab69e3
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/get/get.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,12 @@ const get = (georaster, geom, flat) => {

// use a utility function that converts from the lat/long coordinate
// space to the image coordinate space
// // left, top, right, bottom
const bbox = utils.convertCrsBboxToImageBbox(georaster, geometry);
const bboxLeft = bbox.xmin;
const bboxTop = bbox.ymin;
const bboxRight = bbox.xmax;
const bboxBottom = bbox.ymax;

cropTop = Math.max(bboxTop, 0);
cropLeft = Math.max(bboxLeft, 0);
cropRight = Math.min(bboxRight, georaster.width);
cropBottom = Math.min(bboxBottom, georaster.height);
cropTop = Math.max(bbox.ymin, 0);
cropLeft = Math.max(bbox.xmin, 0);
cropRight = Math.min(bbox.xmax, georaster.width);
cropBottom = Math.min(bbox.ymax, georaster.height);
} catch (error) {
console.error(error);
throw error;
Expand All @@ -69,7 +64,10 @@ const get = (georaster, geom, flat) => {
left: cropLeft,
top: cropTop,
right: cropRight,
bottom: cropBottom
bottom: cropBottom,

// shouldn't resample, but specifying resampleMethod just in case
resampleMethod: "near"
})
.then(bands => {
return bands.map(rows => {
Expand Down

0 comments on commit fab69e3

Please sign in to comment.