14 Replies Latest reply on Jun 10, 2013 2:06 AM by kaiviti

# Formating Fields for Angular Notation

I have a calculation field that works out the course between two geographical points. I would like to display the course as three digits and with the degree notation after it so that it looks like 007o . At the moment it is just showing as one digit which is rather pathetic. The field I am using is a calculation field and the output is Number. If anyone has any idea on how to do this please enlighten me??

PS. The small zero after the 7 should be a superscript zero. It doesn't show correctly in the post.

• ###### 1. Re: Formating Fields for Angular Notation

I'm sure there are better ways but you could have a text field that calculates the leading zeroes and then adds a styled 0 to the end. Apply the style superscript to the trailing zero.

Calc something like ....

Let(TheResult=Case ( number&lt;10; "00"&amp;number;

number&lt;100; "0"&amp;number;

Number) )&amp;

Textstyle(TheResult;superscript)

(I'm not in front of FM so can't check the coand syntax)

• ###### 2. Re: Formating Fields for Angular Notation

Change the output to text and the calculation with:

Let(

result = YourActualCalculation ;

Right ( "000" & result ; 3 ) & "°"

)

• ###### 3. Re: Formating Fields for Angular Notation

Told you there was a better way ;-)

• ###### 4. Re: Formating Fields for Angular Notation

I would like to display the course as three digits and with the degree notation after it so that it looks like 007o .

If the field is a number you can use field formatting options to append the degree symbol. However, you cannot specify leading zeroes.

If you want to have leading zeroes you can a use calculation to generate the output, ie, right( "000" & degrees; 3) & "°".

Malcolm

• ###### 5. Re: Formating Fields for Angular Notation

It is a bit of a kludge, but you can use Daniele's formula and have the output of the calculation be a Number.

Change the display format to be "As Entered".

The Number result will behave properly in numeric searches and sorts. The Text result will be a problem with sorting.

If you can relax the requirement that the result have leading zeros, I would use Malcom's recommendation of the field formatting option to append the degree symbol.

-Tom

• ###### 6. Re: Formating Fields for Angular Notation

Where do you guys find information on formatting like that?  I have used the help files and some tutorials but don't see anything like this.  Is there another resource for scripting that I don't know about yet?

I have tried the method described by Dan and Tom and the formatting does work.  BUT, the results arenow way out.  Before I got the correct bearing but now it is hundreds of degrees out??  The revised formula I am using is:

Let(

course =

Case(

sequence = 1 ; "" ;

dlat and dlong >0 ; 90 - Degrees ( Atan ( Radians ( dlat )  / Radians ( dep )));

dlat and dlong <0 ; 270 - Degrees ( Atan ( Radians ( dlat )  / Radians ( dep )));

dlat > 0 and dlong < 0 ; 270 + Degrees ( Atan ( Radians ( dlat )  / Radians ( dep )));

dlat < 0 and dlong > 0 ; 270 - Degrees ( Atan ( Radians ( dlat )  / Radians ( dep ))) ;

dlat > 0 and dlong  =  0 ; 0 ;

dlat < 0 and dlong  =  0 ; 180 ;

dlat = 0 and dlong  >  0 ; 90 ;

dlat = 0 and dlong  <  0 ; 270

) ;

Right ( "000" & course ; 3 ) & "°"

)

I will obviously play around with my formulae to find the glitch but if any of you can spot it, please let me know.

• ###### 7. Re: Formating Fields for Angular Notation

OK, the field formatting works.  But the leading zero's doesn't.  I have tried the same calculation on different field and every time it gives me three digits with leading zero's but completely screws up the resultant figure.  I am not sure what is happening here??

• ###### 8. Re: Formating Fields for Angular Notation

Hi kaiviti

Firstly, I have to admit that I don't fully understand how your script works, but I notice you are using three fields, when I think you should only be using two.

You have 'dlat' and 'dlong', but what is the purpose of 'dep'?

Perhaps this is where your script is failing?

Best wishes - Alan Stirling, London UK.

