Open issues after beta230

Hi Ben! We got a few new issues with the latest betas - here’s is an overview:

Thank you for the composite WFS work in beta218/219; AGK now uses several component
types, ReadUntilEmptyPage and the draw-scoped completion reuse. We have gone through
beta230 and collected everything still open for us in one post, most important first.
All of it applies to beta230 (Core, UI.Wpf, Gdal and Gpu).

1. Changing LayerOverlay.Layers during a draw throws “Collection was modified”.
LayerOverlay handles Layers.CollectionChanged by clearing and refilling the
DrawingLayers of every LayerTileView child. LayerTileView.DrawAsyncCore enumerates
drawingLayers and awaits each layer’s draw inside that loop. Adding or reordering a
layer while a tile draws therefore throws InvalidOperationException from
LayerTileView, through TileOverlay and LayerOverlay.DrawAsyncCore.

Reproduction: a MultiTile LayerOverlay with a slow async layer (a WFS layer is
enough), start a refresh, and call Layers.Add before it finishes. We hit it on every
layer add in our viewer.

Could a tile draw take a snapshot of its layers when it starts, or could the overlay
replace the list instead of changing it in place? A change would then apply from the next
draw. Today we cancel the draw and wait for it to finish before every change to
Layers.

2. A cancelled composite WFS extent read can return a partial result.
WfsV2CompositeFeatureSource.GetFeaturesInsideBoundingBoxAsync pages with
while (token != null && !cancellationToken.IsCancellationRequested) and then returns
the parents collected so far. AsyncFeatureSource.GetFeaturesInsideBoundingBoxAsync
does not check the token afterwards. A tile cancelled between two pages therefore gets
an incomplete feature list instead of OperationCanceledException. The raw
WfsV2AsyncFeatureSource read throws in the same situation. Could the composite throw
as well, so a cancelled draw can never cache or show a partial tile?

3. GPU polygon fills seem to draw above the border, covering it (cpu works)

4. Raw WFS column and id reads.
WfsV2AsyncFeatureSource.GetFeaturesByColumnValueAsync writes the column name into
fes:ValueReference without the type’s prefix or a namespace binding; the composite
source qualifies the same reference. Bayern’s ATKIS service rejects unqualified property
names, so we build our own prefixed FILTER for raw reads. GetFeaturesByIdsAsync
joins the ids into RESOURCEID without escaping them. Could the raw source qualify
column names the way the composite does, and escape the ids?

5. WFS schema lookup ignores namespaces.
When the source opens, it finds the feature type’s xs:element by the local part of
TypeName (case-insensitive) and its xs:complexType by local name, without comparing
namespaces. It does not follow xs:element ref, groups or imported schemas. Two types
with the same local name in different namespaces can therefore resolve to the wrong
one. A geometry declared through a reference, a group or an imported schema leaves
GeometryType at Invalid. Could the lookup resolve names against
targetNamespace and the type’s prefix, and follow references, groups and imports?

6. The GPU tile buffer is fixed at 8 px, and translation ignores DrawingMarginInPixel.
FeatureSourceVectorTileCutter passes a literal 8 as the tile buffer and pads its
queries by tileWidthInMapUnits * 8 / 512. FeatureLayerTranslator does not read
DrawingMarginInPixel (classic default: 50 px). FeatureSourceVectorTileSource
offers no buffer setting, while archive generation has
VectorTileLayerOptions.TileBufferPixel. Wide strokes and symbols near tile edges can
therefore be cut on GPU where classic draws them. Could the runtime source take a
configurable buffer, with the translator (including the async overloads and those that
take an existing source) honouring DrawingMarginInPixel? Please also say how a changed
buffer invalidates tiles that are already cut.

7. Label opacity.
Layer opacity applies to the labels as well. We need translucent geometry with opaque
labels: classic, we draw geometry and text in two passes; GPU, we translate the same
layer twice with filtered styles. The translator also ignores LabelDisplayMode.
Could labels keep full opacity independently of the layer (a text-style opacity or a
layer option), in classic drawing and in the translator? Could the translator also
honour LabelDisplayMode? This is a duplicated issue, we already had a thread regarding this. If you don’t plan on changing this, that’s fine.

8. Dynamic sources for highlights.
We draw selection highlights with DynamicSource (AddLine, AddArea, AddPoint).
Lines and areas take only colours and widths, so dash patterns, hatch and texture
fills, offsets, direction markers, group opacity and labels are not available.
Point styles are fine: we bake them with StyleImages.Add. A point drawn as a circle
with a dashed outline also has no dash path in the translator. Could dynamic features
take a translated style (the output of FeatureLayerTranslator), or could
AddLine/AddArea gain dash, pattern and offset settings?

