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