当前位置: 首页>>代码示例>>Java>>正文


Java AisTarget类代码示例

本文整理汇总了Java中dk.dma.ais.data.AisTarget的典型用法代码示例。如果您正苦于以下问题:Java AisTarget类的具体用法?Java AisTarget怎么用?Java AisTarget使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AisTarget类属于dk.dma.ais.data包,在下文中一共展示了AisTarget类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: vesselSearch

import dk.dma.ais.data.AisTarget; //导入依赖的package包/类
@GET
@Path("vessel_search")
@Produces(MediaType.APPLICATION_JSON)
public VesselList vesselSearch(@QueryParam("argument") String argument) {
    if (handler.getConf().isAnonymous()) {
        throw new WebApplicationException(Response.Status.FORBIDDEN);
    }

    TargetTracker tt = LegacyResource.this.get(TargetTracker.class);
    final Predicate<TargetInfo> searchPredicate = getSearchPredicate(argument);

    List<AisTarget> aisTargets = tt.stream(e -> true, searchPredicate).map(ti -> ti.getAisTarget()).collect(Collectors.toList());

    // Get response from AisViewHandler and return it
    return handler.searchTargets(argument, aisTargets);
}
 
开发者ID:dma-ais,项目名称:AisView,代码行数:17,代码来源:LegacyResource.java

示例2: getVesselTargetDetails

import dk.dma.ais.data.AisTarget; //导入依赖的package包/类
public synchronized VesselTargetDetails getVesselTargetDetails(Integer anonId, Integer mmsi, boolean pastTrack) {
    // Get MMSI for anonymous id if mmsi not given
    if (mmsi == null && anonId != null) {
        mmsi = AisTargetEntry.getMmsi(anonId);
    }
    if (mmsi == null) {
        return null;
    }
    AisTargetEntry targetEntry = targetsMap.get(mmsi);
    if (targetEntry == null) {
        return null;
    }
    anonId = targetEntry.getAnonId();
    AisTarget target = targetEntry.getTarget();
    if (!(target instanceof AisVesselTarget)) {
        return null;
    }

    VesselTargetDetails details = new VesselTargetDetails((AisVesselTarget) target, targetEntry.getSourceData(), anonId,
            pastTrack ? pastTrackMap.get(mmsi) : null);
    if (conf.isAnonymous()) {
        details.anonymize();
    }

    return details;
}
 
开发者ID:dma-ais,项目名称:AisAnalysis,代码行数:27,代码来源:AisViewHandler.java

示例3: createTargetInfo

import dk.dma.ais.data.AisTarget; //导入依赖的package包/类
private TargetInfo createTargetInfo(Date lastReport){
    AisTarget aisTarget = Mockito.mock(AisTarget.class);
    Mockito.when(aisTarget.getLastReport()).thenReturn(lastReport);

    TargetInfo targetInfo = Mockito.mock(TargetInfo.class);
    Mockito.when(targetInfo.getAisTarget()).thenReturn(aisTarget);

    return targetInfo;
}
 
开发者ID:dma-ais,项目名称:AisTrack,代码行数:10,代码来源:LastReportFilterTest.java

示例4: AisTargetEntry

import dk.dma.ais.data.AisTarget; //导入依赖的package包/类
public AisTargetEntry(AisPacket packet) {
    AisMessage aisMessage = packet.tryGetAisMessage();        
    this.anonId = ++anonymousCounter;
    mmsiAnonIdMap.put(aisMessage.getUserId(), this.anonId);
    anonIdMap.put(this.anonId, aisMessage.getUserId());
    this.target = AisTarget.createTarget(aisMessage);
}
 
开发者ID:dma-ais,项目名称:AisView,代码行数:8,代码来源:AisTargetEntry.java

示例5: update

