Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jts-dev] Minus sign from WKTWriter after JDK 9

Thanks for the report of this issue.   I can create a PR for the bug fix.

I wonder if a better solution is simply to set the Locale of the DecimalFormat instance?  That should avoid any future issues with subtle locale differences, and I think is clearer about what the intention is.

Are you able to try out the following code? 
 
  private static DecimalFormat createFormat(int maximumFractionDigits) {
    NumberFormat nf = NumberFormat.getInstance(Locale.US);
    // This is expected to succeed for Locale.US
    DecimalFormat format;
    try {
      format = (DecimalFormat) nf;
    }
    catch (ClassCastException ex) {
      throw new RuntimeException("Unable to create DecimalFormat for Locale.US");
    }
    format.applyPattern(DECIMAL_PATTERN);
    format.setMaximumFractionDigits(maximumFractionDigits);
    return format;
  }


On Mon, Sep 7, 2020 at 7:19 AM Roar Brænden <roar.brenden.no@xxxxxxxxx> wrote:
Hello,

We have had some problems with our Geoserver instance when experimenting with JDK 9>. Some investigations (1) have discovered that the problem is with the introduction of CLDR as the default number format provider. For our norwegian locale this means that a conversion of a negative number to a string ends up with a sign that is not the usual minus sign. When using this string for instance in a query to postgis we will get an error.

The problem can be solved by specifying the old number format provider as the one to use, but when I debugged a JUnit test I've written in Geoserver I saw that a little change in JTS (2) might solve the problem to a large degree.

I haven't signed up for any contribution agreement, and haven't really thought of making big contributions to JTS. But I did look at the code in org.locationtech.jts.io.OrdinateFormatTest, and it seems like a good idea to iterate through different locales within the functions checkFormat.

Best regards
Roar Brænden


1)

2)
_______________________________________________
jts-dev mailing list
jts-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://dev.eclipse.org/mailman/listinfo/jts-dev

Back to the top