Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]
Created 04-17-2023 12:28 PM
Hello NiFi Community,
I want to convert decimal degree coordinates (e.g. -45.123658) to radians, and I want to use the built-in NiFi math function to do so. However, simply following the simple example in the Expression Language documentation for math, the example fails. I keep getting an "unexpected token" error whenever trying to use toDouble or the math function itself. Anyone have any success with using the math function and any of the methods associated with it, particularly if they take a double as an argument?
Since the function is subjectless, I'm :
${math("toRadians", ${latitude:toDouble()})}
But I've also tried variations of:
${latitude:toDouble():math("toRadians", ${latitude})}${latitude:math("toRadians", ${latitude:toDouble()})}
I appreciate any insight.
Created 04-17-2023 01:18 PM
Hi ,
Did you try the following:
${latitude:toDecimal():math("toRadians")}Or
${latitude:math("toRadians")}
Created 04-17-2023 02:29 PM
Thank you @SAMSAL. I can always count on you to respond with good ideas. It didn't occur to me to include just a single parameter in the math function because the documentation shows using "scalb" and "pow" methods with the second parameter as the value to pass to the input method. But also, I was trying to use a Double because they documentation says "toRadians" only accepts a double, and the NiFi expression language docs shows using a "toDouble()", but "toDouble" doesn't seem to be supported. Seems to be an inconsistency in the docs.
Your suggestions were pretty close. Below is the final result which did the trick.
${latitude:toDecimal():math("toRadians")}
Thank you again!
Created 04-17-2023 01:18 PM
Hi ,
Did you try the following:
${latitude:toDecimal():math("toRadians")}Or
${latitude:math("toRadians")}
Created 04-17-2023 02:29 PM
Thank you @SAMSAL. I can always count on you to respond with good ideas. It didn't occur to me to include just a single parameter in the math function because the documentation shows using "scalb" and "pow" methods with the second parameter as the value to pass to the input method. But also, I was trying to use a Double because they documentation says "toRadians" only accepts a double, and the NiFi expression language docs shows using a "toDouble()", but "toDouble" doesn't seem to be supported. Seems to be an inconsistency in the docs.
Your suggestions were pretty close. Below is the final result which did the trick.
${latitude:toDecimal():math("toRadians")}
Thank you again!