protomaps / protomaps-leaflet

Lightweight vector map rendering + labeling and symbology for Leaflet
https://protomaps.com/docs/frontends/leaflet
BSD 3-Clause "New" or "Revised" License
764 stars 43 forks source link

swap left shift operators for Math.pow for scoped projection/unprojection #172

Closed saranrapjs closed 1 month ago

saranrapjs commented 1 month ago

With the caveat that I'm not very fluent in bitwise operators, and I'm not totally sure I can point to the part of the Javascript spec that explains why this fix works, and the left shift operators don't...but it seems like, in Safari at least, 1 << 15.5 == 1 << 15, which is unexpected.

This branch uses Math.pow instead — where (again, in Safari) Math.pow(2, 15.5) != Math.pow(2, 15), which is expected.

fixes #171

bdon commented 1 month ago

Makes sense, the bit shifting operations only work on 32 bit integers; can you fix the CI formatting failures? then good to merge