We have been using WfsV2FeatureLayer for a while but now it’s marked as obsolete and WfsV2AsyncLayer should be used instead.
There are couple of problems related to this change from your POV.
It seems that WfsV2AsyncLayer does not support QueryTools which we have been using to get features from WfsV2FeatureLayer in different scenarios. Is there some way to query features from WfsV2AsyncLayer or would it be possible to add support for QueryTools ?
We have generic implementation for different layers which use FeatureLayer as base class (OgcApi/Wfs/WfsV2/etc.) for setting styles etc. Problem is that now WfsV2AsyncLayer has totally different inheritance and would mean that instead of common implementation handling FeatureLayer we would need own specific implementation for WfsV2AsyncLayer.
BTW, what is the reason for removing WfsV2FeatureLayer ? It has been working without issues on our case so far.
Good points! Here is why we did it and how we are going to fix it:
Why async
The sync path uses WebRequest, which is legacy and broken on some targets (Blazor WASM for example). Its replacement, HttpClient, exposes only async methods. That leaves two options: block on the async call (.Result), which deadlocks under a SynchronizationContext and wastes a thread-pool thread, or let async go all the way up.
Async also handles cancellation properly, and an async signature is a more honest description of a class that fetches over the network.
What we got wrong
The new async classes (WfsV2AsyncLayer, as well as other web-based async layers) have to pass through FeatureSource, whose core methods (GetAllFeaturesCore, GetFeaturesInsideBoundingBoxCore) are all synchronous. This answers your first question directly: QueryTools hangs off FeatureSource, and WfsV2AsyncLayer doesn’t have one.
We only obsoleted it for WFS 2.0. WFS 1.0 and OGC API FeatureLayers are not deprecated. That’s exactly why your generic code works everywhere except WFS 2.0 — the inconsistency is ours.
What we’ll do
Add an async FeatureSource (plus async feature layer and query surface) for the sources that talk over the network — giving the async model the same shape the sync one has.
Then deprecate the sync network classes together — WFS 1.0, WFS 2.0, OGC API Features — pointing at a replacement that exists.
This will be added within a couple days. I’ll keep you posted
Any change to support GetFeaturesWithinDistanceOf similar to QueryTools ? It has been handy to e.g get stuff near GPS location.
Of course there are lots of different APIs to query features in QueryTools which are now missing from WfsV2AsyncFeatureSource but that GetFeaturesWithinDistanceOf is something what we would need.
// what you asked for
await source.GetFeaturesWithinDistanceOfAsync(gpsPoint, GeographyUnit.Meter, DistanceUnit.Meter, 500, ct);
// and the rest of the spatial predicates
await source.GetFeaturesIntersectingAsync(shape, ct);
await source.GetFeaturesContainingAsync(shape, ct);
await source.GetFeaturesCrossingAsync(shape, ct);
await source.GetFeaturesOverlappingAsync(shape, ct);
await source.GetFeaturesTouchingAsync(shape, ct);
await source.GetFeaturesWithinAsync(shape, ct);
await source.GetFeaturesTopologicalEqualAsync(shape, ct);
// nearest-N, within a radius you name
await source.GetFeaturesNearestToAsync(gpsPoint, GeographyUnit.Meter, 5, DistanceUnit.Meter, 1000, ct);
Each has the same four overloads QueryTools has — target as a BaseShape or a Feature, with or without a column list.
Two differences from the synchronous versions, both deliberate:
GetFeaturesNearestToAsync requires a search radius. Nearest-N over an unbounded area has no safe implementation against a service.
GetFeaturesDisjointed has no counterpart. It reads through “everything outside this box”, that cannot be done against a service.