GlobalEnergyMonitor / maps

Clone of https://github.com/earthrise-media/gem-tracker-maps
0 stars 2 forks source link

Optimizations to consider #56

Open mikelmaron opened 1 week ago

mikelmaron commented 1 week ago

Consider optimizations in https://github.com/GlobalEnergyMonitor/gem-downloads-prototype/, https://gem-downloads-prototype-9vfet.ondigitalocian.app

In my prototype, I am converting points to geojson on the fly in the browser, based on the filter, and keeping any properties not needed for the rendering outside the geojson to lower the size. It is possible to do filtering/aggregation faster outside the geojson/tiles as you can have more control of the data structure.
I think keeping the data separate from rendering information should be possible, if using the vector tiles too, making their file sizes much smaller. Ideally you should not be storing strings either, in the vector tiles, just numbers (enumerations) that you can look up the value of outside the tiles.

CSVs are compressed by some CDNs by default, but it's possible to compress them upfront to make them smaller.

Here is the code that makes the geojson from the data - https://github.com/GlobalEnergyMonitor/gem-downloads-prototype/blob/main/src/interactive-table.jsx#L16

In order to make filtering faster, I store the data as an array of arrays, not arrays of objects (like how geojson is stored). It is a little more tricky to use as you have to get the field index beforehand but seems worth it.