// This file is generated. // Edit platform/darwin/scripts/generate-style-code.js, then run `make style-code-darwin`. #import "MGLSource.h" #import "MGLMapView_Private.h" #import "NSPredicate+MGLAdditions.h" #import "MGLStyleLayer_Private.h" #import "MGLStyleValue_Private.h" #import "MGLRasterStyleLayer.h" #include @interface MGLRasterStyleLayer () @property (nonatomic) mbgl::style::RasterLayer *rawLayer; @end @implementation MGLRasterStyleLayer { std::unique_ptr _pendingLayer; } - (instancetype)initWithIdentifier:(NSString *)identifier source:(MGLSource *)source { if (self = [super initWithIdentifier:identifier source:source]) { auto layer = std::make_unique(identifier.UTF8String, source.identifier.UTF8String); _pendingLayer = std::move(layer); _rawLayer = _pendingLayer.get(); } return self; } #pragma mark - Adding to and removing from a map view - (void)addToMapView:(MGLMapView *)mapView belowLayer:(MGLStyleLayer *)otherLayer { if (_pendingLayer == nullptr) { [NSException raise:@"MGLRedundantLayerException" format:@"This instance %@ was already added to %@. Adding the same layer instance " \ "to the style more than once is invalid.", self, mapView.style]; } if (otherLayer) { const mbgl::optional belowLayerId{otherLayer.identifier.UTF8String}; mapView.mbglMap->addLayer(std::move(_pendingLayer), belowLayerId); } else { mapView.mbglMap->addLayer(std::move(_pendingLayer)); } } - (void)removeFromMapView:(MGLMapView *)mapView { _pendingLayer = nullptr; _rawLayer = nullptr; auto removedLayer = mapView.mbglMap->removeLayer(self.identifier.UTF8String); if (!removedLayer) { return; } mbgl::style::RasterLayer *layer = dynamic_cast(removedLayer.get()); if (!layer) { return; } removedLayer.release(); _pendingLayer = std::unique_ptr(layer); _rawLayer = _pendingLayer.get(); } #pragma mark - Accessing the Paint Attributes - (void)setMaximumRasterBrightness:(MGLStyleValue *)maximumRasterBrightness { MGLAssertStyleLayerIsValid(); auto mbglValue = MGLStyleValueTransformer().toPropertyValue(maximumRasterBrightness); _rawLayer->setRasterBrightnessMax(mbglValue); } - (MGLStyleValue *)maximumRasterBrightness { MGLAssertStyleLayerIsValid(); auto propertyValue = _rawLayer->getRasterBrightnessMax() ?: _rawLayer->getDefaultRasterBrightnessMax(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setMinimumRasterBrightness:(MGLStyleValue *)minimumRasterBrightness { MGLAssertStyleLayerIsValid(); auto mbglValue = MGLStyleValueTransformer().toPropertyValue(minimumRasterBrightness); _rawLayer->setRasterBrightnessMin(mbglValue); } - (MGLStyleValue *)minimumRasterBrightness { MGLAssertStyleLayerIsValid(); auto propertyValue = _rawLayer->getRasterBrightnessMin() ?: _rawLayer->getDefaultRasterBrightnessMin(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setRasterContrast:(MGLStyleValue *)rasterContrast { MGLAssertStyleLayerIsValid(); auto mbglValue = MGLStyleValueTransformer().toPropertyValue(rasterContrast); _rawLayer->setRasterContrast(mbglValue); } - (MGLStyleValue *)rasterContrast { MGLAssertStyleLayerIsValid(); auto propertyValue = _rawLayer->getRasterContrast() ?: _rawLayer->getDefaultRasterContrast(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setRasterFadeDuration:(MGLStyleValue *)rasterFadeDuration { MGLAssertStyleLayerIsValid(); auto mbglValue = MGLStyleValueTransformer().toPropertyValue(rasterFadeDuration); _rawLayer->setRasterFadeDuration(mbglValue); } - (MGLStyleValue *)rasterFadeDuration { MGLAssertStyleLayerIsValid(); auto propertyValue = _rawLayer->getRasterFadeDuration() ?: _rawLayer->getDefaultRasterFadeDuration(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setRasterHueRotation:(MGLStyleValue *)rasterHueRotation { MGLAssertStyleLayerIsValid(); auto mbglValue = MGLStyleValueTransformer().toPropertyValue(rasterHueRotation); _rawLayer->setRasterHueRotate(mbglValue); } - (MGLStyleValue *)rasterHueRotation { MGLAssertStyleLayerIsValid(); auto propertyValue = _rawLayer->getRasterHueRotate() ?: _rawLayer->getDefaultRasterHueRotate(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setRasterOpacity:(MGLStyleValue *)rasterOpacity { MGLAssertStyleLayerIsValid(); auto mbglValue = MGLStyleValueTransformer().toPropertyValue(rasterOpacity); _rawLayer->setRasterOpacity(mbglValue); } - (MGLStyleValue *)rasterOpacity { MGLAssertStyleLayerIsValid(); auto propertyValue = _rawLayer->getRasterOpacity() ?: _rawLayer->getDefaultRasterOpacity(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setRasterSaturation:(MGLStyleValue *)rasterSaturation { MGLAssertStyleLayerIsValid(); auto mbglValue = MGLStyleValueTransformer().toPropertyValue(rasterSaturation); _rawLayer->setRasterSaturation(mbglValue); } - (MGLStyleValue *)rasterSaturation { MGLAssertStyleLayerIsValid(); auto propertyValue = _rawLayer->getRasterSaturation() ?: _rawLayer->getDefaultRasterSaturation(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } @end