Skip to content

WfsAsyncFeatureSource

Namespace: ThinkGeo.Core

Reads features asynchronously from a WFS 1.0 service.

public class WfsAsyncFeatureSource : WebBasedAsyncFeatureSource, IHttpRequestService

Inheritance object → AsyncFeatureSource → WebBasedAsyncFeatureSource → WfsAsyncFeatureSource
Implements IHttpRequestService

Remarks:

WFS 1.0 is a smaller protocol than 2.0, and what this source offers says so. It can push a bounding box and a PropertyIsEqualTo filter to the server, and it can address features by FEATUREID. It offers neither paging nor a feature count: 1.0 has MAXFEATURES but no start index to page from, and resultType=hits - the request that returns a count without the features - was not introduced until 1.1.

Properties

ServiceLocationUrl

Gets or sets the base URL of the WFS service.

public string ServiceLocationUrl { get; set; }

Property Value

string

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 feature type (layer) name to request.

public string TypeName { get; set; }

Property Value

string

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.

WfsNamespace

Gets or sets the namespace prefix used when building filter documents.

public WfsNamespace WfsNamespace { get; set; }

Property Value

WfsNamespace

Remarks:

Some servers expect the OGC prefix on filter elements and reject an unprefixed filter.

HttpClient

Gets or sets the HTTP client used for outbound requests.

public HttpClient HttpClient { get; set; }

Property Value

HttpClient

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

HttpMessageHandler

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

IWebProxy

TimeoutInSeconds

Gets or sets the request timeout, in seconds.

public int TimeoutInSeconds { get; set; }

Property Value

int

Credentials

Gets or sets the credentials used when authenticating requests.

public ICredentials Credentials { get; set; }

Property Value

ICredentials

UserAgent

Gets or sets the user-agent header sent with each request.

public string UserAgent { get; set; }

Property Value

string

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

ConcurrentAccess

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

bool

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

ProjectionConverter

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

WellKnownType

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

WfsAsyncFeatureSource()

Initializes a new instance of the WfsAsyncFeatureSource class.

public WfsAsyncFeatureSource()

WfsAsyncFeatureSource(string, string)

Initializes a new instance of the WfsAsyncFeatureSource class.

public WfsAsyncFeatureSource(string serviceLocationUrl, string typeName)

Parameters

serviceLocationUrl string
The base URL of the WFS service.

typeName string
The feature type to read.

Methods

OpenAsyncCore(CancellationToken)

Reads the feature type schema so the columns and the geometry field are known.

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 schema 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.

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.

GetFeaturesByIdsAsyncCore(IReadOnlyList<string>, IEnumerable<string>, CancellationToken)

Returns the features carrying the given identifiers, using the service's FEATUREID 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.

GetBoundingBoxAsyncCore(CancellationToken)

Returns the extent the service reports for this feature type.

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 reports none.

Remarks:

WFS 1.0 publishes no per-type extent that can be read without a feature request, so this asks for a single feature and reads the boundedBy element the server returns with it.

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;