WebBasedAsyncFeatureSource¶
Namespace: ThinkGeo.Core
Base class for an AsyncFeatureSource that reads its features over HTTP.
public abstract class WebBasedAsyncFeatureSource : AsyncFeatureSource, IHttpRequestService
Inheritance object → AsyncFeatureSource → WebBasedAsyncFeatureSource
Implements IHttpRequestService
Remarks:
Carries the same transport surface as WebBasedAsyncLayer - a caller-supplied WebBasedAsyncFeatureSource.HttpClient or WebBasedAsyncFeatureSource.HttpMessageHandler, a proxy, credentials, a timeout, and request/response events - so a source can be used on its own, without a layer around it. That matters for callers that consume a feature source directly, such as the vector tile sources in the GPU renderer.
Properties¶
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
Methods¶
OpenAsyncCore(CancellationToken)¶
Builds the HTTP client if one is needed, then lets the derived source read its metadata.
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)¶
Disposes the HTTP client when this source created it.
protected Task CloseAsyncCore(CancellationToken cancellationToken)
Parameters¶
cancellationToken CancellationToken
A token that cancels the operation.
Returns¶
Task
A task that represents the asynchronous operation.
SendWebRequestAsync(HttpRequestMessage, CancellationToken)¶
Sends a request, raising the request and response events around it.
protected Task<HttpResponseMessage> SendWebRequestAsync(HttpRequestMessage httpRequest, CancellationToken cancellationToken)
Parameters¶
httpRequest HttpRequestMessage
The request to send.
cancellationToken CancellationToken
A token that cancels the operation.
Returns¶
Task<HttpResponseMessage>
The response, or null when a handler cancelled the request.
GetStringAsync(string, CancellationToken)¶
Issues a GET and returns the body as text.
protected Task<string> GetStringAsync(string requestUrl, CancellationToken cancellationToken)
Parameters¶
requestUrl string
The URL to request.
cancellationToken CancellationToken
A token that cancels the operation.
Returns¶
Task<string>
The response body - including the error document of a refusal, which a caller parses for what the service said - or an empty string when there is nothing to read.
PostXmlAsync(string, string, CancellationToken)¶
Issues a POST carrying an XML body and returns the response as text.
protected Task<string> PostXmlAsync(string requestUrl, string xmlBody, CancellationToken cancellationToken)
Parameters¶
requestUrl string
The URL to post to.
xmlBody string
The XML payload, typically an OGC filter document.
cancellationToken CancellationToken
A token that cancels the operation.
Returns¶
Task<string>
The response body - including the error document of a refusal, which a caller parses for what the service said - or an empty string when there is nothing to read.
OnSendingHttpRequestMessage(SendingHttpRequestMessageEventArgs)¶
Raises WebBasedAsyncFeatureSource.SendingHttpRequest.
protected void OnSendingHttpRequestMessage(SendingHttpRequestMessageEventArgs e)
Parameters¶
e SendingHttpRequestMessageEventArgs
The event data.
Returns¶
OnReceivedHttpResponseMessage(ReceivedHttpResponseMessageEventArgs)¶
Raises WebBasedAsyncFeatureSource.ReceivedHttpResponse.
protected void OnReceivedHttpResponseMessage(ReceivedHttpResponseMessageEventArgs e)
Parameters¶
e ReceivedHttpResponseMessageEventArgs
The event data.
Returns¶
BuildRequestUrl(string, string)¶
Appends a query string to a base URL, respecting any query it already carries.
protected static string BuildRequestUrl(string baseUrl, string queryString)
Parameters¶
baseUrl string
The service endpoint.
queryString string
The query string to append, without a leading separator.
Returns¶
string
The combined URL.
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;