Knime 4.4.1 does work with my 4.3.4 workflow

Hi @TigerCole , sure I can do that. The reason why I did not use double originally is because I don’t know how many precision will Knime keep.

I will need to modify some of the code, so give me a few mins.

Also, you can try these on your side, just create a table with dummy values and type, and just copy my snippet.

Here you go @TigerCole .

I added 2 more columns:
image

So, that’s what Knime shows. However, the values are there.

Code modified as (basically added the last 2 lines):

NumberFormat fmtr = new DecimalFormat("###.###############");      

double lat = Double.valueOf(c_column1);
double lng = Double.valueOf(c_column2);

out_WKT1 = fmtr.format(lng);
out_WKT2 = fmtr.format(lat);

out_WKT = "POLYGON (("+out_WKT1.toString()+", "+out_WKT2.toString()+"))";

out_WKT3 = fmtr.format(c_column3);
out_WKT4 = fmtr.format(c_column4);

Results:

Hi @bruno29a

Here is my output…

“Broken” output after I did a copy and paste of your code. I think that I am going to have to speak to a developer and find a way to force the “.” when doubles are converted to strings.

It does not happen when I use a “number to string” node so it must be something in this particular snippet.

Thanks for all your effort and help.

tC/.

1 Like

Hi @TigerCole,

You need to look at the region and locale settings of your computer. I recalled a similar issue on Windows computers that had a US / UK locale but German number format configured. Java 8 ignored this setting, while Java 11 does not.
https://support.microsoft.com/en-us/office/change-the-windows-regional-settings-to-modify-the-appearance-of-some-data-types-edf41006-f6e2-4360-bc1b-30e9e8a54989

You can force a specific locale during conversion, to ensure consistent results, by setting it explicitly in your code, like in this example from stackoverflow:

DecimalFormat df2 = new DecimalFormat("#.##");           
df2.setDecimalFormatSymbols(DecimalFormatSymbols.getInstance(Locale.ENGLISH));

best,
Gabriel

5 Likes

Hello,

All fine @TigerCole. But doesn’t look like a new issue. More like a cause is found that now needs to be sorted out. And I’m sure it will be :wink:

Br,
Ivan

1 Like

I agree with @gab1one , this kind of behaviour is usually because of the region setting. For example, I know that comma is used instead of dot in French.

@TigerCole I think the setDecimalFormatSymbols(DecimalFormatSymbols.getInstance(Locale.ENGLISH)) suggested by @gab1one should work as it looks like it will force the Locale to English.

3 Likes

My apologies for the delayed response to the comments. I am not sure why, but for some reason having my computers regional settings set to “South Africa” seemed to be the problem. I changed to UK and configured it to work for me and “voila” my workflow works.

I have spoken to our developers who are really experienced Java developers and they could not figure out why South African regional setting caused a problem. It may be that Java is reading the default for region and not picking up the changes in my local configuration.

Thanks for all the support. It is much appreciated.

tC/.

1 Like

Hi @TigerCole as I said, some countries use a comma instead of a dot for the decimal delimiter. South Africa might be one of these countries.

This should have done the trick though:
setDecimalFormatSymbols(DecimalFormatSymbols.getInstance(Locale.ENGLISH))

This would avoid you having to change your system’s regional settings. It would change it only for that node.

4 Likes

Hi @bruno29a … I am definitely going to get this added to the node … I just need to get a few minutes of my developers time.

Thanks again for all your help.

tC/.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.