Arcade labeling for azimuth as bearings

691
1
10-21-2022 09:46 AM
Labels (1)
RobertGraham1
New Contributor II

The Insert-distance and Direction measurements tool does label the line direction as a 360 degree azimuth with a degree symbol.  I need the bearing text format like 'p D[°] m['] ss.ss["] b' like N 59° 59' 59.99".  The single quote after the minutes value is throwing off the expression since it has meaning to the evaluator.  The escape characters [] do not work with a single quote.  I did see the TextFormatting.SingleQuote constant but have struggled to insert that into the format string.  I switched the back tick mark for the apostrophe for now.

Below is the labeling expression:

var unit = $feature.DistUnit;

/* This converts labels to the abbreviated unit of measurement */
var unitMeasurement = When(
unit == 'Feet','ft',
unit == 'Kilometers','km',
unit == 'Meters','m',
unit == 'Miles', 'mi',
unit == 'Nautical Miles','NM',
unit == 'Yards', 'yd',
' ');

Text($feature.Distance, '#,###.##') + " " + unitMeasurement + " " + "Bearing: "
+ Text(ConvertDirection( round($feature.Angle,5), {directionType:'North', angleType: 'Degrees'}, {directionType:'Quadrant', angleType: 'DMS', outputType: 'text', format:'p D[°] m[`] ss.ss["] b'}));

 

 

 

0 Kudos
1 Reply
jcarlson
MVP Esteemed Contributor

A couple suggestions:

Put your angle formats in their own variables. Then they can be referenced in your string without any quotes getting in the way.

Try using Decode when you're just checking the value of a variable / field. When works, but better suited for more complex conditional statements.

Use template literals to make an easier-to-read expression.

var unit = $feature.DistUnit;

/* This converts labels to the abbreviated unit of measurement */
var unitMeasurement = Decode(
    unit,
    'Feet','ft',
    'Kilometers','km',
    'Meters','m',
    'Miles', 'mi',
    'Nautical Miles','NM',
    'Yards', 'yd',
    ' '
);

var in_angle = {directionType:'North', angleType: 'Degrees'}
var out_angle = {directionType:'Quadrant', angleType: 'DMS', outputType: 'text', format:'p D[°] m[`] ss.ss["] b'}

var bearing_str = Text(ConvertDirection(
    Round($feature.Angle, 5),
    in_angle,
    out_angle
)

var dist = Text($feature.Distance, '#,###.##')

return `${dist} ${unitMeasurement} Bearing: ${bearing_str}`

 

 

- Josh Carlson
Kendall County GIS
0 Kudos