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
9 changes: 9 additions & 0 deletions lib/utils/coordinate_utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ describe('CoordinateUtils', () => {
}),
).toBe('12.345 S, 67.890 W');
});

test('formats zero coordinates as N/E', () => {
expect(
CoordinateUtils.coordinateString({
latitude: 0,
longitude: 0,
}),
).toBe('0.000 N, 0.000 E');
});
});

describe('getDirection', () => {
Expand Down
4 changes: 2 additions & 2 deletions lib/utils/coordinate_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ export class CoordinateUtils {
latitude: number;
longitude: number;
}): string {
const latDir = coords.latitude > 0 ? 'N' : 'S';
const lonDir = coords.longitude > 0 ? 'E' : 'W';
const latDir = coords.latitude >= 0 ? 'N' : 'S';
const lonDir = coords.longitude >= 0 ? 'E' : 'W';
return `${Math.abs(coords.latitude).toFixed(3)} ${latDir}, ${Math.abs(coords.longitude).toFixed(3)} ${lonDir}`;
}

Expand Down
Loading