import dk.dma.ais.data.AisTarget; //导入依赖的package包/类
public boolean update(AisPacket packet) {
    boolean targetReplaced = false;
    AisMessage aisMessage = packet.tryGetAisMessage();
    sourceData.update(packet);
    // We want to avoid to update a target position with an older position
    // than the last one received
    boolean oldPos = false;
    if (aisMessage instanceof IVesselPositionMessage) {
        Date thisReport = null;
        // Get timestamp for message tag or fallback to time now
        thisReport = aisMessage.getVdm().getTimestamp();
        if (thisReport == null) {
            thisReport = new Date();
        }
        if (lastReport != null) {
            // We will not update if this report is older than last
            if (thisReport.before(lastReport)) {
                oldPos = true;
            }
        }
        lastReport = thisReport;
    }
    // Update target data
    if (!oldPos) {
        try {
            target.update(aisMessage);
        } catch (IllegalArgumentException e) {
            // Trying to update target with report of different type of target.
            // Replace target with new target
            target = AisTarget.createTarget(aisMessage);
            target.update(aisMessage);
            targetReplaced = true;
        }
    }

    return targetReplaced;
}
 
开发者ID:dma-ais,项目名称:AisView,代码行数:38,代码来源:AisTargetEntry.java

示例6: searchTargets

import dk.dma.ais.data.AisTarget; //导入依赖的package包/类
/**
 * Get simple list of anonymous targets that matches the search criteria.
 * 
 * @param searchCriteria
 *            A string that will be matched to all vessel names, IMOs and
 *            MMSIs.
 * @return A list of targets.
 */
public VesselList searchTargets(String searchCriteria,
        List<AisTarget> targets) {

    VesselList response = new VesselList();

    // Iterate through all vessel targets and add to response
    for (AisTarget target : targets) {
        if (!(target instanceof AisVesselTarget)) {
            continue;
        }

        // TODO: implement sat ttl vs live ttl
        // Determine TTL (could come from configuration)
        // TargetSourceData sourceData = targetEntry.getSourceData();
        // boolean satData = sourceData.isSatData();
        int ttl = conf.getSatTargetTtl();

        // Is it alive
        if (!target.isAlive(ttl)) {
            continue;
        }

        // Maybe filtered away
        if (rejectedBySearchCriteria(target, searchCriteria)) {
            continue;
        }

        response.addTarget((AisVesselTarget) target, target.getMmsi());
    }

    return response;
}
 
开发者ID:dma-ais,项目名称:AisView,代码行数:41,代码来源:AisViewHelper.java

示例7: searchTargets

import dk.dma.ais.data.AisTarget; //导入依赖的package包/类
/**
 * Get simple list of anonymous targets that matches the search criteria.
 * 
 * @param searchCriteria
 *            A string that will be matched to all vessel names, IMOs and MMSIs.
 * @return A list of targets.
 */
public synchronized VesselList searchTargets(String searchCriteria) {

    VesselList response = new VesselList();

    // Iterate through all vessel targets and add to response
    for (AisTargetEntry targetEntry : targetsMap.values()) {
        AisTarget target = targetEntry.getTarget();
        if (!(target instanceof AisVesselTarget)) {
            continue;
        }

        // Determine TTL (could come from configuration)
        TargetSourceData sourceData = targetEntry.getSourceData();
        boolean satData = sourceData.isSatData();
        int ttl = (satData) ? conf.getSatTargetTtl() : conf.getLiveTargetTtl();

        // Is it alive
        if (!target.isAlive(ttl)) {
            continue;
        }

        // Maybe filtered away
        if (rejectedBySearchCriteria(target, searchCriteria)) {
            continue;
        }

        response.addTarget((AisVesselTarget) target, targetEntry.getAnonId());
    }

    return response;
}
 
开发者ID:dma-ais,项目名称:AisAnalysis,代码行数:39,代码来源:AisViewHandler.java

示例8: AisViewHandlerStats

import dk.dma.ais.data.AisTarget; //导入依赖的package包/类
public AisViewHandlerStats(Collection<AisTargetEntry> targets, Collection<IPastTrack> pastTracks, double rate) {
    this.rate = rate;
    totalTargets = targets.size();
    // Go through all targets
    for (AisTargetEntry targetEntry : targets) {
        AisTarget target = targetEntry.getTarget();                   
        if (target instanceof AisVesselTarget) {
            vesselTargets++;
        }
    }
    pastTrackTargets = pastTracks.size();
    for (IPastTrack pastTrack : pastTracks) {
        pastTrackPoints += pastTrack.getPoints().size();
    }
}
 
