FeatureLayerTranslator translates a ZoomLevel's default styles even when it has CustomStyles (15.0.0-beta232)

Hi!

In 15.0.0-beta232, FeatureLayerTranslator translates a zoom level’s DefaultAreaStyle/DefaultLineStyle/DefaultPointStyle/DefaultTextStyle alongside its CustomStyles. Classic drawing uses the defaults only when CustomStyles is empty: ZoomLevel.GetStyles() returns CustomStyles alone once it has entries, and ZoomLevel.DrawCore skips the defaults in that case. As a result, the GPU map draws styles that the classic map ignores.

The translator already follows the classic rule one level down. For ValueItem, ClassBreak and RegexItem, the defaults are only translated when the entry has no CustomStyles. Only the zoom-level step is affected.

Repro

InMemoryFeatureLayer layer = new();
layer.InternalFeatures.Add(new Feature(0, 0, "1",
    new Dictionary<string, string> { ["name"] = "Example" }));

ZoomLevel level = layer.ZoomLevelSet.ZoomLevel01;
level.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
// Ignored by classic drawing, because the level has a custom style:
level.DefaultPointStyle = new PointStyle(PointSymbolType.Circle, 8, GeoBrushes.Red);
level.CustomStyles.Add(new PointStyle(PointSymbolType.Circle, 8, GeoBrushes.Blue));

FeatureSourceVectorTileSource source = new();
source.FeatureSources.Add("features", layer.FeatureSource);
FeatureLayerTranslation translation =
    FeatureLayerTranslator.Translate(layer, source, source.TileMatrixSet.GetScales());

foreach (TranslatedStyleLayer part in translation.Layers)
    Console.WriteLine($"{part.Id}: {((PointStyle)part.Origin).FillBrush}");

Expected: one circle layer, the blue custom style, which is what the classic map draws.

Actual: two circle layers (…-z01-20-01-circle from the red default, …-z01-20-02-circle from the blue custom style). The red circle is drawn on the GPU map only.

The same happens with the WebBasedAsyncFeatureLayer overload, and with any mix of defaults and custom styles. For example, a DefaultTextStyle left on a level whose CustomStyles hold a ValueStyle adds a label on GPU that classic never shows.

Workaround: before translating, we give the layer a copy of its ZoomLevelSet without the default styles on levels that have CustomStyles, then restore the original afterwards.

Could the translator follow ZoomLevel.GetStyles() here, the way it already does for value, class-break and regex items?

Thanks!

Hey Julian,

Fixed, thank you for the precise analysis and repro. The fix will be in the next beta.

FeatureLayerTranslator now follows ZoomLevel.GetStyles() at the zoom-level step, the same rule it already applied to value, class-break and regex items: when a zoom level has CustomStyles, only those are translated, and the level’s default area, line, point and text styles are used only when CustomStyles is empty. With your repro, the translation now contains a single circle layer from the blue custom style, matching the classic map. This applies to every Translate overload, including the WebBasedAsyncFeatureLayer ones, and to any mix of defaults and custom styles, so a DefaultTextStyle left beside a custom ValueStyle no longer adds a label on the GPU. You can remove the workaround that strips the default styles before translating.

One side effect to be aware of: on a level that used to mix defaults and custom styles, the translated style layer IDs change, since the custom styles are now numbered from the first position (…-01-…).

Thanks,
Kyle