Overview
I have a fairly interesting requirement where I need to load geojson data from a service (not a vector tile service) and then cache that data for offline use (using indexDB). So, when running the application offline I need to load that data from indexDB into the map (using mapbox-gl). The amount of data that could be cached offline (in indexDB) could be quite large and therefore I cannot just bring all of the data into memory and add it to the map (in which case mapbox would handle everything for us internally using geojson-vt).
I realize that if the source was a vector tile service that would make things easier, but unfortunately that is not an option at this point in time.
Attempted Solution
I believe the solution to this problem is to index the data when I store it in indexDB. My thought was that I would figure out each of the UTM grid values for each "feature" and that way when the map moves I can simply query the features in the respective grid(s) and load them into mapbox.
Example IndexDB "Table":
feature_id | properties | utm_tiles ({z}_{x}_{y}) 1 ... 14_0_0, 13_1_1, 13_1_2, etc 2 ... 14_0_0, 12_100_100, 12_100_101, etc etc...
Have the info above I could then query select * from index_db_features where utm_tiles in ('14_0_0', '14_0_1')
While this theoretically seems like it would work, the problem I am having is figuring out all of the tiles that a given feature touches. The geojson-vt library seems to do what I want except it doesn't give you an actual list of all tiles that the feature(s) are found in - it does the reverse, where you need to ask it for features based on a given tile.
Does anyone have any suggestions for finding out what all tiles a given feature touches? Or a better suggestion for spatially indexing geojson data for use in indexDB?