WfsV2AsyncFeatureSource¶
Namespace: ThinkGeo.Core
Reads features asynchronously from a WFS 2.0 service.
public class WfsV2AsyncFeatureSource : WebBasedAsyncFeatureSource, IHttpRequestService
Inheritance object → AsyncFeatureSource → WebBasedAsyncFeatureSource → WfsV2AsyncFeatureSource
Implements IHttpRequestService
Remarks:
WFS 2.0 can execute a good deal on the caller's behalf, so this source implements every optional capability: it pages with STARTINDEX/COUNT, counts with resultType=hits, filters on a column with PropertyIsEqualTo, and addresses features by ResourceId. None of those round trips fetch more than they need.
Properties¶
ServiceLocationUrl¶
Gets or sets the base URL of the WFS service.
public string ServiceLocationUrl { get; set; }
Property Value¶
Remarks:
Read when the source opens: the capabilities, schema and geometry type it describes are fetched then and kept. Set it before AsyncFeatureSource.OpenAsync(CancellationToken); a change on an open source takes effect when the source is closed and opened again.
TypeName¶
Gets or sets the fully qualified feature type (layer) name to request.
public string TypeName { get; set; }
Property Value¶
Remarks:
Read when the source opens: the schema, columns and geometry type it describes are fetched then and kept. Set it before AsyncFeatureSource.OpenAsync(CancellationToken); a change on an open source takes effect when the source is closed and opened again.
Give it as the capabilities name it - adv:AX_Strasse - or by its namespace URI and local name, {http://www.adv-online.de/namespaces/adv/gid/7.1}AX_Strasse, which does not depend on the prefix the service happens to use: the source looks the type up in the capabilities when it opens and uses the prefix the service binds there.
WfsAxisOrder¶
Gets or sets the axis order used when reading coordinates from the service.
public WfsAxisOrder WfsAxisOrder { get; set; }
Property Value¶
Remarks:
The default works the order out from the EPSG code the server advertises, which is what most services need; override it for a server that disagrees with its own code.
Crs¶
Gets or sets the CRS features are requested in, for example urn:ogc:def:crs:EPSG::3857.
public string Crs { get; set; }
Property Value¶
Remarks:
Null, the default, takes the server's own default for the feature type. Letting the server reproject is usually better than converting afterwards: it holds the authoritative datum transformation for its national grid, where a generic client-side converter can be out by a hundred metres or more. Applied when the source is opened.
Resolve¶
Gets or sets which of the references in a response the service resolves. The default is WfsResolve.None.
public WfsResolve Resolve { get; set; }
Property Value¶
Remarks:
A property that associates one feature with another holds a reference, and the feature it points at may be where the geometry or the attributes live. Asking the service to resolve them brings those objects back in the same response, where FeaturePage.ReferencedFeatures collects them. It makes the response larger, and a service that does not support resolving answers with an exception rather than ignoring the request, so this is off until a caller asks for it.
ResolveDepth¶
Gets or sets how many steps of references the service follows when WfsV2AsyncFeatureSource.Resolve asks it to resolve them. The default is 1.
public int ResolveDepth { get; set; }
Property Value¶
Remarks:
One step resolves the objects a feature names; two also resolves the objects those ones name, and so on. Left out of the request when WfsV2AsyncFeatureSource.Resolve is WfsResolve.None, which is what the standard says to do with it.
ReadUntilEmptyPage¶
Gets or sets whether a read goes on asking for records until the service answers with none, when the service says neither how many there are nor that there are more. The default is false.
public bool ReadUntilEmptyPage { get; set; }
Property Value¶
Remarks:
A service may return fewer records than were asked for - it caps what one response holds - without a total or a next link to say so. By default a response shorter than the request is then taken as the last, which is right for a service that has no cap and wrong for one that has: asked for 2,000 and capped at 100, the read stops at 100. With this set, the read moves on by the records the service returned and stops only at an empty response. That costs one more request at the end of every read.
It applies to every read: WfsV2AsyncFeatureSource.GetFeaturesPageAsync(RectangleShape, IEnumerable<string>, string, int, CancellationToken) issues a token after a short page, and a read with no page of its own - a bounding box, a column value, a list of ids - asks again from where the last response ended. A page still holds no more than the count it was asked for. A service that ignores STARTINDEX and answers every request with the same records is detected, and the read throws rather than going round for ever or answering with what it had.
HttpClient¶
Gets or sets the HTTP client used for outbound requests.
public HttpClient HttpClient { get; set; }
Property Value¶
Remarks:
Assign this to take full control of the client, including its handler pipeline and default headers. It takes precedence over WebBasedAsyncFeatureSource.HttpMessageHandler, and ownership stays with the caller: the source will not dispose a client it did not create.
HttpMessageHandler¶
Gets or sets an optional handler used to build the client when the source opens.
public HttpMessageHandler HttpMessageHandler { get; set; }
Property Value¶
Remarks:
Useful for Blazor WebAssembly, for DelegatingHandler chains such as Polly or OpenTelemetry, and for tests with a mock handler. Read once during open, ignored when WebBasedAsyncFeatureSource.HttpClient is already assigned, and never disposed by this source.
WebProxy¶
Gets or sets the proxy through which requests should be routed.
public IWebProxy WebProxy { get; set; }
Property Value¶
TimeoutInSeconds¶
Gets or sets the request timeout, in seconds.
public int TimeoutInSeconds { get; set; }
Property Value¶
Credentials¶
Gets or sets the credentials used when authenticating requests.
public ICredentials Credentials { get; set; }
Property Value¶
UserAgent¶
Gets or sets the user-agent header sent with each request.
public string UserAgent { get; set; }
Property Value¶
ConcurrentAccess¶
Gets or sets whether this source can be read from more than one thread at once, and if it cannot, whether copying it per worker is the cheap way to read it anyway.
public ConcurrentAccess ConcurrentAccess { get; set; }
Property Value¶
Remarks:
The same declaration FeatureSource.ConcurrentAccess carries, for the same reason: whoever cuts or draws several tiles at once asks the source before deciding whether to copy it per worker. ConcurrentAccess.UnsafeLock by default; a source that answers each read from its own request says ConcurrentAccess.Safe. https://community.thinkgeo.com/t/features-cut-off-on-tile-border-with-gpu-rendering/12481
IsOpen¶
Gets a value indicating whether the source has been opened and is ready to answer queries.
public bool IsOpen { get; }
Property Value¶
ProjectionConverter¶
Gets or sets the converter that translates between the coordinate system the service publishes and the one the map is drawn in.
public ProjectionConverter ProjectionConverter { get; set; }
Property Value¶
Remarks:
Bounding boxes passed in are converted to the service's own projection before the request is issued, and the features that come back are converted to the map's projection. Where a service can reproject on request, asking it to do so is usually better than converting afterwards, because the server holds the authoritative transformation for its own grid.
GeometryType¶
Gets the kind of geometry the source holds - points, lines or areas - as its service declares it.
public WellKnownType GeometryType { get; protected set; }
Property Value¶
Remarks:
Read when the source opens, at no cost of its own: WFS from the DescribeFeatureType the open already fetches, ArcGIS Server from the layer definition. It is WellKnownType.Invalid before that, after the source closes, and whenever the service does not say - OGC API - Features has no required schema, and a WFS schema may name a geometry (gml:GeometryPropertyType) without saying which. Invalid is not a promise that the source holds no geometry. https://community.thinkgeo.com/t/v15-beta160-follow-up-remaining-gpu-style-parity-source-lifecycle-wfs-v2-and-wms-gaps/12468
Constructors¶
WfsV2AsyncFeatureSource()¶
Initializes a new instance of the WfsV2AsyncFeatureSource class.
public WfsV2AsyncFeatureSource()
WfsV2AsyncFeatureSource(string, string)¶
Initializes a new instance of the WfsV2AsyncFeatureSource class.
public WfsV2AsyncFeatureSource(string serviceLocationUrl, string typeName)
Parameters¶
serviceLocationUrl string
The base URL of the WFS service.
typeName string
The fully qualified feature type to read.
Methods¶
GetBoundingBoxAsyncCore(CancellationToken)¶
Returns the extent the service advertises for this feature type, read when the source opened, in the requested CRS.
protected Task<RectangleShape> GetBoundingBoxAsyncCore(CancellationToken cancellationToken)
Parameters¶
cancellationToken CancellationToken
A token that cancels the operation.
Returns¶
Task<RectangleShape>
The extent, or null when the service advertises none.
C()¶
internal RectangleShape C()
Returns¶
OpenAsyncCore(CancellationToken)¶
Reads the service capabilities and the feature type schema.
protected Task OpenAsyncCore(CancellationToken cancellationToken)
Parameters¶
cancellationToken CancellationToken
A token that cancels the operation.
Returns¶
Task
A task that represents the asynchronous operation.
CloseAsyncCore(CancellationToken)¶
Releases the metadata read at open time.
protected Task CloseAsyncCore(CancellationToken cancellationToken)
Parameters¶
cancellationToken CancellationToken
A token that cancels the operation.
Returns¶
Task
A task that represents the asynchronous operation.
GetColumnsAsyncCore(CancellationToken)¶
Returns the columns read from the DescribeFeatureType response.
protected Task<Collection<FeatureSourceColumn>> GetColumnsAsyncCore(CancellationToken cancellationToken)
Parameters¶
cancellationToken CancellationToken
A token that cancels the operation.
Returns¶
Task<Collection<FeatureSourceColumn>>
The columns this feature type publishes.
GetFeaturesInsideBoundingBoxAsyncCore(RectangleShape, IEnumerable<string>, CancellationToken)¶
Requests the features inside , pushing the extent to the service as BBOX.
protected Task<Collection<Feature>> GetFeaturesInsideBoundingBoxAsyncCore(RectangleShape boundingBox, IEnumerable<string> returningColumnNames, CancellationToken cancellationToken)
Parameters¶
boundingBox RectangleShape
The extent to query, in the service's own projection.
returningColumnNames IEnumerable<string>
The column values to bring back with each feature.
cancellationToken CancellationToken
A token that cancels the operation.
Returns¶
Task<Collection<Feature>>
The features inside the bounding box.
GetFeaturesPageAsync(RectangleShape, IEnumerable<string>, string, int, CancellationToken)¶
Returns one page of features using the service's STARTINDEX and COUNT parameters.
public Task<FeaturePage> GetFeaturesPageAsync(RectangleShape boundingBox, IEnumerable<string> returningColumnNames, string continuationToken, int maxCount, CancellationToken cancellationToken)
Parameters¶
boundingBox RectangleShape
The extent to query, in the map's projection. Pass null for the full extent.
returningColumnNames IEnumerable<string>
The column values to bring back with each feature.
continuationToken string
The token from the previous page, or null to start.
maxCount int
The largest number of features to return.
cancellationToken CancellationToken
A token that cancels the operation.
Returns¶
Task<FeaturePage>
A page of features, and the token for the next page when one exists.
A(int, bool, long, int, int, bool)¶
internal static bool A(int , bool , long , int , int , bool )
Parameters¶
`` int
`` bool
`` long
`` int
`` int
`` bool
Returns¶
A(string, string, string, int)¶
internal static void A(string , string , string , int )
Parameters¶
`` string
`` string
`` string
`` int
Returns¶
A(RectangleShape, string, IReadOnlyList<string>, IEnumerable<string>, string, int, int, CancellationToken)¶
internal Task<EH> A(RectangleShape , string , IReadOnlyList<string> , IEnumerable<string> , string , int , int , CancellationToken )
Parameters¶
`` string
`` string
`` int
`` int
Returns¶
A(string, IReadOnlyList<string>)¶
internal string A(string , IReadOnlyList<string> )
Parameters¶
`` string
Returns¶
A(IReadOnlyList<string>)¶
internal static string A(IReadOnlyList<string> )
Parameters¶
Returns¶
a(string)¶
internal string a(string )
Parameters¶
`` string
Returns¶
GetCountAsyncCore(CancellationToken)¶
Returns how many features the service holds, using resultType=hits.
protected Task<long> GetCountAsyncCore(CancellationToken cancellationToken)
Parameters¶
cancellationToken CancellationToken
A token that cancels the operation.
Returns¶
Task<long>
The feature count, or -1 when the service did not report one.
Remarks:
resultType=hits is a standard WFS 2.0 request that returns the match count with an empty feature collection, so this costs one round trip and no feature data.
GetFeaturesByColumnValueAsyncCore(string, string, IEnumerable<string>, CancellationToken)¶
Returns the features whose equals , filtered by the service with a PropertyIsEqualTo filter.
protected Task<Collection<Feature>> GetFeaturesByColumnValueAsyncCore(string columnName, string columnValue, IEnumerable<string> returningColumnNames, CancellationToken cancellationToken)
Parameters¶
columnName string
The column to filter on.
columnValue string
The value the column must equal.
returningColumnNames IEnumerable<string>
The column values to bring back with each feature.
cancellationToken CancellationToken
A token that cancels the operation.
Returns¶
Task<Collection<Feature>>
The matching features.
Remarks:
The column goes out qualified with the type's prefix, bound in the filter itself, as the composite source qualifies it: a service that resolves property names against the type's namespace, such as Bayern's ATKIS service, rejects a bare one. The value is escaped, so one holding & or < no longer breaks the filter.
GetFeaturesByIdsAsyncCore(IReadOnlyList<string>, IEnumerable<string>, CancellationToken)¶
Returns the features carrying the given identifiers, using the service's ResourceId parameter.
protected Task<Collection<Feature>> GetFeaturesByIdsAsyncCore(IReadOnlyList<string> ids, IEnumerable<string> returningColumnNames, CancellationToken cancellationToken)
Parameters¶
ids IReadOnlyList<string>
The identifiers to fetch.
returningColumnNames IEnumerable<string>
The column values to bring back with each feature.
cancellationToken CancellationToken
A token that cancels the operation.
Returns¶
Task<Collection<Feature>>
The features found.
Remarks:
Each id is escaped for the query string, as escapes it: an id holding &, # or + was cut short or changed on the way.
A(RectangleShape, int, int)¶
internal string A(RectangleShape , int , int )
Parameters¶
`` int
`` int
Returns¶
A(string, CancellationToken)¶
internal Task<ValueTuple<int, Collection<Feature>>> A(string , CancellationToken )
Parameters¶
`` string
Returns¶
Task<ValueTuple<int, Collection<Feature>>>
A(double, double, d&)¶
internal static string A(double , double , d& )
Parameters¶
`` double
`` double
`d&`
Returns¶
Events¶
SendingHttpRequest¶
Occurs before an HTTP request is dispatched so callers can inspect or cancel it.
public event EventHandler<SendingHttpRequestMessageEventArgs> SendingHttpRequest;
ReceivedHttpResponse¶
Occurs after an HTTP response is received.
public event EventHandler<ReceivedHttpResponseMessageEventArgs> ReceivedHttpResponse;