thêm chức năng Sos và thêm glustack-ui
This commit is contained in:
@@ -86,3 +86,25 @@ export const getBanzoneNameByType = (type: number) => {
|
||||
return "Chưa có";
|
||||
}
|
||||
};
|
||||
|
||||
export const convertToDMS = (value: number, isLat: boolean): string => {
|
||||
const deg = Math.floor(Math.abs(value));
|
||||
const minFloat = (Math.abs(value) - deg) * 60;
|
||||
const min = Math.floor(minFloat);
|
||||
const sec = (minFloat - min) * 60;
|
||||
|
||||
const direction = value >= 0 ? (isLat ? "N" : "E") : isLat ? "S" : "W";
|
||||
|
||||
return `${deg}°${min}'${sec.toFixed(2)}"${direction}`;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Chuyển đổi tốc độ từ km/h sang knot (hải lý/giờ)
|
||||
* @param kmh - tốc độ tính bằng km/h
|
||||
* @returns tốc độ tính bằng knot
|
||||
*/
|
||||
export function kmhToKnot(kmh: number): number {
|
||||
const KNOT_PER_KMH = 1 / 1.852; // 1 knot = 1.852 km/h
|
||||
return parseFloat((kmh * KNOT_PER_KMH).toFixed(2)); // làm tròn 2 chữ số thập phân
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user