Class WmsProvider
Web Map Service layer
Inherited Members
Namespace: Mapsui.Providers.Wms
Assembly: Mapsui.dll
Syntax
public class WmsProvider : IProjectingProvider, IProvider
Remarks
The WmsLayer is currently very basic and doesn't support automatic fetching of the WMS Service Description. Instead you would have to add the necessary parameters to the URL, and the WmsLayer will set the remaining BoundingBox property and proper requests that changes between the requests. See the example below.
Constructors
| Edit this page View SourceWmsProvider(XmlDocument, Func<string, Task<Stream>>?, IUrlPersistentCache?)
Declaration
public WmsProvider(XmlDocument capabilities, Func<string, Task<Stream>>? getStreamAsync = null, IUrlPersistentCache? persistentCache = null)
Parameters
| Type | Name | Description |
|---|---|---|
| XmlDocument | capabilities | |
| Func<string, Task<Stream>> | getStreamAsync | |
| IUrlPersistentCache | persistentCache |
Properties
| Edit this page View SourceAxisOrder
Gets or sets a value indicating the axis order
Declaration
public int[] AxisOrder { get; set; }
Property Value
| Type | Description |
|---|---|
| int[] |
Remarks
The axis order is an array of array offsets. It can be either {0, 1} or {1, 0}.
If not set explictly, CrsAxisOrderRegistry is asked for a value based on SRID.CRS
The spatial reference ID (CRS)
Declaration
public string? CRS { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
ContinueOnError
Specifies whether to throw an exception if the Wms request failed, or to just skip rendering the layer
Declaration
public bool ContinueOnError { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
Credentials
Provides the base authentication interface for retrieving credentials for Web client authentication.
Declaration
public ICredentials? Credentials { get; set; }
Property Value
| Type | Description |
|---|---|
| ICredentials |
DefaultCache
Declaration
public static IUrlPersistentCache? DefaultCache { get; set; }
Property Value
| Type | Description |
|---|---|
| IUrlPersistentCache |
ExtraParams
Declaration
public Dictionary<string, string>? ExtraParams { get; set; }
Property Value
| Type | Description |
|---|---|
| Dictionary<string, string> |
GetFeatureInfoFormats
Gets the list of available FeatureInfo Output Format
Declaration
public Collection<string> GetFeatureInfoFormats { get; }
Property Value
| Type | Description |
|---|---|
| Collection<string> |
LayerList
Gets the list of enabled layers
Declaration
public Collection<string>? LayerList { get; }
Property Value
| Type | Description |
|---|---|
| Collection<string> |
OutputFormats
Gets the list of available formats
Declaration
public Collection<string> OutputFormats { get; }
Property Value
| Type | Description |
|---|---|
| Collection<string> |
RootLayer
Gets the hierarchical list of available WMS layers from this service
Declaration
public Client.WmsServerLayer? RootLayer { get; }
Property Value
| Type | Description |
|---|---|
| Client.WmsServerLayer? |
ServiceDescription
Gets the service description from this server
Declaration
public Capabilities.WmsServiceDescription? ServiceDescription { get; }
Property Value
| Type | Description |
|---|---|
| Capabilities.WmsServiceDescription? |
StylesList
Gets the list of enabled styles
Declaration
public Collection<string>? StylesList { get; }
Property Value
| Type | Description |
|---|---|
| Collection<string> |
TimeOut
Timeout of web request in milliseconds. Defaults to 10 seconds
Declaration
public int TimeOut { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
Transparent
If it should set the Wms Image to Transparent
Declaration
public bool? Transparent { get; set; }
Property Value
| Type | Description |
|---|---|
| bool? |
UserAgent
Declaration
public string? UserAgent { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Version
Gets the WMS Server version of this service
Declaration
public string? Version { get; }
Property Value
| Type | Description |
|---|---|
| string |
Methods
| Edit this page View SourceAddLayer(string)
Adds a layer to WMS request
Declaration
public void AddLayer(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Name of layer |
Remarks
Layer names are case sensitive.
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Throws an exception is an unknown layer is added |
AddStyle(string)
Adds a style to the style collection
Declaration
public void AddStyle(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Name of style |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Throws an exception is an unknown layer is added |
CreateAsync(string, string?, Func<string, Task<Stream>>?, IUrlPersistentCache?, string?)
Initializes a new layer, and downloads and parses the service description
Declaration
public static Task<WmsProvider> CreateAsync(string url, string? wmsVersion = null, Func<string, Task<Stream>>? getStreamAsync = null, IUrlPersistentCache? persistentCache = null, string? userAgent = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | url | Url of WMS server |
| string | wmsVersion | Version number of wms leave null to get the default service version |
| Func<string, Task<Stream>> | getStreamAsync | Download method, leave null for default |
| IUrlPersistentCache | persistentCache | |
| string | userAgent | user Agent |
Returns
| Type | Description |
|---|---|
| Task<WmsProvider> |
GetExtent()
MRect of data set
Declaration
public MRect? GetExtent()
Returns
| Type | Description |
|---|---|
| MRect | BoundingBox |
GetFeaturesAsync(FetchInfo)
Declaration
public Task<IEnumerable<IFeature>> GetFeaturesAsync(FetchInfo fetchInfo)
Parameters
| Type | Name | Description |
|---|---|---|
| FetchInfo | fetchInfo |
Returns
| Type | Description |
|---|---|
| Task<IEnumerable<IFeature>> |
GetLayer(string)
Get a layer from the WMS
Declaration
public Client.WmsServerLayer GetLayer(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Name of layer |
Returns
| Type | Description |
|---|---|
| Client.WmsServerLayer |
Remarks
Layer names are case sensitive.
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Throws an exception if the layer is not found |
GetLegendRequestUrls()
Gets the URL for a map request base on current settings, the image size and BoundingBox
Declaration
public IEnumerable<string> GetLegendRequestUrls()
Returns
| Type | Description |
|---|---|
| IEnumerable<string> | URL for WMS request |
GetLegendsAsync()
Declaration
public IAsyncEnumerable<MemoryStream> GetLegendsAsync()
Returns
| Type | Description |
|---|---|
| IAsyncEnumerable<MemoryStream> |
GetRequestUrl(MRect?, int, int)
Gets the URL for a map request base on current settings, the image size and BoundingBox
Declaration
public string GetRequestUrl(MRect? box, int width, int height)
Parameters
| Type | Name | Description |
|---|---|---|
| MRect | box | |
| int | width | |
| int | height |
Returns
| Type | Description |
|---|---|
| string | URL for WMS request |
IsCrsSupported(string)
Queries whether a provider supports projection to a certain CRS.
Declaration
public bool? IsCrsSupported(string crs)
Parameters
| Type | Name | Description |
|---|---|---|
| string | crs | The crs to project to |
Returns
| Type | Description |
|---|---|
| bool? | True if is does, false if it does not, null if it is unknown |
RemoveAllLayers()
Removes all layers
Declaration
public void RemoveAllLayers()
RemoveAllStyles()
Removes all styles from the list
Declaration
public void RemoveAllStyles()
RemoveLayer(string)
Removes a layer from the layer list
Declaration
public void RemoveLayer(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Name of layer to remove |
RemoveLayerAt(int)
Removes the layer at the specified index
Declaration
public void RemoveLayerAt(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index |
RemoveStyle(string)
Removes a style from the collection
Declaration
public void RemoveStyle(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Name of style |
RemoveStyleAt(int)
Removes a style at specified index
Declaration
public void RemoveStyleAt(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | Index |
SetImageFormat(string)
Sets the image type to use when requesting images from the WMS server
Declaration
public void SetImageFormat(string mimeType)
Parameters
| Type | Name | Description |
|---|---|---|
| string | mimeType | Mime type of image format |
Remarks
See the OutputFormats property for a list of available mime types supported by the WMS server
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Throws an exception if either the mime type isn't offered by the WMS or GDI+ doesn't support this mime type. |
TryGetMapAsync(MSection)
Declaration
public Task<(bool Success, MRaster?)> TryGetMapAsync(MSection section)
Parameters
| Type | Name | Description |
|---|---|---|
| MSection | section |
Returns
| Type | Description |
|---|---|
| Task<(bool Success, MRaster)> |