wxString AIS_Target_Data::BuildQueryResult( void ) { wxString html; wxDateTime now = wxDateTime::Now(); wxString tableStart = _T("\n<table border=0 cellpadding=1 cellspacing=0>\n"); wxString tableEnd = _T("</table>\n\n"); wxString rowStart = _T("<tr><td><font size=-2>"); wxString rowStartH = _T("<tr><td nowrap>"); wxString rowSeparator = _T("</font></td><td></td><td><b>"); wxString rowSeparatorH = _T("</td><td></td><td>"); wxString colSeparator = _T("<td></td>"); wxString rowEnd = _T("</b></td></tr>\n"); wxString vertSpacer = _T("<tr><td></td></tr><tr><td></td></tr><tr><td></td></tr>\n\n"); wxString IMOstr, MMSIstr, ClassStr; html << tableStart << _T("<tr><td nowrap colspan=2>"); if( /*( Class != AIS_BASE ) &&*/ ( Class != AIS_SART ) ) { if( b_nameValid ) { html << _T("<font size=+2><i><b>") << GetFullName() ; html << _T("</b></i></font> <b>"); } } if( ( Class != AIS_ATON ) && ( Class != AIS_BASE ) && ( Class != AIS_GPSG_BUDDY ) && ( Class != AIS_SART ) ) { html << trimAISField( CallSign ) << _T("</b>") << rowEnd; if( Class != AIS_CLASS_B ) { if( IMO > 0 ) IMOstr = wxString::Format( _T("%08d"), abs( IMO ) ); } } else html << _T("</b>") << rowEnd; html << vertSpacer; if( Class != AIS_GPSG_BUDDY ) { MMSIstr = wxString::Format( _T("%09d"), abs( MMSI ) ); } ClassStr = wxGetTranslation( Get_class_string( false ) ); if( Class == AIS_ATON ) { wxString cls(_T("AtoN: ") ); cls += Get_vessel_type_string(false); ClassStr = wxGetTranslation( cls ); } if(b_SarAircraftPosnReport) ClassStr = _("SAR Aircraft"); if( IMOstr.Length() ) html << _T("<tr><td colspan=2><table width=100% border=0 cellpadding=0 cellspacing=0>") << rowStart <<_("MMSI") << _T("</font></td><td> </td><td><font size=-2>") << _("Class") << _T("</font></td><td> </td><td align=right><font size=-2>") << _("IMO") << _T("</font></td></tr>") << rowStartH << _T("<b>") << MMSIstr << _T("</b></td><td> </td><td><b>") << ClassStr << _T("</b></td><td> </td><td align=right><b>") << IMOstr << rowEnd << _T("</table></td></tr>"); else html << _T("<tr><td colspan=2><table width=100% border=0 cellpadding=0 cellspacing=0>") << rowStart <<_("MMSI") << _T("</font></td><td> </td><td align=right><font size=-2>") << _("Class") << _T("</font></td></tr>") << rowStartH << _T("<b>") << MMSIstr << _T("</b></td><td> </td><td align=right><b>") << ClassStr << rowEnd << _T("</table></td></tr>"); if((Class != AIS_SART ) && ( Class != AIS_BASE ) && ( Class != AIS_DSC ) ) html << _T("<tr><td colspan=2><table width=100% border=0 cellpadding=0 cellspacing=0>") << rowStart << _("Flag") << rowEnd << _T("</font></td></tr>") << rowStartH << _T("<b>")<< GetCountryCode(true) << rowEnd << _T("</table></td></tr>"); html << vertSpacer; wxString navStatStr; if( ( Class != AIS_BASE ) && ( Class != AIS_CLASS_B ) && ( Class != AIS_SART ) ) { if( ( NavStatus <= 21 ) && ( NavStatus >= 0 ) ) navStatStr = wxGetTranslation(ais_get_status(NavStatus)); } else if( Class == AIS_SART ) { if( NavStatus == RESERVED_14 ) navStatStr = _("Active"); else if( NavStatus == UNDEFINED ) navStatStr = _("Testing"); } wxString sart_sub_type; if( Class == AIS_SART ) { int mmsi_start = MMSI / 1000000; switch( mmsi_start ){ case 970: // sart_sub_type = _T("SART"); break; case 972: sart_sub_type = _T("MOB"); break; case 974: sart_sub_type = _T("EPIRB"); break; default: sart_sub_type = _("Unknown"); break; } } wxString AISTypeStr, UNTypeStr, sizeString; if( ( Class != AIS_BASE ) && ( Class != AIS_SART ) && ( Class != AIS_DSC ) ) { // Ship type AISTypeStr = wxGetTranslation( Get_vessel_type_string() ); if( b_isEuroInland && UN_shiptype ) { ERIShipTypeHash::iterator it = s_ERI_hash.find( UN_shiptype ); wxString type; if( it == s_ERI_hash.end() ) type = _("Undefined"); else type = it->second; UNTypeStr = wxGetTranslation( type ); } if( b_SarAircraftPosnReport ){ AISTypeStr.Clear(); UNTypeStr.Clear(); navStatStr.Clear(); } if( Class == AIS_SART ) { if( MSG_14_text.Len() ) { html << rowStart << _("Safety Broadcast Message") << rowEnd << rowStartH << _T("<b>") << MSG_14_text << rowEnd; } } // Dimensions if( NavStatus != ATON_VIRTUAL && Class != AIS_ARPA && Class != AIS_APRS ) { if( ( Class == AIS_CLASS_B ) || ( Class == AIS_ATON ) ) { sizeString = wxString::Format( _T("%dm x %dm"), ( DimA + DimB ), ( DimC + DimD ) ); } else if(!b_SarAircraftPosnReport) { if( ( DimA + DimB + DimC + DimD ) == 0 ) { if( b_isEuroInland ) { if( Euro_Length == 0.0 ) { if( Euro_Draft > 0.01 ) { sizeString << wxString::Format( _T("---m x ---m x %4.1fm"), Euro_Draft ); } else { sizeString << _T("---m x ---m x ---m"); } } else { if( Euro_Draft > 0.01 ) { sizeString << wxString::Format( _T("%5.1fm x %4.1fm x %4.1fm"), Euro_Length, Euro_Beam, Euro_Draft ); } else { sizeString << wxString::Format( _T("%5.1fm x %4.1fm x ---m\n\n"), Euro_Length, Euro_Beam ); } } } else { if( Draft > 0.01 ) { sizeString << wxString::Format( _T("---m x ---m x %4.1fm"), Draft ); } else { sizeString << _T("---m x ---m x ---m"); } } } else if( Draft < 0.01 ) { sizeString << wxString::Format( _T("%dm x %dm x ---m"), ( DimA + DimB ), ( DimC + DimD ) ); } else { sizeString << wxString::Format( _T("%dm x %dm x %4.1fm"), ( DimA + DimB ), ( DimC + DimD ), Draft ); } } } } if( Class == AIS_SART ) { html << _T("<tr><td colspan=2>") << _T("<b>") << AISTypeStr; if( sart_sub_type.Length() ) html << _T(" (") << sart_sub_type << _T("), "); html << navStatStr; html << rowEnd << _T("<tr><td colspan=2>") << _T("<b>") << sizeString << rowEnd; } else if( Class == AIS_ATON ) { html << _T("<tr><td colspan=2>") << _T("<b>") << navStatStr; html << rowEnd << _T("<tr><td colspan=2>") << _T("<b>") << sizeString << rowEnd; } else if( ( Class != AIS_BASE ) && ( Class != AIS_DSC ) ) { html << _T("<tr><td colspan=2>") << _T("<b>") << AISTypeStr; if( navStatStr.Length() ) html << _T(", ") << navStatStr; if( UNTypeStr.Length() ) html << _T(" (UN Type ") << UNTypeStr << _T(")"); html << rowEnd << _T("<tr><td colspan=2>") << _T("<b>") << sizeString << rowEnd; } if( b_positionOnceValid ) { wxString posTypeStr; if( b_positionDoubtful ) posTypeStr << _(" (Last Known)"); now.MakeGMT(); int target_age = now.GetTicks() - PositionReportTicks; html << vertSpacer << rowStart << _("Position") << posTypeStr << _T("</font></td><td align=right><font size=-2>") << _("Report Age") << _T("</font></td></tr>") << rowStartH << _T("<b>") << toSDMM( 1, Lat ) << _T("</b></td><td align=right><b>") << FormatTimeAdaptive( target_age ) << rowEnd << rowStartH << _T("<b>") << toSDMM( 2, Lon ) << rowEnd; } wxString courseStr, sogStr, hdgStr, rotStr, rngStr, brgStr, destStr, etaStr; if( Class == AIS_GPSG_BUDDY ) { long month, year, day; m_date_string.Mid(0,2).ToLong(&day); m_date_string.Mid(2,2).ToLong(&month); m_date_string.Mid(4,2).ToLong(&year); wxDateTime date; date.SetDay(day); date.SetMonth((wxDateTime::Month)(month-1)); date.SetYear(year + 2000); wxString f_date = date.FormatISODate(); html << vertSpacer << rowStart << _("Report as of") << rowEnd << rowStartH << _T("<b>") << f_date + _T("</b> at <b>") << wxString::Format( _T("%d:%d UTC "), m_utc_hour, m_utc_min ) << rowEnd; } else { if( Class == AIS_CLASS_A && !b_SarAircraftPosnReport ) { html << vertSpacer << rowStart << _("Destination") << _T("</font></td><td align=right><font size=-2>") << _("ETA (UTC)") << _T("</font></td></tr>\n") << rowStartH << _T("<b>"); wxString dest = trimAISField( Destination ); if(dest.Length() ) html << dest; else html << _("---"); html << _T("</b></td><td nowrap align=right><b>"); if( ( ETA_Mo ) && ( ETA_Hr < 24 ) ) { int yearOffset = 0; if( now.GetMonth() > ( ETA_Mo - 1 ) ) yearOffset = 1; wxDateTime eta( ETA_Day, wxDateTime::Month( ETA_Mo - 1 ), now.GetYear() + yearOffset, ETA_Hr, ETA_Min ); html << eta.Format( _T("%b %d %H:%M") ); } else html << _("---"); html << rowEnd; } if( Class == AIS_CLASS_A || Class == AIS_CLASS_B || Class == AIS_ARPA || Class == AIS_APRS ) { int crs = wxRound( COG ); if( crs < 360 ) { if( g_bShowMag ) courseStr << wxString::Format( wxString("%03d°(M) ", wxConvUTF8 ), (int)gFrame->GetTrueOrMag( crs ) ); else courseStr << wxString::Format( wxString("%03d° ", wxConvUTF8 ), (int)gFrame->GetTrueOrMag( crs ) ); } else if( COG == 360.0 ) courseStr = _T("---"); else if( crs == 360 ) courseStr = _T("0°"); double speed_show = toUsrSpeed( SOG ); if( ( SOG <= 102.2 ) || b_SarAircraftPosnReport ){ if( speed_show < 10.0 ) sogStr = wxString::Format( _T("%.2f "), speed_show ) + getUsrSpeedUnit(); else if( speed_show < 100.0 ) sogStr = wxString::Format( _T("%.1f "), speed_show ) + getUsrSpeedUnit(); else sogStr = wxString::Format( _T("%.0f "), speed_show ) + getUsrSpeedUnit(); } // sogStr = wxString::Format( _T("%5.2f ") + getUsrSpeedUnit(), toUsrSpeed( SOG ) ); else sogStr = _("---"); if( (int) HDG != 511 ) hdgStr = wxString::Format( _T("%03d°"), (int) HDG ); else hdgStr = _T("---"); if( ROTAIS != -128 ) { if( ROTAIS == 127 ) rotStr << _T("> 5°/30s ") << _("Right"); else if( ROTAIS == -127 ) rotStr << _T("> 5°/30s ") << _("Left"); else { if( ROTIND > 0 ) rotStr << wxString::Format( _T("%3d°/Min "), ROTIND ) << _("Right"); else if( ROTIND < 0 ) rotStr << wxString::Format( _T("%3d°/Min "), -ROTIND ) << _("Left"); else rotStr = _T("0"); } } else if( !b_SarAircraftPosnReport ) rotStr = _("---"); } } if( b_positionOnceValid && bGPSValid && ( Range_NM >= 0. ) ) rngStr = cc1->FormatDistanceAdaptive( Range_NM ); else rngStr = _("---"); int brg = (int) wxRound( Brg ); if( Brg > 359.5 ) brg = 0; if( b_positionOnceValid && bGPSValid && ( Brg >= 0. ) && ( Range_NM > 0. ) && ( fabs( Lat ) < 85. ) ){ if( g_bShowMag ) brgStr << wxString::Format( wxString("%03d°(M) ", wxConvUTF8 ), (int)gFrame->GetTrueOrMag( Brg ) ); else brgStr << wxString::Format( wxString("%03d° ", wxConvUTF8 ), (int)gFrame->GetTrueOrMag( Brg ) ); } else brgStr = _("---"); wxString turnRateHdr; // Blank if ATON or BASE or Special Position Report (9) if( ( Class != AIS_ATON ) && ( Class != AIS_BASE ) && ( Class != AIS_DSC ) ) { html << vertSpacer << _T("<tr><td colspan=2><table width=100% border=0 cellpadding=0 cellspacing=0>") << rowStart <<_("Speed") << _T("</font></td><td> </td><td><font size=-2>") << _("Course") << _T("</font></td><td> </td><td align=right><font size=-2>"); if( !b_SarAircraftPosnReport ) html << _("Heading") ; html << _T("</font></td></tr>") << rowStartH << _T("<b>") << sogStr << _T("</b></td><td> </td><td><b>") << courseStr << _T("</b></td><td> </td><td align=right><b>"); if(!b_SarAircraftPosnReport) html << hdgStr; html << rowEnd << _T("</table></td></tr>") << vertSpacer; if( !b_SarAircraftPosnReport ) turnRateHdr = _("Turn Rate"); } html << _T("<tr><td colspan=2><table width=100% border=0 cellpadding=0 cellspacing=0>") << rowStart <<_("Range") << _T("</font></td><td> </td><td><font size=-2>") << _("Bearing") << _T("</font></td><td> </td><td align=right><font size=-2>") << turnRateHdr << _T("</font></td></tr>") << rowStartH << _T("<b>") << rngStr << _T("</b></td><td> </td><td><b>") << brgStr << _T("</b></td><td> </td><td align=right><b>"); if(!b_SarAircraftPosnReport) html << rotStr; html << rowEnd << _T("</table></td></tr>") << vertSpacer; if( bCPA_Valid ) { wxString tcpaStr; tcpaStr << _T("</b> ") << _("in ") << _T("</td><td align=right><b>") << FormatTimeAdaptive( (int)(TCPA*60.) ); html<< /*vertSpacer << */rowStart << _T("<font size=-2>") <<_("CPA") << _T("</font>") << rowEnd << rowStartH << _T("<b>") << cc1->FormatDistanceAdaptive( CPA ) << tcpaStr << rowEnd; } if( Class != AIS_BASE ) { if( blue_paddle == 1 ) { html << rowStart << _("Inland Blue Flag") << rowEnd << rowStartH << _T("<b>") << _("Clear") << rowEnd; } else if( blue_paddle == 2 ) { html << rowStart << _("Inland Blue Flag") << rowEnd << rowStartH << _T("<b>") << _("Set") << rowEnd; } } if(b_SarAircraftPosnReport) { wxString altStr; if(altitude != 4095) altStr.Printf(_T("%4d m"), altitude ); else altStr = _("Unknown"); html << rowStart <<_("Altitude") << _T("</font></td><td> </td><td><font size=-0>") << rowStartH << _T("<b>") << altStr << _T("</b></td><td> </td><td><b>") << rowEnd << _T("</table></td></tr>") << vertSpacer; } html << _T("</table>"); return html; }
wxString AIS_Target_Data::GetRolloverString( void ) { wxString result; wxString t; if( b_nameValid ) { result.Append( _T("\"") ); result.Append( GetFullName() ); result.Append( _T("\" ") ); } if( Class != AIS_GPSG_BUDDY ) { t.Printf( _T("%09d"), abs( MMSI ) ); result.Append( t ); result.Append( _T(" ") ); result.Append( GetCountryCode(false) ); } t = trimAISField( CallSign ); if( t.Len() ) { result.Append( _T(" (") ); result.Append( t ); result.Append( _T(")") ); } if( g_bAISRolloverShowClass || ( Class == AIS_SART ) ) { if( result.Len() ) result.Append( _T("\n") ); result.Append( _T("[") ); if( Class == AIS_ATON ) { result.Append( wxGetTranslation( Get_class_string( true ) ) ); result.Append(_T(": ")); result.Append( wxGetTranslation( Get_vessel_type_string( false ) ) ); } else if(b_SarAircraftPosnReport) result.Append(_("SAR Aircraft")); else result.Append( wxGetTranslation( Get_class_string( false ) ) ); result.Append( _T("] ") ); if( ( Class != AIS_ATON ) && ( Class != AIS_BASE ) ) { if( Class == AIS_SART ) { int mmsi_start = MMSI / 1000000; switch( mmsi_start ){ case 970: break; case 972: result += _T("MOB"); break; case 974: result += _T("EPIRB"); break; default: result += _("Unknown"); break; } } if( Class != AIS_SART ) { if( !b_SarAircraftPosnReport ) result.Append( wxGetTranslation( Get_vessel_type_string( false ) ) ); } if( ( Class != AIS_CLASS_B ) && ( Class != AIS_SART ) && !b_SarAircraftPosnReport) { if( ( NavStatus <= 15 ) && ( NavStatus >= 0 ) ) { result.Append( _T(" (") ); result.Append(wxGetTranslation(ais_get_status(NavStatus))); result.Append( _T(")") ); } } else if( Class == AIS_SART ) { result.Append( _T(" (") ); if( NavStatus == RESERVED_14 ) result.Append( _("Active") ); else if( NavStatus == UNDEFINED ) result.Append( _("Testing") ); result.Append( _T(")") ); } } } if( g_bAISRolloverShowCOG && (( SOG <= 102.2 ) || b_SarAircraftPosnReport) && ( ( Class != AIS_ATON ) && ( Class != AIS_BASE ) ) ) { if( result.Len() ) result << _T("\n"); double speed_show = toUsrSpeed( SOG ); if( speed_show < 10.0 ) result << wxString::Format( _T("SOG %.2f "), speed_show ) << getUsrSpeedUnit() << _T(" "); else if( speed_show < 100.0 ) result << wxString::Format( _T("SOG %.1f "), speed_show ) << getUsrSpeedUnit() << _T(" "); else result << wxString::Format( _T("SOG %.0f "), speed_show ) << getUsrSpeedUnit() << _T(" "); int crs = wxRound( COG ); if( b_positionOnceValid ) { if( crs < 360 ) { if( g_bShowMag ) result << wxString::Format( wxString("COG %03d°(M) ", wxConvUTF8 ), (int)gFrame->GetTrueOrMag( crs ) ); else result << wxString::Format( wxString("COG %03d° ", wxConvUTF8 ), (int)gFrame->GetTrueOrMag( crs ) ); } else if( COG == 360.0 ) result << _(" COG Unavailable"); else if( crs == 360 ) result << wxString( " COG 000°", wxConvUTF8 ); } else result << _(" COG Unavailable"); } if( g_bAISRolloverShowCPA && bCPA_Valid ) { if( result.Len() ) result << _T("\n"); result << _("CPA") << _T(" ") << cc1->FormatDistanceAdaptive( CPA ) << _T(" ") << _("in") << _T(" ") << wxString::Format( _T("%.0f"), TCPA ) << _T(" ") << _("min"); } return result; }
wxString AIS_Target_Data::GetRolloverString( void ) { wxString result; wxString t; if( b_nameValid ) { result.Append( _T("\"") ); wxString uret = trimAISField( ShipName ); wxString ret; if( uret == _T("Unknown") ) ret = wxGetTranslation( uret ); else ret = uret; result.Append( ret ); if( strlen( ShipNameExtension ) ) result.Append( wxString( ShipNameExtension, wxConvUTF8 ) ); result.Append( _T("\" ") ); } if( Class != AIS_GPSG_BUDDY ) { t.Printf( _T("%09d"), abs( MMSI ) ); result.Append( t ); } t = trimAISField( CallSign ); if( t.Len() ) { result.Append( _T(" (") ); result.Append( t ); result.Append( _T(")") ); } if( g_bAISRolloverShowClass || ( Class == AIS_SART ) ) { if( result.Len() ) result.Append( _T("\n") ); result.Append( _T("[") ); result.Append( wxGetTranslation( Get_class_string( false ) ) ); result.Append( _T("] ") ); if( ( Class != AIS_ATON ) && ( Class != AIS_BASE ) ) { if( Class == AIS_SART ) { int mmsi_start = MMSI / 1000000; switch( mmsi_start ){ case 970: break; case 972: result += _T("MOB"); break; case 974: result += _T("EPIRB"); break; default: result += _("Unknown"); break; } } if( Class != AIS_SART ) result.Append( wxGetTranslation( Get_vessel_type_string( false ) ) ); if( ( Class != AIS_CLASS_B ) && ( Class != AIS_SART ) ) { if( ( NavStatus <= 15 ) && ( NavStatus >= 0 ) ) { result.Append( _T(" (") ); result.Append(wxGetTranslation(ais_get_status(NavStatus))); result.Append( _T(")") ); } } else if( Class == AIS_SART ) { result.Append( _T(" (") ); if( NavStatus == RESERVED_14 ) result.Append( _("Active") ); else if( NavStatus == UNDEFINED ) result.Append( _("Testing") ); result.Append( _T(")") ); } } } if( g_bAISRolloverShowCOG && ( SOG <= 102.2 ) && ( ( Class != AIS_ATON ) && ( Class != AIS_BASE ) ) ) { if( result.Len() ) result << _T("\n"); if( SOG < 10.0 ) result << wxString::Format( _T("SOG %.2f "), SOG ) << _("Kts") << _T(" "); else result << wxString::Format( _T("SOG %.1f "), SOG ) << _("Kts") << _T(" "); int crs = wxRound( COG ); if( b_positionOnceValid ) { if( crs < 360 ) result << wxString::Format( wxString( " COG %03d°", wxConvUTF8 ), crs ); else if( COG == 360.0 ) result << _(" COG Unavailable"); else if( crs == 360 ) result << wxString( " COG 000°", wxConvUTF8 ); } else result << _(" COG Unavailable"); } if( g_bAISRolloverShowCPA && bCPA_Valid ) { if( result.Len() ) result << _T("\n"); result << _("CPA") << _T(" ") << cc1->FormatDistanceAdaptive( CPA ) << _T(" ") << _("in") << _T(" ") << wxString::Format( _T("%.0f"), TCPA ) << _T(" ") << _("min"); } return result; }