gla-rad / S-100

JAXB mapping for the IHO S-100 Data Model
Apache License 2.0
2 stars 0 forks source link

XML Marshalling is locale dependent #1

Open kaspernielsen opened 7 months ago

kaspernielsen commented 7 months ago

I tried running the test on my machine with a locale that has ',' as the decimal separator instead of '.' and the S100ExchangeSetUtilsTest.testMarchallS125 test fails because we get

Expected:
<posList>-10.0000000 -10.0000000</posList>
<posList>-11.0000000 10.0000000</posList>

Actual:
<posList>-10,0000000 -10,0000000</posList>
<posList>-11,0000000 10,0000000</posList>

Can be reproduced by anyone by temporarily changing this code.

@Test
void testMarchallS125() throws JAXBException {
    Locale.setDefault(Locale.FRANCE);  //Warning sets it globally, but good enough to reproduce

I think we only want to generate xml that always uses . for decimal separator?

nvasta commented 7 months ago

Good question... I don't think the positions number format in S-100 are based on the Locale.

I can raise a question though... for now let's assume it will always be a ".".

In the meatime, I will see if we can set the Marshaller Locale manually to not be system dependent.

kaspernielsen commented 6 months ago

Just found this in the S-124 Spec, I assume it is the same for every S-100 product

9.2 Encoding of Latitude and Longitude

nvasta commented 6 months ago

That is correct, I was aware of the 7 decimal places. We can check S-100 for the decimal point a well.