I'm struggling to come up with the best way to structure my program, regarding a specific function.
Here are some details:
- The input to the function is a vector of (latitude, longitude) coordinates
- These can be in whichever order the user supplies
- The output of the function should be the elevations at the input coordinates, in the same order as the inputs
- The elevations are retrieved by accessing pixel values in TIFF files that are named by whole number latitude, longitude coordinates, e.g.
n40w106
,n40w107
, ...- This number represents the top left corner, for example:
- (39.5, -105.5), (39.8, -105.2) would both be in
n40w106.tif
- (40.3, -106.1), (40.5, -106.9) would both be in
n41w107.tif
- (39.5, -105.5), (39.8, -105.2) would both be in
- This means that multiple points in different spots in the input vector could need to be retrieved from the same file
- This number represents the top left corner, for example:
- I already have the all of the functionality to take input points and retrieve the elevation from the corresponding files
What I am struggling with is these extra requirements that I want to ensure:
- Each file should only get loaded once
- Only store the file's data in memory if it is being used currently (so I don't think caching will work)
- The order of the outputs should correspond to the order of the supplied inputs
Is there some existing paradigm or concept in CS that achieves what I want?
I'm also interested in if there is a model that works well with concurrency. For reference, I am using the Rust programming language.
Aucun commentaire:
Enregistrer un commentaire