Leaflet / Leaflet.VectorGrid

Display gridded vector data (sliced GeoJSON or protobuf vector tiles) in Leaflet 1.0.0
591 stars 192 forks source link

protobuf vectorgrid is not handling Long Integers why? #250

Closed syamasundararao closed 3 years ago

syamasundararao commented 3 years ago

I have feature with id 1126128864018916581 but in protobuf vectorgrid it was showing as 1126128864018916000. Why? How i can use same value

IvanSanchez commented 3 years ago

Why?

Because Javascript uses exclusively 64-bit floating-point format for numbers, and 1126128864018916581 doesn't fit in a 53-bit mantissa. Read https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number and https://en.wikipedia.org/wiki/IEEE_754 .

IvanSanchez commented 3 years ago

Oh, duplicate of https://github.com/mapbox/pbf/issues/126 BTW.

syamasundararao commented 3 years ago

Why?

Because Javascript uses exclusively 64-bit floating-point format for numbers, and 1126128864018916581 doesn't fit in a 53-bit mantissa. Read https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number and https://en.wikipedia.org/wiki/IEEE_754 . I understood the issue But How can i use the same value . is there any possibility of adding support of long int

IvanSanchez commented 3 years ago

Ensure that your IDs are instances of BigInt, or strings. I don't recall any VectorGrid code forcing IDs to be Numbers.