9. Restyling a GPU map.
GpuBasemap.SetStyleAsync(MapStyle) takes no cancellation token, so closing a project
or switching away must wait for it. A different tile grid needs a new host. Sources a
restyle removes are not disposed; that is fine for us, since we own them, but it is not
documented. Could SetStyleAsync take a CancellationToken? Is a grid change on an
existing host planned? Could the documentation say who owns removed sources?

10. Tile replacement detection (low priority).
TileReplacementMode left at its default replaces tiles in groups only when a visible
layer, or a layer inside a GroupLayer, has Opacity < 1. Alpha in a style’s brushes
or pens is not seen, so translucent fills drawn at layer opacity 1 overlap old and new
tiles. We set TileReplacementMode.Grouped ourselves. Could the check consider style
alpha, or the documentation recommend setting the mode for such styles?

Two status questions.

  • GDAL: we still call GdalManager.ConfigureGdal() and ConfigureOgr() at startup to
    avoid the native load-order crash. beta230 still depends on
    ThinkGeo.Gdal.Dependency.Windows 14.5.4. Is the rename of the conflicting native DLLs
    still planned, and in which version?
  • Shapefiles with PolyLineZ/PolygonZ: beta160 fixed point simplification, but line and
    polygon labels for the reported Z-flagged files were still missing, so we flatten them
    to 2D before labelling. Has the labelling of Z-flagged shapes changed since? Then we
    would re-test without the adapter.

Thank you!

Hi,

Thank you for collecting everything in one post and for the detailed analysis. Ben is out of town this week, but we will do our best to fill in for him. Below is where each one stands. Unless noted otherwise, the changes will be in the next beta (beta231).

1. Changing LayerOverlay.Layers during a draw - Fixed. Each tile now draws from a snapshot of the overlay’s layers taken when its draw starts. Adding, removing or reordering layers while tiles are drawing no longer throws, and the change applies from the next draw, as you suggested. You should no longer need to cancel and wait for the draw before changing Layers. Layer open and close are also covered, so changing Layers while the overlay is still opening its layers no longer throws either.

2. Cancelled composite WFS extent read - Fixed. A composite WFS read that is cancelled between pages now throws OperationCanceledException, as the raw WFS source does, instead of returning the records collected so far. A cancelled tile draw can no longer cache or show an incomplete set of features.

3. GPU polygon fills drawn over their border - Fixed. A thin (1 px) polygon border could be covered by the polygon’s own fill on the GPU: borders shared between neighbouring polygons disappeared, and outer borders were only half visible. The border is now always drawn over the fill. This applies to layers translated from classic styles and to fill layers created in code, and the same correction was made in the CPU tile renderer. Thicker borders were not affected. Note that 1 px borders on the GPU are drawn as a single antialiased pixel, so they can look slightly crisper than the classic renderer’s 1 px pen.

4. Raw WFS column and id reads - Fixed. Reading features by column value now qualifies the column name with the feature type’s prefix and declares the namespace inside the filter, as the composite source already did, so services that reject unqualified property names (such as the Bayern ATKIS service) accept it. The value is now escaped as well, so values containing characters like & or < no longer break the request. Reading by IDs now escapes each ID in RESOURCEID, so IDs containing &, # or + reach the service intact. You should be able to drop your own prefixed FILTER for raw reads.

5. WFS schema lookup and namespaces - Fixed. The feature type is now located in the DescribeFeatureType schema by its namespace and name, not by local name alone, so types with the same local name in different namespaces no longer get mixed up. Type names, base types, element references (xs:element ref) and model groups are resolved against the namespaces the schema declares. Schemas imported or included through a schemaLocation are loaded when the feature type needs something from them, so a geometry declared through a reference, a group, or a base type in an imported schema is now detected and GeometryType is set. Standard OGC/W3C/ISO schemas (e.g. GML) are never downloaded. One limitation: a property that refers directly to a global GML element (e.g. ref="gml:pointProperty") is still not recognised as the geometry.

