tangrams / tangram-es

2D and 3D map renderer using OpenGL ES
MIT License
821 stars 238 forks source link

Read values from raster layers at specific screen coordinates #2190

Open kueda opened 3 years ago

kueda commented 3 years ago

Feature request: raster layers include data that could have uses beyond cartography, e.g. the elevation included in a DEM layer, so it would be useful if the application could ask the map for the pixel value at a particular coordinate, perhaps analogous to how pickFeature and FeaturePickListener work in the Android API, though given the potential for multiple overlaid raster layers, it might be useful to specify an optional layer as well, like

mapController.pickRasterPixel(x, y, layerName="my-dem")

and

fun onRasterPixelPick(values: List<Float>, positionX: Float, positionY: Float, layerName: String)

where values is the list of channel values for that pixel, presumably [red,green,blue,alpha] for an RGBA raster or just [value] for a single-channel TIF like a DEM. I'm specifically interested in extracting elevation from Mapzen Terrarium tiles to display to the user of a map app, though deriving slope and/or aspect from a normals tile would also be cool.

matteblair commented 3 years ago

This seems like a pretty good API for this feature. Indeed this would need to be an asynchronous call because the data for raster tiles can only be accessed on our GL thread, not the UI thread. Other considerations:

@bcamper I think you were interested in this feature too!

kueda commented 3 years ago

FWIW, all your preferred answers to the questions you posed sound good to me.