Implementation
static RasterLayer decode(String properties) {
var map = json.decode(properties);
if (map["layout"] == null) {
map["layout"] = {};
}
if (map["paint"] == null) {
map["paint"] = {};
}
return RasterLayer(
id: map["id"],
sourceId: map["source"],
sourceLayer: map["source-layer"],
minZoom: map["minzoom"]?.toDouble(),
maxZoom: map["maxzoom"]?.toDouble(),
visibility: map["layout"]["visibility"] == null
? Visibility.VISIBLE
: Visibility.values.firstWhere((e) => e
.toString()
.split('.')
.last
.toLowerCase()
.contains(map["layout"]["visibility"])),
rasterBrightnessMax: map["paint"]["raster-brightness-max"]?.toDouble(),
rasterBrightnessMin: map["paint"]["raster-brightness-min"]?.toDouble(),
rasterContrast: map["paint"]["raster-contrast"]?.toDouble(),
rasterFadeDuration: map["paint"]["raster-fade-duration"]?.toDouble(),
rasterHueRotate: map["paint"]["raster-hue-rotate"]?.toDouble(),
rasterOpacity: map["paint"]["raster-opacity"]?.toDouble(),
rasterResampling: map["paint"]["raster-resampling"] == null
? null
: RasterResampling.values.firstWhere((e) => e
.toString()
.split('.')
.last
.toLowerCase()
.contains(map["paint"]["raster-resampling"])),
rasterSaturation: map["paint"]["raster-saturation"]?.toDouble(),
);
}