Question

CoordinateConcatenator / attribute string : limit decimal places

  • 17 January 2017
  • 5 replies
  • 5 views

I'm new to FME (2 weeks) and i have a problem with decimal places in attribute.

I use the CoordinateConcatenator to write my x/y values of line feature (source DGN) to attribute.

Example:

267866.5661 239026.86510000002

 

267865.27559999999 239026.7414

 

267865.1519 239025

 

267866.4424 239025.57460000002

 

267866.5661 239026.86510000002

Now i have to restrict the decimal places to 3 (exactly, 0 places included: 239025 -> 239025.000 etc) and then write the attribute to textfile.

I tried:

-) CoordinateRounder before CoordinateConcatenator (no effect), StringFormatter (didn't accept my values -> example)

-) CoordinateExtractor (but i didn't know how to concatenate and format list values, Loop?!, x/y alternation)

-) AttributManager and @Format-function (same as StringFormatter) ....

Now i don't know any more ...

Mayby there is a way to limit all double-values in workspace to 3 decimal places?!

Can someone help me?

Petra

PS: I'm not familiar with python .....


5 replies

Badge +16

Hi @petra, welcome to the world of FME!

You are on the right track the SringFormatter should work, have a look at the attached workspace.

Hope this helps.limit-decimal-places.fmw

Hi @petra, welcome to the world of FME!

You are on the right track the SringFormatter should work, have a look at the attached workspace.

Hope this helps.limit-decimal-places.fmw

Hi itay, thank you for answering.

 

If i have just one int or double value in the attribute (like x or y in your example), the StringFormatter works well. But I have all the double/int values (-> example)

 

in one attribute and than the StringFormatter tells:

 

"StringFormatter: @Tcl2 -- failed to evaluate expression `StringFormatter_formatter' -- expected floating-point number but got "267866.5661 239026.86510000002 267865.2755999999"

 

Badge +16
Hi itay, thank you for answering.

 

If i have just one int or double value in the attribute (like x or y in your example), the StringFormatter works well. But I have all the double/int values (-> example)

 

in one attribute and than the StringFormatter tells:

 

"StringFormatter: @Tcl2 -- failed to evaluate expression `StringFormatter_formatter' -- expected floating-point number but got "267866.5661 239026.86510000002 267865.2755999999"

 

I see in that case I would try to identify the different data types and using the correct syntax per type.
Userlevel 4

This has been covered quite a few times here already, but it could be that you're running into a basic limitation of floating point numbers, where they cannot accurately express every decimal fraction, leading to tiny inaccuracies and floating poing frustrations.

More info here.

Userlevel 2
Badge +17

Hi @petra, I think you may have to decompose each element of the coordinates to format individual values and then reconstruct a string representing the concatenated coordinates. e.g.

See also the attached example (FME 2016.1.3): format-coordinates.fmw

Reply