// 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 "MGLLineStyleLayer.h" #include namespace mbgl { MBGL_DEFINE_ENUM(MGLLineCap, { { MGLLineCapButt, "butt" }, { MGLLineCapRound, "round" }, { MGLLineCapSquare, "square" }, }); MBGL_DEFINE_ENUM(MGLLineJoin, { { MGLLineJoinBevel, "bevel" }, { MGLLineJoinRound, "round" }, { MGLLineJoinMiter, "miter" }, }); MBGL_DEFINE_ENUM(MGLLineTranslateAnchor, { { MGLLineTranslateAnchorMap, "map" }, { MGLLineTranslateAnchorViewport, "viewport" }, }); } @interface MGLLineStyleLayer () @property (nonatomic) mbgl::style::LineLayer *rawLayer; @end @implementation MGLLineStyleLayer { 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 { MGLAssertStyleLayerIsValid(); auto layerID = _rawLayer->getSourceLayer(); return layerID.empty() ? nil : @(layerID.c_str()); } - (void)setSourceLayerIdentifier:(NSString *)sourceLayerIdentifier { MGLAssertStyleLayerIsValid(); _rawLayer->setSourceLayer(sourceLayerIdentifier.UTF8String ?: ""); } - (void)setPredicate:(NSPredicate *)predicate { MGLAssertStyleLayerIsValid(); _rawLayer->setFilter(predicate.mgl_filter); } - (NSPredicate *)predicate { MGLAssertStyleLayerIsValid(); return [NSPredicate mgl_predicateWithFilter:_rawLayer->getFilter()]; } #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::LineLayer *layer = dynamic_cast(removedLayer.get()); if (!layer) { return; } removedLayer.release(); _pendingLayer = std::unique_ptr(layer); _rawLayer = _pendingLayer.get(); } #pragma mark - Accessing the Layout Attributes - (void)setLineCap:(MGLStyleValue *)lineCap { MGLAssertStyleLayerIsValid(); auto mbglValue = MGLStyleValueTransformer().toEnumPropertyValue(lineCap); _rawLayer->setLineCap(mbglValue); } - (MGLStyleValue *)lineCap { MGLAssertStyleLayerIsValid(); auto propertyValue = _rawLayer->getLineCap() ?: _rawLayer->getDefaultLineCap(); return MGLStyleValueTransformer().toEnumStyleValue(propertyValue); } - (void)setLineJoin:(MGLStyleValue *)lineJoin { MGLAssertStyleLayerIsValid(); auto mbglValue = MGLStyleValueTransformer().toEnumPropertyValue(lineJoin); _rawLayer->setLineJoin(mbglValue); } - (MGLStyleValue *)lineJoin { MGLAssertStyleLayerIsValid(); auto propertyValue = _rawLayer->getLineJoin() ?: _rawLayer->getDefaultLineJoin(); return MGLStyleValueTransformer().toEnumStyleValue(propertyValue); } - (void)setLineMiterLimit:(MGLStyleValue *)lineMiterLimit { MGLAssertStyleLayerIsValid(); auto mbglValue = MGLStyleValueTransformer().toPropertyValue(lineMiterLimit); _rawLayer->setLineMiterLimit(mbglValue); } - (MGLStyleValue *)lineMiterLimit { MGLAssertStyleLayerIsValid(); auto propertyValue = _rawLayer->getLineMiterLimit() ?: _rawLayer->getDefaultLineMiterLimit(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setLineRoundLimit:(MGLStyleValue *)lineRoundLimit { MGLAssertStyleLayerIsValid(); auto mbglValue = MGLStyleValueTransformer().toPropertyValue(lineRoundLimit); _rawLayer->setLineRoundLimit(mbglValue); } - (MGLStyleValue *)lineRoundLimit { MGLAssertStyleLayerIsValid(); auto propertyValue = _rawLayer->getLineRoundLimit() ?: _rawLayer->getDefaultLineRoundLimit(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } #pragma mark - Accessing the Paint Attributes - (void)setLineBlur:(MGLStyleValue *)lineBlur { MGLAssertStyleLayerIsValid(); auto mbglValue = MGLStyleValueTransformer().toPropertyValue(lineBlur); _rawLayer->setLineBlur(mbglValue); } - (MGLStyleValue *)lineBlur { MGLAssertStyleLayerIsValid(); auto propertyValue = _rawLayer->getLineBlur() ?: _rawLayer->getDefaultLineBlur(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setLineColor:(MGLStyleValue *)lineColor { MGLAssertStyleLayerIsValid(); auto mbglValue = MGLStyleValueTransformer().toPropertyValue(lineColor); _rawLayer->setLineColor(mbglValue); } - (MGLStyleValue *)lineColor { MGLAssertStyleLayerIsValid(); auto propertyValue = _rawLayer->getLineColor() ?: _rawLayer->getDefaultLineColor(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setLineDashPattern:(MGLStyleValue *> *)lineDashPattern { MGLAssertStyleLayerIsValid(); auto mbglValue = MGLStyleValueTransformer, NSArray *, float>().toPropertyValue(lineDashPattern); _rawLayer->setLineDasharray(mbglValue); } - (MGLStyleValue *> *)lineDashPattern { MGLAssertStyleLayerIsValid(); auto propertyValue = _rawLayer->getLineDasharray() ?: _rawLayer->getDefaultLineDasharray(); return MGLStyleValueTransformer, NSArray *, float>().toStyleValue(propertyValue); } - (void)setLineGapWidth:(MGLStyleValue *)lineGapWidth { MGLAssertStyleLayerIsValid(); auto mbglValue = MGLStyleValueTransformer().toPropertyValue(lineGapWidth); _rawLayer->setLineGapWidth(mbglValue); } - (MGLStyleValue *)lineGapWidth { MGLAssertStyleLayerIsValid(); auto propertyValue = _rawLayer->getLineGapWidth() ?: _rawLayer->getDefaultLineGapWidth(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setLineOffset:(MGLStyleValue *)lineOffset { MGLAssertStyleLayerIsValid(); auto mbglValue = MGLStyleValueTransformer().toPropertyValue(lineOffset); _rawLayer->setLineOffset(mbglValue); } - (MGLStyleValue *)lineOffset { MGLAssertStyleLayerIsValid(); auto propertyValue = _rawLayer->getLineOffset() ?: _rawLayer->getDefaultLineOffset(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setLineOpacity:(MGLStyleValue *)lineOpacity { MGLAssertStyleLayerIsValid(); auto mbglValue = MGLStyleValueTransformer().toPropertyValue(lineOpacity); _rawLayer->setLineOpacity(mbglValue); } - (MGLStyleValue *)lineOpacity { MGLAssertStyleLayerIsValid(); auto propertyValue = _rawLayer->getLineOpacity() ?: _rawLayer->getDefaultLineOpacity(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setLinePattern:(MGLStyleValue *)linePattern { MGLAssertStyleLayerIsValid(); auto mbglValue = MGLStyleValueTransformer().toPropertyValue(linePattern); _rawLayer->setLinePattern(mbglValue); } - (MGLStyleValue *)linePattern { MGLAssertStyleLayerIsValid(); auto propertyValue = _rawLayer->getLinePattern() ?: _rawLayer->getDefaultLinePattern(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setLineTranslate:(MGLStyleValue *)lineTranslate { MGLAssertStyleLayerIsValid(); auto mbglValue = MGLStyleValueTransformer, NSValue *>().toPropertyValue(lineTranslate); _rawLayer->setLineTranslate(mbglValue); } - (MGLStyleValue *)lineTranslate { MGLAssertStyleLayerIsValid(); auto propertyValue = _rawLayer->getLineTranslate() ?: _rawLayer->getDefaultLineTranslate(); return MGLStyleValueTransformer, NSValue *>().toStyleValue(propertyValue); } - (void)setLineTranslateAnchor:(MGLStyleValue *)lineTranslateAnchor { MGLAssertStyleLayerIsValid(); auto mbglValue = MGLStyleValueTransformer().toEnumPropertyValue(lineTranslateAnchor); _rawLayer->setLineTranslateAnchor(mbglValue); } - (MGLStyleValue *)lineTranslateAnchor { MGLAssertStyleLayerIsValid(); auto propertyValue = _rawLayer->getLineTranslateAnchor() ?: _rawLayer->getDefaultLineTranslateAnchor(); return MGLStyleValueTransformer().toEnumStyleValue(propertyValue); } - (void)setLineWidth:(MGLStyleValue *)lineWidth { MGLAssertStyleLayerIsValid(); auto mbglValue = MGLStyleValueTransformer().toPropertyValue(lineWidth); _rawLayer->setLineWidth(mbglValue); } - (MGLStyleValue *)lineWidth { MGLAssertStyleLayerIsValid(); auto propertyValue = _rawLayer->getLineWidth() ?: _rawLayer->getDefaultLineWidth(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } @end