Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Stateful Tile Fetching #15

Merged
merged 5 commits into from
Oct 21, 2024
Merged

Stateful Tile Fetching #15

merged 5 commits into from
Oct 21, 2024

Conversation

c1m50c
Copy link
Owner

@c1m50c c1m50c commented Oct 21, 2024

Description

Resolves #13 by enabling stateful tile fetching via splitting out BatchTileFetcher and IndividualTileFetcher into traits. AFAIK, this shouldn't break any existing code, due to the following impl blocks:

impl<F> BatchTileFetcher for F
where
    F: Fn(&[(i32, i32)], u8) -> Result<Vec<(i32, i32, DynamicImage)>, Error>,
{
    fn fetch_tiles(
        &self,
        coordinate_matrix: &[(i32, i32)],
        zoom: u8,
    ) -> Result<Vec<(i32, i32, DynamicImage)>, Error> {
        (self)(coordinate_matrix, zoom)
    }
}
impl<F> IndividualTileFetcher for F
where
    F: Fn(i32, i32, u8) -> Result<DynamicImage, Error>,
{
    fn fetch_tile(&self, x: i32, y: i32, zoom: u8) -> Result<DynamicImage, Error> {
        (self)(x, y, zoom)
    }
}

@c1m50c c1m50c marked this pull request as ready for review October 21, 2024 18:51
@c1m50c c1m50c merged commit 765b549 into main Oct 21, 2024
20 checks passed
@c1m50c c1m50c deleted the stateful-tile-fetching branch October 21, 2024 18:57
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow keeping state between tile fetches
1 participant