Skip to content

Commit 966c1dd

Browse files
committed
Fix additional test details
1 parent 1509dda commit 966c1dd

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "geojson-map-fit-mercator",
3-
"version": "1.0.0",
3+
"version": "1.0.1-rc.0",
44
"description": "Finds the optimal bearing, zoom and center point for fitting a set of GeoJSON features in a Mapbox GL or LibreMap Mercator map.",
55
"main": "dist/index.cjs",
66
"types": "types/index.d.ts",

src/screen.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ describe('findScreenBearing', () => {
77
expect(result).toEqual(23.564);
88
});
99

10-
it('should return the west-oriented bearing of the most long side of the bounding rectangle if the screen is portrait and preferredBearing 270 is given', () => {
11-
const result = findScreenBearing(23.564,270, 0.5);
10+
it('should return the north-oriented bearing of the most long side of the bounding rectangle if the screen is portrait but the boundingRectangleBearing is facing south', () => {
11+
const result = findScreenBearing(180.1584,0, 0.5);
1212

13-
expect(result).toEqual(203.564);
13+
expect(result).toEqual(0.15840000000002874);
1414
});
1515

1616
it('should return the bearing 90 off the most north-oriented long side of the bounding rectangle if the screen is landscape', () => {
@@ -20,7 +20,7 @@ describe('findScreenBearing', () => {
2020
});
2121

2222
it('should return the south-oriented bearing of the most long side of the bounding rectangle if the screen is landscape and preferredBearing 180 is given', () => {
23-
const result = findScreenBearing(23.564, 180, 1.2);
23+
const result = findScreenBearing(23.564, 180, 1.2);
2424

2525
expect(result).toEqual(113.564);
2626
});

src/screen.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export function findScreenBearing(boundingRectangleBearing: number, preferredBea
5151
}
5252

5353
// Rotate the bearing 180 degrees if the preferred bearing is on the opposite side of the screen
54+
console.log(bearing < (preferredBearing - 90) % 360, bearing > (preferredBearing + 90) % 360);
5455
if (bearing < (preferredBearing - 90) % 360 || bearing > (preferredBearing + 90) % 360) {
5556
bearing = (bearing + 180) % 360;
5657
}
@@ -64,7 +65,7 @@ export function findScreenCenter(
6465
zoom: number,
6566
padding: mapFitPadding,
6667
merc: SphericalMercator,
67-
) {
68+
): LngLat {
6869
const { left = 0, right = 0, top = 0, bottom = 0 } = padding;
6970

7071
// Use the bounding rectangle's pixel location to calculate the centre of the

0 commit comments

Comments
 (0)