• ###### 9. Re: Formating Fields for Angular Notation

Hi Alan,

Navigation formulae is not easy to understand and I didn’t explain it in my last post.  To help out I will explain the various fields I need.  There are 4 calculation fields needed before I can obtain a course. These values are obtained from the latitudes and longitudes of consecutive geographical waypoints.

The 5th field is the calculation field for the course.  The first four fields are:

1)  dlat = difference in latitude between two waypoints expressed in minutes of a degree

2)  midlat = the arithmetical mean of two waypoints expressed in minutes of a degree

3)  dlong = difference in longitude between two waypoints expressed in minutes of a degree

One minute of latitude (dlat) equals one mile but one minute of longitude does not equal one mile (except at the equator).  Therefore, a formula to convert minutes of longitude into miles is:

4)  dep = dlong * cos (midlat)

The 5th field is for the course and is the field I want to display in three-digit notation with the degree symbol.  The formulae is:

5) Tan course = dlat / dep

The formulae I posted earlier was a bit crude.  I have refined it a bit and pasted it below.  But it still doesn't work.  I noticed that if I canged the 3 in the last line to anything else, the value just grows and grows.  For example, using "3" the result is 418;  using "8" the result is 75779418.  Notice the last three digits are the same and nothing is any relation to the results of the calculation.

Let(

\$course =

Case(

dlat and dlong >0 ; 90 - Degrees (Atan ( dlat  / dep ));

dlat and dlong <0 ; 270 - Degrees ( Atan ( dlat  / dep ));

dlat > 0 and dlong < 0 ; 270 + Degrees ( Atan ( dlat  / dep ));

dlat < 0 and dlong > 0 ; 270 - Degrees ( Atan ( dlat  / dep ));

dlat > 0 and dlong  =  0 ; 0 ;

dlat < 0 and dlong  =  0 ; 180 ;

dlat = 0 and dlong  >  0 ; 90 ;

dlat = 0 and dlong  <  0 ; 270

);

Right ( "000" & \$course ; 3 ) & "°"

)

• ###### 10. Re: Formating Fields for Angular Notation

Could \$course return a result in minutes and seconds of degree?

• ###### 11. Re: Formating Fields for Angular Notation

The Right function is returning the characters from the right hand side of the string. If you calculate course to be 14.65987654 then Right(course; 3) returns 654. Right(course; 6) returns 987654.

Here's a simple way to ensure zero padding and, let's say, precision to four decimal places. The result type must be text for this to work. (Increase the final parameter in Middle from 8 to 10 to obtain six decimal places.)

Let([

\$course = 14.025467 ;

\$course + 1000

];

Middle(course ; 2 ; 8) & "°"

)

--> 014.0254°

malcolm

• ###### 12. Re: Formating Fields for Angular Notation

No Dan, the result is degrees and decimals of degrees.

I think Malcom has identified the problem and the solution.  Looking at the reults in my solution the calculated course for the record I was refering to earlier is 19.9899035799418.  The last  8 digits are the same as the ones I reported earlier.  I tried your formula Malcom, but it returned an error with the plus symbol.  So I played with it and came up with a solution that works perfectly.  The revised formulae is below:

Let(

\$course =

Case(

Formulae for calculating course

) ;

Middle ( Round((\$course + 1000) ; 0 ) ; 2 ; 5 ) & " ° "

)

If I want to include decimal places, I only need to change the precision from 0 to whatever.

• ###### 13. Re: Formating Fields for Angular Notation

kaiviti ha scritto:

No Dan, the result is degrees and decimals of degrees.

So my calc becomes:

Let(

result = YourActualCalculation ;

Right ( "000" & Int ( result ) ; 3 ) & "°"

)

• ###### 14. Re: Formating Fields for Angular Notation

Hi Dan,

Yes, that may work.  I haven't tried it yet but I think there may be a problem using Integer.  From my understanding the full calculated result was 19.9899035799418.  If we used Integer we would only get 19 which drops off all the decimals and returns the digits before the decimal; whereas Round(0) will give 20 which is more correct.