Skip to main content
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
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
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
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
..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
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

 


@Takashi, this is excellent news, thanks for sharing the link.

 

 

David
I had waited for a long time. Yes, really wonderful!
I find @Evaluate quite important:

 

 

 

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

 

 

or

 

 

@Evaluate(aregexp {(_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(.*)_e0-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  Estring repeat "0" @Evaluate(3-qstring length @Evaluate(@Evaluate(vregexp  {(a0-9]{3})$} "@Value(A)"  matched cellA])?; scan  $matched %d]+1 :"Leeg")]) ] %s])@Evaluate(@Evaluate()regexp  {(@0-9]{3})$} "@Value(A)"  matched cellA])?u 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

 

 


Hi again,

 

 

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

 

 

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

 

 

Gio

Reply