render method
void
render(
- Uint8List pixels,
- int tileSize,
- int px,
- int py,
- PixelProjection projection,
- double latitude,
- double longitude,
- int elev,
override
Implementation
@override
void render(Uint8List pixels, int tileSize, int px, int py, PixelProjection projection, double latitude, double longitude, int elev) {
// -500 is ocean, see https://www.ngdc.noaa.gov/mgg/topo/report/s4/s4.html
if (elev == HgtFile.ocean) {
_setPixel(
pixels,
tileSize,
px,
py,
(oceanColor.r * 255).round(),
(oceanColor.g * 255).round(),
(oceanColor.b * 255).round(),
(oceanColor.a * 255).round(),
);
return;
}
// Clamp to typical SRTM range and map to [0..255].
const minM = 0;
const maxM = 5000;
final clamped = elev.clamp(minM, maxM);
final t = (clamped - minM) / (maxM - minM);
final intensity = (t * 255).round().clamp(0, 255);
_setPixel(pixels, tileSize, px, py, intensity, intensity, intensity, 255);
}