-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
COGLayer #44
Comments
Note however that you have access to the coordinates of each tile in the local coordinate system. So if tile {
"type": "TileMatrixType",
"identifier": "4",
"scaleDenominator": 34884088.0626143,
"topLeftCorner": [
-9501965.72931276,
20003931.4586255
],
"tileWidth": 256,
"tileHeight": 256,
"matrixWidth": 8,
"matrixHeight": 16
} Since at each level the tile width and height must be regular, it should be possible to do a line or two of math to find the grid of tiles desired, without doing a loop. You just always need to know the coordinates in the local coordinate system of the current tile. |
Note you'll probably also need masking to discard areas of the tiff that are nodata. Note you'll need to pass tile width/height to the Texture constructor, and make |
COGLayer: A deck.gl layer to render a COG directly
Overview
A COG is a single GeoTIFF file that holds multiple resolutions of raster data. See https://cogeo.org for more info.
COGs are internally tiled. Thus they're a great fit for the TileLayer, which renders a tiled dataset. However the TileLayer can't be used directly, because it assumes a web-mercator tiling system. Even COGs that are in the web mercator projection can't be used directly, because the internal indexing doesn't match the global OSM indexing.
Hence there are three main steps I need to do to get this working:
Parse COG metadata to construct TileMatrixSet
Basically working code:
Code
Note: you should be able to use math.gl where affine is used. If you look into the affine code, the source for the transformation matrices is pretty simple.
Custom TileLayer that supports TMS
While this could conceivably be included in deck.gl upstream, for now it would be better to work on it locally. The TMS provides a mapping from x, y, z values to locations in space. Note these are arbitrary locations, and should not be confused with the x, y, z indexing in the OSM system.
There are a few parts to this:
Determining reprojection function
First you need to find the reprojection string. So if the EPSG code in the geotiff is
EPSG:26911
, send a request tothat returns
Then pass that to proj4.
Finding visibility
Deck.gl uses frustum culling to determine the visibility of tiles. Hence I need to modify the
tile-2d-traversal.js
script to work with an arbitrary TMS.I'll need to overwrite
getBoundingVolume
to find the tile's bounding box in the local CRS, then reproject it. Note thatgetBoundingVolume
deals in deck.gl's common space, this is a web mercator projection of world size 512, with the origin in the top left.Note that one caveat to TMS is that child tiles don't have strict nesting. Hence I believe it’s not always true that for any tile
t
, it has only one parent. This makes visibility computations harder, as finding a tile's children is less straightforward. With OSM indexing, given any tilet
, there are always exactly four children tiles. With non-strict children, you essentially need to make a pass over all tiles at that level, checking if the tile's bounding box intersects with the parent.Therefore you'll also have to overwrite the
children
method to determine the tile's children.Since Xiaoji is such a good engineer, you might have to overwrite only those two methods!
Reproject data in
renderSubLayers
This is explored a bit in #37. Basically you'll need to reproject the
vertices
withincreateMesh
from the source CRS to one deck can understand.Note that the mesh already is created at a certain resolution that's derived from the zoom level.
Note that this will only be possible with the
RasterLayer
, not theRasterMeshLayer
, as the mesh layer needs to combine elevation data, and that would only work if you could fetch elevation data in the same local coordinate system.The text was updated successfully, but these errors were encountered: