Skip to content

Commit

Permalink
Avoid returning negative indices
Browse files Browse the repository at this point in the history
  • Loading branch information
katamartin committed Apr 30, 2024
1 parent 7960bec commit b62890f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion components/utils/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,9 @@ const getAxisIndex = (value, { name, axis, chunk_shape, shape }) => {

const chunkStep = axis.step * chunk_shape[index]

return diff < 0 ? Math.ceil(diff / chunkStep) : Math.floor(diff / chunkStep)
return diff < 0
? Math.abs(Math.ceil(diff / chunkStep))
: Math.floor(diff / chunkStep)
}

export const validatePoint = ([lon, lat]) => {
Expand Down

0 comments on commit b62890f

Please sign in to comment.