*
* @param feed The AIS feed for which to calculate the coverage area.
* @since 1.0
*/
private void calculateCoveragePerimiter() {
NavCalculator nav = new NavCalculator();
AISMsg msg;
// Calculate the distances from each target to the base station
double distance;
Position targetPosition;
double key;
for (Target t : getTargets()) {
if (t.getType() == Target.TARGET_BASESTN) {
continue;
}
targetPosition = t.getPosition();
if (targetPosition == null) {
if (targetPosition == null) {
msg = (t.getLatestDynamicMsg() == null
? t.getLatestMessage()
: t.getLatestDynamicMsg());
if (msg.getPosition() != null) {
targetPosition = msg.getPosition();
} else {
continue;
}
}
}
// Filter: Delete targets that have badly configured positions
if (targetPosition.getLatitude() <= 0 || targetPosition.getLongitude() <= -50) {
targetsMap.remove(t.getMMSI());
continue;
}
// Calculate the vessel's distance from the AIS receiver
nav.mercatorSailing(getLocation(), targetPosition);
distance = nav.getDistance();
// Remove targets that are too far away and that are hence the result of badly configured
// receivers
if (distance > 300) {
continue;
}
key = Math.round(nav.getTrueCourse());
if (distanceMap.get(key) == null) {
continue;
}