开发者ID:dma-ais,项目名称:AisAnalysis,代码行数:16,代码来源:AisViewHandlerStats.java

示例9: getTarget

import dk.dma.ais.data.AisTarget; //导入依赖的package包/类
public AisTarget getTarget() {
    return target;
}
 
开发者ID:dma-ais,项目名称:AisView,代码行数:4,代码来源:AisTargetEntry.java

示例10: getFilteredAisVessel

import dk.dma.ais.data.AisTarget; //导入依赖的package包/类
/**
 * Returns a casted AisVesselTarget of the given AisTarget if it is an
 * instance of AisVesselTarget.
 * 
 * @param target
 * @param filter
 * @return
 */
public AisVesselTarget getFilteredAisVessel(AisTarget target,
        VesselListFilter filter) {

    if (!(target instanceof AisVesselTarget)) {
        return null;
    }
    AisVesselTarget vesselTarget = (AisVesselTarget) target;

    Map<String, HashSet<String>> filterMap = filter.getFilterMap();

    // Maybe filtered away
    Set<String> vesselClass = filterMap.get("vesselClass");
    if (vesselClass != null) {
        String vc = (target instanceof AisClassATarget) ? "A" : "B";
        if (!vesselClass.contains(vc)) {
            return null;
        }
    }
    Set<String> country = filterMap.get("country");
    if (country != null) {
        Country mc = target.getCountry();
        if (mc == null) {
            return null;
        }
        if (!country.contains(mc.getThreeLetter())) {
            return null;
        }
    }

    Set<String> staticReport = filterMap.get("staticReport");
    if (staticReport != null) {
        boolean hasStatic = vesselTarget.getVesselStatic() != null;
        if (staticReport.contains("yes") && !hasStatic) {
            return null;
        }
        if (staticReport.contains("no") && hasStatic) {
            return null;
        }
    }

    return vesselTarget;
}
 
开发者ID:dma-ais,项目名称:AisView,代码行数:51,代码来源:AisViewHelper.java

示例11: rejectedBySearchCriteria

import dk.dma.ais.data.AisTarget; //导入依赖的package包/类
/**
 * Returns false if target matches a given searchCriteria. This method only
 * matches on the targets name, mmsi and imo.
 * 
 * @param target
 * @param searchCriteria
 * @return false if the target matches the search criteria.
 * @throws JsonApiException
 */
public boolean rejectedBySearchCriteria(AisTarget target,
        String searchCriteria) {

    if (!(target instanceof AisVesselTarget)) {
        return true;
    }

    // Get length of search criteria
    int searchLength = searchCriteria.length();

    AisVesselTarget vessel = (AisVesselTarget) target;

    // Get details
    Integer mmsi = vessel.getMmsi();

    // Check mmsi
    String mmsiString = Long.toString(mmsi);
    if (mmsiString.length() >= searchLength
            && mmsiString.substring(0, searchLength).equals(searchCriteria)) {
        return false;
    }

    // Check name
    if (vessel.getVesselStatic() != null
            && vessel.getVesselStatic().getName() != null) {
        String name = vessel.getVesselStatic().getName().toUpperCase();

        // Check entire name
        if (name.length() >= searchLength
                && name.substring(0, searchLength).equals(
                        searchCriteria.toUpperCase())) {
            return false;
        }

        // Check each word
        String[] words = name.split(" ");
        for (String w : words) {
            if (w.length() >= searchLength
                    && w.substring(0, searchLength).equals(
                            searchCriteria.toUpperCase())) {
                return false;
            }
        }
    }

    // Check imo - if Class A
    if (vessel instanceof AisClassATarget) {
        AisClassATarget classAVessel = (AisClassATarget) vessel;
        if (classAVessel.getClassAStatic() != null
                && classAVessel.getClassAStatic().getImoNo() != null) {
            int imo = classAVessel.getClassAStatic().getImoNo();
            String imoString = Integer.toString(imo);
            if (imoString.length() >= searchLength
                    && imoString.substring(0, searchLength).equals(
                            searchCriteria)) {
                return false;
            }
        }
    }

    return true;
}
 
开发者ID:dma-ais,项目名称:AisView,代码行数:72,代码来源:AisViewHelper.java

示例12: accept

