PMTiles icon indicating copy to clipboard operation
PMTiles copied to clipboard

use geometric series formula

Open etienneld opened this issue 1 year ago • 3 comments

etienneld avatar Oct 03 '24 16:10 etienneld

Any description? Can you include the comparison here? https://github.com/protomaps/PMTiles/pull/134

bdon avatar Oct 03 '24 17:10 bdon

Hi Brandon, this PR refactors tzValues calculation to leverage geometric series formula

  • Replaced the manual lookup table for tzValues with a direct formula based on the properties of a geometric series.
  • The formula (4^z - 1) / (4 - 1) efficiently computes the same values, eliminating the need for a hardcoded array.
  • This approach simplifies code maintenance.

https://www.wolframalpha.com/input?i=Sum%5B2%5Ei+*+2%5Ei%2C+%7Bi%2C+0%2C+n+-+1%7D%5D

etienneld avatar Oct 03 '24 17:10 etienneld

This change focuses on maintainability rather than performance optimization.

etienneld avatar Oct 03 '24 18:10 etienneld

I've merged #527 with results here: https://github.com/protomaps/PMTiles/pull/527#issuecomment-2663128667

bdon avatar Feb 21 '25 07:02 bdon