sharedstreets / sharedstreets-js

SharedStreets (Node.js & Javascript)
https://sharedstreets.io
MIT License
78 stars 25 forks source link

FYI, Javascript rounding Number issue (FIXED) #4

Closed DenisCarriere closed 6 years ago

DenisCarriere commented 6 years ago

Javascript rounding Number issue

Started to match all the Id's of the *.intersection.pbf file and I've been getting some errors with the following (396 passes, 12 failing):

Issue: Javascript was having an issue rounding the last decimals to 6 decimals.

Solution: I've included bignumber.js to handle that precision issue and reran the tests and now have 0 (zero) failing test cases.

https://github.com/MikeMcl/bignumber.js/

Failing results (before including bignumber.js)

lonlat expected (Java Builder) actual (Javascript)
[-74.0042505, 40.756509900000005] fb689f8e8bac17a958655f27d5aa9b8c 0214d92b42087b0e0eb704bade218a5a
Intersection -74.004250 40.756510
[-74.0063385, 40.7223126] 6cc850b7030cee6445a10beb67a475c4 9f9f1cdfd90da0ea4b8c08f8947f6844
Intersection -74.006338 40.722313
[-74.0090917, 40.7260025] 8037a9444353cd7dd3f58d9a436f2537 bad79f4675d32e12077cf6b1e50a6d80
Intersection -74.009092 40.726002
[-74.0084008, 40.7143685] 1d111b1d9cea78f6f2817d0adde27feb f85ed1140903928e053bda21d8caaaa7
Intersection -74.008401 40.714368
[-74.0103515, 40.7188019] 69342c47cd0554c21bb0bd8071725cbc d2030cc3392f45d609e963098b3aff4d
Intersection -74.010351 40.718802
[-74.0099015, 40.726080800000005] 760e7a134e4417767c9ef71ac3fbdc3f 9379278952664cde5da5dd2d8bc33972
Intersection -74.009901 40.726081
[-74.0052431, 40.7151565] b5bf6f7729b53457f9cc09d2a0c08148 dd33b2443c8665268937598d8f857928
Intersection -74.005243 40.715156
[-74.00656910000001, 40.7495415] 0156ed2b1a6886d5ba9d16e7c55a86c9 9a505cdf3b0150523d8e1947ea2dd931
Intersection -74.006569 40.749541
[-74.0127441, 40.7142475] 10a6527d704d15b93eb8bb250a7c23cb cc4a82bb30f64838cae30404f8984df7
Intersection -74.012744 40.714247
[-74.0152315, 40.7160084] 23140ab6e0a9a062e42c014f2b006c36 f1ef6648621df2326e053276de85ac24
Intersection -74.015231 40.716008
[-74.009651, 40.7227945] 2d13d54f0b23d32f2dd7203731680a25 c35c56c608e2e34513d36f098deeecb6
Intersection-74.009651 40.722794
[-74.0078076, 40.7317805] 54af1a41ab05c3b66c7e9765d6e423bd 875a9d80fcfe80f9fc4c9950dc14124d
Intersection -74.007808 40.731780