import dk.dma.ais.data.AisTarget; //导入依赖的package包/类
@Override
public synchronized void accept(AisPacket packet) {
    flow.received();
    
    // Get AisMessage
    AisMessage aisMessage = packet.tryGetAisMessage();
    if (aisMessage == null) {
        return;
    }
    // We only want to handle messages containing targets data
    // #1-#3, #4, #5, #18, #19, #21, #24
    if (!AisTarget.isTargetDataMessage(aisMessage)) {
        return;
    }
    int mmsi = aisMessage.getUserId();

    // Get existing AisTargetEntry or create new
    AisTargetEntry targetEntry = targetsMap.get(mmsi);
    if (targetEntry == null) {
        targetEntry = new AisTargetEntry(packet);
        targetsMap.put(mmsi, targetEntry);
    }
    // Update entry
    boolean targetReplaced = targetEntry.update(packet);

    if (targetReplaced) {
        pastTrackMap.remove(mmsi);
    }

    // Get or create past track entry for mmsi
    IPastTrack pastTrack = null;
    // Update pasttrack
    if (conf.isRecordPastTrack()) {
        pastTrack = pastTrackMap.get(mmsi);
        if (pastTrack == null) {
            pastTrack = new PastTrackSortedSet();
            pastTrackMap.put(mmsi, pastTrack);
        }

        if (aisMessage instanceof IVesselPositionMessage) {
            IVesselPositionMessage posMessage = (IVesselPositionMessage) aisMessage;
            Position pos = posMessage.getPos().getGeoLocation();
            if (pos != null) {
                // Make VesselPosition instance
                AisVesselPosition vesselPosition = new AisVesselPosition();
                vesselPosition.update((IVesselPositionMessage) aisMessage);

                // Update past track
                pastTrack.addPosition(vesselPosition, conf.getPastTrackMinDist());
            }
        }
    }

}
 
开发者ID:dma-ais,项目名称:AisAnalysis,代码行数:55,代码来源:AisViewHandler.java

示例13: rejectedBySearchCriteria

import dk.dma.ais.data.AisTarget; //导入依赖的package包/类
/**
 * Returns false if target matches a given searchCriteria. This method only matches on the targets name, mmsi and imo.
 * 
 * @param target
 * @param searchCriteria
 * @return false if the target matches the search criteria.
 * @throws JsonApiException
 */
private static boolean rejectedBySearchCriteria(AisTarget target, String searchCriteria) {

    if (!(target instanceof AisVesselTarget)) {
        return true;
    }

    // Get length of search criteria
    int searchLength = searchCriteria.length();

    AisVesselTarget vessel = (AisVesselTarget) target;

    // Get details
    Integer mmsi = vessel.getMmsi();

    // Check mmsi
    String mmsiString = Long.toString(mmsi);
    if (mmsiString.length() >= searchLength && mmsiString.substring(0, searchLength).equals(searchCriteria)) {
        return false;
    }

    // Check name
    if (vessel.getVesselStatic() != null && vessel.getVesselStatic().getName() != null) {
        String name = vessel.getVesselStatic().getName().toUpperCase();

        // Check entire name
        if (name.length() >= searchLength && name.substring(0, searchLength).equals(searchCriteria.toUpperCase())) {
            return false;
        }

        // Check each word
        String[] words = name.split(" ");
        for (String w : words) {
            if (w.length() >= searchLength && w.substring(0, searchLength).equals(searchCriteria.toUpperCase())) {
                return false;
            }
        }
    }

    // Check imo - if Class A
    if (vessel instanceof AisClassATarget) {
        AisClassATarget classAVessel = (AisClassATarget) vessel;
        if (classAVessel.getClassAStatic() != null && classAVessel.getClassAStatic().getImoNo() != null) {
            int imo = classAVessel.getClassAStatic().getImoNo();
            String imoString = Integer.toString(imo);
            if (imoString.length() >= searchLength && imoString.substring(0, searchLength).equals(searchCriteria)) {
                return false;
            }
        }
    }

    return true;
}
 
开发者ID:dma-ais,项目名称:AisAnalysis,代码行数:61,代码来源:AisViewHandler.java


注:本文中的dk.dma.ais.data.AisTarget类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。