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