
1. Re: Formating Fields for Angular Notation
GaryTate Jun 9, 2013 4:53 AM (in response to kaiviti)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<10; "00"&number;
number<100; "0"&number;
Number) )&
Textstyle(TheResult;superscript)
(I'm not in front of FM so can't check the coand syntax)

2. Re: Formating Fields for Angular Notation
raybaudi Jun 9, 2013 5:04 AM (in response to kaiviti)Change the output to text and the calculation with:
Let(
result = YourActualCalculation ;
Right ( "000" & result ; 3 ) & "°"
)

3. Re: Formating Fields for Angular Notation
GaryTate Jun 9, 2013 5:06 AM (in response to raybaudi)Told you there was a better way ;)

4. Re: Formating Fields for Angular Notation
Malcolm Jun 9, 2013 5:37 AM (in response to kaiviti)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
TomHays Jun 9, 2013 6:44 AM (in response to raybaudi)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
kaiviti Jun 9, 2013 4:55 PM (in response to kaiviti)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
kaiviti Jun 9, 2013 8:32 PM (in response to Malcolm)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
AlanStirling Jun 9, 2013 11:29 PM (in response to kaiviti)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
kaiviti Jun 10, 2013 12:01 AM (in response to AlanStirling)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 5^{th} 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 5^{th} field is for the course and is the field I want to display in threedigit 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
raybaudi Jun 10, 2013 12:39 AM (in response to kaiviti)Could $course return a result in minutes and seconds of degree?

11. Re: Formating Fields for Angular Notation
Malcolm Jun 10, 2013 12:41 AM (in response to kaiviti)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
kaiviti Jun 10, 2013 1:41 AM (in response to raybaudi)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.
Thanks for all your help

13. Re: Formating Fields for Angular Notation
raybaudi Jun 10, 2013 1:55 AM (in response to kaiviti)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
kaiviti Jun 10, 2013 2:06 AM (in response to raybaudi)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.