// 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 "MGLFillStyleLayer.h" #include namespace mbgl { MBGL_DEFINE_ENUM(MGLFillTranslateAnchor, { { MGLFillTranslateAnchorMap, "map" }, { MGLFillTranslateAnchorViewport, "viewport" }, }); } @interface MGLFillStyleLayer () @property (nonatomic) mbgl::style::FillLayer *rawLayer; @end @implementation MGLFillStyleLayer { 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; } - (NSString *)sourceLayerIdentifier { auto layerID = _rawLayer->getSourceLayer(); return layerID.empty() ? nil : @(layerID.c_str()); } - (void)setSourceLayerIdentifier:(NSString *)sourceLayerIdentifier { _rawLayer->setSourceLayer(sourceLayerIdentifier.UTF8String ?: ""); } - (void)setPredicate:(NSPredicate *)predicate { _rawLayer->setFilter(predicate.mgl_filter); } - (NSPredicate *)predicate { return [NSPredicate mgl_predicateWithFilter:_rawLayer->getFilter()]; } #pragma mark - Adding to and removing from a map view - (void)addToMapView:(MGLMapView *)mapView { [self addToMapView:mapView belowLayer:nil]; } - (void)addToMapView:(MGLMapView *)mapView belowLayer:(MGLStyleLayer *)otherLayer { 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 { auto removedLayer = mapView.mbglMap->removeLayer(self.identifier.UTF8String); if (!removedLayer) { return; } _pendingLayer = std::move(reinterpret_cast &>(removedLayer)); _rawLayer = _pendingLayer.get(); } #pragma mark - Accessing the Paint Attributes - (void)setFillAntialias:(MGLStyleValue *)fillAntialias { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(fillAntialias); _rawLayer->setFillAntialias(mbglValue); } - (MGLStyleValue *)fillAntialias { auto propertyValue = _rawLayer->getFillAntialias() ?: _rawLayer->getDefaultFillAntialias(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setFillColor:(MGLStyleValue *)fillColor { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(fillColor); _rawLayer->setFillColor(mbglValue); } - (MGLStyleValue *)fillColor { auto propertyValue = _rawLayer->getFillColor() ?: _rawLayer->getDefaultFillColor(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setFillOpacity:(MGLStyleValue *)fillOpacity { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(fillOpacity); _rawLayer->setFillOpacity(mbglValue); } - (MGLStyleValue *)fillOpacity { auto propertyValue = _rawLayer->getFillOpacity() ?: _rawLayer->getDefaultFillOpacity(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setFillOutlineColor:(MGLStyleValue *)fillOutlineColor { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(fillOutlineColor); _rawLayer->setFillOutlineColor(mbglValue); } - (MGLStyleValue *)fillOutlineColor { auto propertyValue = _rawLayer->getFillOutlineColor() ?: _rawLayer->getDefaultFillOutlineColor(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setFillPattern:(MGLStyleValue *)fillPattern { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(fillPattern); _rawLayer->setFillPattern(mbglValue); } - (MGLStyleValue *)fillPattern { auto propertyValue = _rawLayer->getFillPattern() ?: _rawLayer->getDefaultFillPattern(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setFillTranslate:(MGLStyleValue *)fillTranslate { auto mbglValue = MGLStyleValueTransformer, NSValue *>().toPropertyValue(fillTranslate); _rawLayer->setFillTranslate(mbglValue); } - (MGLStyleValue *)fillTranslate { auto propertyValue = _rawLayer->getFillTranslate() ?: _rawLayer->getDefaultFillTranslate(); return MGLStyleValueTransformer, NSValue *>().toStyleValue(propertyValue); } - (void)setFillTranslateAnchor:(MGLStyleValue *)fillTranslateAnchor { auto mbglValue = MGLStyleValueTransformer().toEnumPropertyValue(fillTranslateAnchor); _rawLayer->setFillTranslateAnchor(mbglValue); } - (MGLStyleValue *)fillTranslateAnchor { auto propertyValue = _rawLayer->getFillTranslateAnchor() ?: _rawLayer->getDefaultFillTranslateAnchor(); return MGLStyleValueTransformer().toEnumStyleValue(propertyValue); } @end