nicky-nym / city3d

3D architectural building models made using the three.js Javascript API
The Unlicense
9 stars 4 forks source link

use Tabulator for caching metric values #26

Open nicky-nym opened 4 years ago

nicky-nym commented 4 years ago

Currently, Group has a getValueForMetric() method that calls _aggregateValuesForMetric() every time it is called. Rather than re-calculate the same values for each new query, instead we might want to cache the result value the first time the metric value is calculated.

We could cache the values right in Group (or in Feature, if we move the code there), but it might be cleaner if Group and Feature didn't have to know anything about calculating metrics and managing a cache. An alternative would be to use the Tabulator class instead, which is already partially written but which isn't in use yet. But in order for this to work, either all the Groups (or Features) would need to know what the current Tabulator instance is, or the all the metric-calculation functions in the Metric instances would need to be passed a Tabulator instance as well as a Feature instance. This might all be more trouble than it's worth, given that the code we already have seems to be working fine.

Also, we might want to consider changing the names of getValueForMetric() and setValueForMetric() to be something shorter.