public Optional<VesselPosition> predict(long t) {
        if (!speedMetresPerSecond.isPresent() || !cogDegrees.isPresent()
                || navigationalStatus == NavigationalStatus.AT_ANCHOR
                || navigationalStatus == NavigationalStatus.MOORED)
            return Optional.absent();
        else {
            double lat = this.lat - speedMetresPerSecond.get() / metresPerDegreeLatitude()
                    * (t - time) / 1000.0 * Math.cos(Math.toRadians(cogDegrees.get()));
            if (lat > 90)
                lat = 90;
            else if (lat < -90)
                lat = -90;
            double lon = Position
                    .to180(this.lon + speedMetresPerSecond.get() / metresPerDegreeLongitude()
                            * (t - time) / 1000.0 * Math.sin(Math.toRadians(cogDegrees.get())));

            return Optional.of(new VesselPosition(messageId, id, lat, lon, lengthMetres,
                    widthMetres, cogDegrees, headingDegrees, speedMetresPerSecond, cls,
                    navigationalStatus, time, shipType, positionAisNmea, shipStaticAisNmea, data));
        }
    }
public Optional < VesselPosition > predict ( long t ) { if ( ! speedMetresPerSecond . isPresent ( ) || ! cogDegrees . isPresent ( ) || navigationalStatus == NavigationalStatus . AT_ANCHOR || navigationalStatus == NavigationalStatus . MOORED ) return Optional . absent ( ) ; else { double lat = this . lat - speedMetresPerSecond . get ( ) / metresPerDegreeLatitude ( ) * ( t - time ) / 1000.0 * Math . cos ( Math . toRadians ( cogDegrees . get ( ) ) ) ; if ( lat > 90 ) lat = 90 ; else if ( lat < - 90 ) lat = - 90 ; double lon = Position . to180 ( this . lon + speedMetresPerSecond . get ( ) / metresPerDegreeLongitude ( ) * ( t - time ) / 1000.0 * Math . sin ( Math . toRadians ( cogDegrees . get ( ) ) ) ) ; return Optional . of ( new VesselPosition ( messageId , id , lat , lon , lengthMetres , widthMetres , cogDegrees , headingDegrees , speedMetresPerSecond , cls , navigationalStatus , time , shipType , positionAisNmea , shipStaticAisNmea , data ) ) ; } }
}