decode static method
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"] is num?
? (map["paint"]["raster-brightness-max"] as num?)?.toDouble()
: null,
rasterBrightnessMin: map["paint"]["raster-brightness-min"] is num?
? (map["paint"]["raster-brightness-min"] as num?)?.toDouble()
: null,
rasterContrast: map["paint"]["raster-contrast"] is num?
? (map["paint"]["raster-contrast"] as num?)?.toDouble()
: null,
rasterFadeDuration: map["paint"]["raster-fade-duration"] is num?
? (map["paint"]["raster-fade-duration"] as num?)?.toDouble()
: null,
rasterHueRotate: map["paint"]["raster-hue-rotate"] is num?
? (map["paint"]["raster-hue-rotate"] as num?)?.toDouble()
: null,
rasterOpacity: map["paint"]["raster-opacity"] is num?
? (map["paint"]["raster-opacity"] as num?)?.toDouble()
: null,
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"] is num?
? (map["paint"]["raster-saturation"] as num?)?.toDouble()
: null,
);
}