Skip to content

Commit 8e559e2

Browse files
fix projection
1 parent 32e1855 commit 8e559e2

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/utils/projection.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,14 @@ export class ProjectionGrid {
9898
}
9999

100100
findPointInterpolated(lat: number, lon: number) {
101-
let [x, y] = this.projection.forward(lat, lon);
101+
let [ypos, xpos] = this.projection.forward(lat, lon);
102+
let x = (xpos - this.origin[0]) / this.dx;
103+
let y = (ypos - this.origin[1]) / this.dy;
104+
let xFraction = x - Math.floor(x);
105+
let yFraction = y - Math.floor(y);
102106
if (y < 0 || x < 0 || y >= this.ny || x >= this.nx) {
103107
return null;
104108
}
105-
let xFraction = x / 1 - Math.floor(x / 1);
106-
let yFraction = y / 1 - Math.floor(y / 1);
107109
return { index: Math.floor(y) * this.nx + Math.floor(x), xFraction, yFraction };
108110
}
109111
}

0 commit comments

Comments
 (0)