import shipAlarmIcon from '../../../assets/ship_alarm.png';
import shipAlarmFishingIcon from '../../../assets/ship_alarm_fishing.png';
import shipOnlineIcon from '../../../assets/ship_online.png';
import shipOnlineFishingIcon from '../../../assets/ship_online_fishing.png';
import shipUndefineIcon from '../../../assets/ship_undefine.png';
import shipWarningIcon from '../../../assets/ship_warning.png';
import shipWarningFishingIcon from '../../../assets/ship_warning_fishing.png';
import shipSosIcon from '../../../assets/sos_icon.png';

export const getShipIcon = (type: number, isFishing: boolean) => {
  if (type === 1 && !isFishing) {
    return shipWarningIcon;
  } else if (type === 2 && !isFishing) {
    return shipAlarmIcon;
  } else if (type === 0 && !isFishing) {
    return shipOnlineIcon;
  } else if (type === 1 && isFishing) {
    return shipWarningFishingIcon;
  } else if (type === 2 && isFishing) {
    return shipAlarmFishingIcon;
  } else if (type === 0 && isFishing) {
    return shipOnlineFishingIcon;
  } else if (type === 3) {
    return shipSosIcon;
  } else {
    return shipUndefineIcon;
  }
};

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}`;
};
