Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat (asv-drones): add new measurement unit Accuracy #295

Merged
merged 1 commit into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public interface ILocalizationService
IMeasureUnit<double, AltitudeUnits> Altitude { get; }

IMeasureUnit<double, DistanceUnits> Distance { get; }

IMeasureUnit<double, DistanceUnits> Accuracy { get; } // field for gbs plugin only

IMeasureUnit<double, LatitudeUnits> Latitude { get; }
IMeasureUnit<double, LongitudeUnits> Longitude { get; }
Expand Down
54 changes: 54 additions & 0 deletions src/Asv.Drones.Gui/RS.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions src/Asv.Drones.Gui/RS.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1829,4 +1829,22 @@
<data name="PortView_PacketLossChance" xml:space="preserve">
<value>Packet Loss Chance</value>
</data>
<data name="Accuracy_Description" xml:space="preserve">
<value>Accuracy measure units</value>
</data>
<data name="Accuracy_Meters_Unit" xml:space="preserve">
<value>m</value>
</data>
<data name="Accuracy_Meters_Title" xml:space="preserve">
<value>Meters</value>
</data>
<data name="Accuracy_NauticalMiles_Title" xml:space="preserve">
<value>Nautical miles</value>
</data>
<data name="Accuracy_NauticalMiles_Unit" xml:space="preserve">
<value>NM</value>
</data>
<data name="Accuracy_Title" xml:space="preserve">
<value>Accuracy</value>
</data>
</root>
18 changes: 18 additions & 0 deletions src/Asv.Drones.Gui/RS.ru.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1861,4 +1861,22 @@
<data name="PortView_PacketLossChance" xml:space="preserve">
<value>Шанс потери пакетов</value>
</data>
<data name="Accuracy_Description" xml:space="preserve">
<value>Единицы измерения точности</value>
</data>
<data name="Accuracy_Meters_Title" xml:space="preserve">
<value>Метры</value>
</data>
<data name="Accuracy_Meters_Unit" xml:space="preserve">
<value>м</value>
</data>
<data name="Accuracy_NauticalMiles_Title" xml:space="preserve">
<value>Морские мили</value>
</data>
<data name="Accuracy_NauticalMiles_Unit" xml:space="preserve">
<value>NM</value>
</data>
<data name="Accuracy_Title" xml:space="preserve">
<value>Точность</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ public LocalizationServiceBase(IConfiguration cfgSvc) : base(cfgSvc)

#endregion

Accuracy = new Accuracy(cfgSvc, nameof(Accuracy)).DisposeItWith(Disposable); // for gbs plugin only

Altitude = new Altitude(cfgSvc, nameof(Altitude)).DisposeItWith(Disposable);
Velocity = new Velocity(cfgSvc, nameof(Velocity)).DisposeItWith(Disposable);
Distance = new Distance(cfgSvc, nameof(Distance)).DisposeItWith(Disposable);
Expand Down Expand Up @@ -109,6 +111,9 @@ private void SetLanguage(ILanguageInfo lang)

public IMeasureUnit<double, AltitudeUnits> Altitude { get; }
public IMeasureUnit<double, DistanceUnits> Distance { get; }

public IMeasureUnit<double, DistanceUnits> Accuracy { get; } // need only for gbs plugin

public IMeasureUnit<double, LatitudeUnits> Latitude { get; }
public IMeasureUnit<double, LongitudeUnits> Longitude { get; }
public IMeasureUnit<double, VelocityUnits> Velocity { get; }
Expand Down
24 changes: 24 additions & 0 deletions src/Asv.Drones.Gui/Services/Localization/MeasureUnits/Accuracy.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Asv.Cfg;
using Asv.Drones.Gui.Api;

namespace Asv.Drones.Gui;

public class Accuracy : MeasureUnitBase<double, DistanceUnits>
{
private const double MetersInInternationalNauticalMile = 1852;

private static readonly IMeasureUnitItem<double, DistanceUnits>[] _units =
{
new DoubleMeasureUnitItem<DistanceUnits>(DistanceUnits.Meters, RS.Accuracy_Meters_Title,
RS.Accuracy_Meters_Unit, true, "F2", 1),
new DoubleMeasureUnitItem<DistanceUnits>(DistanceUnits.NauticalMiles, RS.Accuracy_NauticalMiles_Title,
RS.Accuracy_NauticalMiles_Unit, false, "F4", MetersInInternationalNauticalMile),
};

public Accuracy(IConfiguration cfgSvc, string cfgKey) : base(cfgSvc, cfgKey, _units)
{
}

public override string Title => RS.Accuracy_Title;
public override string Description => RS.Accuracy_Description;
}