OpenCPN Partial API docs
Loading...
Searching...
No Matches
ais_target_data.cpp
Go to the documentation of this file.
1/***************************************************************************
2 * Copyright (C) 2010 by David S. Register *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, see <https://www.gnu.org/licenses/>. *
16 **************************************************************************/
17
24#include <unordered_map>
25
26#include <wx/datetime.h>
27#include <wx/intl.h>
28#include <wx/string.h>
29
32#include "model/config_vars.h"
33#include "model/navutil_base.h"
34#include "model/own_ship.h"
35
36static std::unordered_map<int, wxString> s_ERI_hash;
37
38void make_hash_ERI(int key, const wxString &description) {
39 s_ERI_hash[key] = description;
40}
41
42void clear_hash_ERI() { s_ERI_hash.clear(); }
43
44static wxString FormatTimeAdaptive(int seconds) {
45 int m = seconds / 60;
46 if (seconds < 100)
47 return wxString::Format("%3ds", seconds);
48 else if (seconds < 3600) {
49 int m = seconds / 60;
50 int s = seconds % 60;
51 return wxString::Format("%2dmin %02ds", m, s);
52 }
53 int h = seconds / 3600;
54 m -= h * 60;
55 return wxString::Format("%2dh %02dmin", h, m);
56}
57
58static wxString html_escape(const wxString &src) {
59 // Escape &, <, > as well as single and double quotes for HTML.
60 wxString ret = src;
61
62 ret.Replace("<", "&lt;");
63 ret.Replace(">", "&gt;");
64
65 // only < and > in 6 bits AIS ascii
66 // ret.Replace("\"", "&quot;");
67 // ret.Replace("&", "&amp;");
68 // ret.Replace("'", "&#39;");
69
70 // Do we care about multiple spaces?
71 // ret.Replace(" ", "&nbsp;");
72 return ret;
73}
74
75wxString trimAISField(char *data) {
76 // Clip any unused characters (@) from data
77
78 wxString field = wxString::From8BitData(data);
79 while (field.Right(1) == '@' || field.Right(1) == ' ') field.RemoveLast();
80
81 // And remove any leading spaces to properly sort and display
82 field.Trim(false);
83
84 return field;
85}
86
87wxString ais_get_status(int index) {
88 static const wxString ais_status[] = {
89 _("Underway using Engine"),
90 _("At Anchor"),
91 _("Not Under Command"),
92 _("Restricted Manoeuvrability"),
93 _("Constrained by draught"),
94 _("Moored"),
95 _("Aground"),
96 _("Engaged in Fishing"),
97 _("Underway Sailing"),
98 _("High Speed Craft"),
99 _("Wing In Ground Effect"),
100 _("Power-driven vessel towing astern (regional use)"),
101 _("Power-driven vessel pushing ahead or towing alongside (regional use)"),
102 _("Reserved 13"),
103 _("Reserved 14"),
104 _("Undefined"),
105 _("AtoN Virtual"),
106 _("AtoN Virtual (On Position)"),
107 _("AtoN Virtual (Off Position)"),
108 _("AtoN Real"),
109 _("AtoN Real (On Position)"),
110 _("AtoN Real(Off Position)")};
111
112 return ais_status[index];
113}
114
115wxString ais_meteo_get_trend(int tend) {
116 wxString trend = "";
117 if (tend < 3) {
118 if (tend == 0)
119 trend = _("steady");
120 else if (tend == 1)
121 trend = _("decreasing");
122 else if (tend == 2)
123 trend = _("increasing");
124 }
125 return trend;
126}
127
128wxString aisMeteoPrecipType(int precip) {
129 wxString prec = "";
130 switch (precip) {
131 case 0:
132 prec = "Reserved";
133 break;
134 case 1:
135 prec = "Rain";
136 break;
137 case 2:
138 prec = "Thunderstorm";
139 break;
140 case 3:
141 prec = "Freezing rain";
142 break;
143 case 4:
144 prec = "Mixed / ice";
145 break;
146 case 5:
147 prec = "Snow";
148 break;
149 default:
150 prec = "not available";
151 // 6 = reserved 7 = not available = default
152 }
153 return prec;
154}
155
156wxString aisMeteoWaterLevelRef(int refID) {
157 wxString ref = "";
158 switch (refID) {
159 case 0:
160 ref = "MLLW";
161 break;
162 case 1:
163 ref = "IGLD-85";
164 break;
165 case 2:
166 ref = "Local river";
167 break;
168 case 3:
169 ref = "STND";
170 break;
171 case 4:
172 ref = "MHHW";
173 break;
174 case 5:
175 ref = "MHW";
176 break;
177 case 6:
178 ref = "MSL";
179 break;
180 case 7:
181 ref = "MLW";
182 break;
183 case 8:
184 ref = "NGVD-29";
185 break;
186 case 9:
187 ref = "NAVD-88";
188 break;
189 case 10:
190 ref = "WGS-84";
191 break;
192 case 11:
193 ref = "LAT";
194 break;
195 case 12:
196 ref = "Pool";
197 break;
198 case 13:
199 ref = "Gauge";
200 break;
201 }
202 return ref;
203}
204
205AisTargetData::AisTargetData(AisTargetCallbacks cb) : m_callbacks(cb) {
206 strncpy(ShipName, "Unknown ", SHIP_NAME_LEN);
207 strncpy(CallSign, " ", 8);
208 strncpy(Destination, " ", DESTINATION_LEN);
209 ShipNameExtension[0] = 0;
210 b_show_AIS_CPA = false;
211
212 SOG = 555.;
213 COG = 666.;
214 HDG = 511.;
215 ROTAIS = -128;
216 Lat = 0.;
217 Lon = 0.;
218
219 wxDateTime now = wxDateTime::Now();
220 now.MakeGMT();
221 PositionReportTicks = now.GetTicks(); // Default is my idea of NOW
222 StaticReportTicks = now.GetTicks();
223 b_lost = false;
224 b_removed = false;
225
226 IMO = 0;
227 MID = 555;
228 MMSI = 666;
229 NavStatus = UNDEFINED;
230 SyncState = 888;
231 SlotTO = 999;
232 ShipType = 19; // "Unknown"
233 b_isDSCtarget = false;
234 m_dscNature = 99;
235 m_dscTXmmsi = 666;
236
237 CPA = 100; // Large values avoid false alarms
238 TCPA = 100;
239
240 Range_NM = -1.;
241 Brg = -1.;
242
243 DimA = DimB = DimC = DimD = 0;
244 ;
245
246 ETA_Mo = 0;
247 ETA_Day = 0;
248 ETA_Hr = 24;
249 ETA_Min = 60;
250
251 Draft = 0.;
252
253 RecentPeriod = 0;
254
255 m_utc_hour = 0;
256 m_utc_min = 0;
257 m_utc_sec = 0;
258
259 Class = AIS_CLASS_A; // default
260 n_alert_state = AIS_NO_ALERT;
261 b_suppress_audio = false;
262 b_positionDoubtful = false;
263 b_positionOnceValid = false;
264 b_nameValid = false;
265
266 Euro_Length = 0; // Extensions for European Inland AIS
267 Euro_Beam = 0;
268 Euro_Draft = 0;
269 strncpy(Euro_VIN, " ", 8);
270 UN_shiptype = 0;
271
272 b_isEuroInland = false;
273 b_blue_paddle = false;
274
275 b_NoTrack = false;
276 b_OwnShip = false;
277 b_PersistTrack = false;
278 b_mPropPersistTrack = false;
279 b_in_ack_timeout = false;
280
281 b_active = false;
282 blue_paddle = 0;
283 bCPA_Valid = false;
284 b_isFollower = false;
285 ROTIND = 0;
286 b_show_track = g_bAISShowTracks;
287 b_SarAircraftPosnReport = false;
288 altitude = 0;
289 b_nameFromCache = false;
290 importance = 0.0;
291 for (unsigned int i = 0; i < AIS_TARGETDATA_MAX_CANVAS; i++)
292 last_scale[i] = 50;
293 met_data.original_mmsi = 0;
294 met_data.stationID = 0;
295 met_data.month = 0;
296 met_data.day = 0;
297 met_data.hour = 24;
298 met_data.minute = 60;
299 met_data.pos_acc = 1;
300 met_data.wind_kn = 122;
301 met_data.wind_gust_kn = 127;
302 met_data.wind_dir = 360;
303 met_data.wind_gust_dir = 360;
304 met_data.air_temp = -102.4;
305 met_data.rel_humid = 101;
306 met_data.dew_point = 50.1;
307 met_data.airpress = 1310;
308 met_data.airpress_tend = 3;
309 met_data.hor_vis = 12.7;
310 met_data.hor_vis_GT = false;
311 met_data.water_lev_dev = 4001 / 100 - 10;
312 met_data.water_level = -32;
313 met_data.water_lev_trend = 3;
314 met_data.current = 25.5;
315 met_data.curr_dir = 360;
316 met_data.wave_height = 25.5;
317 met_data.wave_period = 63;
318 met_data.wave_dir = 360;
319 met_data.swell_height = 25.5;
320 met_data.swell_per = 63;
321 met_data.swell_dir = 360;
322 met_data.seastate = 13;
323 met_data.water_temp = 501;
324 met_data.precipitation = 7;
325 met_data.salinity = 51.;
326 met_data.ice = 3;
327 met_data.vertical_ref = 14;
328}
329
330void AisTargetData::CloneFrom(AisTargetData *q) {
331 strncpy(ShipName, q->ShipName, SHIP_NAME_LEN);
332 strncpy(CallSign, q->CallSign, 8);
333 strncpy(Destination, q->Destination, DESTINATION_LEN);
334 ShipNameExtension[0] = 0;
335 b_show_AIS_CPA = q->b_show_AIS_CPA;
336 ;
337
338 SOG = q->SOG;
339 COG = q->COG;
340 HDG = q->HDG;
341 ROTAIS = q->ROTAIS;
342 Lat = q->Lat;
343 Lon = q->Lon;
344
345 PositionReportTicks = q->PositionReportTicks;
346 StaticReportTicks = q->StaticReportTicks;
347 b_lost = q->b_lost;
348 b_removed = q->b_removed;
349
350 IMO = q->IMO;
351 MID = q->MID;
352 MMSI = q->MMSI;
353 NavStatus = q->NavStatus;
354 SyncState = q->SyncState;
355 SlotTO = q->SlotTO;
356 ShipType = q->ShipType;
357 b_isDSCtarget = q->b_isDSCtarget;
358 m_dscNature = q->m_dscNature;
359 m_dscTXmmsi = q->m_dscTXmmsi;
360
361 CPA = q->CPA;
362 TCPA = q->TCPA;
363
364 Range_NM = q->Range_NM;
365 Brg = q->Brg;
366
367 DimA = q->DimA;
368 DimB = q->DimB;
369 DimC = q->DimC;
370 DimD = q->DimD;
371
372 ETA_Mo = q->ETA_Mo;
373 ETA_Day = q->ETA_Day;
374 ETA_Hr = q->ETA_Hr;
375 ETA_Min = q->ETA_Min;
376
377 Draft = q->Draft;
378
379 RecentPeriod = q->RecentPeriod;
380
381 m_utc_hour = q->m_utc_hour;
382 m_utc_min = q->m_utc_min;
383 m_utc_sec = q->m_utc_sec;
384
385 Class = q->Class;
386 n_alert_state = q->n_alert_state;
387 b_suppress_audio = q->b_suppress_audio;
388 b_positionDoubtful = q->b_positionDoubtful;
389 b_positionOnceValid = q->b_positionOnceValid;
390 b_nameValid = q->b_nameValid;
391
392 Euro_Length = q->Euro_Length; // Extensions for European Inland AIS
393 Euro_Beam = q->Euro_Beam;
394 Euro_Draft = q->Euro_Draft;
395 memcpy(Euro_VIN, q->Euro_VIN, EURO_VIN_LEN);
396 UN_shiptype = q->UN_shiptype;
397
398 b_isEuroInland = q->b_isEuroInland;
399 b_blue_paddle = q->b_blue_paddle;
400
401 b_OwnShip = q->b_OwnShip;
402 b_in_ack_timeout = q->b_in_ack_timeout;
403
404 m_ptrack = q->m_ptrack;
405
406 b_active = q->b_active;
407 blue_paddle = q->blue_paddle;
408 bCPA_Valid = q->bCPA_Valid;
409 ROTIND = q->ROTIND;
410 b_show_track = q->b_show_track;
411 b_SarAircraftPosnReport = q->b_SarAircraftPosnReport;
412 altitude = q->altitude;
413}
414
415AisTargetData::~AisTargetData() { m_ptrack.clear(); }
416// AisTargetData::~AisTargetData() { m_pMetPoint.clear(); } //TODO Needed?
417
418wxString AisTargetData::GetFullName() {
419 wxString retName;
420 if (b_nameValid) {
421 wxString shipName = trimAISField(ShipName);
422 if (shipName == "Unknown")
423 retName = wxGetTranslation(shipName);
424 else
425 retName = shipName;
426
427 if (strlen(ShipNameExtension)) {
428 wxString shipNameExt = trimAISField(ShipNameExtension);
429 retName += shipNameExt;
430 }
431 }
432
433 return retName;
434}
435
436wxString AisTargetData::BuildQueryResult() {
437 wxString html;
438 wxDateTime now = wxDateTime::Now();
439
440 wxString tableStart =
441 "\n<table width=100% border=0 cellpadding=1 cellspacing=0>\n";
442
443 wxString tableEnd = "</table>\n\n";
444 wxString rowStart = "<tr><td><font size=-2>";
445 wxString rowStartH = "<tr><td nowrap>";
446 wxString rowSeparator = "</font></td><td></td><td><b>";
447 wxString rowSeparatorH = "</td><td></td><td>";
448 wxString colSeparator = "<td></td>";
449 wxString rowEnd = "</b></td></tr>\n";
450 wxString vertSpacer = "<tr><td></td></tr>\n\n";
451
452 wxString IMOstr, MMSIstr, ClassStr;
453
454 html << tableStart << "<tr><td nowrap colspan=2>";
455 if (b_nameValid) {
456 html << "<font size=+2><i><b>" << GetFullName();
457 html << "</b></i></font>&nbsp;&nbsp;<b>";
458 }
459
460 if ((Class != AIS_ATON) && (Class != AIS_BASE) && (Class != AIS_GPSG_BUDDY) &&
461 (Class != AIS_SART) && (Class != AIS_METEO)) {
462 html << trimAISField(CallSign) << "</b>" << rowEnd;
463
464 if (Class != AIS_CLASS_B) {
465 if (IMO > 0) IMOstr = wxString::Format("%08d", abs(IMO));
466 }
467 } else
468 html << "</b>" << rowEnd;
469
470 html << vertSpacer;
471
472 if (Class != AIS_GPSG_BUDDY) {
473 MMSIstr = wxString::Format("%09d", abs(MMSI));
474 }
475 ClassStr = wxGetTranslation(Get_class_string(false));
476
477 if (Class == AIS_ATON) {
478 wxString cls("AtoN: ");
479 cls += Get_vessel_type_string(false);
480 ClassStr = wxGetTranslation(cls);
481 }
482
483 if (b_SarAircraftPosnReport) {
484 int airtype = (MMSI % 1000) / 100;
485 ClassStr = airtype == 5 ? _("SAR Helicopter") : _("SAR Aircraft");
486 }
487
488 if (IMOstr.Length())
489 html << "<tr><td colspan=2><table width=100% border=0 cellpadding=0 "
490 "cellspacing=0>"
491 << rowStart << _("MMSI")
492 << "</font></td><td>&nbsp;</td><td><font size=-2>" << _("Class")
493 << "</font></td><td>&nbsp;</td><td align=right><font size=-2>"
494 << _("IMO") << "</font></td></tr>" << rowStartH << "<b>" << MMSIstr
495 << "</b></td><td>&nbsp;</td><td><b>" << ClassStr
496 << "</b></td><td>&nbsp;</td><td align=right><b>" << IMOstr << rowEnd
497 << "</table></td></tr>";
498
499 else if (Class == AIS_METEO) {
500 MMSIstr = wxString::Format("%09d", abs(met_data.original_mmsi));
501 html << "<tr><td colspan=2><table width=100% border=0 cellpadding=0 "
502 "cellspacing=0>"
503 << rowStart << _("MMSI")
504 << "</font></td><td>&nbsp;</td><td align=right><font size=-2>"
505 << _("Class") << "</font></td></tr>" << rowStartH << "<b>" << MMSIstr
506 << "</b></td><td>&nbsp;</td><td align=right><b>"
507 << "<font size=-1>" << ClassStr << rowEnd << rowStart
508 << "<b>ID: " << MMSI;
509 if (met_data.stationID) { // Facilitate to find a Meteo target on SignalK
510 wxString SK_ID = wxString::Format("%06d", (met_data.stationID - 1000000));
511 html << "<td>&nbsp;</td><td align=right>"
512 << "SK-ID: " << SK_ID;
513 }
514 html << rowEnd << "</b></table></td></tr>";
515 } else
516 html << "<tr><td colspan=2><table width=100% border=0 cellpadding=0 "
517 "cellspacing=0>"
518 << rowStart << _("MMSI")
519 << "</font></td><td>&nbsp;</td><td align=right><font size=-2>"
520 << _("Class") << "</font></td></tr>" << rowStartH << "<b>" << MMSIstr
521 << "</b></td><td>&nbsp;</td><td align=right><b>" << ClassStr << rowEnd
522 << "</table></td></tr>";
523
524 if ((Class != AIS_SART)) //&& (Class != AIS_DSC))
525 html << "<tr><td colspan=2><table width=100% border=0 cellpadding=0 "
526 "cellspacing=0>"
527 << rowStart
528 << ((Class == AIS_BASE || Class == AIS_ATON || Class == AIS_METEO)
529 ? _("Nation")
530 : _("Flag"))
531 << rowEnd << "</font></td></tr>" << rowStartH << "<font size=-1><b>"
532 << GetCountryCode(true);
533 if (Class == AIS_CLASS_B && MMSIstr.StartsWith("8")) {
534 html << "<td align=right>" << _("Handheld");
535 }
536 html << rowEnd << "</font></table></td></tr>";
537
538 wxString navStatStr;
539 if ((Class != AIS_BASE) && (Class != AIS_CLASS_B) && (Class != AIS_SART) &&
540 (Class != AIS_METEO)) {
541 html << vertSpacer;
542 if ((NavStatus <= 21) && (NavStatus >= 0))
543 navStatStr = wxGetTranslation(ais_get_status(NavStatus));
544 } else if (Class == AIS_SART) {
545 if (NavStatus == RESERVED_14)
546 navStatStr = _("Active");
547 else if (NavStatus == UNDEFINED)
548 navStatStr = _("Testing");
549 }
550
551 wxString sart_sub_type;
552 if (Class == AIS_SART) {
553 int mmsi_start = MMSI / 1000000;
554 switch (mmsi_start) {
555 case 970:
556 // sart_sub_type = "SART";
557 break;
558 case 972:
559 sart_sub_type = "MOB";
560 break;
561 case 974:
562 sart_sub_type = "EPIRB";
563 break;
564 default:
565 sart_sub_type = _("Unknown");
566 break;
567 }
568 }
569
570 wxString AISTypeStr, UNTypeStr, sizeString;
571 if ((Class != AIS_BASE) && (Class != AIS_SART) && (Class != AIS_DSC) &&
572 (Class != AIS_METEO)) {
573 // Ship type
574 AISTypeStr = wxGetTranslation(Get_vessel_type_string());
575
576 if (b_isEuroInland && UN_shiptype) {
577 auto it = s_ERI_hash.find(UN_shiptype);
578 wxString type;
579 if (it == s_ERI_hash.end())
580 type = _("Undefined");
581 else
582 type = it->second;
583
584 UNTypeStr = wxGetTranslation(type);
585 }
586
587 if (b_SarAircraftPosnReport) {
588 AISTypeStr.Clear();
589 UNTypeStr.Clear();
590 navStatStr.Clear();
591 }
592
593 if (Class == AIS_SART) {
594 if (MSG_14_text.Len()) {
595 html << rowStart << _("Safety Broadcast Message") << rowEnd << rowStartH
596 << "<b>" << MSG_14_text << rowEnd;
597 }
598 }
599
600 // Dimensions
601
602 if (NavStatus != ATON_VIRTUAL && Class != AIS_ARPA && Class != AIS_APRS &&
603 Class != AIS_BUOY) {
604 if ((Class == AIS_CLASS_B) || (Class == AIS_ATON)) {
605 sizeString =
606 wxString::Format("%dm x %dm", (DimA + DimB), (DimC + DimD));
607 } else if (!b_SarAircraftPosnReport) {
608 if ((DimA + DimB + DimC + DimD) == 0) {
609 if (b_isEuroInland) {
610 if (Euro_Length == 0.0) {
611 if (Euro_Draft > 0.01) {
612 sizeString << wxString::Format("---m x ---m x %4.1fm",
613 Euro_Draft);
614 } else {
615 sizeString << "---m x ---m x ---m";
616 }
617 } else {
618 if (Euro_Draft > 0.01) {
619 sizeString << wxString::Format("%5.1fm x %4.1fm x %4.1fm",
620 Euro_Length, Euro_Beam,
621 Euro_Draft);
622 } else {
623 sizeString << wxString::Format("%5.1fm x %4.1fm x ---m\n\n",
624 Euro_Length, Euro_Beam);
625 }
626 }
627 } else {
628 if (Draft > 0.01) {
629 sizeString << wxString::Format("---m x ---m x %4.1fm", Draft);
630 } else {
631 sizeString << "---m x ---m x ---m";
632 }
633 }
634 } else if (Draft < 0.01) {
635 sizeString << wxString::Format("%dm x %dm x ---m", (DimA + DimB),
636 (DimC + DimD));
637 } else {
638 sizeString << wxString::Format("%dm x %dm x %4.1fm", (DimA + DimB),
639 (DimC + DimD), Draft);
640 }
641 }
642 }
643 }
644
645 if (Class == AIS_SART) {
646 html << "<tr><td colspan=2>"
647 << "<b>" << AISTypeStr;
648 if (sart_sub_type.Length()) html << " (" << sart_sub_type << "), ";
649 html << navStatStr;
650 html << rowEnd << "<tr><td colspan=2>"
651 << "<b>" << sizeString << rowEnd;
652 }
653
654 else if (Class == AIS_ATON) {
655 html << "<tr><td colspan=2>"
656 << "<b>" << navStatStr;
657 html << rowEnd << "<tr><td colspan=2>"
658 << "<b>" << sizeString << rowEnd;
659 } else if (Class == AIS_DSC && (ShipType == 12 || ShipType == 16)) {
660 if (ShipType == 16) { // Distress relay
661 html << "<tr><td colspan=2>"
662 << "<b>" << _("Distress relay");
663 if (m_dscTXmmsi > 2000000) {
664 wxString mmsirelay = wxString::Format(" %09d", abs(m_dscTXmmsi));
665 html << " " << _("by:") << mmsirelay;
666 }
667 html << "<b>" << sizeString << rowEnd;
668 }
669 html << "<tr><td colspan=2>" << _("Nature of distress: ") << rowEnd
670 << "<tr><td colspan=2>";
671 if (m_dscNature < 13) {
672 html << "<tr><td colspan=2>"
673 << "<b>" << GetNatureofDistress(m_dscNature) << "<b>" << sizeString
674 << rowEnd << "<tr><td colspan=2>";
675 }
676 } else if ((Class != AIS_BASE) && (Class != AIS_DSC)) {
677 html << "<tr><td colspan=2>"
678 << "<b>" << AISTypeStr;
679 if (navStatStr.Length()) html << ", " << navStatStr;
680 if (UNTypeStr.Length()) html << " (UN Type " << UNTypeStr << ")";
681 html << rowEnd << "<tr><td colspan=2>"
682 << "<b>" << sizeString << rowEnd;
683 }
684
685 if (b_positionOnceValid) {
686 wxString posTypeStr;
687 if (b_positionDoubtful) posTypeStr << _(" (Last Known)");
688
689 now.MakeGMT();
690 int target_age = now.GetTicks() - PositionReportTicks;
691 // wxLogMessage(wxString::Format("** PositionReportTicks %ld %ld %d",
692 // now.GetTicks(), PositionReportTicks,
693 // target_age));
694
695 html << vertSpacer << rowStart << _("Position") << posTypeStr
696 << "</font></td><td align=right><font size=-2>" << _("Report Age")
697 << "</font></td></tr>"
698
699 << rowStartH << "<b>" << toSDMM(1, Lat)
700 << "</b></td><td align=right><b>" << FormatTimeAdaptive(target_age)
701 << rowEnd << rowStartH << "<b>" << toSDMM(2, Lon);
702 if (Class != AIS_METEO)
703 html << rowEnd;
704 else {
705 wxString meteoTime =
706 wxString::Format(" %02d:%02d", met_data.hour, met_data.minute);
707 html << " </td><td align=right></b></font><font size=-3>"
708 << _("Issued (UTC)") << "</font><font size=-1><b>" << meteoTime
709 << "</font>" << rowEnd;
710 }
711 }
712
713 wxString courseStr, sogStr, hdgStr, rotStr, rngStr, brgStr, destStr, etaStr;
714
715 if (Class == AIS_GPSG_BUDDY) {
716 long month, year, day;
717 m_date_string.Mid(0, 2).ToLong(&day);
718 m_date_string.Mid(2, 2).ToLong(&month);
719 m_date_string.Mid(4, 2).ToLong(&year);
720 wxDateTime date;
721 date.SetDay(day);
722 date.SetMonth((wxDateTime::Month)(month - 1));
723 date.SetYear(year + 2000);
724
725 wxString f_date = date.FormatISODate();
726
727 html << vertSpacer << rowStart << _("Report as of") << rowEnd << rowStartH
728 << "<b>" << f_date + "</b> at <b>"
729 << wxString::Format("%d:%d UTC ", m_utc_hour, m_utc_min) << rowEnd;
730 } else {
731 if (Class == AIS_CLASS_A && !b_SarAircraftPosnReport) {
732 html << vertSpacer << rowStart << _("Destination")
733 << "</font></td><td align=right><font size=-2>" << _("ETA (UTC)")
734 << "</font></td></tr>\n"
735 << rowStartH << "<b>";
736 wxString dest = trimAISField(Destination);
737 if (dest.Length())
738 html << html_escape(dest);
739 else
740 html << "---";
741 html << "</b></td><td nowrap align=right><b>";
742
743 if ((ETA_Mo) && (ETA_Hr < 24)) {
744 int yearOffset = 0;
745 if (now.GetMonth() > (ETA_Mo - 1)) yearOffset = 1;
746 wxDateTime eta(ETA_Day, wxDateTime::Month(ETA_Mo - 1),
747 now.GetYear() + yearOffset, ETA_Hr, ETA_Min);
748 html << eta.Format("%b %d %H:%M");
749 } else
750 html << "---";
751 html << rowEnd;
752 }
753
754 if (Class == AIS_CLASS_A || Class == AIS_CLASS_B || Class == AIS_ARPA ||
755 Class == AIS_APRS || Class == AIS_SART || Class == AIS_BUOY) {
756 int crs = wxRound(COG);
757 if (crs < 360) {
758 wxString magString, trueString;
759 if (g_bShowMag)
760 magString << wxString::Format(
761 wxString("%03d%c(M)"), static_cast<int>(m_callbacks.get_mag(COG)),
762 0x00B0);
763 if (g_bShowTrue)
764 trueString << wxString::Format(wxString("%03d%c "), (int)crs, 0x00B0);
765
766 courseStr << trueString << magString;
767 } else if (COG == 360.0)
768 courseStr = "---";
769 else if (crs == 360)
770 courseStr = "0&deg;";
771
772 double speed_show = toUsrSpeed(SOG);
773
774 if ((SOG <= 102.2) || b_SarAircraftPosnReport) {
775 if (speed_show < 10.0)
776 sogStr = wxString::Format("%.2f ", speed_show) + getUsrSpeedUnit();
777 else if (speed_show < 100.0)
778 sogStr = wxString::Format("%.1f ", speed_show) + getUsrSpeedUnit();
779 else
780 sogStr = wxString::Format("%.0f ", speed_show) + getUsrSpeedUnit();
781 }
782 // sogStr = wxString::Format( "%5.2f " +
783 // getUsrSpeedUnit(), toUsrSpeed( SOG ) );
784 else
785 sogStr = "---";
786
787 if ((int)HDG != 511)
788 hdgStr = wxString::Format("%03d&deg;", (int)HDG);
789 else
790 hdgStr = "---";
791
792 if (ROTAIS != -128) {
793 if (ROTAIS == 127)
794 rotStr << "> 5&deg;/30s " << _("Right");
795 else if (ROTAIS == -127)
796 rotStr << "> 5&deg;/30s " << _("Left");
797 else {
798 if (ROTIND > 0)
799 rotStr << wxString::Format("%3d&deg;/Min ", ROTIND) << _("Right");
800 else if (ROTIND < 0)
801 rotStr << wxString::Format("%3d&deg;/Min ", -ROTIND) << _("Left");
802 else
803 rotStr = "0";
804 }
805 } else if (!b_SarAircraftPosnReport)
806 rotStr = "---";
807 }
808 }
809
810 if (b_positionOnceValid && bGPSValid && (Range_NM >= 0.))
811 rngStr = FormatDistanceAdaptive(Range_NM);
812 else
813 rngStr = "---";
814
815 int brg = (int)wxRound(Brg);
816 if (Brg > 359.5) brg = 0;
817 if (b_positionOnceValid && bGPSValid && (Brg >= 0.) && (Range_NM > 0.) &&
818 (fabs(Lat) < 85.)) {
819 wxString magString, trueString;
820 if (g_bShowMag)
821 magString << wxString::Format(wxString("%03d%c(M)"),
822 static_cast<int>(m_callbacks.get_mag(Brg)),
823 0x00B0);
824 if (g_bShowTrue)
825 trueString << wxString::Format(wxString("%03d%c "), (int)Brg, 0x00B0);
826
827 brgStr << trueString << magString;
828 } else
829 brgStr = "---";
830
831 wxString turnRateHdr; // Blank if ATON or BASE or Special Position Report (9)
832 if ((Class != AIS_ATON) && (Class != AIS_BASE) && (Class != AIS_DSC) &&
833 (Class != AIS_METEO)) {
834 html << vertSpacer
835 << "<tr><td colspan=2><table width=100% border=0 cellpadding=0 "
836 "cellspacing=0>"
837 << rowStart << _("Speed")
838 << "</font></td><td>&nbsp;</td><td><font size=-2>" << _("Course")
839 << "</font></td><td>&nbsp;</td><td align=right><font size=-2>";
840 if (!b_SarAircraftPosnReport) html << _("Heading");
841
842 html << "</font></td></tr>" << rowStartH << "<b>" << sogStr
843 << "</b></td><td>&nbsp;</td><td><b>" << courseStr
844 << "</b></td><td>&nbsp;</td><td align=right><b>";
845 if (!b_SarAircraftPosnReport) html << hdgStr;
846 html << rowEnd << "</table></td></tr>" << vertSpacer;
847
848 if (!b_SarAircraftPosnReport) turnRateHdr = _("Turn Rate");
849 }
850 if (Class != AIS_METEO) {
851 html << "<tr><td colspan=2><table width=100% border=0 cellpadding=0 "
852 "cellspacing=0>"
853 << rowStart << _("Range")
854 << "</font></td><td>&nbsp;</td><td><font size=-2>" << _("Bearing")
855 << "</font></td><td>&nbsp;</td><td align=right><font size=-2>"
856 << turnRateHdr << "</font></td></tr>" << rowStartH << "<b>" << rngStr
857 << "</b></td><td>&nbsp;</td><td><b>" << brgStr
858 << "</b></td><td>&nbsp;</td><td align=right><b>";
859 if (!b_SarAircraftPosnReport) html << rotStr;
860 html << rowEnd << "</table></td></tr>" << vertSpacer;
861 }
862
863 if (bCPA_Valid && Class != AIS_METEO) {
864 wxString tcpaStr;
865 tcpaStr << "</b> " << _("in ") << "</td><td align=right><b>"
866 << FormatTimeAdaptive((int)(TCPA * 60.));
867
868 html << /*vertSpacer << */ rowStart << "<font size=-2>" << _("CPA")
869 << "</font>" << rowEnd << rowStartH << "<b>"
870 << FormatDistanceAdaptive(CPA) << tcpaStr << rowEnd;
871 }
872
873 if (Class != AIS_BASE && Class != AIS_METEO) {
874 if (blue_paddle == 1) {
875 html << rowStart << _("Inland Blue Flag") << rowEnd << rowStartH << "<b>"
876 << _("Clear") << rowEnd;
877 } else if (blue_paddle == 2) {
878 html << rowStart << _("Inland Blue Flag") << rowEnd << rowStartH << "<b>"
879 << _("Set") << rowEnd;
880 }
881 }
882
883 if (b_SarAircraftPosnReport) {
884 wxString altStr;
885 if (altitude != 4095)
886 altStr.Printf("%4d m", altitude);
887 else
888 altStr = _("Unknown");
889
890 html << rowStart << _("Altitude")
891 << "</font></td><td>&nbsp;</td><td><font size=-0>" << rowStartH
892 << "<b>" << altStr << "</b></td><td>&nbsp;</td><td><b>" << rowEnd
893 << "</table></td></tr>" << vertSpacer;
894 }
895
896 if (Class == AIS_METEO) {
897 if (met_data.wind_kn < 122) {
898 double userwindspeed = toUsrWindSpeed(met_data.wind_kn);
899 wxString wspeed =
900 wxString::Format("%0.1f %s %d%c", userwindspeed,
901 getUsrWindSpeedUnit(), met_data.wind_dir, 0x00B0);
902
903 double userwindgustspeed = toUsrWindSpeed(met_data.wind_gust_kn);
904 wxString wspeedGust = wxString::Format("%.0f %s %d%c", userwindgustspeed,
905 getUsrWindSpeedUnit(),
906 met_data.wind_gust_dir, 0x00B0);
907 if (met_data.wind_gust_kn >= 126) wspeedGust = "";
908
909 html << vertSpacer << rowStart << _("Wind speed")
910 << "</font></td><td align=right><font size=-2>" << _("Wind gust")
911 << "</font></td></tr>" << rowStartH << "<b>" << wspeed
912 << "</b></td><td align=right><b>" << wspeedGust << rowEnd;
913 }
914
915 if (met_data.water_lev_dev < 30. || met_data.water_level > -32. ||
916 met_data.current < 25.5) {
917 wxString wlevel_txt = _("Water level deviation");
918 wxString wlevel;
919 if (met_data.water_lev_dev < 30.) {
920 double userlevel = toUsrDepth(met_data.water_lev_dev);
921 wlevel =
922 wxString::Format("%.1f %s %s", userlevel, getUsrDepthUnit(),
923 ais_meteo_get_trend(met_data.water_lev_trend));
924 if (met_data.vertical_ref < 14) {
925 wlevel_txt = _("Water level dev. Ref: ");
926 wlevel_txt << aisMeteoWaterLevelRef(met_data.vertical_ref);
927 }
928
929 if (met_data.water_lev_dev >= 30.) wlevel = "";
930
931 } else if (met_data.water_level > -32.) {
932 double userlevel = toUsrDepth(met_data.water_level);
933 wlevel =
934 wxString::Format("%.1f %s %s", userlevel, getUsrDepthUnit(),
935 ais_meteo_get_trend(met_data.water_lev_trend));
936 wlevel_txt = _("Water level");
937 if (met_data.water_level <= -32.) wlevel = "";
938 }
939
940 wxString current = wxString::Format("%.1f kts %d%c", met_data.current,
941 met_data.curr_dir, 0x00B0);
942 if (met_data.current >= 25.5) current = "";
943
944 html << vertSpacer << rowStart << wlevel_txt
945 << "</font></td><td align=right><font size=-2>"
946 << _("Surface current ") << "</font></td></tr>" << rowStartH << "<b>"
947 << wlevel << "</b></td><td align=right><b>" << current << rowEnd;
948 }
949
950 if (met_data.wave_height < 24.6 || met_data.swell_height < 24.6) {
951 double userwave = toUsrDepth(met_data.wave_height);
952 wxString wave = wxString::Format("%.1f %s %d%c %d %s ", userwave,
953 getUsrDepthUnit(), met_data.wave_dir,
954 0x00B0, met_data.wave_period, _("s"));
955 if (met_data.wave_height >= 24.6) wave = "";
956
957 double userswell = toUsrDepth(met_data.swell_height);
958 wxString swell = wxString::Format("%.1f %s %d%c %d %s", userswell,
959 getUsrDepthUnit(), met_data.swell_dir,
960 0x00B0, met_data.swell_per, _("s"));
961 if (met_data.swell_height >= 25.) swell = "";
962
963 html << vertSpacer << rowStart << _("Waves height & period")
964 << "</font></td><td align=right><font size=-2>"
965 << _("Swell height & period ") << "</font></td></tr>" << rowStartH
966 << "<b>" << wave << "</b></td><td align=right><b>" << swell
967 << rowEnd;
968 }
969
970 if (met_data.air_temp != -102.4 || met_data.airpress < 1310) {
971 double usertemp = toUsrTemp(met_data.air_temp);
972 wxString airtemp =
973 wxString::Format("%.1f%c%s", usertemp, 0x00B0, getUsrTempUnit());
974 if (met_data.air_temp == -102.4) airtemp = "";
975
976 wxString airpress =
977 wxString::Format("%d hPa %s", met_data.airpress,
978 ais_meteo_get_trend(met_data.airpress_tend));
979 const int ap = met_data.airpress;
980 if (ap < 800 || ap >= 1310) airpress = "";
981
982 html << vertSpacer << rowStart << _("Air Temperatur")
983 << "</font></td><td align=right><font size=-2>" << _("Air pressure")
984 << "</font></td></tr>" << rowStartH << "<b>" << airtemp
985 << "</b></td><td align=right><b>" << airpress << rowEnd;
986 }
987
988 if (met_data.rel_humid < 101 || met_data.dew_point < 50.) {
989 wxString humid = wxString::Format("%d%c", met_data.rel_humid, '%');
990 if (met_data.rel_humid >= 101) humid = "";
991
992 double usertempDew = toUsrTemp(met_data.dew_point);
993 wxString dewpoint =
994 wxString::Format("%.1f%c%s", usertempDew, 0x00B0, getUsrTempUnit());
995 if (met_data.dew_point >= 50.) dewpoint = "";
996
997 html << vertSpacer << rowStart << _("Relative Humidity")
998 << "</font></td><td align=right><font size=-2>" << _("Dew Point ")
999 << "</font></td></tr>" << rowStartH << "<b>" << humid
1000 << "</b></td><td align=right><b>" << dewpoint << rowEnd;
1001 }
1002
1003 if (met_data.water_temp < 50.1 || met_data.seastate < 13) {
1004 double usertemp = toUsrTemp(met_data.water_temp);
1005 wxString watertemp =
1006 wxString::Format("%.1f%c%s", usertemp, 0x00B0, getUsrTempUnit());
1007 if (met_data.water_temp >= 50.1) watertemp = "";
1008
1009 wxString seastate = wxString::Format("%d Bf ", met_data.seastate);
1010 if (met_data.seastate == 13) seastate = "";
1011
1012 html << vertSpacer << rowStart << _("Water Temperatur")
1013 << "</font></td><td align=right><font size=-2>" << _("Sea state")
1014 << "</font></td></tr>" << rowStartH << "<b>" << watertemp
1015 << "</b></td><td align=right><b>" << seastate << rowEnd;
1016 }
1017
1018 if (met_data.precipitation < 7 || met_data.hor_vis < 12.7) {
1019 wxString precip =
1020 wxString::Format("%s", aisMeteoPrecipType(met_data.precipitation));
1021 if (met_data.precipitation >= 6) precip = "";
1022
1023 double userVisDist = toUsrDistance(met_data.hor_vis);
1024 wxString horVis =
1025 wxString::Format("%s%.1f %s", (met_data.hor_vis_GT ? ">" : ""),
1026 userVisDist, getUsrDistanceUnit());
1027 if (met_data.hor_vis >= 12.7) horVis = "";
1028 html << vertSpacer << rowStart << _("Precipitation")
1029 << "</font></td><td align=right><font size=-2>"
1030 << _("Horizontal Visibility") << "</font></td></tr>" << rowStartH
1031 << "<b>" << precip << "</b></td><td align=right><b>" << horVis
1032 << rowEnd;
1033 }
1034
1035 if (met_data.salinity < 50. || met_data.ice < 2) {
1036 wxString sal = wxString::Format("%.1f%c", met_data.salinity, 0x2030);
1037 if (met_data.salinity >= 50.) sal = "";
1038
1039 wxString icestatus = _("No");
1040 if (met_data.ice == 1) icestatus = _("Yes");
1041 if (met_data.ice >= 2) icestatus = "";
1042
1043 html << vertSpacer << rowStart << _("Sea salinity")
1044 << "</font></td><td align=right><font size=-2>" << _("Ice status")
1045 << "</font></td></tr>" << rowStartH << "<b>" << sal
1046 << "</b></td><td align=right><b>" << icestatus << rowEnd;
1047 }
1048 }
1049 html << "</table>";
1050 return html;
1051}
1052
1053wxString AisTargetData::GetRolloverString() {
1054 wxString result;
1055 wxString t;
1056 if (b_nameValid) {
1057 result.Append("\"");
1058 result.Append(GetFullName());
1059 result.Append("\" ");
1060 }
1061 if (Class != AIS_GPSG_BUDDY) {
1062 t.Printf("%09d", abs(MMSI));
1063 result.Append(t);
1064 result.Append(" ");
1065 result.Append(GetCountryCode(false));
1066 }
1067 t = trimAISField(CallSign);
1068 if (t.Len()) {
1069 result.Append(" (");
1070 result.Append(t);
1071 result.Append(")");
1072 }
1073 if (g_bAISRolloverShowClass || (Class == AIS_SART)) {
1074 if (result.Len()) result.Append("\n");
1075 result.Append("[");
1076 if (Class == AIS_ATON) {
1077 result.Append(wxGetTranslation(Get_class_string(true)));
1078 result.Append(": ");
1079 result.Append(wxGetTranslation(Get_vessel_type_string(false)));
1080 } else if (b_SarAircraftPosnReport) {
1081 int airtype = (MMSI % 1000) / 100;
1082 result.Append(airtype == 5 ? _("SAR Helicopter") : _("SAR Aircraft"));
1083 } else
1084 result.Append(wxGetTranslation(Get_class_string(false)));
1085
1086 result.Append("] ");
1087 if ((Class != AIS_ATON) && (Class != AIS_BASE)) {
1088 if (Class == AIS_SART) {
1089 int mmsi_start = MMSI / 1000000;
1090 switch (mmsi_start) {
1091 case 970:
1092 break;
1093 case 972:
1094 result += "MOB";
1095 break;
1096 case 974:
1097 result += "EPIRB";
1098 break;
1099 default:
1100 result += _("Unknown");
1101 break;
1102 }
1103 }
1104
1105 if (Class != AIS_SART && Class != AIS_METEO) {
1106 if (!b_SarAircraftPosnReport)
1107 result.Append(wxGetTranslation(Get_vessel_type_string(false)));
1108 }
1109
1110 if ((Class != AIS_CLASS_B) && (Class != AIS_SART) && Class != AIS_DSC &&
1111 Class != AIS_METEO && !b_SarAircraftPosnReport) {
1112 if ((NavStatus <= 15) && (NavStatus >= 0)) {
1113 result.Append(" (");
1114 result.Append(wxGetTranslation(ais_get_status(NavStatus)));
1115 result.Append(")");
1116 }
1117 } else if (Class == AIS_SART) {
1118 result.Append(" (");
1119 if (NavStatus == RESERVED_14)
1120 result.Append(_("Active"));
1121 else if (NavStatus == UNDEFINED)
1122 result.Append(_("Testing"));
1123 result.Append(")");
1124 } else if (Class == AIS_DSC) {
1125 result.Append(" (");
1126 result.Append(GetNatureofDistress(m_dscNature));
1127 result.Append(")");
1128 }
1129 }
1130 }
1131
1132 if (g_bAISRolloverShowCOG && ((SOG <= 102.2) || b_SarAircraftPosnReport) &&
1133 !((Class == AIS_ATON) || (Class == AIS_BASE) || (Class == AIS_METEO))) {
1134 if (result.Len()) result << "\n";
1135
1136 double speed_show = toUsrSpeed(SOG);
1137 if (speed_show < 10.0)
1138 result << wxString::Format("SOG %.2f ", speed_show) << getUsrSpeedUnit()
1139 << " ";
1140 else if (speed_show < 100.0)
1141 result << wxString::Format("SOG %.1f ", speed_show) << getUsrSpeedUnit()
1142 << " ";
1143 else
1144 result << wxString::Format("SOG %.0f ", speed_show) << getUsrSpeedUnit()
1145 << " ";
1146
1147 int crs = wxRound(COG);
1148 if (b_positionOnceValid) {
1149 if (crs < 360) {
1150 wxString magString, trueString;
1151 if (g_bShowMag)
1152 magString << wxString::Format(
1153 wxString("%03d%c(M) "),
1154 static_cast<int>(m_callbacks.get_mag(COG)), 0x00B0);
1155 if (g_bShowTrue)
1156 trueString << wxString::Format(wxString("%03d%c "), (int)crs, 0x00B0);
1157
1158 result << trueString << magString;
1159 }
1160
1161 else if (COG == 360.0)
1162 result << _(" COG Unavailable");
1163 else if (crs == 360)
1164 result << wxString(" COG 000\u00B0");
1165 } else
1166 result << _(" COG Unavailable");
1167 }
1168
1169 if (g_bAISRolloverShowCPA && bCPA_Valid && Class != AIS_METEO) {
1170 if (result.Len()) result << "\n";
1171 result << _("CPA") << " " << FormatDistanceAdaptive(CPA) << " " << _("in")
1172 << " " << wxString::Format("%.0f", TCPA) << " " << _("min");
1173 }
1174 if (Class == AIS_METEO) {
1175 if (met_data.wind_kn < 122) {
1176 if (result.Len()) result << "\n";
1177 double userwindspeed = toUsrWindSpeed(met_data.wind_kn);
1178 result << _("Wind speed");
1179 result << wxString::Format(": %0.1f %s", userwindspeed,
1180 getUsrWindSpeedUnit())
1181 << wxString::Format(" %d%c ", met_data.wind_dir, 0x00B0);
1182 }
1183
1184 if (met_data.water_lev_dev < 30.) {
1185 if (result.Len()) result << "\n";
1186 result << _("Water level deviation");
1187 double userdepth;
1188 userdepth = toUsrDepth(met_data.water_lev_dev);
1189 result << wxString::Format(": %.1f %s", userdepth, getUsrDepthUnit());
1190
1191 } else if (met_data.water_level > -32.) {
1192 if (result.Len()) result << "\n";
1193 result << _("Water level");
1194 double userdepth;
1195 userdepth = toUsrDepth(met_data.water_level);
1196 result << wxString::Format(": %.1f %s", userdepth, getUsrDepthUnit());
1197 }
1198
1199 if (met_data.current < 25.) {
1200 if (result.Len()) result << "\n";
1201 result << _("Current");
1202 result << wxString::Format(": %.1f ", met_data.current) << _("kts")
1203 << wxString::Format(" %d%c ", met_data.curr_dir, 0x00B0);
1204 }
1205
1206 if (met_data.wave_height < 24.6) {
1207 if (result.Len()) result << "\n";
1208 double userwh = toUsrDepth(met_data.wave_height);
1209 result << _("Wave height")
1210 << wxString::Format(": %.1f %s", userwh, getUsrDepthUnit())
1211 << " / " << met_data.wave_period << " " << _("s");
1212 }
1213
1214 if (met_data.water_temp < 50.) {
1215 if (result.Len()) result << "\n";
1216 double usertemp = toUsrTemp(met_data.water_temp);
1217 result << _("Water temp");
1218 result << wxString::Format(": %.1f%c", usertemp, 0x00B0)
1219 << getUsrTempUnit();
1220 }
1221
1222 if (met_data.air_temp != -102.4) {
1223 if (result.Len()) result << "\n";
1224 double usertemp = toUsrTemp(met_data.air_temp);
1225 result << _("Air temp");
1226 result << wxString::Format(": %.1f%c", usertemp, 0x00B0)
1227 << getUsrTempUnit() << " ";
1228 }
1229
1230 if (met_data.airpress > 799 && met_data.airpress < 1310) {
1231 if (met_data.air_temp == -102.4 && result.Len()) result << "\n";
1232 result << _("Air press");
1233 result << wxString::Format(": %d hPa", met_data.airpress);
1234 }
1235
1236 if (met_data.hor_vis < 12.) {
1237 if (result.Len()) result << "\n";
1238 double userVisDist = toUsrDistance(met_data.hor_vis);
1239 wxString horVis =
1240 wxString::Format(": %s%.1f %s", (met_data.hor_vis_GT ? ">" : ""),
1241 userVisDist, getUsrDistanceUnit());
1242 result << _("Visibility") << horVis;
1243 }
1244 }
1245 return result;
1246}
1247
1248wxString AisTargetData::Get_vessel_type_string(bool b_short) {
1249 int i = 19;
1250 if (Class == AIS_ATON) {
1251 i = ShipType + 20;
1252 } else
1253 switch (ShipType) {
1254 case 30:
1255 i = 0;
1256 break;
1257 case 31:
1258 i = 1;
1259 break;
1260 case 32:
1261 i = 2;
1262 break;
1263 case 33:
1264 i = 3;
1265 break;
1266 case 34:
1267 i = 4;
1268 break;
1269 case 35:
1270 i = 5;
1271 break;
1272 case 36:
1273 i = 6;
1274 break;
1275 case 37:
1276 i = 7;
1277 break;
1278 case 50:
1279 i = 9;
1280 break;
1281 case 51:
1282 i = 10;
1283 break;
1284 case 52:
1285 i = 11;
1286 break;
1287 case 53:
1288 i = 12;
1289 break;
1290 case 54:
1291 i = 13;
1292 break;
1293 case 55:
1294 i = 14;
1295 break;
1296 case 58:
1297 i = 15;
1298 break;
1299 default:
1300 i = 19;
1301 break;
1302 }
1303
1304 if ((Class == AIS_CLASS_B) || (Class == AIS_CLASS_A)) {
1305 if ((ShipType >= 40) && (ShipType < 50)) i = 8;
1306
1307 if ((ShipType >= 60) && (ShipType < 70)) i = 16;
1308
1309 if ((ShipType >= 70) && (ShipType < 80)) i = 17;
1310
1311 if ((ShipType >= 80) && (ShipType < 90)) i = 18;
1312 } else if (Class == AIS_GPSG_BUDDY)
1313 i = 52;
1314 else if (Class == AIS_ARPA)
1315 i = 55;
1316 else if (Class == AIS_APRS)
1317 i = 56;
1318 else if (Class == AIS_BUOY)
1319 i = 57;
1320 else if (Class == AIS_DSC)
1321 i = (ShipType == 12 || ShipType == 16) ? 54 : 53; // 12 & 16 is distress
1322
1323 if (!b_short)
1324 return ais_get_type(i);
1325 else
1326 return ais_get_short_type(i);
1327}
1328
1329wxString AisTargetData::Get_class_string(bool b_short) {
1330 switch (Class) {
1331 case AIS_CLASS_A:
1332 return _("A");
1333 case AIS_CLASS_B:
1334 return _("B");
1335 case AIS_ATON:
1336 return b_short ? _("AtoN") : _("Aid to Navigation");
1337 case AIS_BASE:
1338 return b_short ? _("Base") : _("Base Station");
1339 case AIS_GPSG_BUDDY:
1340 return b_short ? _("Buddy") : _("GPSGate Buddy");
1341 case AIS_DSC:
1342 if (ShipType == 12 || (ShipType == 16 && m_dscNature < 13))
1343 return b_short ? _("DSC") : _("DSC Distress");
1344 else
1345 return b_short ? _("DSC") : _("DSC Position Report");
1346 case AIS_SART:
1347 return b_short ? _("SART") : _("SART");
1348 case AIS_ARPA:
1349 return b_short ? _("ARPA") : _("ARPA");
1350 case AIS_BUOY:
1351 return b_short ? _("Buoy") : _("BUOY");
1352 case AIS_APRS:
1353 return b_short ? _("APRS") : _("APRS Position Report");
1354 case AIS_METEO:
1355 return b_short ? _("Meteo") : _("Meteorologic");
1356
1357 default:
1358 return b_short ? _("Unk") : _("Unknown");
1359 }
1360}
1361
1362wxString AisTargetData::GetNatureofDistress(int dscnature) {
1363 // Natures of distress from: Rec. ITU-R M.493-10.
1364 wxString dscDistressType[] = {_("Fire, explosion"),
1365 _("Flooding"),
1366 _("Collision"),
1367 _("Grounding"),
1368 _("Listing, in danger of capsizing"),
1369 _("Sinking"),
1370 _("Disabled and adrift"),
1371 _("Undesignated distress"),
1372 _("Abandoning ship"),
1373 _("Piracy/armed robbery attack"),
1374 _("Man overboard"),
1375 "-",
1376 _("EPIRB emission")};
1377 if (dscnature >= 0 && dscnature < 13) return dscDistressType[dscnature];
1378
1379 return "";
1380}
1381
1382void AisTargetData::Toggle_AIS_CPA() {
1383 b_show_AIS_CPA = !b_show_AIS_CPA ? true : false;
1384}
1385
1386void AisTargetData::ToggleShowTrack() {
1387 b_show_track = !b_show_track ? true : false;
1388}
1389
1390bool AisTargetData::IsValidMID(int mid) {
1391 if (mid >= 201 && mid <= 775) return true;
1392 return false;
1393}
1394
1395// Get country name and code according to ITU 2023-02
1396// (http://www.itu.int/en/ITU-R/terrestrial/fmd/Pages/mid.aspx)
1397wxString AisTargetData::GetCountryCode(bool b_CntryLongStr) {
1398 if (Class == AIS_BUOY) return "";
1399 /***** Check for a valid MID *****/
1400 // Meteo adaption
1401 int tmpMmsi = met_data.original_mmsi ? met_data.original_mmsi : MMSI;
1402 // First check the most common case
1403 int nMID = tmpMmsi / 1000000;
1404 if (!IsValidMID(nMID) || Class == AIS_ATON) {
1405 // SART, MOB, EPIRB starts with 97 and don't use MID (ITU-R M.1371-5)
1406 // or healthy check
1407 if (tmpMmsi < 1000 || 97 == tmpMmsi / 10000000) return "";
1408
1409 // Find MID when not in first position like e.g. SAR/ATON
1410 wxString s_mmsi;
1411 s_mmsi << tmpMmsi;
1412 bool foundMID = false;
1413 size_t i;
1414 i = nMID > 900 ? 2 : 0; // AIS_ATON or others where MMSI starts with 9x
1415 for (i; i < s_mmsi.length() - 3; i++) {
1416 nMID = wxAtoi(s_mmsi.Mid(i, 3));
1417 if (IsValidMID(nMID)) {
1418 foundMID = true;
1419 break;
1420 }
1421 }
1422 if (!foundMID) return "";
1423 }
1424
1425#if wxUSE_XLOCALE || !wxCHECK_VERSION(3, 0, 0)
1426
1427 switch (nMID) {
1428 case 201:
1429 return b_CntryLongStr ? _("Albania") : "AL";
1430 case 202:
1431 return b_CntryLongStr ? _("Andorra") : "AD";
1432 case 203:
1433 return b_CntryLongStr ? _("Austria") : "AT";
1434 case 204:
1435 return b_CntryLongStr ? _("Azores") : "AZ";
1436 case 205:
1437 return b_CntryLongStr ? _("Belgium") : "BE";
1438 case 206:
1439 return b_CntryLongStr ? _("Belarus") : "BY";
1440 case 207:
1441 return b_CntryLongStr ? _("Bulgaria") : "BG";
1442 case 208:
1443 return b_CntryLongStr ? _("Vatican City State") : "VA";
1444 case 209:
1445 case 210:
1446 return b_CntryLongStr ? _("Cyprus") : "CY";
1447 case 211:
1448 return b_CntryLongStr ? _("Germany") : "DE";
1449 case 212:
1450 return b_CntryLongStr ? _("Cyprus") : "CY";
1451 case 213:
1452 return b_CntryLongStr ? _("Georgia") : "GE";
1453 case 214:
1454 return b_CntryLongStr ? _("Moldova") : "MD";
1455 case 215:
1456 return b_CntryLongStr ? _("Malta") : "MT";
1457 case 216:
1458 return b_CntryLongStr ? _("Armenia") : "AM";
1459 case 218:
1460 return b_CntryLongStr ? _("Germany") : "DE";
1461 case 219:
1462 case 220:
1463 return b_CntryLongStr ? _("Denmark") : "DK";
1464 case 224:
1465 return b_CntryLongStr ? _("Spain") : "ES";
1466 case 225:
1467 return b_CntryLongStr ? _("Spain") : "ES";
1468 case 226:
1469 case 227:
1470 case 228:
1471 return b_CntryLongStr ? _("France") : "FR";
1472 case 229:
1473 return b_CntryLongStr ? _("Malta") : "MT";
1474 case 230:
1475 return b_CntryLongStr ? _("Finland") : "FI";
1476 case 231:
1477 return b_CntryLongStr ? _("Faroe Islands") : "FO";
1478 case 232:
1479 case 233:
1480 case 234:
1481 case 235:
1482 return b_CntryLongStr ? _("Great Britain") : "GB";
1483 case 236:
1484 return b_CntryLongStr ? _("Gibraltar") : "GI";
1485 case 237:
1486 return b_CntryLongStr ? _("Greece") : "GR";
1487 case 238:
1488 return b_CntryLongStr ? _("Croatia") : "HR";
1489 case 239:
1490 case 240:
1491 case 241:
1492 return b_CntryLongStr ? _("Greece") : "GR";
1493 case 242:
1494 return b_CntryLongStr ? _("Morocco") : "MA";
1495 case 243:
1496 return b_CntryLongStr ? _("Hungary") : "HU";
1497 case 244:
1498 case 245:
1499 case 246:
1500 return b_CntryLongStr ? _("Netherlands") : "NL";
1501 case 247:
1502 return b_CntryLongStr ? _("Italy") : "IT";
1503 case 248:
1504 case 249:
1505 return b_CntryLongStr ? _("Malta") : "MT";
1506 case 250:
1507 return b_CntryLongStr ? _("Ireland") : "IE";
1508 case 251:
1509 return b_CntryLongStr ? _("Iceland") : "IS";
1510 case 252:
1511 return b_CntryLongStr ? _("Liechtenstein") : "LI";
1512 case 253:
1513 return b_CntryLongStr ? _("Luxembourg") : "LU";
1514 case 254:
1515 return b_CntryLongStr ? _("Monaco") : "MC";
1516 case 255:
1517 return b_CntryLongStr ? _("Madeira") : "PT";
1518 case 256:
1519 return b_CntryLongStr ? _("Malta") : "MT";
1520 case 257:
1521 case 258:
1522 case 259:
1523 return b_CntryLongStr ? _("Norway") : "NO";
1524 case 261:
1525 return b_CntryLongStr ? _("Poland") : "PL";
1526 case 262:
1527 return b_CntryLongStr ? _("Montenegro") : "ME";
1528 case 263:
1529 return b_CntryLongStr ? _("Portugal") : "PT";
1530 case 264:
1531 return b_CntryLongStr ? _("Romania") : "RO";
1532 case 265:
1533 case 266:
1534 return b_CntryLongStr ? _("Sweden") : "SE";
1535 case 267:
1536 return b_CntryLongStr ? _("Slovak Republic") : "SK";
1537 case 268:
1538 return b_CntryLongStr ? _("San Marino") : "SM";
1539 case 269:
1540 return b_CntryLongStr ? _("Switzerland") : "CH";
1541 case 270:
1542 return b_CntryLongStr ? _("Czech Republic") : "CZ";
1543 case 271:
1544 return b_CntryLongStr ? _("Turkey") : "TR";
1545 case 272:
1546 return b_CntryLongStr ? _("Ukraine") : "UA";
1547 case 273:
1548 return b_CntryLongStr ? _("Russian") : "RU";
1549 case 274:
1550 return b_CntryLongStr ? _("Macedonia") : "MK";
1551 case 275:
1552 return b_CntryLongStr ? _("Latvia") : "LV";
1553 case 276:
1554 return b_CntryLongStr ? _("Estonia") : "EE";
1555 case 277:
1556 return b_CntryLongStr ? _("Lithuania") : "LT";
1557 case 278:
1558 return b_CntryLongStr ? _("Slovenia") : "SI";
1559 case 279:
1560 return b_CntryLongStr ? _("Serbia") : "RS";
1561 case 301:
1562 return b_CntryLongStr ? _("Anguilla") : "AI";
1563 case 303:
1564 return b_CntryLongStr ? _("Alaska") : "AK";
1565 case 304:
1566 case 305:
1567 return b_CntryLongStr ? _("Antigua and Barbuda") : "AG";
1568 case 306:
1569 return b_CntryLongStr ? _("Antilles") : "AN";
1570 case 307:
1571 return b_CntryLongStr ? _("Aruba") : "AW";
1572 case 308:
1573 case 309:
1574 return b_CntryLongStr ? _("Bahamas") : "BS";
1575 case 310:
1576 return b_CntryLongStr ? _("Bermuda") : "BM";
1577 case 311:
1578 return b_CntryLongStr ? _("Bahamas") : "BS";
1579 case 312:
1580 return b_CntryLongStr ? _("Belize") : "BZ";
1581 case 314:
1582 return b_CntryLongStr ? _("Barbados") : "BB";
1583 case 316:
1584 return b_CntryLongStr ? _("Canada") : "CA";
1585 case 319:
1586 return b_CntryLongStr ? _("Cayman Islands") : "KY";
1587 case 321:
1588 return b_CntryLongStr ? _("Costa Rica") : "CR";
1589 case 323:
1590 return b_CntryLongStr ? _("Cuba") : "CU";
1591 case 325:
1592 return b_CntryLongStr ? _("Dominica") : "DM";
1593 case 327:
1594 return b_CntryLongStr ? _("Dominican Republic") : "DM";
1595 case 329:
1596 return b_CntryLongStr ? _("Guadeloupe") : "GP";
1597 case 330:
1598 return b_CntryLongStr ? _("Grenada") : "GD";
1599 case 331:
1600 return b_CntryLongStr ? _("Greenland") : "GL";
1601 case 332:
1602 return b_CntryLongStr ? _("Guatemala") : "GT";
1603 case 334:
1604 return b_CntryLongStr ? _("Honduras") : "HN";
1605 case 336:
1606 return b_CntryLongStr ? _("Haiti") : "HT";
1607 case 338:
1608 return b_CntryLongStr ? _("United States of America") : "US";
1609 case 339:
1610 return b_CntryLongStr ? _("Jamaica") : "JM";
1611 case 341:
1612 return b_CntryLongStr ? _("Saint Kitts and Nevis") : "KN";
1613 case 343:
1614 return b_CntryLongStr ? _("Saint Lucia") : "LC";
1615 case 345:
1616 return b_CntryLongStr ? _("Mexico") : "MX";
1617 case 347:
1618 return b_CntryLongStr ? _("Martinique") : "MQ";
1619 case 348:
1620 return b_CntryLongStr ? _("Montserrat") : "MS";
1621 case 350:
1622 return b_CntryLongStr ? _("Nicaragua") : "NI";
1623 case 351:
1624 case 352:
1625 case 353:
1626 case 354:
1627 case 355:
1628 case 356:
1629 case 357:
1630 return b_CntryLongStr ? _("Panama") : "PA";
1631 case 358:
1632 return b_CntryLongStr ? _("Puerto Rico") : "PR";
1633 case 359:
1634 return b_CntryLongStr ? _("El Salvador") : "SV";
1635 case 361:
1636 return b_CntryLongStr ? _("Saint Pierre and Miquelon") : "PM";
1637 case 362:
1638 return b_CntryLongStr ? _("Trinidad and Tobago") : "TT";
1639 case 364:
1640 return b_CntryLongStr ? _("Turks and Caicos Islands") : "TC";
1641 case 366:
1642 case 367:
1643 case 368:
1644 case 369:
1645 return b_CntryLongStr ? _("United States of America") : "US";
1646 case 370:
1647 case 371:
1648 case 372:
1649 case 373:
1650 case 374:
1651 return b_CntryLongStr ? _("Panama") : "PA";
1652 case 375:
1653 case 376:
1654 case 377:
1655 return b_CntryLongStr ? _("Saint Vincent and the Grenadines") : "VC";
1656 case 378:
1657 return b_CntryLongStr ? _("British Virgin Islands") : "VG";
1658 case 379:
1659 return b_CntryLongStr ? _("United States Virgin Islands") : "AE";
1660 case 401:
1661 return b_CntryLongStr ? _("Afghanistan") : "AF";
1662 case 403:
1663 return b_CntryLongStr ? _("Saudi Arabia") : "SA";
1664 case 405:
1665 return b_CntryLongStr ? _("Bangladesh") : "BD";
1666 case 408:
1667 return b_CntryLongStr ? _("Bahrain") : "BH";
1668 case 410:
1669 return b_CntryLongStr ? _("Bhutan") : "BT";
1670 case 412:
1671 case 413:
1672 case 414:
1673 return b_CntryLongStr ? _("China") : "CN";
1674 case 416:
1675 return b_CntryLongStr ? _("Taiwan") : "TW";
1676 case 417:
1677 return b_CntryLongStr ? _("Sri Lanka") : "LK";
1678 case 419:
1679 return b_CntryLongStr ? _("India") : "IN";
1680 case 422:
1681 return b_CntryLongStr ? _("Iran") : "IR";
1682 case 423:
1683 return b_CntryLongStr ? _("Azerbaijani Republic") : "AZ";
1684 case 425:
1685 return b_CntryLongStr ? _("Iraq") : "IQ";
1686 case 428:
1687 return b_CntryLongStr ? _("Israel") : "IL";
1688 case 431:
1689 return b_CntryLongStr ? _("Japan") : "JP";
1690 case 432:
1691 return b_CntryLongStr ? _("Japan") : "JP";
1692 case 434:
1693 return b_CntryLongStr ? _("Turkmenistan") : "TM";
1694 case 436:
1695 return b_CntryLongStr ? _("Kazakhstan") : "KZ";
1696 case 437:
1697 return b_CntryLongStr ? _("Uzbekistan") : "UZ";
1698 case 438:
1699 return b_CntryLongStr ? _("Jordan") : "JO";
1700 case 440:
1701 case 441:
1702 return b_CntryLongStr ? _("Korea") : "KR";
1703 case 443:
1704 return b_CntryLongStr ? _("Palestine") : "PS";
1705 case 445:
1706 return b_CntryLongStr ? _("People's Rep. of Korea") : "KP";
1707 case 447:
1708 return b_CntryLongStr ? _("Kuwait") : "KW";
1709 case 450:
1710 return b_CntryLongStr ? _("Lebanon") : "LB";
1711 case 451:
1712 return b_CntryLongStr ? _("Kyrgyz Republic") : "KG";
1713 case 453:
1714 return b_CntryLongStr ? _("Macao") : "MO";
1715 case 455:
1716 return b_CntryLongStr ? _("Maldives") : "MV";
1717 case 457:
1718 return b_CntryLongStr ? _("Mongolia") : "MN";
1719 case 459:
1720 return b_CntryLongStr ? _("Nepal") : "NP";
1721 case 461:
1722 return b_CntryLongStr ? _("Oman") : "OM";
1723 case 463:
1724 return b_CntryLongStr ? _("Pakistan") : "PK";
1725 case 466:
1726 return b_CntryLongStr ? _("Qatar") : "QA";
1727 case 468:
1728 return b_CntryLongStr ? _("Syrian Arab Republic") : "SY";
1729 case 470:
1730 case 471:
1731 return b_CntryLongStr ? _("United Arab Emirates") : "AE";
1732 case 472:
1733 return b_CntryLongStr ? _("Tajikistan") : "TJ";
1734 case 473:
1735 case 475:
1736 return b_CntryLongStr ? _("Yemen") : "YE";
1737 case 477:
1738 return b_CntryLongStr ? _("Hong Kong") : "HK";
1739 case 478:
1740 return b_CntryLongStr ? _("Bosnia and Herzegovina") : "BA";
1741 case 501:
1742 return b_CntryLongStr ? _("Adelie Land") : "TF";
1743 case 503:
1744 return b_CntryLongStr ? _("Australia") : "AU";
1745 case 506:
1746 return b_CntryLongStr ? _("Myanmar") : "MM";
1747 case 508:
1748 return b_CntryLongStr ? _("Brunei Darussalam") : "BN";
1749 case 510:
1750 return b_CntryLongStr ? _("Micronesia") : "FM";
1751 case 511:
1752 return b_CntryLongStr ? _("Palau") : "PW";
1753 case 512:
1754 return b_CntryLongStr ? _("New Zealand") : "NZ";
1755 case 514:
1756 case 515:
1757 return b_CntryLongStr ? _("Cambodia") : "KH";
1758 case 516:
1759 return b_CntryLongStr ? _("Christmas Island") : "CX";
1760 case 518:
1761 return b_CntryLongStr ? _("Cook Islands") : "CK";
1762 case 520:
1763 return b_CntryLongStr ? _("Fiji") : "FJ";
1764 case 523:
1765 return b_CntryLongStr ? _("Cocos (Keeling) Islands") : "CC";
1766 case 525:
1767 return b_CntryLongStr ? _("Indonesia") : "ID";
1768 case 529:
1769 return b_CntryLongStr ? _("Kiribati") : "KI";
1770 case 531:
1771 return b_CntryLongStr ? _("Lao People's Dem. Rep.") : "LA";
1772 case 533:
1773 return b_CntryLongStr ? _("Malaysia") : "MY";
1774 case 536:
1775 return b_CntryLongStr ? _("Northern Mariana Islands") : "MP";
1776 case 538:
1777 return b_CntryLongStr ? _("Marshall Islands") : "MH";
1778 case 540:
1779 return b_CntryLongStr ? _("New Caledonia") : "NC";
1780 case 542:
1781 return b_CntryLongStr ? _("Niue") : "NU";
1782 case 544:
1783 return b_CntryLongStr ? _("Nauru") : "NR";
1784 case 546:
1785 return b_CntryLongStr ? _("French Polynesia") : "PF";
1786 case 548:
1787 return b_CntryLongStr ? _("Philippines") : "PH";
1788 case 550:
1789 return b_CntryLongStr ? _("East Timor") : "TL";
1790 case 553:
1791 return b_CntryLongStr ? _("Papua New Guinea") : "PG";
1792 case 555:
1793 return b_CntryLongStr ? _("Pitcairn Island") : "PN";
1794 case 557:
1795 return b_CntryLongStr ? _("Solomon Islands") : "SB";
1796 case 559:
1797 return b_CntryLongStr ? _("American Samoa") : "AS";
1798 case 561:
1799 return b_CntryLongStr ? _("Samoa") : "WS";
1800 case 563:
1801 case 564:
1802 case 565:
1803 case 566:
1804 return b_CntryLongStr ? _("Singapore") : "SG";
1805 case 567:
1806 return b_CntryLongStr ? _("Thailand") : "TH";
1807 case 570:
1808 return b_CntryLongStr ? _("Tonga") : "TO";
1809 case 572:
1810 return b_CntryLongStr ? _("Tuvalu") : "TV";
1811 case 574:
1812 return b_CntryLongStr ? _("Viet Nam") : "VN";
1813 case 576:
1814 case 577:
1815 return b_CntryLongStr ? _("Vanuatu") : "VU";
1816 case 578:
1817 return b_CntryLongStr ? _("Wallis and Futuna Islands") : "WF";
1818 case 601:
1819 return b_CntryLongStr ? _("South Africa") : "ZA";
1820 case 603:
1821 return b_CntryLongStr ? _("Angola") : "AO";
1822 case 605:
1823 return b_CntryLongStr ? _("Algeria") : "DZ";
1824 case 607:
1825 return b_CntryLongStr ? _("Saint Paul") : "TF";
1826 case 608:
1827 return b_CntryLongStr ? _("Ascension Island") : "SH";
1828 case 609:
1829 return b_CntryLongStr ? _("Burundi") : "BI";
1830 case 610:
1831 return b_CntryLongStr ? _("Benin") : "BJ";
1832 case 611:
1833 return b_CntryLongStr ? _("Botswana") : "BW";
1834 case 612:
1835 return b_CntryLongStr ? _("Central African Republic") : "CF";
1836 case 613:
1837 return b_CntryLongStr ? _("Cameroon") : "CM";
1838 case 615:
1839 return b_CntryLongStr ? _("Congo") : "CD";
1840 case 616:
1841 return b_CntryLongStr ? _("Comoros") : "KM";
1842 case 617:
1843 return b_CntryLongStr ? _("Capo Verde") : "CV";
1844 case 618:
1845 return b_CntryLongStr ? _("Crozet Archipelago") : "TF";
1846 case 619:
1847 return b_CntryLongStr ? _("Ivory Coast") : "CI";
1848 case 620:
1849 return b_CntryLongStr ? _("Comoros (Union of the)") : "KM";
1850 case 621:
1851 return b_CntryLongStr ? _("Djibouti") : "DJ";
1852 case 622:
1853 return b_CntryLongStr ? _("Egypt") : "EG";
1854 case 624:
1855 return b_CntryLongStr ? _("Ethiopia") : "ET";
1856 case 625:
1857 return b_CntryLongStr ? _("Eritrea") : "ER";
1858 case 626:
1859 return b_CntryLongStr ? _("Gabonese Republic") : "GA";
1860 case 627:
1861 return b_CntryLongStr ? _("Ghana") : "GH";
1862 case 629:
1863 return b_CntryLongStr ? _("Gambia") : "GM";
1864 case 630:
1865 return b_CntryLongStr ? _("Guinea-Bissau") : "GW";
1866 case 631:
1867 return b_CntryLongStr ? _("Equatorial Guinea") : "GQ";
1868 case 632:
1869 return b_CntryLongStr ? _("Guinea") : "GN";
1870 case 633:
1871 return b_CntryLongStr ? _("Burkina Faso") : "BF";
1872 case 634:
1873 return b_CntryLongStr ? _("Kenya") : "KE";
1874 case 635:
1875 return b_CntryLongStr ? _("Kerguelen Islands") : "TF";
1876 case 636:
1877 case 637:
1878 return b_CntryLongStr ? _("Liberia") : "LR";
1879 case 638:
1880 return b_CntryLongStr ? _("South Sudan (Republic of)") : "SS";
1881 case 642:
1882 return b_CntryLongStr ? _("Libya") : "LY";
1883 case 644:
1884 return b_CntryLongStr ? _("Lesotho") : "LS";
1885 case 645:
1886 return b_CntryLongStr ? _("Mauritius") : "MU";
1887 case 647:
1888 return b_CntryLongStr ? _("Madagascar") : "MG";
1889 case 649:
1890 return b_CntryLongStr ? _("Mali") : "ML";
1891 case 650:
1892 return b_CntryLongStr ? _("Mozambique") : "MZ";
1893 case 654:
1894 return b_CntryLongStr ? _("Mauritania") : "MR";
1895 case 655:
1896 return b_CntryLongStr ? _("Malawi") : "MW";
1897 case 656:
1898 return b_CntryLongStr ? _("Niger") : "NE";
1899 case 657:
1900 return b_CntryLongStr ? _("Nigeria") : "NG";
1901 case 659:
1902 return b_CntryLongStr ? _("Namibia") : "NA";
1903 case 660:
1904 return b_CntryLongStr ? _("Reunion") : "RE";
1905 case 661:
1906 return b_CntryLongStr ? _("Rwanda") : "RW";
1907 case 662:
1908 return b_CntryLongStr ? _("Sudan") : "SD";
1909 case 663:
1910 return b_CntryLongStr ? _("Senegal") : "SN";
1911 case 664:
1912 return b_CntryLongStr ? _("Seychelles") : "SC";
1913 case 665:
1914 return b_CntryLongStr ? _("Saint Helena") : "SH";
1915 case 666:
1916 return b_CntryLongStr ? _("Somalia") : "SO";
1917 case 667:
1918 return b_CntryLongStr ? _("Sierra Leone") : "SL";
1919 case 668:
1920 return b_CntryLongStr ? _("Sao Tome and Principe") : "ST";
1921 case 669:
1922 return b_CntryLongStr ? _("Eswatini") : "SZ";
1923 case 670:
1924 return b_CntryLongStr ? _("Chad") : "TD";
1925 case 671:
1926 return b_CntryLongStr ? _("Togolese Republic") : "TG";
1927 case 672:
1928 return b_CntryLongStr ? _("Tunisia") : "TN";
1929 case 674:
1930 return b_CntryLongStr ? _("Tanzania") : "TZ";
1931 case 675:
1932 return b_CntryLongStr ? _("Uganda") : "UG";
1933 case 676:
1934 return b_CntryLongStr ? _("Dem Rep.of the Congo") : "CD";
1935 case 677:
1936 return b_CntryLongStr ? _("Tanzania") : "TZ";
1937 case 678:
1938 return b_CntryLongStr ? _("Zambia") : "ZM";
1939 case 679:
1940 return b_CntryLongStr ? _("Zimbabwe") : "ZW";
1941 case 701:
1942 return b_CntryLongStr ? _("Argentine Republic") : "AR";
1943 case 710:
1944 return b_CntryLongStr ? _("Brazil") : "BR";
1945 case 720:
1946 return b_CntryLongStr ? _("Bolivia") : "BO";
1947 case 725:
1948 return b_CntryLongStr ? _("Chile") : "CL";
1949 case 730:
1950 return b_CntryLongStr ? _("Colombia") : "CO";
1951 case 735:
1952 return b_CntryLongStr ? _("Ecuador") : "EC";
1953 case 740:
1954 return b_CntryLongStr ? _("Falkland Islands") : "FK";
1955 case 745:
1956 return b_CntryLongStr ? _("France - Guiana") : "GY";
1957 case 750:
1958 return b_CntryLongStr ? _("Guyana") : "GY";
1959 case 755:
1960 return b_CntryLongStr ? _("Paraguay") : "PY";
1961 case 760:
1962 return b_CntryLongStr ? _("Peru") : "PE";
1963 case 765:
1964 return b_CntryLongStr ? _("Suriname") : "SR";
1965 case 770:
1966 return b_CntryLongStr ? _("Uruguay") : "UY";
1967 case 775:
1968 return b_CntryLongStr ? _("Venezuela") : "VE";
1969
1970 default:
1971 return "";
1972 }
1973#else
1974 return "";
1975#endif
1976}
1977
1978wxString ais_get_type(int index) {
1979 static const wxString ais_type[] = {
1980 _("Fishing Vessel"), // 30 0
1981 _("Towing Vessel"), // 31 1
1982 _("Towing Vessel, Long"), // 32 2
1983 _("Dredger"), // 33 3
1984 _("Diving Ops Vessel"), // 34 4
1985 _("Military Vessel"), // 35 5
1986 _("Sailing Vessel"), // 36 6
1987 _("Pleasure craft"), // 37 7
1988 _("High Speed Craft"), // 4x 8
1989 _("Pilot Vessel"), // 50 9
1990 _("Search and Rescue Vessel"), // 51 10
1991 _("Tug"), // 52 11
1992 _("Port Tender"), // 53 12
1993 _("Pollution Control Vessel"), // 54 13
1994 _("Law Enforcement Vessel"), // 55 14
1995 _("Medical Transport"), // 58 15
1996 _("Passenger Ship"), // 6x 16
1997 _("Cargo Ship"), // 7x 17
1998 _("Tanker"), // 8x 18
1999 _("Unknown"), // 19
2000 _("Unspecified"), // 00 20
2001 _("Reference Point"), // 01 21
2002 _("RACON"), // 02 22
2003 _("Fixed Structure"), // 03 23
2004 _("Spare"), // 04 24
2005 _("Light"), // 05 25
2006 _("Light w/Sectors"), // 06 26
2007 _("Leading Light Front"), // 07 27
2008 _("Leading Light Rear"), // 08 28
2009 _("Cardinal N Beacon"), // 09 29
2010 _("Cardinal E Beacon"), // 10 30
2011 _("Cardinal S Beacon"), // 11 31
2012 _("Cardinal W Beacon"), // 12 32
2013 _("Beacon, Port Hand"), // 13 33
2014 _("Beacon, Starboard Hand"), // 14 34
2015 _("Beacon, Preferred Channel Port Hand"), // 15 35
2016 _("Beacon, Preferred Channel Starboard Hand"), // 16 36
2017 _("Beacon, Isolated Danger"), // 17 37
2018 _("Beacon, Safe Water"), // 18 38
2019 _("Beacon, Special Mark"), // 19 39
2020 _("Cardinal Mark N"), // 20 40
2021 _("Cardinal Mark E"), // 21 41
2022 _("Cardinal Mark S"), // 22 42
2023 _("Cardinal Mark W"), // 23 43
2024 _("Port Hand Mark"), // 24 44
2025 _("Starboard Hand Mark"), // 25 45
2026 _("Preferred Channel Port Hand"), // 26 46
2027 _("Preferred Channel Starboard Hand"), // 27 47
2028 _("Isolated Danger"), // 28 48
2029 _("Safe Water"), // 29 49
2030 _("Special Mark"), // 30 50
2031 _("Light Vessel/Rig"), // 31 51
2032 _("GpsGate Buddy"), // xx 52
2033 _("Position Report"), // xx 53
2034 _("Distress"), // xx 54
2035 _("ARPA radar target"), // xx 55
2036 _("APRS Position Report"), // xx 56
2037 _("Buoy or similar") // xx 57
2038 };
2039
2040 return ais_type[index];
2041}
2042
2043wxString ais_get_short_type(int index) {
2044 static const wxString short_ais_type[] = {
2045 _("F/V"), // 30 0
2046 _("Tow"), // 31 1
2047 _("Long Tow"), // 32 2
2048 _("Dredge"), // 33 3
2049 _("D/V"), // 34 4
2050 _("Mil/V"), // 35 5
2051 _("S/V"), // 36 6
2052 _("Yat"), // 37 7
2053 _("HSC"), // 4x 8
2054 _("P/V"), // 50 9
2055 _("SAR/V"), // 51 10
2056 _("Tug"), // 52 11
2057 _("Tender"), // 53 12
2058 _("PC/V"), // 54 13
2059 _("LE/V"), // 55 14
2060 _("Med/V"), // 58 15
2061 _("Pass/V"), // 6x 16
2062 _("M/V"), // 7x 17
2063 _("M/T"), // 8x 18
2064 _("?"), // 19
2065
2066 _("AtoN"), // 00 20
2067 _("Ref. Pt"), // 01 21
2068 _("RACON"), // 02 22
2069 _("Fix.Struct."), // 03 23
2070 _("?"), // 04 24
2071 _("Lt"), // 05 25
2072 _("Lt sect."), // 06 26
2073 _("Ldg Lt Front"), // 07 27
2074 _("Ldg Lt Rear"), // 08 28
2075 _("Card. N"), // 09 29
2076 _("Card. E"), // 10 30
2077 _("Card. S"), // 11 31
2078 _("Card. W"), // 12 32
2079 _("Port"), // 13 33
2080 _("Stbd"), // 14 34
2081 _("Pref. Chnl"), // 15 35
2082 _("Pref. Chnl"), // 16 36
2083 _("Isol. Dngr"), // 17 37
2084 _("Safe Water"), // 18 38
2085 _("Special"), // 19 39
2086 _("Card. N"), // 20 40
2087 _("Card. E"), // 21 41
2088 _("Card. S"), // 22 42
2089 _("Card. W"), // 23 43
2090 _("Port Hand"), // 24 44
2091 _("Stbd Hand"), // 25 45
2092 _("Pref. Chnl"), // 26 46
2093 _("Pref. Chnl"), // 27 47
2094 _("Isol. Dngr"), // 28 48
2095 _("Safe Water"), // 29 49
2096 _("Special"), // 30 50
2097 _("LtV/Rig"), // 31 51
2098 _("Buddy"), // xx 52
2099 _("DSC"), // xx 53
2100 _("Distress"), // xx 54
2101 _("ARPA"), // xx 55
2102 _("APRS"), // xx 56
2103 _("Buoy or similar") // xx 57
2104 };
2105 return short_ais_type[index];
2106}
Global state for AIS decoder.
AIS target definitions.
Global variables stored in configuration file.
double toUsrDepth(double m_depth, int unit)
Convert a depth from meters to user display units.
double toUsrTemp(double cel_temp, int unit)
Convert a temperature from Celsius to user display units.
double toUsrDistance(double nm_distance, int unit)
Convert a distance from nautical miles (NMi) to user display units.
wxString FormatDistanceAdaptive(double distance)
Format a distance (given in nautical miles) using the current distance preference,...
Navigation Utility Functions without GUI dependencies.
bool bGPSValid
Indicate whether the Global Navigation Satellite System (GNSS) has a valid position.
Definition own_ship.cpp:34
Position, course, speed, etc.