6. GPU tile buffer and DrawingMarginInPixel - Implemented. FeatureSourceVectorTileSource now has a TileBufferInPixels property (0-512 tile pixels, default 8). FeatureLayerTranslator sets it from the layer’s DrawingMarginInPixel, rounded up. This applies to all overloads, including the asynchronous-layer overloads and those that take an existing source. A source shared by several layers is only ever raised, so it keeps the widest margin any of them asks for. The GPU and CPU tile renderers now keep everything within that buffer, so wide strokes and symbols near tile edges are drawn as the classic renderer draws them. Note that a layer translated with the classic default margin of 50 px is now cut with a 50 px buffer instead of 8, which means somewhat more data per tile; lower DrawingMarginInPixel if you prefer the previous cost.

On invalidation: changing TileBufferInPixels while the source is open is treated like a change to the data. Tiles already cut are discarded, the source’s tiles in its VectorTileCache are removed, and DataChanged is raised for the whole source, so the map discards its decoded tiles and requests them again. Tiles stored in a VectorTileCache from a previous run are not tracked by buffer size. If you change the buffer between runs, clear that cache or use a different SourceId.

7. Label opacity and LabelDisplayMode - Partly addressed. FeatureLayerTranslator now honours the layer’s LabelDisplayMode, the same way classic drawing does: LabelsOnly translates only the text styles, and ShapesOnly translates everything except them, including custom styles and the items of value, class-break and regex styles. For translucent geometry with opaque labels on the GPU, you can now translate the same layer twice, once with ShapesOnly at the layer’s opacity and once with LabelsOnly at full opacity, without maintaining filtered copies of your styles. Keeping labels at full opacity independently of the layer’s opacity, in classic drawing and in the translator, needs a larger change to how layers are drawn. We’ll follow up on that in the existing thread.

8. Dynamic sources for highlights - Partly addressed. A point drawn as a circle with a dashed outline now keeps its dash when translated (it is drawn as an icon instead of a plain circle). Richer styling for DynamicSource lines and areas (dash patterns, hatch and texture fills, offsets, direction markers, group opacity and labels), or letting dynamic features take a translated style, needs changes to the engine’s dynamic-geometry rendering, and we’re tracking it as a separate feature request. In the meantime, for fully styled highlights you can put the highlight features in an InMemoryFeatureSource inside a FeatureSourceVectorTileSource and draw it with a translated layer. All translated styling then applies, and adding or removing highlight features updates the affected tiles automatically, at somewhat higher update cost than DynamicSource.

9. Restyling a GPU map - GpuBasemap.SetStyleAsync now has an overload that takes a CancellationToken. The token is honoured while the style compiles (resolving it and loading its sprite and glyphs, which is the slow part), so closing a project or switching away no longer has to wait for it. A cancelled call throws OperationCanceledException and leaves the map with the style, sources and picture it had. Once the new style is being bound, the switch completes, so a call that returns has applied its style.

Ownership of removed sources is documented on GpuBasemap.SetStyleAsync: the map never disposes a source that a restyle removes, since the sources are yours. Dispose of any you won’t use again. Sources the map still holds when it closes are disposed then.

Changing the tile grid on an existing host is not part of this release; a style whose sources use a different grid still needs a new host. We have noted it as a feature request.

10. Tile replacement detection - Done. With TileReplacementMode left at its default, a LayerOverlay now also replaces tiles in groups when a visible feature layer’s styles at the current scale use translucent colours: fills, outlines, line pens, point symbols, and label text, halos and masks, including inside value, class-break, regex, composite and custom styles. Translucent fills drawn at layer opacity 1 no longer overlap old and new tiles during a redraw, so you should not need to set Grouped yourself for such styles. Transparency that the overlay cannot read from the styles, such as an image or texture with alpha or a custom style class, still needs TileReplacementMode.Grouped, and the documentation now says so.

Status questions

GDAL: The rename of the conflicting native GDAL DLLs is not in beta231; it still depends on ThinkGeo.Gdal.Dependency.Windows 14.5.4. I believe we will have this fixed before the official 15.0 release, but I will have to check with Ben on the exact timeline on that. Until then, please keep calling GdalManager.ConfigureGdal() and ConfigureOgr() at startup.

Shapefiles with PolyLineZ/PolygonZ: Yes - line and polygon Z support has been reworked since then. Z values are kept by default (ThinkGeoSettings.PreserveZ), and lines and polygons read from Z-flagged shapefiles are drawn and labelled like their 2D equivalents, in classic drawing and on the GPU. We verified it on beta231 with PolyLineZ and PolygonZ files and added regression tests. Please re-test without your 2D adapter; if any of your files still lose their labels, a sample file would let us reproduce it exactly.

Thanks again for the thorough report.

1 Like