<commit_before>﻿using System;
using Mapsui.Layers;
using Mapsui.Rendering.Skia.Extensions;
using Mapsui.Rendering.Skia.SkiaStyles;
using Mapsui.Styles;
using SkiaSharp;
using Topten.RichTextKit;

namespace Mapsui.Rendering.Skia
{
    public class CalloutStyleRenderer : ISkiaStyleRenderer
    {
        public bool Draw(SKCanvas canvas, IReadOnlyViewport viewport, ILayer layer, IFeature feature, Styles.IStyle style, ISymbolCache symbolCache, long iteration)
        {
            var pointFeature = (PointFeature)feature;
            var calloutStyle = (CalloutStyle)style;

            var opacity = (float)(layer.Opacity * style.Opacity);

            var (x, y) = viewport.WorldToScreenXY(pointFeature.Point.X, pointFeature.Point.Y);

            if (calloutStyle.BitmapId < 0 || calloutStyle.Invalidated)
            {
                if (calloutStyle.Content < 0 && calloutStyle.Type == CalloutType.Custom)
                    return false;

                if (calloutStyle.Invalidated)
                {
                    UpdateContent(calloutStyle);
                }
<commit_msg>Fix Pin callout for #1546<commit_after>﻿using System;
using Mapsui.Layers;
using Mapsui.Rendering.Skia.Extensions;
using Mapsui.Rendering.Skia.SkiaStyles;
using Mapsui.Styles;
using SkiaSharp;
using Topten.RichTextKit;

namespace Mapsui.Rendering.Skia
{
    public class CalloutStyleRenderer : ISkiaStyleRenderer
    {
        public bool Draw(SKCanvas canvas, IReadOnlyViewport viewport, ILayer layer, IFeature feature, Styles.IStyle style, ISymbolCache symbolCache, long iteration)
        {
            var centroid = feature.Extent?.Centroid;

            if (centroid is null) 
                return false;

            var calloutStyle = (CalloutStyle)style;

            // Todo: Use opacity
            var opacity = (float)(layer.Opacity * style.Opacity);

            var (x, y) = viewport.WorldToScreenXY(centroid.X, centroid.Y);

            if (calloutStyle.BitmapId < 0 || calloutStyle.Invalidated)
            {
                if (calloutStyle.Content < 0 && calloutStyle.Type == CalloutType.Custom)
                    return false;

                if (calloutStyle.Invalidated)
                {
                    UpdateContent(calloutStyle);
                }

{'fraction_non_alphanumeric': 0.08351648351648351, 'fraction_numerical': 0.0035164835164835165, 'mean_word_length': 2.327485380116959, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '673926', 'n_tokens_mistral': 662, 'n_tokens_neox': 629, 'n_words': 143}