This commit is contained in:
Applevangelist 2025-01-02 13:15:13 +01:00
parent fc8c1c156f
commit 2cb58bd351
2 changed files with 30 additions and 10 deletions

View File

@ -968,8 +968,10 @@ do -- COORDINATE
-- @return DCS#Distance Distance The distance in meters.
function COORDINATE:Get2DDistance(TargetCoordinate)
if not TargetCoordinate then return 1000000 end
local a={x=TargetCoordinate.x-self.x, y=0, z=TargetCoordinate.z-self.z}
local norm=UTILS.VecNorm(a)
--local a={x=TargetCoordinate.x-self.x, y=0, z=TargetCoordinate.z-self.z}
local a = self:GetVec2()
local b = TargetCoordinate:GetVec2()
local norm=UTILS.VecDist2D(a,b)
return norm
end
@ -1329,13 +1331,16 @@ do -- COORDINATE
-- @param Core.Settings#SETTINGS Settings
-- @param #string Language (Optional) Language "en" or "ru"
-- @param #boolean MagVar If true, also state angle in magnetic
-- @param #number Precision Rounding precision, defaults to 0
-- @return #string The BR Text
function COORDINATE:GetBRText( AngleRadians, Distance, Settings, Language, MagVar )
function COORDINATE:GetBRText( AngleRadians, Distance, Settings, Language, MagVar, Precision )
local Settings = Settings or _SETTINGS -- Core.Settings#SETTINGS
Precision = Precision or 0
local BearingText = self:GetBearingText( AngleRadians, 0, Settings, MagVar )
local DistanceText = self:GetDistanceText( Distance, Settings, Language, 0 )
local DistanceText = self:GetDistanceText( Distance, Settings, Language, Precision )
local BRText = BearingText .. DistanceText
@ -2909,12 +2914,13 @@ do -- COORDINATE
-- @param #COORDINATE FromCoordinate The coordinate to measure the distance and the bearing from.
-- @param Core.Settings#SETTINGS Settings (optional) The settings. Can be nil, and in this case the default settings are used. If you want to specify your own settings, use the _SETTINGS object.
-- @param #boolean MagVar If true, also get angle in MagVar for BR/BRA
-- @param #number Precision Rounding precision, currently full km as default (=0)
-- @return #string The BR text.
function COORDINATE:ToStringBR( FromCoordinate, Settings, MagVar )
function COORDINATE:ToStringBR( FromCoordinate, Settings, MagVar, Precision )
local DirectionVec3 = FromCoordinate:GetDirectionVec3( self )
local AngleRadians = self:GetAngleRadians( DirectionVec3 )
local Distance = self:Get2DDistance( FromCoordinate )
return "BR, " .. self:GetBRText( AngleRadians, Distance, Settings, nil, MagVar )
return "BR, " .. self:GetBRText( AngleRadians, Distance, Settings, nil, MagVar, Precision )
end
--- Return a BRA string from a COORDINATE to the COORDINATE.

View File

@ -74,7 +74,7 @@
-- @image Designation.JPG
--
-- Date: 24 Oct 2021
-- Last Update: May 2024
-- Last Update: Jan 2025
--
--- Class AUTOLASE
-- @type AUTOLASE
@ -89,6 +89,7 @@
-- @field #table playermenus
-- @field #boolean smokemenu
-- @field #boolean threatmenu
-- @field #number RoundingPrecision
-- @extends Ops.Intel#INTEL
---
@ -100,6 +101,7 @@ AUTOLASE = {
alias = "",
debug = false,
smokemenu = true,
RoundingPrecision = 0,
}
--- Laser spot info
@ -118,7 +120,7 @@ AUTOLASE = {
--- AUTOLASE class version.
-- @field #string version
AUTOLASE.version = "0.1.26"
AUTOLASE.version = "0.1.27"
-------------------------------------------------------------------
-- Begin Functional.Autolase.lua
@ -207,6 +209,7 @@ function AUTOLASE:New(RecceSet, Coalition, Alias, PilotSet)
self.playermenus = {}
self.smokemenu = true
self.threatmenu = true
self.RoundingPrecision = 0
-- Set some string id for output to DCS.log file.
self.lid=string.format("AUTOLASE %s (%s) | ", self.alias, self.coalition and UTILS.GetCoalitionName(self.coalition) or "unknown")
@ -600,6 +603,15 @@ function AUTOLASE:SetSmokeTargets(OnOff,Color)
return self
end
--- (User) Function to set rounding precision for BR distance output.
-- @param #AUTOLASE self
-- @param #number IDP Rounding precision before/after the decimal sign. Defaults to zero. Positive values round right of the decimal sign, negative ones left of the decimal sign.
-- @return #AUTOLASE self
function AUTOLASE:SetRoundingPrecsion(IDP)
self.RoundingPrecision = IDP or 0
return self
end
--- (User) Show the "Switch smoke target..." menu entry for pilots. On by default.
-- @param #AUTOLASE self
-- @return #AUTOLASE self
@ -787,7 +799,9 @@ function AUTOLASE:ShowStatus(Group,Unit)
elseif settings:IsA2G_LL_DMS() then
locationstring = entry.coordinate:ToStringLLDMS(settings)
elseif settings:IsA2G_BR() then
locationstring = entry.coordinate:ToStringBR(Group:GetCoordinate() or Unit:GetCoordinate(),settings)
-- attention this is the distance from the ASKING unit to target, not from RECCE to target!
local startcoordinate = Unit:GetCoordinate() or Group:GetCoordinate()
locationstring = entry.coordinate:ToStringBR(startcoordinate,settings,false,self.RoundingPrecision)
end
end
end