Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/geo/bboxUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { degreesToTile, tileToDegrees } from './geoConvertor';
import { degreesPerTile } from './tiles';

const snapMinCordToTileGrid = (cord: number, tileRes: number): number => {
const newCord = cord - Math.abs(cord % tileRes);
const newCord = Math.floor(cord / tileRes) * tileRes;
return newCord;
};

Expand Down
4 changes: 2 additions & 2 deletions tests/unit/geo/bboxUtils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import { bboxFromTiles, bboxToTileRange, snapBBoxToTileGrid } from '../../../src
describe('bboxUtils', () => {
describe('snapBBoxToTileGrid', () => {
it('rounds coordinates to tile grid', () => {
const roundedBbox = snapBBoxToTileGrid([1, 2, 3, 4], 20);
const roundedBbox = snapBBoxToTileGrid([-180, -179.9999, 179.9999, 180], 20);
const gridStep = 180 / (1 << 20);
for (const cord of roundedBbox) {
expect(cord % gridStep).toBe(0);
expect(Math.abs(cord % gridStep)).toEqual(0);
}
});

Expand Down