EXIficient / exificient.js

JavaScript Implementation of EXI and EXI for JSON
24 stars 3 forks source link

Bug on encoding numbers in EXIforJSON #1

Closed shaohu closed 7 years ago

shaohu commented 8 years ago

Hi guys,

Firstly thanks a lot for this library, it helps a lot for my work. Good job!

When I tested the EXIforJSON functions, I found that there are some bugs on converting numbers. Attached is the test sample. In your online demo, when you convert these JSON scripts into EXI and then convert them back, the numbers in "coordinates" will change.
I will be very grateful if you guys can fix this bug. Or you can tell me where is the bug, probably I can also help with it.

Regards, Hu Shao

{ "type": "FeatureCollection", "totalFeatures": 2, "features": [ { "type": "Feature", "id": "poi.1", "geometry": { "type": "Point", "coordinates": [ 40.707587626256554, -74.01046109936333 ] }, "geometry_name": "the_geom", "properties": { "NAME": "museam", "THUMBNAIL": "pics/22037827-Ti.jpg", "MAINPAGE": "pics/22037827-L.jpg" } }, { "type": "Feature", "id": "poi.2", "geometry": { "type": "Point", "coordinates": [ 40.70754683896324, -74.0108375113659 ] }, "geometry_name": "the_geom", "properties": { "NAME": "stock", "THUMBNAIL": "pics/22037829-Ti.jpg", "MAINPAGE": "pics/22037829-L.jpg" } } ], "crs": { "type": "EPSG", "properties": { "code": "4326" } } }

danielpeintner commented 8 years ago

Hi,

thanks for pointing us to the issue. We will try to take look but I am not sure when we get to it.

I believe it relates how the code retrieves the mantissa and exponent (see function getEXIFloat(value) on lin 1262 in https://github.com/EXIficient/exificient.js/blob/master/exificient.js)

If you have a fix/proposal let us know...

Thanks!

coderextreme commented 8 years ago

I also have a problem with numbers from the online demo. Here is my source file:

ArchHalf.txt

I'd say this is pretty important. The line number may have changed from 1262. Can you update? I wrote a test case for getEXIFloat(value) which I will report next.

coderextreme commented 8 years ago

Here is a test case you can try for getEXIFloat which shows (in my case, and I tested 4 numbers from the original problem report) that it's not the problem. Is the website up to date? getfloat.txt

coderextreme commented 8 years ago

Here's a very simple test case to show how horrible this bug is:

[-74.01046109936333]

Encodes and decodes to:

[-0.00001415142092]

Way way off!

coderextreme commented 8 years ago

Definitely the web site is out of date. I was able to download code here and make it work. Please update?

danielpeintner commented 8 years ago

Your are right. The website was not in sync. You should not see the same issue after commit https://github.com/EXIficient/exificient.github.io/commit/4d51babb880d4acb9ca90f4dbf21b18d1d10d1d8

danielpeintner commented 7 years ago

@shaohu and @coderextreme can you confirm that the issue has been fixed. If so let me know or close the issue yourself. Thanks!