kylebarron / landsat8.earth

2D/3D WebGL Landsat 8 satellite image analysis
https://landsat8.earth
MIT License
40 stars 4 forks source link

Custom mosaics #23

Open kylebarron opened 4 years ago

kylebarron commented 4 years ago

Idea

Create mosaics aligned with the mercator tile grid. One drawback of vincent’s simple implementation in awspds-mosaic is that once you get to the edge of a current mosaic, a new mosaic is generated and it essentially deletes all tiles in the old region

But with mosaics aligned with the minzoom, I can store multiple mosaic urls in state and pass different urls for different tiles based on which mosaic they’re contained in. And then you never get the “flicker” from panning, until you change the parameters of the custom mosaic.

You most likely don't want to create one mosaic per zoom 7 tile, since zoom 7 is the minzoom, so if you were at zoom 7.01 and created a new custom mosaic, you'd be creating a new mosaic for each of the tiles on the screen.

I think caching mosaic definitions at zoom 5 might be ideal. By definition tiles at zoom 5 align with tiles at zoom 7. There would be 16 zoom 7 tiles within each zoom 5 tiles. So that would probably give a good balance between fast mosaic creation and not constantly creating a new one every time you pan.

So you can have a state argument like landsatUrlMap that where the key is the bounding tile and the value is the url of the mosaic. So for prebuilt mosaics it might be '0', the quadkey of the global zoom-0 tile:

landsatUrlMap: {
    '0': mosaicUrl
}

But for a custom mosaic it could be something like:

landsatUrlMap: {
    '01232': 'mosaicUrl',
    '01231': 'mosaicUrl'
}

where the keys are each quadkeys referring to zoom 5 tiles.

The function consuming this object can first check for '0', and if it exists assume there's a global mosaic. If the '0' key doesn't exist, then it checks if the requested tile is within any of the tiles that exist as keys. If not, send a request to create a new mosaic for the desired zoom-5 tile.

Only clear this object when a new custom mosaic is desired. Otherwise you're only adding to the state object.

Other notes:

References:

kylebarron commented 4 years ago

Zoom 5 tiles cover large sections of the U.S.: image

kylebarron commented 4 years ago

Requesting STAC results for tile 6, 12, 5 (zoom 5), which is over southwestern US, with parameters:

returned 175 results in about 1.5s. That should be faster from AWS as well. So I think zoom 5 is probably good. The parent tile at zoom 4 returned 488 results in 3.5s for the same search, so I think zoom 5 is probably a good medium.