AIS船舶相关信息

本文介绍如何利用JAVA将AIS船舶的相关信息进行封装,包括获取船舶状态、船舶类型以及通过MMSI查询船舶国籍。
摘要由CSDN通过智能技术生成

本篇文章主要讲 AIS 船舶相关信息用JAVA封装成了一个工具类

  1. 获取船舶状态 
  2. 获取船舶类型
  3. 根据mmsi 获取 所属国籍
import org.springframework.util.StringUtils;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * AIS 船舶相关信息工具类
 * 获取船舶状态 
 * 获取船舶类型
 * 根据mmsi 获取 所属国籍
 */
public class AisShipUtil {

    /**
     * 获取船舶状态 描述
     * @param navStatus
     * @return
     */
    public static String getNavStatusDesc(Integer navStatus) {
        NavigationStatus navigationStatus = NavigationStatus.fromInteger(navStatus);
        return navigationStatus==null?null:navigationStatus.getDesc();
    }

    /**
     * 获取船舶类型 描述
     * @param shipType
     * @return
     */
    public static String getShipTypeDesc(Integer shipType) {
        ShipType shipType1 = ShipType.fromInteger(shipType);
        return shipType1==null?null:shipType1.getDesc();
    }

    /**
     * 根据mmsi 获取 所属国籍
     * @param mmsi
     * @return
     */
    public static String getShipNations(String mmsi) {
        if(!StringUtils.isEmpty(mmsi) || mmsi.length()<3){
            Integer key = Integer.valueOf(mmsi.substring(0, 3));
            return shipNationsMap.get(key);
        }
        return null;
    }

//    public static void main(String[] args) throws Exception {
//        System.out.println(getNavStatusDesc(13));
//        System.out.println(getShipTypeDesc(200));
        System.out.println(getShipTypeDesc(33));
        System.out.println(getShipTypeDesc(99));
        System.out.println(getShipTypeDesc(1));
        System.out.println(getShipTypeDesc(54));
        System.out.println(getShipTypeDesc(70));

        FusionArpaDetailResp fusionArpaDetailResp = new FusionArpaDetailResp();
        fusionArpaDetailResp.setNavStatusDesc(AisShipUtil.getNavStatusDesc(null));
        fusionArpaDetailResp.setShipTypeDesc(AisShipUtil.getShipTypeDesc(null));
        System.out.println(fusionArpaDetailResp);
//        String mmsi = "416766040";
//        Integer integer = Integer.valueOf(mmsi.substring(0,3));
//        System.out.println(integer);
//        System.out.println(ShipNations.fromInteger(mmsi).getCode());
//        System.out.println(ShipNations.fromInteger(mmsi).getDesc());
//    }


    public enum NavigationStatus {
        UnderwayUsingEngine(0, "在航(主机推动)"),
        AtAnchor(1, "锚泊"),
        NotUnderCommand(2, "失控"),
        RestrictedManoeuverability(3, "操作受限"),
        ConstrainedByHerDraught(4, "吃水受限"),
        Moored(5, "靠泊"),
        Aground(6, "搁浅"),
        EngagedInFising(7, "捕捞作业"),
        UnderwaySailing(8, "靠船帆提供动力");
        //9~15为未来保留。

        private Integer code;

        private String desc;

        private NavigationStatus(Integer code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        public Integer getCode() {
            return this.code;
        }

        public String getDesc() {
            return this.desc;
        }

        public static NavigationStatus fromInteger(Integer integer) {
            if (integer != null) {
                if(integer>8 || integer<0){
                    return null;
                }
                NavigationStatus[] var1 = values();
                int var2 = var1.length;

                for(int var3 = 0; var3 < var2; ++var3) {
                    NavigationStatus b = var1[var3];
                    if (integer.equals(b.code)) {
                        return b;
                    }
                }
            }
            return null;
        }
    }

    public enum ShipType {
        NotAvailable(0, "其他"),
        Other1(1, "其他"),
        Other2(2, "其他"),
        Other3(3, "其他"),
        Other4(4, "其他"),
        Other5(5, "其他"),
        Other6(6, "其他"),
        Other7(7, "其他"),
        Other8(8, "其他"),
        Other9(9, "其他"),
        Other10(10, "其他"),
        Other11(11, "其他"),
        Other12(12, "其他"),
        Other13(13, "其他"),
        Other14(14, "其他"),
        Other15(15, "其他"),
        Other16(16, "其他"),
        Other17(17, "其他"),
        Other18(18, "其他"),
        Other19(19, "其他"),
        WingInGround(20, "地效应船"),
        WingInGroundHazardousA(21, "地效应船"),
        WingInGroundHazardousB(22, "地效应船"),
        WingInGroundHazardousC(23, "地效应船"),
        WingInGroundHazardousD(24, "地效应船"),
        WingInGroundFuture1(25, null),
        WingInGroundFuture2(26, null),
        WingInGroundFuture3(27, null),
        WingInGroundFuture4(28, null),
        WingInGroundFuture5(29, null),
        Fishing(30, "捕捞"),
        Towing(31, "拖引"),
        LargeTowing(32, "大型拖带船"),
        DredgingOrUnderwaterOps(33, "疏浚或水下作业"),
        DivingOps(34, "潜水作业"),
        MilitaryOps(35, "参与军事行动"),
        Sailing(36, "帆船"),
        PleasureCraft(37, "快艇"),
        Other38(38, "其他"),
        Other39(39, "其他"),
        HighSpeedCraft(40, "高速船"),
        HighSpeedCraftHarzardousA(41, "高速船"),
        HighSpeedCraftHarzardousB(42, "高速船"),
        HighSpeedCraftHarzardousC(43, "高速船"),
        HighSpeedCraftHarzardousD(44, &#
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值