// This file is generated. // Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. #import "MGLSource.h" #import "MGLMapView_Private.h" #import "NSPredicate+MGLAdditions.h" #import "MGLStyleLayer_Private.h" #import "MGLStyleValue_Private.h" #import "MGLRasterStyleLayer.h" #include #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); self.rawLayer = _pendingLayer.get(); } return self; } - (mbgl::style::RasterLayer *)rawLayer { return (mbgl::style::RasterLayer *)super.rawLayer; } - (void)setRawLayer:(mbgl::style::RasterLayer *)rawLayer { super.rawLayer = rawLayer; } - (NSString *)sourceIdentifier { MGLAssertStyleLayerIsValid(); return @(self.rawLayer->getSourceID().c_str()); } #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 { if (self.rawLayer != mapView.mbglMap->getLayer(self.identifier.UTF8String)) { return; } 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); self.rawLayer = _pendingLayer.get(); } #pragma mark - Accessing the Paint Attributes - (void)setMaximumRasterBrightness:(MGLStyleValue *)maximumRasterBrightness { MGLAssertStyleLayerIsValid(); auto mbglValue = MGLStyleValueTransformer().toInterpolatablePropertyValue(maximumRasterBrightness); self.rawLayer->setRasterBrightnessMax(mbglValue); } - (MGLStyleValue *)maximumRasterBrightness { MGLAssertStyleLayerIsValid(); auto propertyValue = self.rawLayer->getRasterBrightnessMax(); if (propertyValue.isUndefined()) { return MGLStyleValueTransformer().toStyleValue(self.rawLayer->getDefaultRasterBrightnessMax()); } return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setRasterBrightnessMax:(MGLStyleValue *)rasterBrightnessMax { } - (MGLStyleValue *)rasterBrightnessMax { return self.maximumRasterBrightness; } - (void)setMinimumRasterBrightness:(MGLStyleValue *)minimumRasterBrightness { MGLAssertStyleLayerIsValid(); auto mbglValue = MGLStyleValueTransformer().toInterpolatablePropertyValue(minimumRasterBrightness); self.rawLayer->setRasterBrightnessMin(mbglValue); } - (MGLStyleValue *)minimumRasterBrightness { MGLAssertStyleLayerIsValid(); auto propertyValue = self.rawLayer->getRasterBrightnessMin(); if (propertyValue.isUndefined()) { return MGLStyleValueTransformer().toStyleValue(self.rawLayer->getDefaultRasterBrightnessMin()); } return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setRasterBrightnessMin:(MGLStyleValue *)rasterBrightnessMin { } - (MGLStyleValue *)rasterBrightnessMin { return self.minimumRasterBrightness; } - (void)setRasterContrast:(MGLStyleValue *)rasterContrast { MGLAssertStyleLayerIsValid(); auto mbglValue = MGLStyleValueTransformer().toInterpolatablePropertyValue(rasterContrast); self.rawLayer->setRasterContrast(mbglValue); } - (MGLStyleValue *)rasterContrast { MGLAssertStyleLayerIsValid(); auto propertyValue = self.rawLayer->getRasterContrast(); if (propertyValue.isUndefined()) { return MGLStyleValueTransformer().toStyleValue(self.rawLayer->getDefaultRasterContrast()); } return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setRasterFadeDuration:(MGLStyleValue *)rasterFadeDuration { MGLAssertStyleLayerIsValid(); auto mbglValue = MGLStyleValueTransformer().toInterpolatablePropertyValue(rasterFadeDuration); self.rawLayer->setRasterFadeDuration(mbglValue); } - (MGLStyleValue *)rasterFadeDuration { MGLAssertStyleLayerIsValid(); auto propertyValue = self.rawLayer->getRasterFadeDuration(); if (propertyValue.isUndefined()) { return MGLStyleValueTransformer().toStyleValue(self.rawLayer->getDefaultRasterFadeDuration()); } return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setRasterHueRotation:(MGLStyleValue *)rasterHueRotation { MGLAssertStyleLayerIsValid(); auto mbglValue = MGLStyleValueTransformer().toInterpolatablePropertyValue(rasterHueRotation); self.rawLayer->setRasterHueRotate(mbglValue); } - (MGLStyleValue *)rasterHueRotation { MGLAssertStyleLayerIsValid(); auto propertyValue = self.rawLayer->getRasterHueRotate(); if (propertyValue.isUndefined()) { return MGLStyleValueTransformer().toStyleValue(self.rawLayer->getDefaultRasterHueRotate()); } return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setRasterHueRotate:(MGLStyleValue *)rasterHueRotate { } - (MGLStyleValue *)rasterHueRotate { return self.rasterHueRotation; } - (void)setRasterOpacity:(MGLStyleValue *)rasterOpacity { MGLAssertStyleLayerIsValid(); auto mbglValue = MGLStyleValueTransformer().toInterpolatablePropertyValue(rasterOpacity); self.rawLayer->setRasterOpacity(mbglValue); } - (MGLStyleValue *)rasterOpacity { MGLAssertStyleLayerIsValid(); auto propertyValue = self.rawLayer->getRasterOpacity(); if (propertyValue.isUndefined()) { return MGLStyleValueTransformer().toStyleValue(self.rawLayer->getDefaultRasterOpacity()); } return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setRasterSaturation:(MGLStyleValue *)rasterSaturation { MGLAssertStyleLayerIsValid(); auto mbglValue = MGLStyleValueTransformer().toInterpolatablePropertyValue(rasterSaturation); self.rawLayer->setRasterSaturation(mbglValue); } - (MGLStyleValue *)rasterSaturation { MGLAssertStyleLayerIsValid(); auto propertyValue = self.rawLayer->getRasterSaturation(); if (propertyValue.isUndefined()) { return MGLStyleValueTransformer().toStyleValue(self.rawLayer->getDefaultRasterSaturation()); } return MGLStyleValueTransformer().toStyleValue(propertyValue); } @end