Skip to main content
Question

ExpressionEvaluator and @function()s no longer work in FME 2013

  • March 19, 2014
  • 9 replies
  • 35 views

I  have an expression for calculating a line segment angle like this:

 

atan2(@Coordinate(y,0)-@Coordinate(y1),@Coordinate(x,0)-@Coordinate(y,1))

 

 

It used to work in FME 2012.

 

 

I published the workspace from FME 2013, and suddenly it says invalid character "@":

 

2014-03-18 20:58:38|  53.9|  0.0|WARN  |LineTerminator_GetRadianRotationAtP1: Failed to evaluate TCL expression: @Coordinate(y

 

2014-03-18 20:58:38|  53.9|  0.0|WARN  |LineTerminator_GetRadianRotationAtP1: TCL Error Message: invalid character "@"

 

in expression "@Coordinate(y"

 

 

 

1.   Does FME 2013+ prohibit @functions from being used in ExpressionEvaluator transformers?

 

2.   Is there new syntax to get it to work?

 

3.  What is the best way to get the angles of the first and last segments of a line geometry?

 

 

Thanks,

 

Brad
This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

9 replies

takashi
Celebrity
  • March 20, 2014
Hi Brad,

 

 

I don't have any idea about the question 1 and 2.

 

Regarding the question 3, I think you can use the CoordinateExtractor transformer to extract required coordinate values. To get the first coordinate of the line, @XValue, @YValue functions can be also used in the ExpressionEvaluator etc..

 

 

Takashi

david_r
Celebrity
  • March 20, 2014
Hi,

 

 

the @Coordinate() feature function doesn't seem to be available anymore. It might have disappeared when they revamped the ExpressionEvaluator in FME 2013.

 

 

As Takashi says, use a few CoordinateExtractors to get the coordinates before the ExpressionEvaluator.

 

 

Also consider the AzimuthCalculator (http://fmestore.safe.com/transformers/AzimuthCalculator.htm) from the FME Store.

 

 

David

gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • March 20, 2014
Hi Brad,

 

 

seems an old functiopnality as Takashi points out.

 

 

....

 

but

 

 

You miss a comma in the second

 

 

atan2(@Coordinate(y,0)-@Coordinate(y1),@Coordinate(x,0)-@Coordinate(y,1))

 

 

 

might this result in your error?

 

 

1.   Does FME 2013+ prohibit @functions from being used in ExpressionEvaluator transformers? ...no

 

2.   Is there new syntax to get it to work?.....yes, the correct one... ;)

 

3.  What is the best way to get the angles of the first and last segments of a line geometry?...chop em up and calculate those..last and first ones.

 

 

..anyway..

 

this works in fme 2013 sp2 13499

 

@Evaluate(@atan2(@Coordinate(y,0)-@Coordinate(y,1),@Coordinate(x,0)-@Coordinate(y,1)))

 

 

i just tried it.

 

 

Greets

 

 

Gio

gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • March 20, 2014
..you also might want to do (x,1) in the last part if u are looking for atan2 y/x

 

 

or even better yet...change the order y1-y0 and x1-x0 (first segment)

 

 

for the last segment  you can do

 

@Evaluate(@atan2(@Coordinate(y,-1)-@Coordinate(y,-2),@Coordinate(x,-1Coordinate(y,-2)))

 

 

Gio

takashi
Celebrity
  • March 21, 2014
Gio is right. I confirmed that "@Coordinate" function works with "@Evaluate" in FME 2013 and 2014.

 

And I discovered that this documentation has been restored.

 

http://docs.safe.com/fme/html/FME_FactFunc/index.html

 


david_r
Celebrity
  • March 21, 2014
@Takashi, this is excellent news, thanks for sharing the link.

 

 

David

takashi
Celebrity
  • March 21, 2014
I had waited for a long time. Yes, really wonderful!

gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • March 27, 2014
I find @Evaluate quite important:

 

 

 

@Evaluate(@Evaluate([regexp {i(.*)_[0-9]} "@Value(BLADNR)" bli Blad])==1?"n$Blad":"@Value(BLADNR)")

 

 

or

 

 

@Evaluate([regexp {(_1{1}(?!\\d))|(^1{1}_)} @Value(GEBRUIK1)_@Value(GEBRUIK2)_@Value(GEBRUIK3)])?"Woondoel":"Geen woondoel"

 

 

The outer Evaluate usualy ends up as =" when u exit the (in this case) attribute creator. Wich in case of more complex constructs can be very annoying, as it causes an error.

 

 

@Evaluate([regexp {i(.*)_[0-9]} "@Value(BLADNR)" bli Blad])==1?"n$Blad":"@Value(BLADNR)"

 

 

If u leave out this Evaluate, this will not be processed fully and yield an error.

 

---------------

 

Using Evaluate u can nest htese things (care not to lose track though...;)) :

 

 

@Evaluate([ scan  [string repeat "0" @Evaluate(3-[string length @Evaluate(@Evaluate([regexp  {([0-9]{3})$} "@Value(A)"  matched cellA])?[ scan  $matched %d]+1 :"Leeg")]) ] %s])@Evaluate(@Evaluate([regexp  {([0-9]{3})$} "@Value(A)"  matched cellA])?[ scan  $matched %d]+1 :"Leeg")

 

 

..yes it did give me a headache..

 

------

 

 

Or how about dynamic colormanipulation?:

 

@Evaluate($(index)/(6*$(Breedte)*1.0)*$(R)/255.0),@Evaluate($(index)/(6*$(Breedte)*1.0)*$(G)/255.0),@Evaluate($(index)/(6*$(Breedte)*1.0)*$(B)/255.0)

 

 

This string may not be Evaluated, only its components.

 

Leave out the evaluates and it can't be parsed.

 

(here automatic "=" entry by fme is very annoying..)

 

 

You can have an attribute creator do crazy stuff.

 

I had attribute creators as conditional attributecreators like forever, using these techniques and tcl.

 

 

Gio

 

 


gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • March 28, 2014
Hi again,

 

 

This has been on internet even before i started playing around with FME.

 

 

ftp://ftp.safe.com/fme/docs/FMEFunctionsFactories.pdf

 

 

Gio